pHP / *: :::::::::::::::::::::: ::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: TECHNOLOGY LTD (www.discuz.com) :: ::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::: @ Discuz.com) :: :: Version: 2.6u 2005/04/20 17:00 :: ::::::::::::::::: :::::::::::::::::: ! 2.6 Unofficial Edit Author: bobgao (bobgao@gmail.com) :: :::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::: )) {EXIT ('Access Denied'); Function Parse_Template ($ FILE, $ TemplateId, $ TPLDIR) {Global $ Language; $ Nest = 5; $ TPLFILE = Discuz_Root. ". / $ TPLDIR / $ file.htm" $ Objfile = discuz_root. "./ forumdata / templates / {$ templateid} _ $ file.tpl.php"; if (! @ $ Fp = fopen ($ TPLFILE, 'R')) { EXIT ("Current Template File './ TPLDIR/$File.htm' NOT Found or Have No Access!");} elseif (! INCLUDE LANGUAGE ('Templates', $ TemplateId, $ TPLDIR) {EXIT ("< br> Current template pack do not have a necessary language file 'templates.lang.php' or have syntax error ");!} $ plugins_languagepack = DISCUZ_ROOT. '/ plugins / plugin.lang.php.'; if (file_exists ($ plugins_languagepack)) {include $ plugins_languagepack; if (count ($ plglang)) {$ language = array_merge ($ language, $ plglang);}} unset ($ plugins_languagepack); $ template =
Fread ($ FP, FILESIZE); Fclose ($ fp); $ var_regexp = "((/ $ [A-ZA-Z_X7F-XFF] [A-ZA-Z0-9_X7F-XFF] *) ([[[ [A-ZA-Z0-9 -. [] _ / "'$ x7f-xff] ]) *)"; $ const_regEXP = "([A-ZA-Z_X7F-XFF] [A-ZA-Z0-9_x7f -xff] *) "; $ template = preg_replace (" / ([NR] ) T / S "," / 1 ", $ TEMPLATE); $ TEMPLATE = preg_replace (" /< !-- {(( ? )} -> / s "," {/ 1} ", $ template); $ template = preg_replace (" / {langs (. ?)} / es "," Languagevar ", $ Template); $ template = str_replace ("{lf}", " = /" / n / "?". ">", $ template); $ template = preg_replace ("/ {(/ $ [A-ZA -Z0-9 _ [] / "$ x7f-xff] )} / s", "<= / 1" .php_close_tag, $ template); $ template = preg_replace ("/ $ var_regexp / es", "Addquote (' = / 1?'. '>') ", $ Template); $ template = preg_replace (" / = = $ Var_regexp?>?> / Es "," addquote (' = / 1?> ') ", $ Template); $ template = preg_replace (" / s * {templates (. ?)} S * / IS "," n ') ", $ Template); $ template = preg_replace (" / s * {else} s * / is "," n <} else {".php_close_tag." N ", $ template); for ($ I = 0; $ I <$ NEST; $ I ) {$ Template = preg_replace ("/ s * {loops (s ) s (s )} s * (. ?) S * {/ loop} S * / ity", "StripvTags ('n i (is_ARRAY (/ 1)) {FOREACH (/ 1 as / 2) {' .php_close_tag, 'N / 3N }}' .php_close_tag.'n ')", $ template) $ Template = preg_replace ("/ s * {loops (S ) S * (. ) S * {/ loop} S * / es", "stripvtags ('n IF (is_ARRAY (/ 1)) {FOREACH (/ 1 as / 2 => / 3) {'.php_close_tag,' N / 4N }} '.php_close_tag.'n') ", $ template); $ TEMPLATE = Preg_replace ("/ s * {IFS (. ?)} S * (. ?) S * {/ if} s * / es", "stripvtags ('n F (/ 1) {' .php_close_tag , 'N / 2N }' .php_close_tag.'n ') ", $ template);} $ template = preg_replace (" / {$ const_regEXP} / s "," = / 1 ".php_close_tag, $ TEMPLATE $ Template = preg_replace ("/?> [Nr] * / S", "", $ template); $ template = preg_replace ("/?> [Nr] * = / S", " n echo ", $ Template); $ TEMPLATE =" if (! defined ('in_discuz')) EXIT ('Access Denie D '); ".php_close_tag." $ template "; if (! @ $ fp = fopen ($ ObjFile,' W ')) {EXIT (" Directory' ./forumdata/templates/ 'NOT Found or Have No Access! ");} Flock ($ FP, 3); FWRITE ($ FP, $ Template); Fclose ($ fp);} Function AddQuote ($ VAR) {Return Str_Replace (" // "," "", preg_replace "