Send Completed

0) { $timeunits = $timediff / ($total-$numLeft); $timediff = ($timeunits * $numLeft); } else { $timediff = 0; } $timewaiting = timedifference($timediff); ?>

Sending...

Your newsletter is currently being sent. Please do not close this window.

There are emails remaining in the queue.

Time taken so far (approx):
Time until completion (approx):

'; window.close();">Pause / Stop Sending (Can be resumed later)
0) { $throttle_check_result = mysql_query("SELECT * FROM " . $TABLEPREFIX . "sends_perhour WHERE SendID='".addslashes($SendID)."'"); if (mysql_num_rows($throttle_check_result) > 0) { $throttle_check = mysql_fetch_assoc($throttle_check_result); } else { $throttle_check = array('HourStarted' => $SYSTEMTIME, 'HourEnded' => $SYSTEMTIME, 'EmailsSent' => 0); mysql_query("INSERT INTO " . $TABLEPREFIX . "sends_perhour (SendID, HourStarted, HourEnded, EmailsSent) VALUES('" . addslashes($SendID) . "', '" . addslashes($SYSTEMTIME) . "', '" . addslashes($SYSTEMTIME) . "', 0)"); } $PAUSE = 3600/$CURRENTADMIN['PerHour']; // if they're over an hour out, then reset the hourended. this will actually get updated in the database below. if ($SYSTEMTIME - $throttle_check['HourEnded'] > 3600) $throttle_check['HourEnded'] = $SYSTEMTIME; // if the time between the last hourended and the hourstarted are less than the hour, then check the number per hour. $diff = (int)$throttle_check['HourEnded'] - (int)$throttle_check['HourStarted']; if ($diff > 0 && $diff < 3600) { if ($throttle_check['EmailsSent'] >= $CURRENTADMIN['PerHour']) { ?>

:: Send Information ::

Your newsletter has been paused. You have reached your limit of sending emails per hour.

'; window.close();">[Stop Sending -- You Can Always Resume Later]
= 3600) { $result = mysql_query("UPDATE " . $TABLEPREFIX . "sends_perhour SET HourStarted='".addslashes($SYSTEMTIME)."', HourEnded='".addslashes($SYSTEMTIME)."', EmailsSent=0 WHERE SendID='".addslashes($SendID)."'"); } } if ($do_send) { OutputPageFooter(false); } if($PageID=='DoSending' && $do_send) { if ($send['Completed'] != 1) { $max_ex=get_cfg_var('max_execution_time')-3; $time_start=getmicrotime(); $newsletter_query = "SELECT * FROM " . $TABLEPREFIX . "composed_emails WHERE ComposedID='" . $send['ComposedID'] . "'"; $newsletter_result = mysql_query($newsletter_query); $newsletter_details = mysql_fetch_assoc($newsletter_result); require($ROOTDIR . '/includes/email.php'); $Email_API = &new Email_API(); if ($CURRENTADMIN['EmailServer'] || $CURRENTADMIN['EmailServer'] != '') { if (strpos($CURRENTADMIN['EmailServer'], ';') !== false) { list($servername, $username, $password) = explode(';', str_replace(' ', '', $CURRENTADMIN['EmailServer'])); } else { $servername = $CURRENTADMIN['EmailServer']; $username = $password = false; } $Email_API->SetSmtp($servername, $username, $password); } $Email_API->Set('BaseURL', $ROOTURL); $Email_API->TrackLinks($send['TrackLinks']); $Email_API->TrackOpens($send['TrackOpens']); $Email_API->Set('AdminID', $CURRENTADMIN['AdminID']); $Email_API->Set('ComposedID', $send['ComposedID']); $Email_API->Set('TablePrefix', $TABLEPREFIX); $Email_API->Set('ReplyTo', $send['ReplyTo']); $Email_API->Set('BounceAddress', $send['ReturnPath']); $Email_API->Set('SendFrom', $send['SendFrom']); $Email_API->Set('Subject', html_entity_decode(stripslashes($newsletter_details['Subject']))); $Email_API->AddBody('text', stripslashes($newsletter_details['TextBody'])); $Email_API->AddBody('html', html_entity_decode(stripslashes($newsletter_details['HTMLBody']))); $custom_fields_to_replace = $Email_API->GetCustomFields(); $attachment_ids = explode(':', $newsletter_details['AttachmentIDs']); if (!empty($attachment_ids) && $attachment_ids[0] != '') { $attachment_filename_result = mysql_query("SELECT AttachmentName, AttachmentFilename FROM " . $TABLEPREFIX . "attachments WHERE AttachmentID IN (" . implode(',', $attachment_ids) . ")"); while($attachment_row = mysql_fetch_assoc($attachment_filename_result)) { $attachment_file = dirname(dirname(__FILE__)) . '/' . $attachment_row['AttachmentFilename']; $Email_API->AddAttachment($attachment_file, $attachment_row['AttachmentName']); } } $query = "SELECT sr.MemberID, sr.Format, Problems, Email, ConfirmCode, SubscribeDate, m.Confirmed, m.Status FROM " . $TABLEPREFIX . "send_recipients sr, " . $TABLEPREFIX . "members m WHERE sr.MemberID=m.MemberID AND sr.SendID='".addslashes($SendID)."' AND Problems='0' LIMIT 1"; $result = mysql_query($query); while ($e = mysql_fetch_assoc($result)) { $update_problem_query = "UPDATE " . $TABLEPREFIX . "send_recipients SET Problems='1' WHERE MemberID='".addslashes($e['MemberID'])."' AND SendID='".addslashes($SendID)."'"; // if we don't send an email for whatever reason, then we need to update the user stats to reflect it properly. $update_user_stats_query = "UPDATE " . $TABLEPREFIX . "sends_permonth SET EmailsSent = EmailsSent - 1 WHERE SendID='" . (int)$SendID . "'"; // if somehow the subscriber has been marked as 'bad', then skip it. // just in case. if ($e['Problems'] == 1) { mysql_query($update_user_stats_query); mysql_query($update_problem_query); continue; } if (Banned($e['Email'], $send['ListID'])) { log_mailing_error(DisplayDate(time()) . ',' . $e['Email'] . ',' . 'Email address (or domain) is banned from the mailing list'); mysql_query($update_user_stats_query); mysql_query($update_problem_query); continue; } if (in_array($e['MemberID'], $_SESSION['AlreadySent'])) { $temp_mem = load_member($e['MemberID'], $list_details['ListID']); log_mailing_error(DisplayDate(time()) . ',' . $temp_mem['Email'] . ',' . 'Already received in this run'); mysql_query($update_problem_query); continue; } $Email_API->ClearRecipients(); $Email_API->Set('Multipart', false); // if somehow the subscriber has been marked as 'bad', then skip it. // just in case. if ($e['Problems'] == 1) { $_SESSION['AlreadySent'][] = $e['MemberID']; continue; } $_SESSION['AlreadySent'][] = $e['MemberID']; if ($e['Format'] == '3') { $Email_API->Set('Multipart', true); } switch($e['Format']) { case '1': $format = 'text'; break; case '2': case '3': $format = 'html'; break; } if (empty($newsletter_details['HTMLBody']) || empty($newsletter_details['TextBody'])) { $Email_API->Set('Multipart', false); } switch($e['Format']) { case '1': $format = 'text'; break; case '2': case '3': $format = 'html'; break; } if (empty($newsletter_details['HTMLBody'])) { $format = 'text'; $e['Format'] = '1'; } $Email_API->AddRecipient($e['Email'], '', $format, $e['MemberID']); $custom_fields = array(); if (!empty($custom_fields_to_replace)) { $query = "SELECT v.FieldID AS FieldID, Value, FieldType, AllValues, DefaultValue FROM " . $TABLEPREFIX . "list_field_values v, " . $TABLEPREFIX . "list_fields f WHERE v.FieldID=f.FieldID AND v.ListID='" . addslashes($send['ListID']) . "' AND v.UserID='".addslashes($e['MemberID'])."' AND v.FieldID IN (" . implode(',', $custom_fields_to_replace) . ")"; $customfields_result = mysql_query($query); while($customfields_row = mysql_fetch_assoc($customfields_result)) { $value = stripslashes($customfields_row['Value']); switch($customfields_row['FieldType']) { case 'checkbox': if ($customfields_row['Value'] == 'CHECKED') { $value = 'Yes'; } else { $value = 'No'; } break; case 'longtext': if ($format=='HTML') { $value=nl2br($customfields_row['Value']); } break; case 'multicheckbox': $myvals = explode(':', $value); $value = ''; $fieldvals=explode(';',$customfields_row['AllValues']); foreach($fieldvals as $fieldval){ if (!$fieldval) continue; list($sys,$lab)=explode('->',$fieldval); if (in_array($sys, $myvals)) $value .= $lab . ', '; } $value = substr($value, 0, -2); break; case 'datebox': $order = explode(',', $customfields_row['AllValues']); list($day, $month, $year) = explode(':', $value); $value = ''; foreach($order as $o) { if (!in_array($o, array('month', 'day', 'year'))) continue; $value .= $$o . '/'; } $value = substr($value, 0, -1); break; } $custom_fields[] = array('fieldid' => $customfields_row['FieldID'], 'data' => $value); } } if ($e['Confirmed'] == 1) { $confirmation = 'Confirmed'; } else { $confirmation = 'Unconfirmed'; } if ($e['Status'] == 1) { $status = 'Active'; } else { $status = 'Inactive'; } switch($e['Format']) { case '1': $cf_format = 'Text'; break; case '2': case '3': $cf_format = 'HTML'; break; } $customfield_info = array( 'listid' => $send['ListID'], 'confirmcode' => $e['ConfirmCode'], 'sendid' => $SendID, 'CustomFields' => $custom_fields, 'subscriberid' => $e['MemberID'], 'subscribedate' => $e['SubscribeDate'], 'confirmation' => $confirmation, 'status' => $status, 'format' => $cf_format, 'listname' => $list_details['ListName'] ); $Email_API->AddCustomFieldInfo($e['Email'], $customfield_info); $delete_member_query = "DELETE FROM " . $TABLEPREFIX . "send_recipients WHERE MemberID='".addslashes($e['MemberID'])."' AND SendID='".addslashes($SendID)."'"; mysql_query($delete_member_query); if ($e['Email']) { $mail_result = $Email_API->Send(true); if ($mail_result['success'] > 0) { $email_result = true; } else { $email_result = false; list($bad_email, $servermsg) = current($mail_result['fail']); } if ($email_result) { if($e['Format'] == 1) { $s=", TextRecipients=TextRecipients+1"; } else { $s=", HTMLRecipients=HTMLRecipients+1"; } $update_result = mysql_query("UPDATE " . $TABLEPREFIX . "sends SET EmailsSent=EmailsSent+1 $s WHERE SendID='".addslashes($SendID)."'"); } else { mysql_query($update_user_stats_query); $logmsg = 'Unable to Queue Email'; if ($servermsg) $logmsg .= ': ' . $servermsg; log_mailing_error(DisplayDate(time()) . ',' . $e['Email'] . ',' . $logmsg); } } else { mysql_query($update_user_stats_query); log_mailing_error(DisplayDate(time()) . ',' . $e['MemberID'] . ',' . 'Unable to find email address for subscriber'); } $qry = "UPDATE " . $TABLEPREFIX . "sends_perhour set EmailsSent=EmailsSent+1, HourEnded='".addslashes($SYSTEMTIME)."' WHERE SendID='".addslashes($SendID)."'"; mysql_query($qry); if ($PAUSE > 0 && $PAUSE < 1) { $p = floor($PAUSE*1000000); usleep($p); } else { sleep(floor($PAUSE)); } } } } # end if (page == dosending) $refresh_link = MakeAdminLink("send?SendID=$SendID&Action=DoSending&PageID=DoSending&newsletter_archives=$ser_newsletter_archives&StartTime=$StartTime&random=" . getmicrotime()); ?>