Beispiel #1
0
 $confirm_body = str_replace("[!ipaddress!]", $ip, $confirm_body);
 $confirm_subject = str_replace("[!date!]", $date, $confirm_subject);
 $confirm_body = str_replace("[!date!]", $date, $confirm_body);
 $confirm_subject = str_replace("[!url!]", $url, $confirm_subject);
 $confirm_body = str_replace("[!url!]", $url, $confirm_body);
 $confirm_subject = str_replace("[!newslettername!]", $newslettername, $confirm_subject);
 $confirm_body = str_replace("[!newslettername!]", $newslettername, $confirm_body);
 $confirm_subject = str_replace("[!address!]", $address, $confirm_subject);
 $confirm_body = str_replace("[!address!]", $address, $confirm_body);
 $confirm_body = str_replace("[!confirm!]", $confirm, $confirm_body);
 $additional_parameters = array("ipaddress" => $_SERVER['REMOTE_ADDR'], "date" => date("g:i d F Y", time()), "url" => $_SERVER['HTTP_REFERER']);
 $params = array();
 date_default_timezone_set($zone);
 $params[0] = $confirm_subject;
 $params[1] = $confirm_body;
 wpr_create_temporary_tables($nid);
 wpr_make_subscriber_temptable($nid);
 wpr_place_tags($id, $params, $additional_parameters);
 $from_email = $newsletter->fromemail;
 if (!$from_email) {
     $from_email = get_bloginfo("admin_email");
 }
 $from_name = $newsletter->fromname;
 if (!$from_name) {
     $from_name = get_bloginfo("name");
 }
 $subject = $params[0];
 $body = $params[1];
 $verificationEmail = array('to' => $email, 'subject' => $subject, 'textbody' => $body, 'fromname' => $from_name, 'from' => $from_email);
 @dispatchEmail($verificationEmail);
 if (empty($return_url)) {
Beispiel #2
0
function _wpr_process_broadcasts()
{
    global $wpdb;
    $prefix = $wpdb->prefix;
    $last_cron_status = get_option("_wpr_newsletter_process_status");
    set_time_limit(3600);
    /*
    
    
    When the cron is running the _wpr_newsletter_process_status
    is set to the timestamp at which the cron processing was started.
    
    Before shutting down the _wpr_newsletter_process_status is
    set to 'stopped'.
    
    This cron will run only if the _wpr_newsletter_process_status option
    is set to "stopped" or is empty.
    */
    $timeOfStart = time();
    $timeMaximumExecutionTimeAgo = $timeOfStart - WPR_MAX_NEWSLETTER_PROCESS_EXECUTION_TIME;
    if (!empty($last_cron_status) && $last_cron_status != "stopped") {
        $last_cron_status = intval($last_cron_status);
        if ($last_cron_status != 0 && $last_cron_status > $timeMaximumExecutionTimeAgo) {
            return;
        }
    }
    delete_option("_wpr_newsletter_process_status");
    add_option("_wpr_newsletter_process_status", $timeOfStart);
    $email_mailouts = wpr_get_mailouts();
    foreach ($email_mailouts as $broadcast) {
        $nid = $broadcast->nid;
        $subject = $broadcast->subject;
        $body = $broadcast->body;
        wpr_create_temporary_tables($nid);
        //this creates the tables based on which a bigger table will be created
        wpr_make_subscriber_temptable($nid);
        //this table will be used for getting the user list.
        $customFieldsConditions = trim(wpr_filter_query($nid, $broadcast->recipients));
        $customFields = $customFieldsConditions ? " AND " . $customFieldsConditions : "";
        $query = "SELECT * FROM " . $prefix . "wpr_subscribers_" . $nid . " where active=1 and confirmed=1 {$customFields};";
        $subscribersList = $wpdb->get_results($query);
        $subject = $broadcast->subject;
        $text_body = $broadcast->textbody;
        $html_body = $broadcast->htmlbody;
        $whetherToAttachImages = $broadcast->attachimages;
        $query = "SELECT fromname, fromemail from " . $wpdb->prefix . "wpr_newsletters where id=" . $nid;
        $results = $wpdb->get_results($query);
        $fromname = $results[0]->fromname;
        $fromemail = $results[0]->fromemail;
        if (count($subscribersList)) {
            $broadcastId = $broadcast->id;
            $newsletterId = $broadcast->nid;
            foreach ($subscribersList as $subscriber) {
                $sid = $subscriber->id;
                $email = $subscriber->email;
                $meta_key = sprintf("BR-%s-%s-%s", $sid, $broadcastId, $newsletterId);
                $emailParameters = array("subject" => $subject, "from" => $fromname, "fromemail" => $fromemail, "textbody" => $text_body, "htmlbody" => $html_body, "htmlenabled" => empty($html_body) ? 0 : 1, "attachimages" => $whetherToAttachImages, "meta_key" => $meta_key);
                wpr_place_tags($sid, $emailParameters);
                $emailParameters["to"] = $subscriber->email;
                sendmail($sid, $emailParameters);
            }
        }
        $timeThisInstant = time();
        $timeSinceStart = $timeThisInstant - $timeOfStart;
        if ($timeSinceStart > WPR_MAX_NEWSLETTER_PROCESS_EXECUTION_TIME) {
            return;
        }
        mailout_expire($broadcast->id);
    }
    delete_option("_wpr_newsletter_process_status");
    add_option("_wpr_newsletter_process_status", "stopped");
}