Skip to content

Commit 117731a

Browse files
committed
fix rewrite, function_call, uc_server blank
1 parent 945de2f commit 117731a

File tree

6 files changed

+40
-67
lines changed

6 files changed

+40
-67
lines changed

source/function/cache/cache_setting.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,19 +448,29 @@ function build_cache_setting() {
448448
}
449449
if($output['preg']){
450450
foreach($data['footernavs'] as $id => $nav) {
451-
$data['footernavs'][$id]['code'] = rewritereplace($nav['code']);
451+
foreach ($output['preg']['search'] as $key => $value) {
452+
$data['footernavs'][$id]['code'] = preg_replace_callback($value, create_function('$matches', 'return '.$output['preg']['replace'][$key].';'), $nav['code']);
453+
}
452454
}
453455
foreach($data['spacenavs'] as $id => $nav) {
454-
$data['spacenavs'][$id]['code'] = rewritereplace($nav['code']);
456+
foreach ($output['preg']['search'] as $key => $value) {
457+
$data['spacenavs'][$id]['code'] = preg_replace_callback($value, create_function('$matches', 'return '.$output['preg']['replace'][$key].';'), $nav['code']);
458+
}
455459
}
456460
foreach($data['mynavs'] as $id => $nav) {
457-
$data['mynavs'][$id]['code'] = rewritereplace($nav['code']);
461+
foreach ($output['preg']['search'] as $key => $value) {
462+
$data['mynavs'][$id]['code'] = preg_replace_callback($value, create_function('$matches', 'return '.$output['preg']['replace'][$key].';'), $nav['code']);
463+
}
458464
}
459465
foreach($data['topnavs'] as $id => $nav) {
460-
$data['topnavs'][$id]['code'] = rewritereplace($nav['code']);
466+
foreach ($output['preg']['search'] as $key => $value) {
467+
$data['topnavs'][$id]['code'] = preg_replace_callback($value, create_function('$matches', 'return '.$output['preg']['replace'][$key].';'), $nav['code']);
468+
}
461469
}
462470
foreach($data['plugins']['jsmenu'] as $key => $nav) {
463-
$data['plugins']['jsmenu'][$key]['url'] = rewritereplace($nav['url']);
471+
foreach ($output['preg']['search'] as $key => $value) {
472+
$data['plugins']['jsmenu'][$key]['url'] = preg_replace_callback($value, create_function('$matches', 'return '.$output['preg']['replace'][$key].';'), $nav['url']);
473+
}
464474
}
465475
}
466476
}

source/function/function_admincp.php

Lines changed: 18 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,93 +1325,53 @@ function getposttableselect() {
13251325
return $posttableselect;
13261326
}
13271327

