diff options
Diffstat (limited to 'common.php')
-rw-r--r-- | common.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common.php b/common.php new file mode 100644 index 0000000..c505660 --- /dev/null +++ b/common.php @@ -0,0 +1,29 @@ +<?php + +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]; + return ""; + }, + $__page + ); + $page = SRCDIR . "/pages/" . bin2hex(random_bytes(8)) . ".tmp"; + file_put_contents($page, $__page); + unset($__page); + + ob_start(); + include SRCDIR . "/template.php"; + $output = ob_get_clean(); + if ($output === false) + $output = ""; + + if (is_file($page)) + unlink($page); + + return $output; +} |