more preparations and also small sanity fixes
This commit is contained in:
parent
92765b79fe
commit
cb50641bc4
14
web/api.php
14
web/api.php
|
@ -7,6 +7,13 @@ ini_set('display_errors', 1);
|
|||
|
||||
include_once(ROOT.DS.'inc'.DS.'core.php');
|
||||
|
||||
if (PHP_SAPI === 'cli-server')
|
||||
$_SERVER['SCRIPT_NAME'] = pathinfo(__FILE__, PATHINFO_BASENAME);
|
||||
|
||||
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),'/')));
|
||||
|
||||
$action = strtolower($_REQUEST['a']);
|
||||
$email = strtolower($_REQUEST['email']);
|
||||
if(!empty($email)){
|
||||
|
@ -88,15 +95,13 @@ switch($action)
|
|||
$emails = listEmailAdresses();
|
||||
$emaillist = array();
|
||||
|
||||
if(count($emails))
|
||||
if(count($emails)>0)
|
||||
{
|
||||
foreach($emails as $email)
|
||||
{
|
||||
$emaildata = getEmailsOfEmail($email);
|
||||
foreach($emaildata as $time=>$d)
|
||||
{
|
||||
$emaillist[$time.'-'.$email]=$d;
|
||||
}
|
||||
}
|
||||
if(is_array($emaillist))
|
||||
krsort($emaillist);
|
||||
|
@ -126,5 +131,4 @@ switch($action)
|
|||
break;
|
||||
}
|
||||
|
||||
echo json_encode($o);
|
||||
//var_dump($o);
|
||||
echo json_encode($o);
|
|
@ -33,7 +33,7 @@ function emailIDExists($email,$id)
|
|||
|
||||
function getEmailsOfEmail($email)
|
||||
{
|
||||
$o = false;
|
||||
$o = [];
|
||||
if ($handle = opendir(getDirForEmail($email))) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if (endsWith($entry,'.json')) {
|
||||
|
@ -54,7 +54,6 @@ function getEmailsOfEmail($email)
|
|||
function listEmailAdresses()
|
||||
{
|
||||
$o = array();
|
||||
$o = false;
|
||||
if ($handle = opendir(ROOT.DS.'..'.DS.'data'.DS)) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if(filter_var($entry, FILTER_VALIDATE_EMAIL))
|
||||
|
|
|
@ -10,7 +10,13 @@ include_once(ROOT.DS.'inc'.DS.'core.php');
|
|||
|
||||
header("Content-Type: application/rss+xml; charset=UTF8");
|
||||
|
||||
$url = explode('/',ltrim($_GET['url'],'/'));
|
||||
if (PHP_SAPI === 'cli-server')
|
||||
$_SERVER['SCRIPT_NAME'] = pathinfo(__FILE__, PATHINFO_BASENAME);
|
||||
|
||||
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),'/')));
|
||||
|
||||
array_shift($url);
|
||||
|
||||
$email = $url[0];
|
||||
|
|
Loading…
Reference in a new issue