summaryrefslogtreecommitdiff
path: root/common.php
diff options
context:
space:
mode:
Diffstat (limited to 'common.php')
-rw-r--r--common.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/common.php b/common.php
index c505660..cba823a 100644
--- a/common.php
+++ b/common.php
@@ -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";