Files
Testing/mailservices/bateworld/mail/subscriptions.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

263 lines
4.3 KiB
PHP

<?php header('Content-type: text/html; charset=utf-8');
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/includes/');
include(PATHTOINCLUDES."base.php");
//include(PATHTOINCLUDES."mail/class_folders.php");
//Written by Philip Poremba 07/28/2012
$dbcon=dbconnect();
$em="";
$_SESSION["user_uri"]="/bateworld/mail/subscriptions.php";
$_SESSION["pagename"]="Process Subscriptions";
$_SESSION["the_section_location"] = "/bateworld/mail/subscriptions.php";
$_SESSION["the_section_container"]="section_content";
$_SESSION["the_tab"]="three";
if(isset($_GET["maid"])){$_SESSION["inbox_maid"]=$_GET["maid"];}
$sql="SELECT
`mail_accounts`.`maid`,
`mail_accounts`.`username`,
`mail_accounts`.`password`,
`mail_accounts`.`host`,
`mail_accounts`.`port`
FROM
`mail_accounts`
WHERE `mail_accounts`.`maid`=".$_SESSION["inbox_maid"];
$result=mysql_query($sql) or $em=$em.mysql_error();
$m=mysql_fetch_assoc($result);
$mbox = @imap_open("{localhost:143/novalidate-cert}", $m["username"], $m["password"]);
$folders = imap_listmailbox($mbox, "{localhost:143}", "*");
if(!in_array('{localhost:143}INBOX.Processed',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Processed"));
$change=1;
}
if(!in_array('{localhost:143}INBOX.Scanned',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Scanned"));
$change=1;
}
if(!in_array('{localhost:143}Inbox.Action',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Action"));
$change=1;
}
if(!in_array('{localhost:143}Inbox.Forwarded',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Forwarded"));
$change=1;
}
if(!in_array('{localhost:143}Inbox.Saved',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Saved"));
$change=1;
}
if(!in_array('{localhost:143}Inbox.Abuse',$folders)) {
@imap_createmailbox($mbox, imap_utf7_encode("{localhost:143}INBOX.Abuse"));
$change=1;
}
imap_close($mbox);
?>
<div id="mailboxcont" style="padding:10px;">
<h1 style="margin-bottom:10px;font-size:90%;">Process <?php echo $m["username"];?></h1>
<?php
if (($mbox = imap_open("{localhost:143/novalidate-cert}INBOX", $m["username"], $m["password"])) !=false)
{
@$n_msgs = imap_num_msg($mbox);
}
else
{
$n_msgs=0;
}
for ($i=1; $i<=$n_msgs; $i++) {
//$thebody=imap_qprint(imap_body($mbox, $i));
$thebody=imap_fetchbody($mbox, $i, '');
$header = imap_headerinfo($mbox, $i);
$subject = imap_utf8($header->Subject);
$from = $header->from;
$prettydate = date("m-d-Y", $header->udate);
foreach ($from as $id => $object) {
$fromname = $object->personal;
$fromaddress = $object->mailbox . "@" . $object->host;
}
if (stripos($subject, 'delivery failed') !== false || stripos($subject, 'Delivery Status Notification (Failure)') !== false){
// echo "<div style=\"padding-bottom:20px;\">".$thebody."</div>";
// $testabc=imap_fetchstructure($mbox, $i);
// echo var_dump($testabc);
//echo stripos($thebody, 'relval');
$start=stripos($thebody, 'refval');
if($start){
$end=stripos($thebody,"'",$start);
$start=$start+7;
$end=$end;
$clong=$end-$start;
$rest = substr($thebody, $start, $clong);
echo "<div>Date: ".$prettydate."&nbsp; From:".$fromname."<br />Subject: ".$subject."</div>";
$dbcon2=dbconnect2();
$sql2="SELECT `se_users`.`user_id`, `se_users`.`user_email`
FROM `se_users`
WHERE `se_users`.`user_id` = ".$rest;
$result2=mysql_query($sql2) or $em=$em.mysql_error();
echo $em;
$m2=mysql_fetch_assoc($result2);
$mail=$m2["user_email"];
if (stripos($thebody,$mail) !== false)
{
$sqlup="UPDATE `se_users` SET `se_users`.`user_pdp_evc` = 3 WHERE `se_users`.`user_id` = ".$rest;
$resultup=mysql_query($sqlup) or $em=$em.mysql_error;
$move = "INBOX.Processed";
echo "<div>...Moving to Processed Folder</div>";
echo "<hr />";
@imap_mail_move($mbox, $i, $move);
}
mysql_close();
}
}
//$header = imap_headerinfo($mbox, $i);
//echo $header->Subject;
//echo imap_utf8($header->Subject);
}
imap_expunge($mbox);
imap_close($mbox);
?>
<div>&nbsp;</div>
</div>