@@ -44,27 +44,27 @@ function parse_template($tplfile, $templateid, $tpldir, $file, $cachefile) {
44
44
$ this ->subtemplates = array ();
45
45
for ($ i = 1 ; $ i <= 3 ; $ i ++) {
46
46
if (strexists ($ template , '{subtemplate ' )) {
47
- $ template = preg_replace ("/[ \n\r\t]*(\<\!\-\-)?\{subtemplate\s+([a-z0-9_:\/]+)\}(\-\-\>)?[ \n\r\t]*/ies " , "\$ this->loadsubtemplate(' \\ 2') " , $ template );
47
+ $ template = preg_replace_callback ("/[ \n\r\t]*(\<\!\-\-)?\{subtemplate\s+([a-z0-9_:\/]+)\}(\-\-\>)?[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->loadsubtemplate ($ matches [ 2 ]); } , $ template );
48
48
}
49
49
}
50
50
51
51
$ template = preg_replace ("/([ \n\r]+) \t+/s " , "\\1 " , $ template );
52
52
$ template = preg_replace ("/\<\!\-\-\{(.+?)\}\-\-\>/s " , "{ \\1} " , $ template );
53
- $ template = preg_replace ("/\{lang\s+(.+?)\}/ies " , "\$ this->languagevar(' \\ 1') " , $ template );
54
- $ template = preg_replace ("/[ \n\r\t]*\{block\/(\d+?)\}[ \n\r\t]*/ie " , "\$ this->blocktags(' \\ 1') " , $ template );
55
- $ template = preg_replace ("/[ \n\r\t]*\{blockdata\/(\d+?)\}[ \n\r\t]*/ie " , "\$ this->blockdatatags(' \\ 1') " , $ template );
56
- $ template = preg_replace ("/[ \n\r\t]*\{ad\/(.+?)\}[ \n\r\t]*/ie " , "\$ this->adtags(' \\ 1') " , $ template );
57
- $ template = preg_replace ("/[ \n\r\t]*\{ad\s+([a-zA-Z0-9_\[\]]+)\/(.+?)\}[ \n\r\t]*/ie " , "\$ this->adtags(' \\ 2', ' \\ 1') " , $ template );
58
- $ template = preg_replace ("/[ \n\r\t]*\{date\((.+?)\)\}[ \n\r\t]*/ie " , "\$ this->datetags(' \\ 1') " , $ template );
59
- $ template = preg_replace ("/[ \n\r\t]*\{avatar\((.+?)\)\}[ \n\r\t]*/ie " , "\$ this->avatartags(' \\ 1') " , $ template );
60
- $ template = preg_replace ("/[ \n\r\t]*\{eval\}\s*(\<\!\-\-)*(.+?)(\-\-\>)*\s*\{\/eval\}[ \n\r\t]*/ies " , "\$ this->evaltags(' \\ 2') " , $ template );
61
- $ template = preg_replace ("/[ \n\r\t]*\{eval\s+(.+?)\s*\}[ \n\r\t]*/ies " , "\$ this->evaltags(' \\ 1') " , $ template );
62
- $ template = preg_replace ("/[ \n\r\t]*\{csstemplate\}[ \n\r\t]*/ies " , "\$ this->loadcsstemplate() " , $ template );
53
+ $ template = preg_replace_callback ("/\{lang\s+(.+?)\}/is " , function ( $ matches ) { return $ this ->languagevar ($ matches [ 1 ]); } , $ template );
54
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{block\/(\d+?)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->blocktags ($ matches [ 1 ]); } , $ template );
55
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{blockdata\/(\d+?)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->blockdatatags ($ matches [ 1 ]); } , $ template );
56
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{ad\/(.+?)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->adtags ($ matches [ 1 ]); } , $ template );
57
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{ad\s+([a-zA-Z0-9_\[\]]+)\/(.+?)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->adtags ($ matches [ 2 ], $ matches [ 1 ]); } , $ template );
58
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{date\((.+?)\)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->datetags ($ matches [ 1 ]); } , $ template );
59
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{avatar\((.+?)\)\}[ \n\r\t]*/i " , function ( $ matches ) { return $ this ->avatartags ($ matches [ 1 ]); } , $ template );
60
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{eval\}\s*(\<\!\-\-)*(.+?)(\-\-\>)*\s*\{\/eval\}[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->evaltags ($ matches [ 2 ]); } , $ template );
61
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{eval\s+(.+?)\s*\}[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->evaltags ($ matches [ 1 ]); } , $ template );
62
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{csstemplate\}[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->loadcsstemplate (); } , $ template );
63
63
$ template = str_replace ("{LF} " , "<?= \"\\n \"?> " , $ template );
64
64
$ template = preg_replace ("/\{( \\\$[a-zA-Z0-9_\-\>\[\]\' \"\$\. \x7f- \xff]+)\}/s " , "<?= \\1?> " , $ template );
65
- $ template = preg_replace ("/\{hook\/(\w+?)(\s+(.+?))?\}/ie " , "\$ this->hooktags(' \\ 1', ' \\ 3') " , $ template );
66
- $ template = preg_replace ("/ $ var_regexp/es " , " template::addquote('<?= \\ 1 ?>')" , $ template );
67
- $ template = preg_replace ("/\<\?\=\<\?\= $ var_regexp\?\>\?\>/es " , "\$ this->addquote('<?= \\ 1 ?>')" , $ template );
65
+ $ template = preg_replace_callback ("/\{hook\/(\w+?)(\s+(.+?))?\}/i " , function ( $ matches ) { return $ this ->hooktags ($ matches [ 1 ], $ matches [ 3 ]); } , $ template );
66
+ $ template = preg_replace_callback ("/ $ var_regexp/s " , function ( $ matches ) { return template::addquote ('<?= ' . $ matches [ 1 ]. ' ?> ' ); } , $ template );
67
+ $ template = preg_replace_callback ("/\<\?\=\<\?\= $ var_regexp\?\>\?\>/s " , function ( $ matches ) { return $ this ->addquote ('<?= ' . $ matches [ 1 ]. ' ?> ' ); } , $ template );
68
68
69
69
$ headeradd = $ headerexists ? "hookscriptoutput(' $ basefile'); " : '' ;
70
70
if (!empty ($ this ->subtemplates )) {
@@ -82,17 +82,17 @@ function parse_template($tplfile, $templateid, $tpldir, $file, $cachefile) {
82
82
83
83
$ template = "<? if(!defined('IN_DISCUZ')) exit('Access Denied'); {$ headeradd }?> \n$ template " ;
84
84
85
- $ template = preg_replace ("/[ \n\r\t]*\{template\s+([a-z0-9_:\/]+)\}[ \n\r\t]*/ies " , "\$this->stripvtags('<? include template(\' \\1\'); ?>') " , $ template );
86
- $ template = preg_replace ("/[ \n\r\t]*\{template\s+(.+?)\}[ \n\r\t]*/ies " , "\$this->stripvtags('<? include template(\' \\1\'); ?>') " , $ template );
87
- $ template = preg_replace ("/[ \n\r\t]*\{echo\s+(.+?)\}[ \n\r\t]*/ies " , "\$this->stripvtags('<? echo \\1; ?>') " , $ template );
85
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{template\s+([a-z0-9_:\/]+)\}[ \n\r\t]*/is " , function ($ matches ) { return $ this ->stripvtags ('<? include template( \'' .$ matches [1 ].'\'); ?> ' ); }, $ template );
86
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{template\s+(.+?)\}[ \n\r\t]*/is " , function ($ matches ) { return $ this ->stripvtags ('<? include template( \'' .$ matches [1 ].'\'); ?> ' ); }, $ template );
87
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{echo\s+(.+?)\}[ \n\r\t]*/is " , function ($ matches ) { return $ this ->stripvtags ('<? echo ' .$ matches [1 ].'; ?> ' ); }, $ template );
88
+ $ template = preg_replace_callback ("/([ \n\r\t]*)\{if\s+(.+?)\}([ \n\r\t]*)/is " , function ($ matches ) { return $ this ->stripvtags ($ matches [1 ].'<? if( ' .$ matches [2 ].') { ?> ' .$ matches [3 ]); }, $ template );
89
+ $ template = preg_replace_callback ("/([ \n\r\t]*)\{elseif\s+(.+?)\}([ \n\r\t]*)/is " , function ($ matches ) { return $ this ->stripvtags ($ matches [1 ].'<? } elseif( ' .$ matches [2 ].') { ?> ' .$ matches [3 ]); }, $ template );
88
90
89
- $ template = preg_replace ("/([ \n\r\t]*)\{if\s+(.+?)\}([ \n\r\t]*)/ies " , "\$this->stripvtags(' \\1<? if( \\2) { ?> \\3') " , $ template );
90
- $ template = preg_replace ("/([ \n\r\t]*)\{elseif\s+(.+?)\}([ \n\r\t]*)/ies " , "\$this->stripvtags(' \\1<? } elseif( \\2) { ?> \\3') " , $ template );
91
91
$ template = preg_replace ("/\{else\}/i " , "<? } else { ?> " , $ template );
92
92
$ template = preg_replace ("/\{\/if\}/i " , "<? } ?> " , $ template );
93
93
94
- $ template = preg_replace ("/[ \n\r\t]*\{loop\s+(\S+)\s+(\S+)\}[ \n\r\t]*/ies " , "\$ this->stripvtags('<? if(is_array( \\ 1 )) foreach(\\ 1 as \\ 2 ) { ?>')" , $ template );
95
- $ template = preg_replace ("/[ \n\r\t]*\{loop\s+(\S+)\s+(\S+)\s+(\S+)\}[ \n\r\t]*/ies " , "\$ this->stripvtags('<? if(is_array( \\ 1 )) foreach(\\ 1 as \\ 2 => \\ 3 ) { ?>')" , $ template );
94
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{loop\s+(\S+)\s+(\S+)\}[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->stripvtags ('<? if(is_array( ' . $ matches [ 1 ]. ' )) foreach( ' . $ matches [ 1 ]. ' as ' . $ matches [ 2 ]. ' ) { ?> ' ); } , $ template );
95
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{loop\s+(\S+)\s+(\S+)\s+(\S+)\}[ \n\r\t]*/is " , function ( $ matches ) { return $ this ->stripvtags ('<? if(is_array( ' . $ matches [ 1 ]. ' )) foreach( ' . $ matches [ 1 ]. ' as ' . $ matches [ 2 ]. ' => ' . $ matches [ 3 ]. ' ) { ?> ' ); } , $ template );
96
96
$ template = preg_replace ("/\{\/loop\}/i " , "<? } ?> " , $ template );
97
97
98
98
$ template = preg_replace ("/\{ $ const_regexp\}/s " , "<?= \\1?> " , $ template );
@@ -105,9 +105,9 @@ function parse_template($tplfile, $templateid, $tpldir, $file, $cachefile) {
105
105
$ this ->error ('directory_notfound ' , dirname (DISCUZ_ROOT .$ cachefile ));
106
106
}
107
107
108
- $ template = preg_replace ("/ \"(http)?[\w\.\/:]+\?[^ \"]+?&[^ \"]+? \"/e " , "\$ this->transamp(' \\ 0') " , $ template );
109
- $ template = preg_replace ("/\<script[^\>]*?src= \"(.+?) \"(.*?)\>\s*\<\/script\>/ies " , "\$ this->stripscriptamp(' \\ 1', ' \\ 2') " , $ template );
110
- $ template = preg_replace ("/[ \n\r\t]*\{block\s+([a-zA-Z0-9_\[\]]+)\}(.+?)\{\/block\}/ies " , "\$ this->stripblock(' \\ 1', ' \\ 2') " , $ template );
108
+ $ template = preg_replace_callback ("/ \"(http)?[\w\.\/:]+\?[^ \"]+?&[^ \"]+? \"/ " , function ( $ matches ) { return $ this ->transamp ($ matches [ 0 ]); } , $ template );
109
+ $ template = preg_replace_callback ("/\<script[^\>]*?src= \"(.+?) \"(.*?)\>\s*\<\/script\>/is " , function ( $ matches ) { return $ this ->stripscriptamp ($ matches [ 1 ], $ matches [ 2 ]); } , $ template );
110
+ $ template = preg_replace_callback ("/[ \n\r\t]*\{block\s+([a-zA-Z0-9_\[\]]+)\}(.+?)\{\/block\}/is " , function ( $ matches ) { return $ this ->stripblock ($ matches [ 1 ], $ matches [ 2 ]); } , $ template );
111
111
$ template = preg_replace ("/\<\?(\s{1})/is " , "<?php \\1 " , $ template );
112
112
$ template = preg_replace ("/\<\?\=(.+?)\?\>/is " , "<?php echo \\1;?> " , $ template );
113
113
@@ -226,7 +226,7 @@ function hooktags($hookid, $key = '') {
226
226
if (isset ($ _G ['config ' ]['plugindeveloper ' ]) && $ _G ['config ' ]['plugindeveloper ' ] == 2 ) {
227
227
$ dev = "echo '<hook>[ " .($ key ? 'array ' : 'string ' )." $ hookid " .($ key ? '/ \'. ' .$ key .'. \'' : '' )."]</hook>'; " ;
228
228
}
229
- $ key = $ key !== '' ? "[ $ key] " : '' ;
229
+ $ key = $ key != '' ? "[ $ key] " : '' ;
230
230
$ this ->replacecode ['replace ' ][$ i ] = "<?php {$ dev }if(!empty( \$_G['setting']['pluginhooks'][' $ hookid'] $ key)) echo \$_G['setting']['pluginhooks'][' $ hookid'] $ key;?> " ;
231
231
return $ search ;
232
232
}
@@ -257,7 +257,8 @@ function loadcsstemplate() {
257
257
$ scripts = array (STYLEID .'_common ' );
258
258
$ content = $ this ->csscurmodules = '' ;
259
259
$ content = @implode ('' , file (DISCUZ_ROOT .'./data/cache/style_ ' .STYLEID .'_module.css ' ));
260
- $ content = preg_replace ("/\[(.+?)\](.*?)\[end\]/ies " , "\$this->cssvtags(' \\1',' \\2') " , $ content );
260
+ $ content = preg_replace_callback ("/\[(.+?)\](.*?)\[end\]/is " , function ($ matches ) { return $ this ->cssvtags ($ matches [1 ], $ matches [2 ]); }, $ content );
261
+
261
262
if ($ this ->csscurmodules ) {
262
263
$ this ->csscurmodules = preg_replace (array ('/\s*([,;:\{\}])\s*/ ' , '/[\t\n\r]/ ' , '/\/\*.+?\*\// ' ), array ('\\1 ' , '' ,'' ), $ this ->csscurmodules );
263
264
if (@$ fp = fopen (DISCUZ_ROOT .'./data/cache/style_ ' .STYLEID .'_ ' .$ _G ['basescript ' ].'_ ' .CURMODULE .'.css ' , 'w ' )) {
@@ -303,8 +304,8 @@ function addquote($var) {
303
304
304
305
305
306
function stripvtags ($ expr , $ statement = '' ) {
306
- $ expr = str_replace (" \\\"" , "\"" , preg_replace ("/\<\?\=( \\\$.+?)\?\>/s " , "\\1 " , $ expr ));
307
- $ statement = str_replace (" \\\"" , "\"" , $ statement );
307
+ $ expr = str_replace (' \\\" ' , ' \" ' , preg_replace ("/\<\?\=( \\\$.+?)\?\>/s " , "\\1 " , $ expr ));
308
+ $ statement = str_replace (' \\\" ' , ' \" ' , $ statement );
308
309
return $ expr .$ statement ;
309
310
}
310
311
0 commit comments