function wpr_autoresponder()
{
    if (_wpr_no_newsletters("To create an autoresponder")) {
        return;
    }
    $action = $_GET['action'];
    switch ($action) {
        case 'create':
            _wpr_autoresponder_create();
            break;
        case 'delete':
            _wpr_autoresponder_delete();
            break;
        case 'manage':
            wpr_manage_responder();
            break;
        default:
            _wpr_autoresponder_list();
    }
}
Beispiel #2
0
function wpr_subscriptionforms()
{
    if (_wpr_no_newsletters("To create subscription forms")) {
        return;
    }
    $action = isset($_GET['action']) ? $_GET['action'] : '';
    switch ($action) {
        case 'create':
            _wpr_subscriptionforms_create();
            break;
        case 'form':
            $id = $_GET['fid'];
            $form = _wpr_subscriptionform_get($id);
            _wpr_subscriptionform_getcode($form, "'" . $form->name . "' Form HTML Code");
            return;
            break;
        case 'delete':
            if (isset($_POST['forms'])) {
                $formsToDelete = $_POST['forms'];
                if (count($formsToDelete) > 0) {
                    _wpr_subscriptionforms_delete($formsToDelete);
                    _wpr_subscriptionform_delete_done();
                } else {
                    _wpr_subscriptionform_delete_notfound();
                }
            } else {
                _wpr_subscriptionform_delete_notfound();
            }
            break;
        case 'edit':
            $id = (int) $_GET['fid'];
            $errors = array();
            do_action("_wpr_subscriptionform_edit_form_controller", $id);
            $form = _wpr_subscriptionform_get($id);
            $form->confirm_subject = stripslashes($form->confirm_subject);
            $form->confirm_body = stripslashes($form->confirm_body);
            $form->confirmed_subject = stripslashes($form->confirmed_subject);
            $form->confirmed_body = stripslashes($form->confirmed_body);
            if (isset($_POST['fid'])) {
                $checkList = array("name" => "Name field is required", "confirm_subject" => "E-Mail Confirmation Subject Field is required", "confirm_body" => "E-Mail Confirmation Body field", "confirmed_subject" => "Confirmed Subscription subject field is required", "confirmed_body" => "Confirmed subscription body field is required");
                $errors = array();
                foreach ($checkList as $field => $errorMessage) {
                    $theValue = $_POST[$field];
                    $theValue = trim($theValue);
                    if (empty($theValue)) {
                        $errors[] = $checkList[$field];
                    }
                }
                $errors = apply_filters("_wpr_subscriptionform_edit_handler_validate", $errors);
                if (count($errors) == 0) {
                    $info['id'] = $_GET['fid'];
                    $info['name'] = $_POST['name'];
                    $info['return_url'] = $_POST['return_url'];
                    if (!isset($_POST['followup']) || !preg_match("@postseries_[0-9]+@", $_POST['followup']) && !preg_match("@autoresponder_[0-9]+@", $_POST['followup'])) {
                        $info['followup_id'] = 0;
                        $info['followup_type'] = "none";
                    } else {
                        if (preg_match("@autoresponder_[0-9]+@", $_POST['followup'])) {
                            $followup = "autoresponder";
                            $followupid = str_replace("autoresponder_", "", $_POST['followup']);
                        } else {
                            if (preg_match("@postseries_[0-9]+@", $_POST['followup'])) {
                                $followup = "postseries";
                                $followupid = str_replace("postseries_", "", $_POST['followup']);
                            } else {
                                $followup = "none";
                                $followupid = 0;
                            }
                        }
                        $info['followup_type'] = $followup;
                        $info['followup_id'] = $followupid;
                    }
                    //if it is a unknown follow-up type its probably an extended one.
                    switch ($_POST['blogsubscription']) {
                        case 'none':
                        case 'all':
                            $blogSubscription = $_POST['blogsubscription'];
                            $blogCategory = 0;
                            break;
                        default:
                            if (preg_match("@category_[0-9]+@", $_POST['blogsubscription'])) {
                                $blogSubscription = "cat";
                                $blogCategory = str_replace("category_", "", $_POST['blogsubscription']);
                            }
                    }
                    $info['blogsubscription_type'] = $blogSubscription;
                    $info['blogsubscription_id'] = $blogCategory;
                    $info['submit_button'] = $_POST['submit_value'];
                    $info['custom_fields'] = isset($_POST['custom_fields']) && is_array($_POST['custom_fields']) ? implode(",", $_POST['custom_fields']) : "";
                    $info['confirm_subject'] = $_POST['confirm_subject'];
                    $info['confirm_body'] = $_POST['confirm_body'];
                    $info['nid'] = $_POST['newsletter'];
                    $info['confirmed_subject'] = $_POST['confirmed_subject'];
                    $info['confirmed_body'] = $_POST['confirmed_body'];
                    _wpr_subscriptionform_update($info);
                    do_action("_wpr_subscriptionform_edit_handler_save", $info['id']);
                    $form = _wpr_subscriptionform_get($info['id']);
                    _wpr_subscriptionform_getcode($form, "Form Saved");
                    return;
                } else {
                    $form = (object) $_POST;
                }
            }
            _wpr_subscriptionform_form($form, $errors);
            break;
        default:
            _wpr_subscriptionforms_list();
    }
}
Beispiel #3
0
function wpr_newmail()
{
    global $wpdb;
    if (isset($_POST['subject'])) {
        date_default_timezone_set("UTC");
        $subject = $_POST['subject'];
        $nid = $_POST['newsletter'];
        $textbody = trim($_POST['body']);
        $htmlbody = trim($_POST['htmlbody']);
        $whentosend = $_POST['whentosend'];
        $date = $_POST['date'];
        $htmlenabled = $_POST['htmlenabled'] == "on";
        $recipients = $_POST['recipients'];
        $hour = $_POST['hour'];
        $shouldAttachImages = isset($_POST['attachimages']) ? 1 : 0;
        $timezoneOffset = $_POST['timezoneoffset'];
        $min = $_POST['minute'];
        if ($whentosend == "now") {
            $timeToSend = time();
        } else {
            if (empty($date)) {
                $error = "The date field is required";
            } else {
                $sections = explode("/", $date);
                $timeToSend = mktime($hour, $min, 0, $sections[0], $sections[1], $sections[2]);
                $timeToSend = $timeToSend - $timezoneOffset;
            }
        }
        if (!(trim($subject) && trim($textbody))) {
            $error = "Subject and the Text Body are mandatory.";
        }
        if ($timeToSend < time() && !$error) {
            $error = "The time mentioned is in the past. Please enter a time in the future.";
            if ($htmlenabled && !$error) {
                if (empty($htmlbody)) {
                    $error = "HTML Body is empty. Enter the HTML body of this email";
                }
            }
        }
        if (!$htmlenabled) {
            $htmlbody = "";
        }
        if (!$error) {
            $query = "insert into " . $wpdb->prefix . "wpr_newsletter_mailouts (nid,subject,textbody,htmlbody,time,status,recipients,attachimages) values ('{$nid}','{$subject}','{$textbody}','{$htmlbody}','{$timeToSend}',0,'{$recipients}','{$shouldAttachImages}');";
            $wpdb->query($query);
            _wpr_mail_sending();
            return;
        }
    }
    $param = (object) array("nid" => $nid, "textbody" => $textbody, "subject" => $subject, "htmlbody" => $htmlbody, "htmlenabled" => 1, "whentosend" => $whentosend, "date" => $date, "hour" => $hour, "minute" => $min, "title" => "New Mail");
    //There are no newsletters. Ask to create one before sending mailouts
    if (_wpr_no_newsletters("To send a new e-mail broadcast")) {
        return;
    }
    ?>

 

        <?php 
    wpr_mail_form($param, "new", $error);
}