more preparations and also small sanity fixes
This commit is contained in:
parent
92765b79fe
commit
cb50641bc4
12
web/api.php
12
web/api.php
|
@ -7,6 +7,13 @@ ini_set('display_errors', 1);
|
||||||
|
|
||||||
include_once(ROOT.DS.'inc'.DS.'core.php');
|
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']);
|
$action = strtolower($_REQUEST['a']);
|
||||||
$email = strtolower($_REQUEST['email']);
|
$email = strtolower($_REQUEST['email']);
|
||||||
if(!empty($email)){
|
if(!empty($email)){
|
||||||
|
@ -88,16 +95,14 @@ switch($action)
|
||||||
$emails = listEmailAdresses();
|
$emails = listEmailAdresses();
|
||||||
$emaillist = array();
|
$emaillist = array();
|
||||||
|
|
||||||
if(count($emails))
|
if(count($emails)>0)
|
||||||
{
|
{
|
||||||
foreach($emails as $email)
|
foreach($emails as $email)
|
||||||
{
|
{
|
||||||
$emaildata = getEmailsOfEmail($email);
|
$emaildata = getEmailsOfEmail($email);
|
||||||
foreach($emaildata as $time=>$d)
|
foreach($emaildata as $time=>$d)
|
||||||
{
|
|
||||||
$emaillist[$time.'-'.$email]=$d;
|
$emaillist[$time.'-'.$email]=$d;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(is_array($emaillist))
|
if(is_array($emaillist))
|
||||||
krsort($emaillist);
|
krsort($emaillist);
|
||||||
$data = (count($emaillist)?$emaillist:array());
|
$data = (count($emaillist)?$emaillist:array());
|
||||||
|
@ -127,4 +132,3 @@ switch($action)
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($o);
|
echo json_encode($o);
|
||||||
//var_dump($o);
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ function emailIDExists($email,$id)
|
||||||
|
|
||||||
function getEmailsOfEmail($email)
|
function getEmailsOfEmail($email)
|
||||||
{
|
{
|
||||||
$o = false;
|
$o = [];
|
||||||
if ($handle = opendir(getDirForEmail($email))) {
|
if ($handle = opendir(getDirForEmail($email))) {
|
||||||
while (false !== ($entry = readdir($handle))) {
|
while (false !== ($entry = readdir($handle))) {
|
||||||
if (endsWith($entry,'.json')) {
|
if (endsWith($entry,'.json')) {
|
||||||
|
@ -54,7 +54,6 @@ function getEmailsOfEmail($email)
|
||||||
function listEmailAdresses()
|
function listEmailAdresses()
|
||||||
{
|
{
|
||||||
$o = array();
|
$o = array();
|
||||||
$o = false;
|
|
||||||
if ($handle = opendir(ROOT.DS.'..'.DS.'data'.DS)) {
|
if ($handle = opendir(ROOT.DS.'..'.DS.'data'.DS)) {
|
||||||
while (false !== ($entry = readdir($handle))) {
|
while (false !== ($entry = readdir($handle))) {
|
||||||
if(filter_var($entry, FILTER_VALIDATE_EMAIL))
|
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");
|
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);
|
array_shift($url);
|
||||||
|
|
||||||
$email = $url[0];
|
$email = $url[0];
|
||||||
|
|
Loading…
Reference in a new issue