diff options
Diffstat (limited to 'common.php')
-rw-r--r-- | common.php | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -2,19 +2,19 @@ define("SRCDIR", realpath(__DIR__ . "/src/")); -function hzcom_expand(string $__page): string { - $title = ""; - $__page = preg_replace_callback( - ';<title>(.*?)</title>;i', - function(array $matches) use(&$title): string { - $title = $matches[1]; +function hzcom_expand(string $pageContents): string { + $params = []; + $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; + file_put_contents($page, preg_replace_callback( + "/<param:(?'paramName'[a-z][a-z0-9_-]*?)\s*>" . + "(?'paramValue'.*?)<\/param:\\1\s*>/s", + function(array $matches) use (&$params) { + $params[$matches['paramName']] = $matches['paramValue']; return ""; }, - $__page - ); - $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; - file_put_contents($page, $__page); - unset($__page); + $pageContents + )); + unset($pageContents); ob_start(); include SRCDIR . "/template.php"; |