This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
dogstats/web/index.php
Chris 3bb9f4ea76
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s
rewrite for cleaner dev aber geht noch nicht
2023-10-21 13:04:53 +02:00

35 lines
1.1 KiB
PHP

<?php
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
if($_SERVER['HTTP_HX_REQUEST']!='true')
exit(file_get_contents(ROOT.DS.'templates'.DS.'mainpage.html'));
// 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();
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),'/')));
if($url==[] && $_SERVER['HTTP_HX_CURRENT_URL'])
$url = explode('/',ltrim(parse_url($_SERVER['HTTP_HX_CURRENT_URL'], PHP_URL_PATH),'/'));
//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']);