function _wpr_newsletter_edit() { _wpr_setview("newsletter_form"); if (!_wpr_isset("parameters")) { $id = $_GET['nid']; $newsletter = _wpr_newsletter_get($id); _wpr_set("parameters", $newsletter); } _wpr_set("heading", __("Edit Newsletter", 'wpr_autoresponder')); _wpr_set("edit", true); _wpr_set("button_text", __("Save Changes", 'wpr_autoresponder')); _wpr_set("wpr_form", "newsletter_edit_form"); }
function wpr_mail_form($parameters = array(), $mode = "new", $error) { global $wpdb; ?> <style> .wrap label { font-family: Arial; font-size: 15px; font-weight: bold; } </style> <script> function Field(id,name,label) { this.id = id; this.name = name; this.label= label; } var ListOfFields = new Array(); <?php $query = "select id,name from " . $wpdb->prefix . "wpr_newsletters"; $newsletters = $wpdb->get_results($query); foreach ($newsletters as $newsletter) { $query = "select * from " . $wpdb->prefix . "wpr_custom_fields where nid=" . $newsletter->id; $fields = $wpdb->get_results($query); ?> ListOfFields['<?php echo $newsletter->id; ?> '] = new Array(); <?php foreach ($fields as $field) { ?> ListOfFields['<?php echo $newsletter->id; ?> '].push(new Field("<?php echo $field->id; ?> ","<?php echo $field->name; ?> ","<?php echo $field->label; ?> ")); <?php } } ?> function loadCustomFields(id) { var fieldList = ListOfFields[id]; var container = document.getElementById('custom_fields'); container.innerHTML='' var listItem = document.createElement("ol"); var item1 = document.createElement("li"); newItem = document.createElement("li"); newItem.innerHTML = "Enter <strong>[!name!]</strong> to substitute for Name."; listItem.appendChild(newItem); newItem = document.createElement("li"); newItem.innerHTML = "Enter <strong>[!email!]</strong> to substitute for E-Mail Address."; listItem.appendChild(newItem); var newItem; if (fieldList.length >0) { for (field in fieldList) { newItem = document.createElement("li"); newItem.innerHTML = "Enter <strong>[!"+fieldList[field].name+"!]</strong> to substitute for "+fieldList[field].label+"."; listItem.appendChild(newItem); } } container.appendChild(listItem); } /* * Functions for the preview email function. */ function wpr_GetNewsletter() { return document.mailForm.newsletter.value; } function wpr_GetSubject() { return document.mailForm.subject.value; } function wpr_GetHtmlBody() { return editor.getData(); } function wpr_GetTextBody() { return document.mailForm.body.value; } function wpr_GetWhetherHtmlEnabled() { return (document.mailForm.htmlenabled.checked)?1:0; } function showPreviewForm() { var nid = wpr_GetNewsletter(); if (!window.open('<?php echo get_bloginfo("wpurl"); ?> /?wpr-admin-action=preview_email&nid='+nid,'previewWindow','width=500,height=500')) alert("Please disable your pop up blocker to see the preview email form."); } function previewEmail() { if (validateFieldValues()) showPreviewForm(); } </script> <div style="clear:both"></div> <blockquote> <div class="wrap"> <h2><?php echo $parameters->formtitle ? $parameters->formtitle : "New Mail"; ?> </h2> <?php if ($error) { ?> <div class="updated fade" style="background-color: rgb(255,241,204);"> <div style="color:red; font-weight:bold; display:inline"> Error: </div> <?php echo $error; ?> </div> <?php } ?> <form action="<?php echo $_SERVER['REQUEST_URI']; ?> " name="mailForm" method="post"> <table width="800" cellpadding="20" border="0" cellspacing="10"> <?php if (!isset($_GET['aid'])) { $query = "SELECT id,name from " . $wpdb->prefix . "wpr_newsletters"; $newsletters = $wpdb->get_results($query); ?> <tr> <td width="200"><label for="thenewsletter">Select A Newsletter:</label> <br> <small>Select the newsletter that receives this email broadcast.</small></td> <td width="474"><select style="width: 520px;" name="newsletter" id="thenewsletter" onchange="var davalue=this.options[this.selectedIndex].value; loadCustomFields(davalue); newsletterChanged(davalue) "> <?php foreach ($newsletters as $newsletter) { ?> <option value="<?php echo $newsletter->id; ?> " <?php if ($parameters->nid == $newsletter->id) { echo 'selected="selected"'; } ?> ><?php echo $newsletter->name; ?> </option> <?php } ?> </select></td> </tr> <?php } else { $responder = _wpr_autoresponder_get($_GET['aid']); $newsletter = _wpr_newsletter_get($responder->nid); ?> <tr> <td width="200">Select A Newsletter: <p><small>Select the newsletter that receives this email.</td> <td width="474"><?php echo $newsletter->name; ?> </td> </tr> <input type="hidden" name="newsletter" id="thenewsletter" value="<?php echo $newsletter->id; ?> " /> <?php } ?> <tr> <td><label for="subject">Subject</label> <br> <small>Enter the subject of the email that your subscribers will receive</small></td> <td><input name="subject" value="<?php echo $parameters->subject; ?> " type="text" id="subject" size="70" /></td> </tr> <tr> <td colspan="2"><label for="textbody">Text Body </label> <br /> <small>Enter the email to be shown to subscribers who read your email in a mail client that doesn't support HTML email. </small> <div style="float:right"><a href="http://www.krusible.com/"><img src="http://www.wpresponder.com/mailpage.png" /></a></div> <textarea name="body" id="textbody" cols="55" rows="20" wrap="hard"><?php echo $parameters->textbody; ?> </textarea> <br /> Hard breaks are inserted at the end of each line. </p> <h2>Custom Fields:</h2> <div id="custom_fields"> <?php if (isset($_GET['nid'])) { $fields = _wpr_newsletter_all_custom_fields_get($nid); if (count($fields)) { ?> Use the following placeholders to be substituted in the newsletter. <ul> <?php foreach ($fields as $field) { ?> <li><!<?php echo $field->name; ?> !> for <?php echo $field->label; ?> </li> <?php } ?> </ul> <?php } } ?> </div></td> </tr> <tr> <td colspan="2"><input type="checkbox" name="htmlenabled" id="htmlenabled" onchange="changeHTMLBodyFieldsAvailability(this.checked,'htmlbodyfields');" <?php if ($parameters->htmlenabled == 1) { echo 'checked="checked"'; } ?> /> <label for="htmlenable">Enable HTML Body</label> <br /> <div id="htmlbodyfields"> <small>Check/uncheck this checkbox to enable or disable the HTML body of the email. When disabled only the text body will be sent.</small><br/> <br/> <?php CreateNewTemplateSwitcherButton("editor", "htmlbody"); ?> <label for="htmlbody">Enter the HTML Body Of The Email:</label> <br> <small>When HTML is enabled, most of your subscribers will see only the content in this body when they open the email. If you don't enter a HTML body the email will be sent as text email. <div id="htmlwrapper"> <textarea name="htmlbody" id="htmlbody" rows="20" cols="90"><?php echo htmlspecialchars($parameters->htmlbody); ?> </textarea> </div> <input type="button" value="Disable WYSIWYG Editor" onclick="toggleHTML();this.value=(editorExists)?'Disable WYSIWYG Editor':'Enable WYSIWYG Editor';"> </div> <br/> </div> </td> </tr> <?php if ($mode == "new") { $theminute = date("i", $parameters->time); $thehour = date("H", $parameters->time); if ($parameters->time) { $date = date("m/d/Y", $parameters->time); } ?> <tr> <td>Send At: </td> <td><?php if (empty($parameters->time)) { ?> <input name="whentosend" <?php if ($parameters->whentosend == "now") { echo "checked=\"checked\""; } ?> type="radio" id="sendnow" value="now" checked="checked" /> <label for="sendnow"> Immediately </label> (Now)<br /> <input type="radio" <?php if ($parameters->whentosend == "date") { echo "checked=\"checked\""; } ?> name="whentosend" id="sendattime" value="date" /> <label for="sendattime"> <?php } ?> On <input type="text" name="date" id="date" value="<?php echo $date; ?> "> </label> at <select name="hour" id="hour" onfocus="document.getElementById('sendattime').checked=true;"> <?php for ($i = 0; $i < 24; $i++) { $hour = sprintf("%'02d", $i); ?> <option><?php echo $hour; ?> </option> <?php } ?> </select> : <select name="minute" id="minute"> <option value="0">00</option> <option value="30">30</option> </select> Hrs<br/> Date format: mm/dd/yyyy <div style="background-color: #fefefe; padding: 5px; border: 1px solid #ccc;"> The e-mail will delivered as per your local time. Your timezone has been detected to be:<br /> <strong> <input type="hidden" name="timezoneoffset" id="timezonefield" value="0" /> <script> var thedate = new Date(); var theoffset = thedate.getTimezoneOffset(); var theoffset = theoffset *60; var theDirection = (theoffset<0)?1:0; theoffset = (theoffset<0)?-theoffset:theoffset; var theHours = Math.floor(theoffset/3600); var theMinutes = ((theoffset%3600)/3600)*60; var theSymbol = (theDirection==1)?"+":"-"; document.write("GMT "+theSymbol+" "+theHours+" hours and "+theMinutes+" minutes"); document.getElementById('timezonefield').value=(-theoffset); var theBroadcastTime = <?php if (empty($parameters->time)) { echo time() + 3600; } else { echo $parameters->time; } ?> ; theBroadcastTime *= 1000; function setTheTime() { var theDate = new Date(); if (theBroadcastTime ==0) return false; theDate.setTime(theBroadcastTime); var month = (theDate.getMonth()+1).toString(); //add a zero if the month is a single digit. if (month.length==1) { month = "0"+month; } var date = theDate.getDate().toString(); date = (date.length==1)?"0"+date:date; var year = theDate.getFullYear(); theFullDate = month+"/"+date+"/"+year; document.getElementById('date').value = theFullDate; whichHour = theDate.getHours().toString(); if (whichHour.length==1) { whichHour = "0"+whichHour; } hourField = document.getElementById('hour') var size = hourField.options.length; for (var curr=0; curr<size;curr++) { if (hourField.options[curr].value==whichHour) { hourField.selectedIndex=curr; break; } } whichMinute = theDate.getMinutes(); whichMinute = (whichMinute/3600==0)?0:30; minuteField = document.getElementById('minute') var size = minuteField.options.length; for (var curr=0; curr<size;curr++) { if (minuteField.options[curr].value==whichMinute) { minuteField.selectedIndex=curr; break; } } } setTheTime(); function setActualTime() { var theFullDate = document.getElementById('date').value; var theDateParts = theFullDate.split("/"); var themonth = theDateParts[0]; var thedate = theDateParts[1]; var theyear = theDateParts[2]; var theHour = document.getElementById('hour').options[document.getElementById('hour').selectedIndex].value; var theMinute = document.getElementById('minute').options[document.getElementById('minute').selectedIndex].value; themonth = themonth.replace(/^0/,''); thedate = thedate.replace(/^0/,''); theHour = theHour.replace(/^0/,''); month= parseInt(themonth); thedate = parseInt(thedate); var goDate = new Date(); thedate = parseInt(thedate); goDate.setDate(thedate); goDate.setYear(theyear); month=parseInt(themonth); month -=1; goDate.setMonth(month); theMinute = parseInt(theMinute); goDate.setMinutes(theMinute); theHour = parseInt(theHour); goDate.setHours(theHour); goDate.setSeconds(0); var utcStamp = goDate.getTime(); var utcStamp = utcStamp/1000; // utcStamp += theoffset; utcStamp = Math.floor(utcStamp); document.getElementById('actualTime').value= utcStamp.toString(); } function getCurrentUTCTime() { var theDate = new Date(); var theTime = theDate.getTime(); theTime = Math.floor(theTime/1000); return (theTime); } function validateTheForm() { //if the broadcast is scheduled to go out at a later time. if (document.getElementById('sendattime').checked==true) { currentTime = getCurrentUTCTime(); scheduledTime = parseInt(document.getElementById('actualTime').value); if (currentTime > scheduledTime) { alert('You cannot schedule a mailout to go out in the past. Please select a time in the future.'); return false; } } if (!validateFieldValues()) { return false; } return true; } window.setInterval('setActualTime()',1); </script> </strong> <input type="hidden" name="actualTime" value="0" id="actualTime" /> <br /> </div> </div> <script> jQuery(document).ready(function() { //jQuery("#date").datepicker({ minDate: 0}); }); function changeHTMLBodyFieldsAvailability(field,nameOfTheDivToHide) { if (!field) { document.getElementById(nameOfTheDivToHide).style.display = "none"; } else { document.getElementById(nameOfTheDivToHide).style.display="inline"; } } var editorExists=false; var editor; function toggleHTML() { if (editorExists) { var html = editor.getData(); editor.destroy(); editorExists=false; var textElement = document.createElement("textarea"); } else { var element = document.getElementById("htmlbody"); editor = CKEDITOR.replace("htmlbody",{ skin: 'moono', toolbar : [ ['Source','Maximize','ShowBlocks','-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], '/', ['Bold', 'Italic','Underline','Strike', '-', 'NumberedList', 'BulletedList','-','Subscript','Superscript','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock', '-','Outdent','Indent','Blockquote','-', 'Link','Image','SpellChecker'],['Link','Unlink','Anchor',], '/', ['Format','Font','FontSize','TextColor','BGColor','-','-','Table','CreateDiv'], ] }); editorExists=true; } } function setVisibilityOfHTMLFields() { changeHTMLBodyFieldsAvailability(document.getElementById('htmlenabled').checked,'htmlbodyfields'); } setVisibilityOfHTMLFields(); toggleHTML(); </script></td> </tr> <?php } else { ?> <tr> <td>Send On<br /> <small>0 for immediately after subscribing</small></td> <td><label for="select2"></label> <label for="textfield2"></label> <input name="sequence" type="text" id="textfield2" size="4" maxlength="3" value="<?php echo (int) $parameters->sequence; ?> " /> <label for="radio3"> Days </label> <script> jQuery(document).ready(function() { //jQuery("#date").datepicker({ minDate: 0}); }); function changeHTMLBodyFieldsAvailability(field,nameOfTheDivToHide) { if (!field) { document.getElementById(nameOfTheDivToHide).style.display = "none"; } else { document.getElementById(nameOfTheDivToHide).style.display="inline"; } } var editorExists=false; var editor; function toggleHTML() { if (editorExists) { var html = editor.getData(); editor.destroy(); editorExists=false; var textElement = document.createElement("textarea"); } else { var element = document.getElementById("htmlbody"); editor = CKEDITOR.replace("htmlbody",{ toolbar : [ ['Source','-','Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat','-','NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link','Image'], '/', ['Styles', 'Format','Font','FontSize','-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Table'], ] }); editorExists=true; } } function setVisibilityOfHTMLFields() { changeHTMLBodyFieldsAvailability(document.getElementById('htmlenabled').checked,'htmlbodyfields'); } setVisibilityOfHTMLFields(); toggleHTML(); </script></td> </tr> <?php printTheJavascript(); } ?> <?php if ($mode == "new") { ?> <tr> <td colspan="3"><br /> <input type="hidden" name="mid" value="<?php echo $parameters->id; ?> " /> <br /></td> </tr> <?php } ?> <tr> <td colspan="2"><label for="button"></label> <input type="submit" class="button-primary" onclick="return validateTheForm();" name="button" id="button" value="<?php echo $parameters->buttontext ? $parameters->buttontext : "Send Message"; ?> "/> <input type="button" name="PreviewEmailButton" onclick="wpr_GetHtmlBody();previewEmail()" value="Preview This Email" class="button-primary"></td> </tr> <script> function validateFieldValues() { var errors = new Array(); //the subject must be mentioned subject = trim(document.getElementById('subject').value); count=0; if (subject.length== 0) { errors[count++] = "- Subject is empty. A Subject is mandatory for a broadcast"; } //the text body must be mentioned textbody = trim(document.getElementById('textbody').value); if (textbody.length==0) { errors[count++] = "- Text body field is empty. A text body is mandatory for a broadcast."; } htmlbody = trim(editor.getData()); if (document.getElementById('htmlenabled').checked==true && htmlbody.length==0) { errors[count++] = "- HTML body is enabled but the HTML Body has not filled out."; } if (errors.length > 0) { var message = "Some errors were found in the form: \n\n"+ errors.join("\n"); alert(message); return false; } //if the html body is emabled, the html bdoy should have some text. return true; } function trim(stringToTrim) { stringToTrim = stringToTrim.toString(); return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); } function getCurrentNewsletter() { newsletter = document.getElementById('thenewsletter'); var nid = newsletter.options[newsletter.selectedIndex].value; return nid; } jQuery(document).ready( function () { var ele = document.getElementById('thenewsletter') if (ele.tagName == "SELECT") { var id = ele.options[document.getElementById('thenewsletter').selectedIndex].value } else { var id = ele.value; } loadCustomFields(id) } ); </script> </table> </form> </blockquote> <?php }
function sendConfirmedEmail($id) { global $wpdb; $query = "select * from " . $wpdb->prefix . "wpr_subscribers where id={$id}"; $sub = $wpdb->get_results($query); $sub = $sub[0]; //get the confirmation email and subject from newsletter $newsletter = _wpr_newsletter_get($sub->nid); $confirmed_subject = $newsletter->confirmed_subject; $confirmed_body = $newsletter->confirmed_body; //if a registered form was used to subscribe, then override the newsletter's confirmed email. $sid = $sub->id; //the susbcriber id $unsubscriptionURL = wpr_get_unsubscription_url($sid); $unsubscriptionInformation = "\n\nTo manage your email subscriptions or to unsubscribe click on the URL below:\n{$unsubscriptionURL}\n\nIf the above URL is not a clickable link simply copy it and paste it in your web browser."; $fid = $args[2]; $query = "SELECT a.* from " . $wpdb->prefix . "wpr_subscription_form a, " . $wpdb->prefix . "wpr_subscribers b where a.id=b.fid and b.id={$sid};"; $form = $wpdb->get_results($query); if (count($form)) { $confirmed_subject = $form[0]->confirmed_subject; $confirmed_body = $form[0]->confirmed_body; } $confirmed_body .= $unsubscriptionInformation; $params = array($confirmed_subject, $confirmed_body); wpr_place_tags($sub->id, $params); $fromname = $newsletter->fromname; if (!$fromname) { $fromname = get_bloginfo('name'); } $fromemail = $newsletter->fromemail; if (!$fromemail) { $fromemail = get_bloginfo('admin_email'); } $email = $sub->email; $emailBody = $params[1]; $emailSubject = $params[0]; $mailToSend = array('to' => $email, 'fromname' => $fromname, 'from' => $fromemail, 'textbody' => $emailBody, 'subject' => $emailSubject); try { dispatchEmail($mailToSend); } catch (Swift_RfcComplianceException $exception) { //disable all subscribers with that email. $email = $mailToSend['to']; $query = "UPDATE " . $wpdb->prefix . "wpr_subscribers set active=3, confirmed=0 where email='{$email}'"; $wpdb->query($query); } }
function _wpr_autoresponder_list() { global $wpdb; $getAutorespondersQuery = "SELECT a.* FROM " . $wpdb->prefix . "wpr_autoresponders a, " . $wpdb->prefix . "wpr_newsletters b where a.nid=b.id;"; $autoresponders = $wpdb->get_results($getAutorespondersQuery); ?> <div class="wrap"><h2>Manage Autoresponders</h2></div> <table class="widefat"> <thead> <tr> <th scope="col">Autoresponder Name</th> <th scope="col">Belongs To Newsletter</th> <th scope="col">Actions</th> </tr> </thead> <?php if (count($autoresponders)) { foreach ($autoresponders as $responder) { ?> <tr> <td><?php echo $responder->name; ?> </td> <td><?php $newsletter = _wpr_newsletter_get($responder->nid); echo $newsletter->name; ?> </td> <td><input type="button" value="Manage Messages" class="button" onclick="window.location='admin.php?page=wpresponder/autoresponder.php&action=manage&aid=<?php echo $responder->id; ?> ';" /><input type="button" value="Delete" onclick="window.location='admin.php?page=wpresponder/autoresponder.php&action=delete&aid=<?php echo $responder->id; ?> ';" class="button" /> </tr> <?php } } else { ?> <tr> <td colspan="10" align="center">-No Autoresponders -</td> </tr> <?php } ?> </table> <input type="button" value="Create New" class="button-primary" onclick="window.location='admin.php?page=wpresponder/autoresponder.php&action=create';" /> <?php }
$query = $wpdb->prepare("SELECT * from {$wpdb->prefix}wpr_subscription_form where id=%d", $fid); $theForm = $wpdb->get_results($query); if (count($theForm) != 0) { $theForm = $theForm[0]; $confirm_subject = $theForm->confirm_subject; $confirm_body = $theForm->confirm_body; } } do_action("_wpr_subscriber_added", $id); $theqstring = $subscriber->id . "%%" . $subscriber->hash . "%%" . $fid; $p = trim(base64_encode($theqstring), "="); $link = home_url("/?wpr-confirm=" . $p); $dirname = str_replace("optin.php", "", __FILE__); $confirm = file_get_contents($dirname . "/templates/confirm.txt"); $confirm = str_replace("[!confirm_link!]", $link, $confirm); $newsletter = _wpr_newsletter_get($nid); $newslettername = $newsletter->name; $url = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : "Unknown"; $ip = $_SERVER['REMOTE_ADDR']; $date = "At " . date("g:i dS M, Y"); $address = get_option('wpr_address'); $confirm_subject = str_replace("[!ipaddress!]", $ip, $confirm_subject); $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);
function _wpr_newsletter_custom_fields_list() { global $wpdb; $id = intval($_GET['nid']); $newsletter = _wpr_newsletter_get($id); $query = "SELECT * FROM " . $wpdb->prefix . "wpr_custom_fields where nid={$id}"; $result = $wpdb->get_results($query); _wpr_set("newsletter", $newsletter); _wpr_set("newsletterCustomFieldList", $result); _wpr_set("_wpr_view", "newsletter_custom_fields_list"); }
function _wpr_subscriptionforms_list() { global $wpdb; $tprefix = $wpdb->prefix; $query = "SELECT a.* FROM " . $tprefix . "wpr_subscription_form a, " . $tprefix . "wpr_newsletters b where a.nid=b.id;"; $forms = $wpdb->get_results($query); ?> <div class="wrap"> <h2>Subscription Forms</h2> </div> <script> function selectAllFormsCheckBox(state) { jQuery(".forms_check").attr({ checked: state}); } </script> <ul style="padding:20px;"> <li>Click on <em>Create New Form</em> button below to create a new subscription form. To place the newly created subscription form in the sidebar of your blog, go to the <a href="widgets.php">Widgets section</a>. To place the subscription form in a separate page or another website, copy the generated HTML code for the form and paste the code it in your own HTML page. </ul> <form name="formslist" action="admin.php?page=wpresponder/subscriptionforms.php&action=delete" method="post"> <table class="widefat" style="margin: 10px; margin:10px 0px;;"> <thead> <tr> <th><input type="checkbox" name="selectall" value="1" onclick="selectAllFormsCheckBox(this.checked);" /></th> <th scope="col">Name</th> <th>Newsletter</th> <th>Follow-Up</th> <th>Blog Subscription</th> <th scope="col">Actions</th> </tr> </thead> <?php if (count($forms) > 0) { foreach ($forms as $form) { ?> <tr> <td align="center"width="20"><input type="checkbox" name="forms[]" class="forms_check" value="<?php echo $form->id; ?> " /></td> <td><?php echo $form->name; ?> </td> <td><a href="admin.php?page=wpresponder/subscribers.php&action=nmanage&nid=<?php echo $form->nid; ?> "> <?php $newsletter = _wpr_newsletter_get($form->nid); echo $newsletter->name; ?> </a></td> <td><?php switch ($form->followup_type) { case 'postseries': $postseries = _wpr_postseries_get($form->followup_id); echo "Subscribe to the '" . $postseries->name . "' post series"; break; case 'autoresponder': $autoresponder = Autoresponder::getAutoresponder((int) $form->followup_id); echo sprintf("Subscribe to the '%s' autoresponder.", $autoresponder->getName()); break; case 'none': echo "None"; break; } ?> </td> <td><?php switch ($form->blogsubscription_type) { case 'cat': $category = get_category($form->blogsubscription_id); echo "Posts in the " . $category->name . " category"; break; case 'all': echo "All Blog Posts "; break; case 'none': echo "No blog subscription"; break; } ?> <td><a href="admin.php?page=wpresponder/subscriptionforms.php&action=edit&fid=<?php echo $form->id; ?> " class="button">Edit</a> <a href="admin.php?page=wpresponder/subscriptionforms.php&action=form&fid=<?php echo $form->id; ?> " class="button">Get Form HTML</a></td> </tr> <?php } } else { ?> <tr> <td colspan="10"><div align="center"><big>--No subscription forms defined. <a href="admin.php?page=wpresponder/subscriptionforms.php&action=create">Click here</a> to create one now--</big> </div></td> </tr> <?php } ?> </td></td> </table> <input type="submit" name="submit" value="Delete Forms" class="button" onclick="return confirm('Are you sure you want to delete the selected subscription forms?');" /> <input type="button" onclick="window.location='admin.php?page=wpresponder/subscriptionforms.php&action=create';" class="button" value="Create New Form"> </form> <?php }
<?php $id = $_GET['id']; $id = intval($id); $query = "select * from " . $wpdb->prefix . "wpr_newsletter_mailouts where id={$id}"; $mailout = $wpdb->get_results($query); $mailout = $mailout[0]; $output["Subject"] = $mailout->subject; $output["Text Body"] = "<pre>" . $mailout->textbody . "</pre>"; $output["HTML Body"] = $mailout->htmlbody; $output["Sent At"] = date("H:ia \\o\\n dS F Y", $mailout->time); $newsletter = _wpr_newsletter_get($mailout->nid); $output["Newsletter"] = $newsletter->name; $output["Recipients"] = !$mailout->recipients ? "All Subscribers" : $mailout->recipients; ?> <h2>Viewing Broadcast</h2> <table width="800" border="1" style="border: 1px solid #ccc;" cellpadding="10"> <tr> <td ><strong>Subject Of E-Mail:</strong></td> <td ><?php echo $output["Subject"]; ?> </td> </tr> <tr> <td><strong>Newsletter:</strong></td> <td><?php echo $output["Newsletter"]; ?> </td> </tr>
function _wpr_subscriber_nmanage_home() { global $wpdb; $nid = (int) $_GET['nid']; $querystring = $_SERVER['QUERY_STRING']; $pageNumber = (int) $_GET['pg']; $pageNumber = (int) $pageNumber; if ($pageNumber == 0) { $pageNumber = 1; } $numberPerPage = (int) $_GET['perpage']; $numberPerPage = $numberPerPage <= 0 ? 10 : $numberPerPage; $start = ($pageNumber - 1) * $numberPerPage; $start = $start; $limitClause = "limit {$start} , {$numberPerPage} "; $query = "SELECT * FROM " . $wpdb->prefix . "wpr_subscribers where nid={$nid} order by date desc {$limitClause};"; $subscribers = $wpdb->get_results($query); $newsletter = _wpr_newsletter_get($nid); ?> <div class="wrap"><h2>Manage Subscribers of <?php echo $newsletter->name; ?> </h2></div> <?php _wpr_subscriber_search_form($nid); ?> <br /> <div style="float:left;"><a href="admin.php?page=wpresponder/subscribers.php"> « Back To Subscribers' Home</a></div><div align="right"><div style="display:block; margin:10px;"> <a href="admin.php?page=_wpr/importexport" class="button-primary">Import/Export Subscribers</a></div></div> <?php $backUrl = "page=wpresponder/subscribers.php"; _wpr_subscriber_list($subscribers, false, $backUrl); $query = "SELECT count(*) num from " . $wpdb->prefix . "wpr_subscribers where nid={$nid};"; $subscriberCountRetriever = $wpdb->get_results($query); $subscriberCount = $subscriberCountRetriever[0]->num; ?> <br /> <br /> Total Number Of Subscribers: <?php echo $subscriberCount; ?> subscribers<br/> <?php $numberOfPages = ceil($subscriberCount / $numberPerPage); pageNumbers($numberOfPages); recordsPerPageSelector(); }
function _wpr_newsletter_add() { _wpr_setview("newsletter_form"); if (!_wpr_isset("parameters")) { $id = $_GET['nid']; $newsletter = _wpr_newsletter_get($id); _wpr_set("parameters", $newsletter); } _wpr_set("heading", __("Create Newsletter")); _wpr_set("edit", false); _wpr_set("button_text", __("Create Newsletter")); _wpr_set("wpr_form", "newsletter_create_form"); }
function wpr_actions() { ?> <div class="wrap"> <h2>Automatic Inter-Newsletter Subscriber Transfer</h2> <script> function checkAll(state) { jQuery(".rulecheck").attr({checked: state}); } </script> Here you can define rules such that if someone subscribes to newsletter B, they will be automatically unsubscribed from Newsletter A. <h3>Subscriber Transfer Rules</h3> <p> <table id="rulelist" class="widefat" width="1100"> <thead><tr> <th> <input type="checkbox" name="checker" onChange="checkAll(this.checked)" value="all"></th> <th> Unsubscribe a subscriber from newsletter....</th> <th> ...if they subscribe to newsletter</th> </tr> </thead> <tr> <?php $rules = _wpr_get_transfer_rules(); foreach ($rules as $name => $rule) { ?> <tr id="rule_<?php echo $rule->id; ?> "> <td ><input class="rulecheck" type="checkbox" name="rules[]" value="<?php echo $rule->id; ?> "></td> <td ><?php $sourceNewsletter = _wpr_newsletter_get($rule->source); echo $sourceNewsletter->name; ?> </td> <td><?php $destNewsletter = _wpr_newsletter_get($rule->dest); echo $destNewsletter->name; ?> </td> <?php } ?> </table> <p></p> <input type="submit" name="submit" onclick="deleteSelected();" value="Delete" class="button-primary" /> <script> </script> <script> var existingRules; function deleteSelected() { var rulesToDelete = new Array(); if (!window.confirm('Are you sure you want to delete the selected rules?')) { jQuery(".rulecheck").each (function() { this.checked=false; }); return false; } jQuery(".rulecheck").each ( function() { var id = this.value; if (this.checked) rulesToDelete.push(id); }); rulesString = rulesToDelete.join(","); jQuery.post('admin.php?page=wpresponder/actions.php', { rulesList: rulesString, wpr_form: "sub_transfer_delete_form" }, function(data) { var result = eval(data); if (result[0] == 'SUCCESS') { removeRows(rulesString); } else if (result[0] == 'ERROR') { alert('An unknown error occured. Plesae try again later.'); } }); } var debu; function removeRows(rulesList) { var rulesToDelete = rulesList.split(","); debu = rulesToDelete; if (rulesToDelete.length > 0) { for (var i in rulesToDelete) { rowName = "#rule_"+rulesToDelete[i]; jQuery(rowName).remove(); } return true; } else return false; } function dest() { return document.getElementById('destination'); } function source() { return document.getElementById('source'); } function addRule() { var sid = source().options[source().selectedIndex].value; var did = dest().options[dest().selectedIndex].value; if (sid == did) { alert("The source and destination newsletters cannot be the same. Please select a different combination"); return false; } jQuery.post('admin.php?page=wpresponder/actions.php', { source: sid, destination: did, wpr_form: "sub_transfer_add_rule" }, function(data) { var response = eval(data); if (response[0] == 'SUCCESS') { addRowToTable(response[1],sid,did); } else if (response[0]=='EXISTS') { alert("That rule already exists."); } else { alert("An unknown internal error occured. The response from the server was not recognized."); } }); } function Newsletter(id,name) { this.id=id; this.name=name; } var Newsletters = new Array(); <?php $newsletters = _wpr_get_newsletters(); foreach ($newsletters as $newsletter) { ?> Newsletters[<?php echo $newsletter->id; ?> ] = new Newsletter(<?php echo $newsletter->id; ?> ,"<?php echo $newsletter->name; ?> "); <?php } ?> function ge(id) { return document.getElementById(id); } function addRowToTable(id,sid,did) { var tr = ce("tr"); tr.setAttribute("id","rule_"+id); var td1 = ce("td"); var input = ce("input"); input.setAttribute("name","rules[]"); input.setAttribute("value",id.toString()); input.setAttribute("type","checkbox"); input.setAttribute("class","rulecheck"); td1.appendChild(input); tr.appendChild(td1); var td2 = ce("td"); td2.innerHTML = Newsletters[sid].name; tr.appendChild(td2); var td3 = ce("td"); td3.innerHTML = Newsletters[did].name; tr.appendChild(td3); ge('rulelist').appendChild(tr); } function ce(tagname) { return document.createElement(tagname); } </script> <h3>Add Rule</h3> <?php if (count($newsletters) > 0) { ?> <form name="subscriber_transfer"> <table> <tr> <td>Unsubscribe a subscriber from newsletter <select name="source_nid" id="source"> <?php $newsletters = _wpr_get_newsletters(); foreach ($newsletters as $newsletter) { ?> <option value="<?php echo $newsletter->id; ?> "><?php echo $newsletter->name; ?> </option><?php } ?> </select> if they subscribe to newsletter <select name="destination_nid" id="destination"> <?php $newsletters = _wpr_get_newsletters(); foreach ($newsletters as $newsletter) { ?> <option value="<?php echo $newsletter->id; ?> "><?php echo $newsletter->name; ?> </option><?php } ?> </select>. </td> </tr> </table> <input type="button" class="button-primary" onClick="addRule();" value="Add Rule"> </form> <?php } else { ?> You must first <a href="admin.php?page=_wpr/newsletter&act=add">create a newsletter</a> before adding a rule.<?php } ?> </div> <?php }
function _wpr_finished_mailouts() { global $wpdb; $query = "SELECT * FROM " . $wpdb->prefix . "wpr_newsletter_mailouts where status=1;"; $mailouts = $wpdb->get_results($query); $offset = get_option('gmt_offset'); ?> <div class="wrap"><h2>Sent Broadcasts</h2></div> <table class="widefat"> <tr> <thead> <th>Subject</th> <th>Newsletter</th> <th>Sent at*</th> <th>Actions</th> </thead> </tr> <?php foreach ($mailouts as $mailout) { ?> <tr> <td><?php echo $mailout->subject; ?> </td> <td><?php $newsletter = _wpr_newsletter_get($mailout->nid); echo $newsletter->name; ?> </td> <td><?php echo date("g:ia d F Y", $mailout->time + $offset * 3600); ?> </td> <td><a href="<?php echo $_SERVER['REQUEST_URI']; ?> &action=show_broadcast&id=<?php echo $mailout->id; ?> " class="button" style="margin:10px; margin-top:20px;" >View Broadcast</a></td> </tr> <?php } ?> </table> <br /> * Time is approximate. Actual send time depends on the frequency you set for the wordpress cron job or amount of traffic you get. <?php }
function _wpr_import_finished() { $newsletter = _wpr_newsletter_get($_SESSION['wpr_import_newsletter']); _wpr_set("newsletter", $newsletter); _wpr_set("_wpr_view", "import.finished"); }
function confirm_unsubscription($nid, $sid, $hash) { global $wpdb; $query = "SELECT * FROM " . $wpdb->prefix . "wpr_subscribers where id='{$sid}' and hash='{$hash}' and active=1 and confirmed=1;"; $subscriber = $wpdb->get_results($query); if (count($subscriber) > 0) { $newsletter = _wpr_newsletter_get($nid); $subscriber = _wpr_subscriber_get($sid); $query = "SELECT b.* FROM `" . $wpdb->prefix . "wpr_subscribers` `a`, `" . $wpdb->prefix . "wpr_newsletters` `b` WHERE `b`.`id`=`a`.`nid` and `a`.`email`='" . $subscriber->email . "' and `a`.`active`=1 and `a`.`confirmed`=1;"; $newsletters = $wpdb->get_results($query); ?> <div style="font-family:Verdana, Geneva, sans-serif; font-size:12px; padding:20px; margin-left: auto; margin-right: auto; width:300px; background-color:#f0f0f0; border: 1px solid #c0c0c0;"><form action="<?php print $_SERVER['REQUEST_URI']; ?> " method="post"> <input type="hidden" name="confirmed" value="true"> You are about to unsubscribe from:<br><br /> <input type="hidden" name="email" value="<?php echo $subscriber->email; ?> " /> <?php foreach ($newsletters as $newsletter) { ?> <div class="newsletter"><input type="checkbox" name="newsletter[]" checked="checked" value="<?php echo $newsletter->id; ?> " id="nl_<?php echo $newsletter->id; ?> " /> <label for="nl_<?php echo $newsletter->id; ?> "><?php echo $newsletter->name; ?> Newsletter<br /> <blockquote> <?php //get blog subscriptions $query = sprintf("SELECT * FROM {$wpdb->prefix}wpr_blog_subscription WHERE `type`='cat' AND `sid`=%d", $sid); $bsubs = $wpdb->get_results($query); foreach ($bsubs as $sub) { $cat = get_category($sub->eid); ?> You will stop receiving posts from the <?php echo $cat->name; ?> category.<br /> <?php } $query = "select * from " . $wpdb->prefix . "wpr_blog_subscription where type='all' AND sid='{$sid}'"; $bsubs = $wpdb->get_results($query); if (count($bsubs) > 0) { ?> New articles posted on the blog will not be delivered.<br /> <?php } //get post series $query = "SELECT b.* FROM " . $wpdb->prefix . "wpr_followup_subscriptions a, wpr_post_series b where type='postseries' and sid='{$sid}' and b.id=a.eid;"; $pssubs = $wpdb->get_results($query); if (count($pssubs) > 0) { } foreach ($pssubs as $sub) { "You will stop receiving " . $sub->name . " post series<br>"; } ?> </blockquote> </label><br> <?php } ?> Are you sure you want to unsubscribe from the above newsletter(s)? <br /> <br /> <div align="center"> <input type="submit" value="Unsubscribe"> <input type="button" onclick="window.location='/'" value="Cancel"></div> </form></div> <?php } else { header("HTTP/1.0 404 Not Found"); exit; } }
function getNewsletterCustomizationFormCode($arguments, $mode = "new") { global $wpdb; $nid = $arguments['nid']; $newsletter = _wpr_newsletter_get($nid); ?> <h2><?php echo $newsletter->name; ?> </h2> <p> <input type="checkbox" <?php if ($arguments['disable']) { echo 'checked="checked"'; } ?> autocomplete="off" onchange="toggleStatus(<?php echo $nid; ?> ,this.checked);" id="toggleForm-<?php echo $nid; ?> " name="skipnewsletter-<?php echo $nid; ?> " value="1" id="skipnewsletter-<?php echo $nid; ?> "> Don't deliver this blog post to blog subscribres or blog category subscribers. But use these settings for post series deliveries. </p> <p> <input type="checkbox" <?php if ($arguments['nopostseries'] == 1) { echo 'checked="checked"'; } ?> name="nopostseries-<?php echo $nid; ?> " autocomplete="off" id="nopostseries"> <label for="nopostseries"> Don't use these settings while delivering email to post series subscribers. Use a default layout that uses the blog post's content.</label> </p> <div id="editorformitems-<?php echo $nid; ?> "> <p> <input autocomplete="off" type="checkbox" <?php if ($arguments['skipactivesubscribers']) { echo 'checked="checked"'; } ?> name="skipfollowup-<?php echo $nid; ?> " value="1" id="skipfollowup-<?php echo $nid; ?> "> Don't deliver this blog post to subscribers who are receiving a follow up sequence associated with this newsletter.</p> <p> <fieldset style="border:1px solid #909090; padding:10px;"> <legend><input type="checkbox" <?php if ($arguments['nocustomization']) { echo 'checked="checked"'; } ?> autocomplete="off" onchange="toggleCustomization(<?php echo $nid; ?> , this.checked);" name="disablecustomization-<?php echo $nid; ?> " value="1" id="disablecustomization-<?php echo $nid; ?> "> Disable all customization (use default layout for the email)</p></legend> <div id="customizationsform-<?php echo $nid; ?> "> <div id="form-<?php echo $nid; ?> "> <p style="font-size: 17px; font-weight: bold">Subject: <input type="text" name="subject-<?php echo $nid; ?> " value="<?php echo $arguments['subject']; ?> " size="50"></p> <p style="font-size: 17px; font-weight: bold">Text Body:</p> <textarea style="border: 1px solid #c0c0c0;" name="textbody-<?php echo $nid; ?> " rows="10" cols="80"><?php echo $arguments['textbody']; ?> </textarea> <p style="font-size: 17px; font-weight: bold">HTML Body:</p> <?php CreateNewTemplateSwitcherButton("listOfEditors[" . $nid . "]", "htmlbody-" . $nid, $nid); ?> <p> <input type="checkbox" <?php if ($arguments['htmlenable']) { echo 'checked="checked"'; } ?> onchange="toggleHtmlBody(<?php echo $nid; ?> ,this.checked)" name="htmlenable-<?php echo $nid; ?> " id="htmlenable-<?php echo $nid; ?> " value="1"> Enable HTML Body</p> <div id="htmlformitems-<?php echo $nid; ?> "> <p> <input type="checkbox" name="attachimages-<?php echo $nid; ?> " <?php if ($arguments['attachimages']) { echo 'checked="checked"'; } ?> value="1"> Images in the email are attached with the email instead of being given a URL in the source code</p> <div style="float:right; padding-bottom:20px;"><a class="button-primary" target="_blank" href="http://www.krusible.com/newsletter-design/">Get a custom Email Newsletter template</a> </div> <br/><br/><br/> <div style="clear:both"></div> <div id="editor-<?php echo $nid; ?> "> <textarea id="htmlbody-<?php echo $nid; ?> " name="htmlbody-<?php echo $nid; ?> " rows="20" cols="80"><?php echo $arguments['htmlenable'] ? $arguments['htmlbody'] : ""; ?> </textarea> </div> <input type="button" onclick="createEditor(<?php echo $nid; ?> )" value="Enable WYSIWYG" name="enable"/> <input type="button" value="Disable WYSIWYG" onclick="removeEditor(<?php echo $nid; ?> )" name="enable"/> </div> </div> <script> toggleStatus(<?php echo $nid; ?> ,document.getElementById("toggleForm-<?php echo $nid; ?> ").checked); toggleHtmlBody(<?php echo $nid; ?> ,document.getElementById("htmlenable-<?php echo $nid; ?> ").checked); toggleCustomization(<?php echo $nid; ?> ,document.getElementById("disablecustomization-<?php echo $nid; ?> ").checked); </script> <p style="font-size: 17px; font-weight: bold">Shortcodes</p> <div style="font-size: 14px;"> Use the following codes in the Text or HTML body to replace it with the appropriate text. <p></p> <ol> <li>Post related shortcodes:<br> <ol> <li>[!post_url!] - Replace with the URL of this post when it is published</li> <li>[!delivery_date!] - Date when this email was delivered</li> <li>[!post_date!] - Date under which you file this post for publishing.</li> </ol> </li> <li>Subscriber attributes and custom fields: <ol> <li>[!name!] - Name of the subscriber</li> <li>[!email!] - The email address of the subscriber.</li> <?php $query = "SELECT * from " . $wpdb->prefix . "wpr_custom_fields where nid={$nid};"; $results = $wpdb->get_results($query); foreach ($results as $custom_fields) { ?> <li>[!<?php echo $custom_fields->name; ?> !] - <?php echo $custom_fields->name; ?> </li> <?php } ?> </ol> </li> </ol> </div> </div> </p></fieldset> </div> </div> <?php }