2023-10-18 22:42:01 +02:00
|
|
|
<?php
|
2023-10-22 23:05:24 +02:00
|
|
|
|
2023-10-18 22:42:01 +02:00
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
|
|
|
define('ROOT', dirname(__FILE__));
|
|
|
|
|
|
|
|
// if(file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
|
|
|
|
// include_once(ROOT.DS.'inc'.DS.'config.inc.php');
|
|
|
|
// else die('ERR: no config file found :(');
|
|
|
|
|
|
|
|
include_once(ROOT.DS.'inc'.DS.'core.php');
|
|
|
|
includeManagement();
|
|
|
|
|
2023-10-22 23:05:24 +02:00
|
|
|
session_start();
|
|
|
|
|
2023-10-22 01:46:22 +02:00
|
|
|
if($_SERVER['HTTP_HX_REQUEST']!='true')
|
|
|
|
{
|
|
|
|
include(ROOT.DS.'templates'.DS.'mainpage.html');
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2023-10-18 22:42:01 +02:00
|
|
|
if($_GET['url'])
|
|
|
|
$url = explode('/',ltrim(parse_url($_GET['url'], PHP_URL_PATH),'/'));
|
|
|
|
else $url = array_filter(explode('/',ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/')));
|
|
|
|
|
|
|
|
|
2023-10-20 20:41:49 +02:00
|
|
|
if($url==[] && $_SERVER['HTTP_HX_CURRENT_URL'])
|
|
|
|
$url = explode('/',ltrim(parse_url($_SERVER['HTTP_HX_CURRENT_URL'], PHP_URL_PATH),'/'));
|
|
|
|
|
2023-10-22 09:57:29 +02:00
|
|
|
$GLOBALS['url'] = $url;
|
2023-10-18 22:42:01 +02:00
|
|
|
//echo print_r(['url'=>$url,'server'=>$_SERVER,'request'=>$_REQUEST,'cookie'=>$_COOKIE,'session'=>$_SESSION],true);
|
|
|
|
|
|
|
|
$response = callHook($url);
|
|
|
|
|
|
|
|
if(is_string($response))
|
|
|
|
echo $response;
|
|
|
|
else if(is_array($response))
|
|
|
|
echo json_encode($response);
|
|
|
|
else if(is_object($response))
|
|
|
|
echo json_encode($response);
|
|
|
|
else echo json_encode(['error'=>'unknown response type']);
|