This commit is contained in:
2024-03-29 15:47:35 +01:00
parent 85d2cf4be2
commit 7619856ef2
27 changed files with 2255 additions and 193 deletions

13
inc/db.inc.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$config = require_once __DIR__ . '/../config.php';
$db = new PDO(
$config->sql->dsn,
$config->sql->user,
$config->sql->password,
[
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
]
);
?>

View File

@ -1,15 +1,15 @@
<?php
$routes = [
'doppelklinge' => 'doppelklinge',
'vermessung' => 'vermessung',
'default' => 'default'
];
ob_start();
if(array_key_exists($_page, $routes))
require_once("./pages/{$routes[$_page]}.page.php");
else
require_once("./pages/{$routes['default']}.page.php");
$_content = ob_get_contents();
ob_end_clean();
<?php
$_page = isset($_GET['p']) ? $_GET['p'] : '';
$routes = [
'doppelklinge' => 'doppelklinge',
'vermessung' => 'vermessung',
'knochen' => 'knochen',
'default' => 'default'
];
ob_start();
require_once __DIR__ . "/../pages/{$routes[array_key_exists($_page, $routes)?$_page:'default']}.php";
$_content = ob_get_contents();
ob_end_clean();

View File

@ -1,6 +1,7 @@
<?php
class tpl {
static $blocks = array();
static $views_path = '/home/users/flumm/www/dev.fwtrash.de/views/';
static $cache_path = '/home/users/flumm/tmp/';
static function view($file, $data = array()) {
@ -32,12 +33,11 @@ class tpl {
}
static function includeFiles($file) {
$code = file_get_contents($file);
$code = file_get_contents(self::$views_path . $file);
preg_match_all('/{% ?(extends|include) ?\'?(.*?)\'? ?%}/i', $code, $matches, PREG_SET_ORDER);
foreach($matches as $value)
$code = str_replace($value[0], self::includeFiles($value[2]), $code);
$code = preg_replace('/{% ?(extends|include) ?\'?(.*?)\'? ?%}/i', '', $code);
return $code;
return preg_replace('/{% ?(extends|include) ?\'?(.*?)\'? ?%}/i', '', $code);
}
static function compilePHP($code) {
@ -69,8 +69,7 @@ class tpl {
static function compileYield($code) {
foreach(self::$blocks as $block => $value)
$code = preg_replace('/{% ?yield ?' . $block . ' ?%}/', $value, $code);
$code = preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code);
return $code;
return preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code);
}
}
?>