2023-11-08 18:24:48 +00:00
|
|
|
<?php
|
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
|
|
|
define('ROOT', dirname(__FILE__));
|
|
|
|
|
2023-11-08 21:29:13 +00:00
|
|
|
include_once(ROOT.DS.'inc'.DS.'OpenTrashmailBackend.class.php');
|
2023-11-08 18:24:48 +00:00
|
|
|
include_once(ROOT.DS.'inc'.DS.'core.php');
|
|
|
|
|
|
|
|
$url = array_filter(explode('/',ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/')));
|
|
|
|
|
2023-11-09 08:45:31 +00:00
|
|
|
$backend = new OpenTrashmailBackend($url);
|
|
|
|
|
2023-11-08 18:24:48 +00:00
|
|
|
if($_SERVER['HTTP_HX_REQUEST']!='true')
|
|
|
|
{
|
2023-11-08 21:29:13 +00:00
|
|
|
if(count($url)==0 || !file_exists(ROOT.DS.implode('/', $url)))
|
2023-11-11 15:41:14 +00:00
|
|
|
if($url[0]!='api' && $url[0]!='rss' && $url[0]!='json')
|
2023-11-09 22:21:17 +00:00
|
|
|
exit($backend->renderTemplate('index.html',[
|
2023-11-11 13:36:34 +00:00
|
|
|
'url'=>implode('/', $url),
|
|
|
|
'settings'=>loadSettings(),
|
2023-11-09 22:21:17 +00:00
|
|
|
]));
|
2023-11-08 18:24:48 +00:00
|
|
|
}
|
2023-11-11 16:01:07 +00:00
|
|
|
else if(count($url)==1 && $url[0] == 'api') {
|
|
|
|
exit($backend->renderTemplate('intro.html'));
|
|
|
|
}
|
2023-11-08 18:24:48 +00:00
|
|
|
|
2023-11-09 08:45:31 +00:00
|
|
|
|
2023-11-08 21:29:13 +00:00
|
|
|
$answer = $backend->run();
|
|
|
|
|
2023-11-08 18:24:48 +00:00
|
|
|
|
|
|
|
if($answer === false)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
echo $answer;
|
|
|
|
|