<div class="animated fadeInDown2">

<div class="box-body">
<div class="padd-lr10">

<div class='clearX infoboxline'></div>

<?PHP 
$saveFile="./../".$SYSD."/messages3.inc.txt";
if (file_exists($saveFile)){unlink($saveFile);}
$saveFile4="./../".$SYSD."/messages3x.inc.txt";
if (file_exists($saveFile4)){unlink($saveFile4);}
$saveFile2="./../".$SYSD."/messagebox3.inc.txt";

$saveMailFile="./../".$SYSD."/check-mails.inc.php";
if (file_exists($saveMailFile)){unlink($saveMailFile);}

include("./functions/messages-check.inc.php");
echo "
<div class='ph10'></div>
<div class='tdu font20'>".$messagedata4."</div>
";

if($mesBox1 <= 0){
echo "<div class=''>".$topinfoX4."</div>";
}

$mailProjects=opendir ("./../".$SYSI."/dataA");
while ($pFiles=readdir ($mailProjects)){
$pFilesArray[] = $pFiles;
}
closedir($mailProjects);
natcasesort ($pFilesArray);
foreach($pFilesArray as $valueM)
if($valueM != '.' && $valueM != '..' && $valueM != '.htaccess'){

$pFileA=substr($valueM, 0, 9);
$pFileB=substr($valueM, 10, 6);
$pFileC=substr($valueM, 0, -4);
$pFileD=substr($valueM, 0, 16);
$pFileP=file_get_contents("../".$SYSI."/dataA/".$valueM);

if($pFileB != "p00"){
include("./../configure/".$pFileD."-data.inc.php");
$pFileX=$folderR1;
//echo $pFileX;
include("./function/messages-new-list.inc.php");
}
}

$handle=opendir("./../".$SYSD."/messages-new");
if($handle)
$mailsSum=0;
while($file=readdir($handle))
{$mailsSum++;}
$mailsSum=$mailsSum-2;

echo "
<div class='ph15'></div>
<div class='clearX infoboxline'></div>
<div class='ph10'></div>
<div class='tdu font20'>".$messagedata1a." (".$mailsSum.")</div>
";

$mailsNew=opendir ("./../".$SYSD."/messages-new");
while ($pMails=readdir ($mailsNew)){
$pMailsArray[] = $pMails;
}
closedir($mailsNew);
arsort ($pMailsArray);
foreach($pMailsArray as $mailsX)
if($mailsX != '.' && $mailsX != '..' && $valueM != '.htaccess'){

$mails1=substr($mailsX, 16, 10);
$mails2=substr($mailsX, 27, 8);
$mails2=str_replace("-",":",$mails2);
$mails3a=substr($mailsX, 0, 36);
$mails3b=substr($mailsX, 0, -8);
$mails4=str_replace($mails3a,"",$mailsX);
$mails4=substr($mails4, 0, -8);
include("./../configure/".$mails4."-project.inc.php");

echo "
<div>
<a href='$elink?mailopen=$mailsX'>
<span><i class='fa fa-envelope font18 padd-right5 resB'></i>
</a>
<span>".$mails1." ".$mails2." </span>
<span class='wbx'></span>
<span> ".$messagedata3." ".$project1."</span>
</div>
<div class='ph5'></div>
";
}
echo "
<div class='ph10'></div>
<div class='clearX infoboxline'></div>
";

if($mesBox1 <= 0){}else{
$file = file($saveFile);
if(count($file)){
$sum=0;
foreach($file as $line){
$int=(int) preg_replace('~(.*)\|(\d+)\|(.*)~','$2',$line);
$sum += $int;
}
$sumA=$sum;
}
$handle=fopen($saveFile2, "w");
fwrite($handle,$sumA);
fclose($handle);
$oldumask = umask(0);
chmod($saveFile2, 0644);
umask($oldumask);
}

include("./../configure/os-data.inc.php");
?>

</div><!-- padd -->
</div><!-- End box-body -->

<div class="clearX box-footer"></div>

</div><!-- End animated -->
