uff
This commit is contained in:
		@@ -1,6 +1,4 @@
 | 
			
		||||
<?php
 | 
			
		||||
$config = require_once __DIR__ . '/../config.php';
 | 
			
		||||
 | 
			
		||||
$db = new PDO(
 | 
			
		||||
  $config->sql->dsn,
 | 
			
		||||
  $config->sql->user,
 | 
			
		||||
@@ -10,4 +8,3 @@ $db = new PDO(
 | 
			
		||||
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
 | 
			
		||||
  ]
 | 
			
		||||
);
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
$_page = isset($_GET['p']) ? $_GET['p'] : '';
 | 
			
		||||
 | 
			
		||||
$routes = [
 | 
			
		||||
@@ -9,6 +11,7 @@ $routes = [
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
ob_start();
 | 
			
		||||
 | 
			
		||||
require_once __DIR__ . "/../pages/{$routes[array_key_exists($_page, $routes)?$_page:'default']}.php";
 | 
			
		||||
 | 
			
		||||
$_content = ob_get_contents();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
<?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()) {
 | 
			
		||||
    $cached_file = self::cache($file);
 | 
			
		||||
@@ -12,9 +10,10 @@ class tpl {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static function cache($file) {
 | 
			
		||||
    if(!file_exists(self::$cache_path))
 | 
			
		||||
      mkdir(self::$cache_path, 0744);
 | 
			
		||||
    $cached_file = self::$cache_path . str_replace(array('/', '.html'), array('_', ''), $file . '.php');
 | 
			
		||||
    global $config;
 | 
			
		||||
    if(!file_exists($config->env->cache))
 | 
			
		||||
      mkdir($config->env->cache, 0744);
 | 
			
		||||
    $cached_file = $config->env->cache . str_replace(array('/', '.html'), array('_', ''), $file . '.php');
 | 
			
		||||
    if(!file_exists($cached_file) || filemtime($cached_file) < filemtime($file)) {
 | 
			
		||||
      $code = self::includeFiles($file);
 | 
			
		||||
      $code = self::compileCode($code);
 | 
			
		||||
@@ -33,7 +32,8 @@ class tpl {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static function includeFiles($file) {
 | 
			
		||||
    $code = file_get_contents(self::$views_path . $file);
 | 
			
		||||
    global $config;
 | 
			
		||||
    $code = file_get_contents($config->env->views . $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);
 | 
			
		||||
@@ -72,4 +72,3 @@ class tpl {
 | 
			
		||||
    return preg_replace('/{% ?yield ?(.*?) ?%}/i', '', $code);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								index.php
									
									
									
									
									
								
							@@ -1,9 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
session_start();
 | 
			
		||||
 | 
			
		||||
error_reporting(0);
 | 
			
		||||
ini_set('display_errors', 0);
 | 
			
		||||
 | 
			
		||||
require_once __DIR__ . '/config.php';
 | 
			
		||||
require_once __DIR__ . '/inc/db.inc.php';
 | 
			
		||||
require_once __DIR__ . '/inc/tpl.class.php';
 | 
			
		||||
require_once __DIR__ . '/inc/router.inc.php';
 | 
			
		||||
 | 
			
		||||
@@ -15,7 +12,8 @@ if(!@$tpl->debug) {
 | 
			
		||||
  tpl::view($tpl->file,
 | 
			
		||||
    array_merge([
 | 
			
		||||
      'page' => $_page,
 | 
			
		||||
      'generated' => $generated
 | 
			
		||||
      'generated' => $generated,
 | 
			
		||||
      'basepath' => $config->env->basepath
 | 
			
		||||
    ],
 | 
			
		||||
    gettype($tpl->data) !== 'string' ? $tpl->data : [])
 | 
			
		||||
  );
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +1,7 @@
 | 
			
		||||
<?php
 | 
			
		||||
session_start();
 | 
			
		||||
 | 
			
		||||
error_reporting(E_ALL);
 | 
			
		||||
ini_set('display_errors', 1);
 | 
			
		||||
 | 
			
		||||
require_once '../index.php';
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
<head>
 | 
			
		||||
  <meta charset="utf-8" />
 | 
			
		||||
  <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
  <base href="https://fwtrash.de/">
 | 
			
		||||
  <base href="{{ $basepath ?? "https://fwtrash.de" }}">
 | 
			
		||||
  <title>{% yield title %}</title>
 | 
			
		||||
  <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css">
 | 
			
		||||
  <link rel="stylesheet" type="text/css" href="./css/style.css">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user