integrating admin email into "getEmailsOfEmail"

This commit is contained in:
Christian Haschek 2022-02-09 19:05:20 +01:00
parent afe04765ae
commit 742c251fd6
2 changed files with 34 additions and 8 deletions

View file

@ -93,6 +93,7 @@ switch($action)
break;
case 'list':
/*
$settings = loadSettings();
if($settings['ADMIN'] && $settings['ADMIN']==$admincheck)
{
@ -117,7 +118,7 @@ switch($action)
$o['emails']=$data;
}
else if(!is_dir($dir))
else */if(!is_dir($dir))
$o = array('status'=>'ok','emails'=>[]);
else
{

View file

@ -41,15 +41,40 @@ function emailIDExists($email,$id)
function getEmailsOfEmail($email)
{
$o = [];
if ($handle = opendir(getDirForEmail($email))) {
while (false !== ($entry = readdir($handle))) {
if (endsWith($entry,'.json')) {
$time = substr($entry,0,-5);
$json = json_decode(file_get_contents(getDirForEmail($email).DS.$entry),true);
$o[$time] = array('email'=>$email,'id'=>$time,'from'=>$json['parsed']['from'],'subject'=>$json['parsed']['subject'],'md5'=>md5($time.$json['raw']),'maillen'=>strlen($json['raw']));
$settings = loadSettings();
if($settings['ADMIN'] && $settings['ADMIN']==$email)
{
$emails = listEmailAdresses();
if(count($emails)>0)
{
foreach($emails as $email)
{
if ($handle = opendir(getDirForEmail($email))) {
while (false !== ($entry = readdir($handle))) {
if (endsWith($entry,'.json')) {
$time = substr($entry,0,-5);
$json = json_decode(file_get_contents(getDirForEmail($email).DS.$entry),true);
$o[$time] = array('email'=>$email,'id'=>$time,'from'=>$json['parsed']['from'],'subject'=>$json['parsed']['subject'],'md5'=>md5($time.$json['raw']),'maillen'=>strlen($json['raw']));
}
}
closedir($handle);
}
}
}
closedir($handle);
}
else
{
if ($handle = opendir(getDirForEmail($email))) {
while (false !== ($entry = readdir($handle))) {
if (endsWith($entry,'.json')) {
$time = substr($entry,0,-5);
$json = json_decode(file_get_contents(getDirForEmail($email).DS.$entry),true);
$o[$time] = array('email'=>$email,'id'=>$time,'from'=>$json['parsed']['from'],'subject'=>$json['parsed']['subject'],'md5'=>md5($time.$json['raw']),'maillen'=>strlen($json['raw']));
}
}
closedir($handle);
}
}
if(is_array($o))