155 lines
6.3 KiB
PHP
155 lines
6.3 KiB
PHP
<?php header('Content-type: text/html; charset=utf-8');
|
|
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/mailservices/includes/');
|
|
include(PATHTOINCLUDES."base.php");
|
|
require_once(PATHTOINCLUDES."/PHPMailer_5.2.1/class.phpmailer.php");
|
|
//Written by Philip Poremba 07/06/2015
|
|
$dconn=dbconnect2();
|
|
$em="";
|
|
$_SESSION["user_uri"]="/mailservices/bateworld/birthday_mail.php";
|
|
$_SESSION["pagename"]="Mail Accounts";
|
|
$_SESSION["the_section_location"] = "/mailservices//bateworld/birthday_mail.php";
|
|
$_SESSION["the_section_container"]="section_content";
|
|
$_SESSION["the_tab"]="six";
|
|
$iTime = time();
|
|
$iMonth = date('n', $iTime);
|
|
$iDay = date('j', $iTime);
|
|
$iYear = date('Y', $iTime);
|
|
$datecheck=0;
|
|
$sqlchkdate="SELECT Count(`birthdayemail_sent`.`thedate`)
|
|
FROM `birthdayemail_sent` WHERE
|
|
DAY(`birthdayemail_sent`.`thedate`) = '".$iDay."' AND MONTH(`birthdayemail_sent`.`thedate`) = '".$iMonth."' AND YEAR(`birthdayemail_sent`.`thedate`) = '".$iYear."'";
|
|
$qchkdate=mysql_query($sqlchkdate) or $em=$em.mysql_error();
|
|
$datecheck = mysql_result($qchkdate,0);
|
|
$sql="SELECT
|
|
`u`.`user_id`,
|
|
`u`.`user_displayname`,
|
|
`u`.`user_fname`,
|
|
`u`.`user_lname`,
|
|
`u`.`user_username`,
|
|
`u`.`user_email`,
|
|
`u`.`user_pdp_evc`,
|
|
`u`.`user_enabled`,
|
|
(floor((UNIX_TIMESTAMP()-`u`.`user_lastlogindate`) / (60*60*24))) AS `daysinactive`,
|
|
`v`.`profilevalue_4` AS `bDate`,
|
|
DAY(`v`.`profilevalue_4`) AS `day`,
|
|
MONTH(`v`.`profilevalue_4`) AS `month`
|
|
FROM `se_users` AS `u`
|
|
INNER JOIN `se_profilevalues` AS `v`
|
|
ON `v`.`profilevalue_user_id` = `u`.`user_id`
|
|
WHERE
|
|
`u`.`user_enabled` = 1 AND
|
|
`u`.`user_pdp_optout` = 0 AND
|
|
(floor((UNIX_TIMESTAMP()-`u`.`user_lastlogindate`) / (60*60*24))) < 90 AND
|
|
(`u`.`user_pdp_evc` = 1 OR `u`.`user_pdp_evc` = 3 OR `u`.`user_pdp_evc` = 5) AND
|
|
DAY(`v`.`profilevalue_4`) = '".$iDay."' AND
|
|
MONTH(`v`.`profilevalue_4`) = '".$iMonth."' AND
|
|
`u`.`user_level_id` IN (1,2)
|
|
ORDER BY `u`.`user_lastlogindate` ASC";
|
|
$result=mysql_query($sql) or $em=$em.mysql_error();
|
|
|
|
if($datecheck == 0)
|
|
{
|
|
if(isset($_GET["process"]))
|
|
{
|
|
if($_GET["process"]==1)
|
|
{
|
|
set_time_limit(300);
|
|
$thedate=$iYear.'-'.$iMonth.'-'.$iDay;
|
|
$sqlupbddate="INSERT INTO `birthdayemail_sent` (`birthdayemail_sent`.`thedate`) VALUES('".$thedate."')";
|
|
$qupbddate=mysql_query($sqlupbddate) or $em=$em.mysql_error();
|
|
//exit();
|
|
$smtpusername="happybirthday@b8world.com";
|
|
$smtppassword="0yC8TiCzZszw";
|
|
|
|
$thetemplate=file_get_contents ("http://bateworld.com/mailservices/email/birthday-email-template.html");
|
|
$subject="Happy Birthday (NSFW)";
|
|
while ($row = mysql_fetch_assoc($result)) {
|
|
$userid=$row["user_id"];
|
|
$mailbody=str_replace('[userid]', $userid, $thetemplate);
|
|
$recipient=$row["user_email"];
|
|
// $recipient="porembaphilip@gmail.com";
|
|
$message=$mailbody;
|
|
$charset="UTF-8";
|
|
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
|
|
try {
|
|
//$mail = new PHPMailer();
|
|
$mail->IsSMTP(); // telling the class to use SMTP
|
|
$mail->Host = "b8world.com"; // SMTP server
|
|
$mail->SMTPAuth = true; // authentication enabled
|
|
$mail->Port = 587;
|
|
// $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
|
|
$mail->CharSet = $charset;
|
|
$mail->Username = $smtpusername; // SMTP account username
|
|
$mail->Password = $smtppassword; // SMTP account password
|
|
//$mail->From = "mailservices@b8world.com";
|
|
$mail->SetFrom($smtpusername, 'Bateworld');
|
|
$mail->AddReplyTo($smtpusername, 'Bateworld');
|
|
$mail->AddAddress($recipient);
|
|
$mail->Subject = $subject;
|
|
$mail->MsgHTML($message);
|
|
$mail->Send();
|
|
} catch (phpmailerException $e) {mail("phil@b8world.com", "MAIL ERROR", $e->errorMessage());
|
|
} catch (Exception $e) {
|
|
//mail("phil@b8world.com", "MAIL ERROR", $e->getMessage());
|
|
}
|
|
$themailsent="Mail Sent";
|
|
echo "<div style=\"font-weight:normal;text-align:left;padding:2px 0 2px 0;\">Mail sent to ".$recipient."</div>";
|
|
} //end while
|
|
exit();
|
|
}// end process = 1
|
|
} // end isset $_GET
|
|
} // end datecheck;
|
|
|
|
|
|
?>
|
|
<div id="birthday_mail" class="list-container">
|
|
<div style="padding:0 0 3px 0;"><h1 style="display:inline-block;">Birthday Email</h1><input type="button" name="pbdmail" id="pbdmail" value="Process Birthday Mail" class="redbutton search-btn" style="float:right;" onclick="getmenucontent('/mailservices/bateworld/birthday_mail.php?process=1','section_content','b8world_tabs','one',this.parentNode,'v');"></div>
|
|
|
|
<?php if($datecheck==0) { ?>
|
|
<div id="useraccounts" class="list-wrap">
|
|
<table width="100%" cellpadding="0" cellspacing="1" id="tb-full" class="tb-full">
|
|
<thead>
|
|
<tr>
|
|
<th class="th-first">On/Off</th>
|
|
<th nowrap="nowrap">EV<sup style="font-size:60%;vertical-align:top;line-height:280%;">2</sup>C</th>
|
|
<th nowrap="nowrap">User</th>
|
|
<th nowrap="nowrap">Email Address</th>
|
|
<th nowrap="nowrap">Birthday</th>
|
|
<th nowrap="nowrap">Inactive</th>
|
|
<th class="th-last" style="text-align:right;padding-right:3px;width:100%;"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$rownum=0;
|
|
while ($row = mysql_fetch_assoc($result)) {
|
|
$rownum=$rownum+1;
|
|
if($rownum % 2 != 0){$rc="#ffff99";} else{$rc="#fff";}
|
|
|
|
echo '<tr style="background:'.$rc.'" onmouseover="this.style.background=\'#ccffcc\';" onmouseout="this.style.background=\''.$rc.'\';" class="trr" valign="top">';
|
|
echo "<td style=\"text-align:center;\">".$row["user_enabled"]."</td>";
|
|
if($row["user_pdp_evc"]==5)
|
|
{
|
|
$sqlup="UPDATE se_users SET user_pdp_evc = 1 WHERE user_id = ".$row["user_id"]."";
|
|
$qyo=mysql_query($sqlup) or $em=$em.mysql_error();
|
|
}
|
|
echo "<td style=\"text-align:center;\">".$row["user_pdp_evc"]."</td>";
|
|
echo "<td>".$row["user_username"]."</td>";
|
|
echo "<td>".$row["user_email"]."</td>";
|
|
echo "<td nowrap=\"nowrap\">".$row["bDate"]."</td>";
|
|
echo "<td nowrap=\"nowrap\" style=\"text-align:right;\">".$row["daysinactive"]."</td>";
|
|
echo "<td></td>";
|
|
echo "</tr>";
|
|
} //end while
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="page-nav">
|
|
<div style="float: right;">
|
|
<?php echo $rownum;?> Records
|
|
</div>
|
|
</div>
|
|
<?php } else {echo "</div><p style=\"text-align:center;font-weight:bold;font-size:120%;\">Today's Birthday Email has already been sent.</p></div>";} ?>
|
|
</div>
|