opentrashmail/web/index.php

34 lines
855 B
PHP
Raw Normal View History

2023-11-08 18:24:48 +00:00
<?php
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
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')
{
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')
exit($backend->renderTemplate('index.html',[
'url'=>implode('/', $url),
'settings'=>loadSettings(),
]));
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
$answer = $backend->run();
2023-11-08 18:24:48 +00:00
if($answer === false)
return false;
else
echo $answer;