2023-10-18 22:42:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
spl_autoload_register('autoload');
|
|
|
|
function autoload($className)
|
|
|
|
{
|
|
|
|
//one of the global classes?
|
|
|
|
if (file_exists(ROOT . DS . 'inc'. DS. 'classes' . DS . $className . '.class.php'))
|
|
|
|
require_once(ROOT . DS . 'inc'. DS. 'classes' . DS . $className . '.class.php');
|
|
|
|
else if (file_exists(ROOT . DS . 'pages' . DS . strtolower($className) . DS . 'controller.php'))
|
|
|
|
require_once(ROOT . DS . 'pages' . DS . strtolower($className) . DS . 'controller.php');
|
|
|
|
}
|
|
|
|
|
|
|
|
function includeManagement()
|
|
|
|
{
|
|
|
|
require_once(ROOT.DS.'inc'.DS.'helpers.php');
|
|
|
|
require_once(ROOT.DS.'inc'.DS.'config.inc.php');
|
|
|
|
|
|
|
|
//settings from config
|
|
|
|
if(defined('DEV') && DEV===true)
|
|
|
|
ini_set("display_errors", 1);
|
|
|
|
else ini_set("display_errors", 0);
|
|
|
|
|
|
|
|
if(file_exists(ROOT.DS.'inc'.DS.'vendor'.DS.'autoload.php'))
|
|
|
|
require_once(ROOT.DS.'inc'.DS.'vendor'.DS.'autoload.php');
|
2023-10-18 19:08:38 +02:00
|
|
|
|
|
|
|
//DB
|
|
|
|
if(defined('REDIS_SERVER') && REDIS_SERVER !='')
|
|
|
|
$GLOBALS['redis'] = new Redis();
|
|
|
|
else
|
|
|
|
$GLOBALS['redis'] = false;
|
2023-10-18 22:42:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function callHook($url)
|
|
|
|
{
|
|
|
|
$queryString = array();
|
|
|
|
|
|
|
|
if (!$url[0]) {
|
|
|
|
$component = 'home';
|
|
|
|
$action = 'index';
|
|
|
|
} else {
|
|
|
|
$urlArray = $url;
|
|
|
|
$component = $urlArray[0];
|
|
|
|
array_shift($urlArray);
|
|
|
|
$params = $urlArray;
|
|
|
|
if (isset($urlArray[0])) {
|
|
|
|
$action = $urlArray[0];
|
|
|
|
array_shift($urlArray);
|
|
|
|
} else
|
|
|
|
$action = 'index'; // Default Action
|
|
|
|
$queryString = $urlArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!file_exists(ROOT . DS . 'pages' . DS . $component . DS . 'controller.php')) {
|
|
|
|
$component = 'err';
|
|
|
|
$action = 'notfound';
|
|
|
|
$queryString = array($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
$componentName = ucfirst($component);
|
|
|
|
|
|
|
|
$dispatch = new $componentName($component, $action, false);
|
|
|
|
|
|
|
|
if (!$dispatch->maySeeThisPage()) {
|
|
|
|
$componentName = 'err';
|
|
|
|
$action = 'notallowed';
|
|
|
|
$dispatch = new $componentName('error', $action, true);
|
|
|
|
} else
|
|
|
|
$dispatch = new $componentName($component, $action, true, $queryString);
|
|
|
|
|
|
|
|
if (method_exists($componentName, $action)) {
|
2023-10-20 20:41:49 +02:00
|
|
|
$response = call_user_func_array(array($dispatch, $action), $queryString);
|
2023-10-18 22:42:01 +02:00
|
|
|
} else if (method_exists($componentName, 'catchAll'))
|
2023-10-20 20:41:49 +02:00
|
|
|
$response = call_user_func_array(array($dispatch, 'catchAll'), array($params));
|
2023-10-18 22:42:01 +02:00
|
|
|
|
2023-10-20 20:41:49 +02:00
|
|
|
if(is_string($response))
|
|
|
|
return $response;
|
|
|
|
else
|
|
|
|
return $dispatch->renderPagecontent();
|
2023-10-18 22:42:01 +02:00
|
|
|
}
|