Skip to content

Commit

Permalink
Bugfix for unexpected T_FUNCTION with PHP 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkh committed Mar 2, 2014
1 parent b718494 commit 2ce2696
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Binary file modified backend/tpl/projektvorlage.tar
Binary file not shown.
39 changes: 19 additions & 20 deletions projekt01/cms/inc/frontend.php
Expand Up @@ -264,34 +264,33 @@
header("HTTP/1.1 404 Not Found");
header ('Status: 404 Not Found');
}

// Sefrengolinks ersetzen
// Anonymous functions become available with PHP 5.3.0 and preg_replace with /e modifier is deprecated since PHP 5.5.0
// @see: http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php#reference.pcre.pattern.modifiers.eval
if (version_compare(PHP_VERSION, '5.3.0') >= 0)
{
$code = preg_replace_callback(
'!cms://idcat=(\d+)!',
function($match) use ($con_tree) {
return $con_tree[$match[1]]['link'];
},
$code);
$code = preg_replace_callback(
'!cms://idcatside=(\d+)!',
function($match) use ($con_side) {
return $con_side[$match[1]]['link'];
},
$code);
function match_tree(array $match) {
global $con_tree;
return $con_tree[$match[1]]['link'];
}

$code = preg_replace_callback('!cms://idcat=(\d+)!', 'match_tree', $code);

function match_side(array $match) {
global $con_side;
return $con_side[$match[1]]['link'];
}

$code = preg_replace_callback('!cms://idcatside=(\d+)!', 'match_side', $code);

if ($cfg_client['url_rewrite'] == '2')
{
$code = preg_replace_callback(
'!(<a[\s]+[^>]*?href[\s]?=[\s\"\']+)#(.*?)([\"\'])!',
function($match) {
return $match[1].str_replace('&', '&amp;', $_SERVER['REQUEST_URI']).'#'.$match[2].$match[3];
},
$code);
function match_amp(array $match) {
return $match[1].str_replace('&', '&amp;', $_SERVER['REQUEST_URI']).'#'.$match[2].$match[3];
}

$code = preg_replace_callback('!(<a[\s]+[^>]*?href[\s]?=[\s\"\']+)#(.*?)([\"\'])!', 'match_amp', $code);
}
}
else
Expand Down

0 comments on commit 2ce2696

Please sign in to comment.