1328-
function rewritereplace($content){
1329-
global $_G;
1330-
if(in_array('portal_topic', $_G['setting']['rewritestatus'])) {
1331-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['portal']."\?mod\=topic&(amp;)?topic\=([^#]+?)?\"([^\>]*)\>/", function($matches) { return rewriteoutput('portal_topic', 0, $matches[1], $matches[3], $matches[4]); }, $content);
1332-
}
1333-
1334-
if(in_array('portal_article', $_G['setting']['rewritestatus'])) {
1335-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['portal']."\?mod\=view&(amp;)?aid\=(\d+)(&page\=(\d+))?\"([^\>]*)\>/", function($matches) { return rewriteoutput('portal_article', 0, $matches[1], $matches[3], $matches[5], $matches[6]); }, $content);
1336-
}
1337-
1338-
if(in_array('forum_forumdisplay', $_G['setting']['rewritestatus'])) {
1339-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['forum']."\?mod\=forumdisplay&(amp;)?fid\=(\w+)(&page\=(\d+))?\"([^\>]*)\>/", function($matches) { return rewriteoutput('forum_forumdisplay', 0, $matches[1], $matches[3], $matches[5], $matches[6]); }, $content);
1340-
}
1341-
1342-
if(in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
1343-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['forum']."\?mod\=viewthread&(amp;)?tid\=(\d+)(&extra\=(page\%3D(\d+))?)?(&page\=(\d+))?\"([^\>]*)\>/", function($matches) { return rewriteoutput('forum_viewthread', 0, $matches[1], $matches[3], $matches[8], $matches[6], $matches[9]); }, $content);
1344-
}
1345-
1346-
if(in_array('group_group', $_G['setting']['rewritestatus'])) {
1347-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['forum']."\?mod\=group&(amp;)?fid\=(\d+)(&page\=(\d+))?\"([^\>]*)\>/", function($matches) { return rewriteoutput('group_group', 0, $matches[1], $matches[3], $matches[5], $matches[6]); }, $content);
1348-
}
1349-
1350-
if(in_array('home_space', $_G['setting']['rewritestatus'])) {
1351-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/", function($matches) { return rewriteoutput('home_space', 0, $matches[1], $matches[4], $matches[5], $matches[6]); }, $content);
1352-
}
1353-
1354-
if(in_array('home_blog', $_G['setting']['rewritestatus'])) {
1355-
$content = preg_replace_callback("/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?uid\=(\d+)&(amp;)?do=blog&(amp;)?id=(\d+)\"([^\>]*)\>/", function($matches) { return rewriteoutput('home_blog', 0, $matches[1], $matches[3], $matches[6], $matches[7]); }, $content);
1356-
}
1357-
1358-
if(in_array('forum_archiver', $_G['setting']['rewritestatus'])) {
1359-
$content = preg_replace_callback("/<a href\=\"\?(fid|tid)\-(\d+)\.html(&page\=(\d+))?\"([^\>]*)\>/", function($matches) { return rewriteoutput('forum_archiver', 0, $matches[1], $matches[2], $matches[4], $matches[5]); }, $content);
1360-
}
1361-
1362-
if(in_array('plugin', $_G['setting']['rewritestatus'])) {
1363-
$content = preg_replace_callback("/<a href\=\"plugin\.php\?id=([a-z]+[a-z0-9_]*):([a-z0-9_\-]+)(&amp;|&)?(.*?)?\"([^\>]*)\>/", function($matches) { return rewriteoutput('plugin', 0, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]); }, $content);
1364-
}
1365-
return $content;
1366-
}
1367-
13681328
function rewritedata($alldata = 1) {
13691329
global $_G;
13701330
$data = array();
13711331
if(!$alldata) {
13721332
if(in_array('portal_topic', $_G['setting']['rewritestatus'])) {
1373-
$data['search']['portal_topic'] = "/".$_G['domain']['pregxprw']['portal']."\?mod\=topic&(amp;)?topic\=([^#]+?)?\"([^\>]*)\>/e";
1374-
$data['replace']['portal_topic'] = "rewriteoutput('portal_topic', 0, '\\1', '\\3', '\\4')";
1333+
$data['search']['portal_topic'] = "/".$_G['domain']['pregxprw']['portal']."\?mod\=topic&(amp;)?topic\=([^#]+?)?\"([^\>]*)\>/";
1334+
$data['replace']['portal_topic'] = 'rewriteoutput(\'portal_topic\', 0, $matches[1], $matches[3], $matches[4])';
13751335
}
13761336

13771337
if(in_array('portal_article', $_G['setting']['rewritestatus'])) {
1378-
$data['search']['portal_article'] = "/".$_G['domain']['pregxprw']['portal']."\?mod\=view&(amp;)?aid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/e";
1379-
$data['replace']['portal_article'] = "rewriteoutput('portal_article', 0, '\\1', '\\3', '\\5', '\\6')";
1338+
$data['search']['portal_article'] = "/".$_G['domain']['pregxprw']['portal']."\?mod\=view&(amp;)?aid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/";
1339+
$data['replace']['portal_article'] = 'rewriteoutput(\'portal_article\', 0, $matches[1], $matches[3], $matches[5], $matches[6])';
13801340
}
13811341

13821342
if(in_array('forum_forumdisplay', $_G['setting']['rewritestatus'])) {
1383-
$data['search']['forum_forumdisplay'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=forumdisplay&(amp;)?fid\=(\w+)(&amp;page\=(\d+))?\"([^\>]*)\>/e";
1384-
$data['replace']['forum_forumdisplay'] = "rewriteoutput('forum_forumdisplay', 0, '\\1', '\\3', '\\5', '\\6')";
1343+
$data['search']['forum_forumdisplay'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=forumdisplay&(amp;)?fid\=(\w+)(&amp;page\=(\d+))?\"([^\>]*)\>/";
1344+
$data['replace']['forum_forumdisplay'] = 'rewriteoutput(\'forum_forumdisplay\', 0, $matches[1], $matches[3], $matches[5], $matches[6])';
13851345
}
13861346

13871347
if(in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
1388-
$data['search']['forum_viewthread'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=viewthread&(amp;)?tid\=(\d+)(&amp;extra\=(page\%3D(\d+))?)?(&amp;page\=(\d+))?\"([^\>]*)\>/e";
1389-
$data['replace']['forum_viewthread'] = "rewriteoutput('forum_viewthread', 0, '\\1', '\\3', '\\8', '\\6', '\\9')";
1348+
$data['search']['forum_viewthread'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=viewthread&(amp;)?tid\=(\d+)(&amp;extra\=(page\%3D(\d+))?)?(&amp;page\=(\d+))?\"([^\>]*)\>/";
1349+
$data['replace']['forum_viewthread'] = 'rewriteoutput(\'forum_viewthread\', 0, $matches[1], $matches[3], $matches[8], $matches[6], $matches[9])';
13901350
}
13911351

13921352
if(in_array('group_group', $_G['setting']['rewritestatus'])) {
1393-
$data['search']['group_group'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=group&(amp;)?fid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/e";
1394-
$data['replace']['group_group'] = "rewriteoutput('group_group', 0, '\\1', '\\3', '\\5', '\\6')";
1353+
$data['search']['group_group'] = "/".$_G['domain']['pregxprw']['forum']."\?mod\=group&(amp;)?fid\=(\d+)(&amp;page\=(\d+))?\"([^\>]*)\>/";
1354+
$data['replace']['group_group'] = 'rewriteoutput(\'group_group\', 0, $matches[1], $matches[3], $matches[5], $matches[6])';
13951355
}
13961356

13971357
if(in_array('home_space', $_G['setting']['rewritestatus'])) {
1398-
$data['search']['home_space'] = "/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/e";
1399-
$data['replace']['home_space'] = "rewriteoutput('home_space', 0, '\\1', '\\4', '\\5', '\\6')";
1358+
$data['search']['home_space'] = "/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/";
1359+
$data['replace']['home_space'] = 'rewriteoutput(\'home_space\', 0, $matches[1], $matches[4], $matches[5], $matches[6])';
14001360
}
14011361

14021362
if(in_array('home_blog', $_G['setting']['rewritestatus'])) {
1403-
$data['search']['home_blog'] = "/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?uid\=(\d+)&(amp;)?do=blog&(amp;)?id=(\d+)\"([^\>]*)\>/e";
1404-
$data['replace']['home_blog'] = "rewriteoutput('home_blog', 0, '\\1', '\\3', '\\6', '\\7')";
1363+
$data['search']['home_blog'] = "/".$_G['domain']['pregxprw']['home']."\?mod=space&(amp;)?uid\=(\d+)&(amp;)?do=blog&(amp;)?id=(\d+)\"([^\>]*)\>/";
1364+
$data['replace']['home_blog'] = 'rewriteoutput(\'home_blog\', 0, $matches[1], $matches[3], $matches[6], $matches[7])';
14051365
}
14061366

14071367
if(in_array('forum_archiver', $_G['setting']['rewritestatus'])) {
1408-
$data['search']['forum_archiver'] = "/<a href\=\"\?(fid|tid)\-(\d+)\.html(&page\=(\d+))?\"([^\>]*)\>/e";
1409-
$data['replace']['forum_archiver'] = "rewriteoutput('forum_archiver', 0, '\\1', '\\2', '\\4', '\\5')";
1368+
$data['search']['forum_archiver'] = "/<a href\=\"\?(fid|tid)\-(\d+)\.html(&page\=(\d+))?\"([^\>]*)\>/";
1369+
$data['replace']['forum_archiver'] = 'rewriteoutput(\'forum_archiver\', 0, $matches[1], $matches[2], $matches[4], $matches[5])';
14101370
}
14111371

14121372
if(in_array('plugin', $_G['setting']['rewritestatus'])) {
1413-
$data['search']['plugin'] = "/<a href\=\"plugin\.php\?id=([a-z]+[a-z0-9_]*):([a-z0-9_\-]+)(&amp;|&)?(.*?)?\"([^\>]*)\>/e";
1414-
$data['replace']['plugin'] = "rewriteoutput('plugin', 0, '\\1', '\\2', '\\3', '\\4', '\\5')";
1373+
$data['search']['plugin'] = "/<a href\=\"plugin\.php\?id=([a-z]+[a-z0-9_]*):([a-z0-9_\-]+)(&amp;|&)?(.*?)?\"([^\>]*)\>/";
1374+
$data['replace']['plugin'] = 'rewriteoutput(\'plugin\', 0, $matches[1], $matches[2], $matches[3], $matches[4], $matches[5])';
14151375
}
14161376
} else {
14171377
$data['rulesearch']['portal_topic'] = 'topic-{name}.html';

source/function/function_core.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,10 @@ function output_replace($content) {
10861086
$_G['setting']['output']['preg']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['preg']['replace']);
10871087
}
10881088

1089-
$content = preg_replace($_G['setting']['output']['preg']['search'], $_G['setting']['output']['preg']['replace'], $content);
1089+
foreach ($_G['setting']['output']['preg']['search'] as $key => $value) {
1090+
$content = preg_replace_callback($value, create_function('$matches', 'return '.$_G['setting']['output']['preg']['replace'][$key].';'), $content);
1091+
}
1092+
10901093
}
10911094

10921095
return $content;

source/plugin/mobile/mobile.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function activeHook($module, $mobileapihook, &$param, $isavariables = false) {
277277
if(!$isavariables) {
278278
$value[$module.'_'.$hookname][$plugin] = $pluginclasses[$hook['class']]->$hook['method']($param);
279279
} else {
280-
$pluginclasses[$hook['class']]->$hook['method']($param);
280+
call_user_func(array($pluginclasses[$hook['class']], $hook['method']), $param);
281281
}
282282
}
283283
}

source/plugin/wechat/wechat.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static public function redirect($type) {
285285
if (!method_exists($class, $hook['method'])) {
286286
return;
287287
}
288-
$return = $class->$hook['method']($type);
288+
$return = call_user_func(array($class, $hook['method']), $type);
289289
if($return) {
290290
return $return;
291291
}

uc_server/lib/template.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function gettpl($file) {
7474
function complie() {
7575
$template = file_get_contents($this->tplfile);
7676
$template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template);
77-
$template = preg_replace("/\{lang\s+(\w+?)\}/ise", "\$this->lang('\\1')", $template);
77+
$template = preg_replace_callback("/\{lang\s+(\w+?)\}/is", function($matches) { return $this->lang($matches[1]); }, $template);
7878

7979
$template = preg_replace("/\{($this->var_regexp)\}/", "<?=\\1?>", $template);
8080
$template = preg_replace("/\{($this->const_regexp)\}/", "<?=\\1?>", $template);

0 commit comments

Comments
 (0)