Advertisement
Guest User

email-posts-to-subscribers/sendmail/sendmail-subscriber.php

a guest
Aug 20th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.57 KB | None | 0 0
  1. <?php if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); } ?>
  2. <?php //if ( ! empty( $_POST ) && ! wp_verify_nonce( $_REQUEST['wp_create_nonce'], 'sendmail-nonce' ) ) { die('<p>Security check failed.</p>'); } ?>
  3. <?php
  4. elp_cls_common::elp_check_latest_update();
  5.  
  6. $elp_errors = array();
  7. $elp_success = '';
  8. $elp_error_found = FALSE;
  9.  
  10. $elp_set_guid = isset($_POST['elp_set_guid']) ? sanitize_text_field($_POST['elp_set_guid']) : '';
  11. $elp_sent_type = isset($_POST['elp_sent_type']) ? sanitize_text_field($_POST['elp_sent_type']) : '';
  12. $elp_sent_group = isset($_POST['elp_sent_group']) ? sanitize_text_field($_POST['elp_sent_group']) : '';
  13. $elp_search_query = isset($_POST['elp_search_query']) ? sanitize_text_field($_POST['elp_search_query']) : 'A,B,C';
  14. $sendmailsubmit = isset($_POST['sendmailsubmit']) ? sanitize_text_field($_POST['sendmailsubmit']) : 'no';
  15.  
  16. if ($sendmailsubmit == 'yes')
  17. {
  18. check_admin_referer('elp_form_submit');
  19.  
  20. $form['elp_set_guid'] = isset($_POST['elp_set_guid']) ? sanitize_text_field($_POST['elp_set_guid']) : '';
  21. if ($form['elp_set_guid'] == '')
  22. {
  23. $elp_errors[] = __('Please select mail configuration.', 'email-posts-to-subscribers');
  24. $elp_error_found = TRUE;
  25. }
  26. //$recipients = $_POST['eemail_checked'];
  27. $recipients = isset($_POST['eemail_checked']) ? $_POST['eemail_checked'] : '';
  28. $elp_sent_type = isset($_POST['elp_sent_type']) ? sanitize_text_field($_POST['elp_sent_type']) : 'Instant Mail';
  29. if ($recipients == '')
  30. {
  31. $elp_errors[] = __('No email address selected.', 'email-posts-to-subscribers');
  32. $elp_error_found = TRUE;
  33. }
  34.  
  35. if ($elp_error_found == FALSE)
  36. {
  37. $data = array();
  38. $data = elp_cls_dbquery::elp_configuration_cron($form['elp_set_guid']);
  39.  
  40. if(count($data) > 0)
  41. {
  42. $subject = $data[0]['elp_set_name'];
  43. $content = elp_cls_newsletter::elp_template_compose($data[0]['elp_set_templid'], $data[0]['elp_set_postcount'],
  44. $data[0]['elp_set_postcategory'], $data[0]['elp_set_postorderby'], $data[0]['elp_set_postorder'], "send");
  45. //mattblox-2019-04-13
  46. $first_post_title = elp_cls_newsletter::elp_template_compose($data[0]['elp_set_templid'], $data[0]['elp_set_postcount'],
  47. $data[0]['elp_set_postcategory'], $data[0]['elp_set_postorderby'], $data[0]['elp_set_postorder'], "first_post_title");
  48. $subject = substr_count($subject, "###POSTTITLEONLY###")?$first_post_title:str_replace("###POSTTITLE###", $first_post_title, $subject);
  49. //mattblox-2019-04-13
  50.  
  51. if($content == "NO_POST_FOUND_FOR_THIS_MAIL_CONFIGURATION")
  52. {
  53. $sendguid = elp_cls_common::elp_generate_guid(60);
  54. $currentdate = date('Y-m-d G:i:s');
  55. elp_cls_dbquery2::elp_sentmail_ins($sendguid, 0, "manual", $currentdate, $currentdate, 0, $content, $elp_sent_type, $subject);
  56. $elp_success_msg = TRUE;
  57. $elp_success = __('No post found for this mail configuration', 'email-posts-to-subscribers');
  58. }
  59. else
  60. {
  61. elp_cls_sendmail::elp_prepare_newsletter_manual($subject, $content, $recipients, $elp_sent_type);
  62. $elp_success_msg = TRUE;
  63. $elp_success = __('Mail sent successfully', 'email-posts-to-subscribers');
  64. }
  65. }
  66.  
  67. if ($elp_success_msg == TRUE)
  68. {
  69. ?>
  70. <div class="updated fade">
  71. <p>
  72. <strong><?php echo $elp_success; ?> <a href="<?php echo ELP_ADMINURL; ?>?page=elp-sentmail"><?php _e('Click here for details', 'email-posts-to-subscribers'); ?></a></strong>
  73. </p>
  74. </div>
  75. <?php
  76. }
  77. }
  78. }
  79.  
  80. if ($elp_set_guid <> "")
  81. {
  82. $data = elp_cls_dbquery::elp_configuration_cron($elp_set_guid);
  83. if(count($data) > 0)
  84. {
  85. $perpage = $data[0]['elp_set_totalsent'];
  86. }
  87. }
  88.  
  89. if ($elp_error_found == TRUE && isset($elp_errors[0]) == TRUE)
  90. {
  91. ?><div class="error fade"><p><strong><?php echo $elp_errors[0]; ?></strong></p></div><?php
  92. }
  93. ?>
  94. <style>
  95. .form-table th {
  96. width: 250px;
  97. }
  98. </style>
  99. <div class="wrap">
  100. <div class="form-wrap">
  101. <div id="icon-plugins" class="icon32"></div>
  102. <h2><?php _e(ELP_PLUGIN_DISPLAY, 'email-posts-to-subscribers'); ?></h2>
  103. <h3><?php _e('Send Mail Manually', 'email-posts-to-subscribers'); ?></h3>
  104. <form name="elp_form" method="post" action="#" onsubmit="return _elp_submit()" >
  105. <table class="form-table">
  106. <tbody>
  107. <tr>
  108. <th scope="row">
  109. <label for="elp">
  110. <?php _e('Select your mail configuration', 'email-posts-to-subscribers'); ?>
  111. <p class="description"><?php _e('Select a mail configuration from available list. To create please check mail configuration menu.', 'email-posts-to-subscribers'); ?></p>
  112. </label>
  113. </th>
  114. <td>
  115. <select name="elp_set_guid" id="elp_set_guid" onChange="_elp_mailsubject(this.options[this.selectedIndex].value)">
  116. <option value=''><?php _e('Select', 'email-posts-to-subscribers'); ?></option>
  117. <?php
  118. $configs = array();
  119. $configs = elp_cls_dbquery::elp_configuration_select(0, 0, 100);
  120. $thisselected = "";
  121. if(count($configs) > 0)
  122. {
  123. $i = 1;
  124. foreach ($configs as $config)
  125. {
  126. if($config["elp_set_guid"] == $elp_set_guid)
  127. {
  128. $thisselected = "selected='selected'" ;
  129. }
  130. ?><option value='<?php echo $config["elp_set_guid"]; ?>' <?php echo $thisselected; ?>><?php echo $config["elp_set_name"]; ?></option><?php
  131. $thisselected = "";
  132. }
  133. }
  134. ?>
  135. </select>
  136. </td>
  137. </tr>
  138. <tr>
  139. <th scope="row">
  140. <label for="elp">
  141. <?php _e('Mail Type', 'email-posts-to-subscribers'); ?>
  142. <p class="description"><?php _e('Select your mail type.', 'email-posts-to-subscribers'); ?></p>
  143. </label>
  144. </th>
  145. <td>
  146. <select name="elp_sent_type" id="elp_sent_type">
  147. <option value=''>Select</option>
  148. <option value='Instant Mail' <?php if($elp_sent_type == 'Instant Mail') { echo "selected='selected'" ; } ?>>Send mail immediately.</option>
  149. <option value='Cron Mail' <?php if($elp_sent_type == 'Cron Mail') { echo "selected='selected'" ; } ?>>Send mail via cron job.</option>
  150. </select>
  151. </td>
  152. </tr>
  153. <tr>
  154. <th scope="row">
  155. <label for="elp">
  156. <?php _e('Select subscriber group', 'email-posts-to-subscribers'); ?>
  157. <p class="description"><?php _e('Select your subscriber group to send email.', 'email-posts-to-subscribers'); ?></p>
  158. </label>
  159. </th>
  160. <td>
  161. <select name="elp_sent_group" id="elp_sent_group" onChange="_elp_mailgroup(this.options[this.selectedIndex].value)">
  162. <option value=''><?php _e('All Group', 'email-posts-to-subscribers'); ?></option>
  163. <?php
  164. $groups = array();
  165. $thisselected = "";
  166. $groups = elp_cls_dbquery::elp_view_subscriber_group();
  167. if(count($groups) > 0)
  168. {
  169. $i = 1;
  170. foreach ($groups as $group)
  171. {
  172. if(stripslashes($group["elp_email_group"]) == stripslashes($elp_sent_group))
  173. {
  174. $thisselected = "selected='selected'" ;
  175. }
  176. ?><option value="<?php echo esc_html($group["elp_email_group"]); ?>" <?php echo $thisselected; ?>><?php echo stripslashes($group["elp_email_group"]); ?></option><?php
  177. $thisselected = "";
  178. }
  179. }
  180. ?>
  181.  
  182. </select>
  183. <input type="button" name="CheckAll" value="<?php _e('Check All', 'email-posts-to-subscribers'); ?>" onClick="_elp_checkall('elp_form', 'eemail_checked[]', true);">
  184. <input type="button" name="UnCheckAll" value="<?php _e('Uncheck All', 'email-posts-to-subscribers'); ?>" onClick="_elp_checkall('elp_form', 'eemail_checked[]', false);">
  185. </td>
  186. </tr>
  187. <tr>
  188. <td colspan="2">
  189. <div class="tablenav">
  190. <input type="button" class="button action <?php if($elp_search_query == "A,B,C"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('A,B,C')" id="" value="A,B,C" />
  191. <input type="button" class="button action <?php if($elp_search_query == "D,E,F"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('D,E,F')" id="" value="D,E,F" />
  192. <input type="button" class="button action <?php if($elp_search_query == "G,H,I"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('G,H,I')" id="" value="G,H,I" />
  193. <input type="button" class="button action <?php if($elp_search_query == "J,K,L"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('J,K,L')" id="" value="J,K,L" />
  194. <input type="button" class="button action <?php if($elp_search_query == "M,N,O"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('M,N,O')" id="" value="M,N,O" />
  195. <input type="button" class="button action <?php if($elp_search_query == "P,Q,R"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('P,Q,R')" id="" value="P,Q,R" />
  196. <input type="button" class="button action <?php if($elp_search_query == "S,T,U"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('S,T,U')" id="" value="S,T,U" />
  197. <input type="button" class="button action <?php if($elp_search_query == "V,W,X,Y,Z"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('V,W,X,Y,Z')" id="" value="V,W,X,Y,Z" />
  198. <input type="button" class="button action <?php if($elp_search_query == "0,1,2,3,4,5,6,7,8,9"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('0,1,2,3,4,5,6,7,8,9')" id="" value="0 to 9" />
  199. <input type="button" class="button action <?php if($elp_search_query == "ALL"){ echo 'button-primary'; } ?>" onclick="javascript:_elp_sendemailsearch('ALL')" id="" value="ALL" />
  200. </div>
  201. </td>
  202. </tr>
  203. <tr>
  204. <td colspan="2">
  205. <?php
  206. $subscribers = array();
  207. $subscribers = elp_cls_dbquery::elp_view_subscriber_sendmail($elp_search_query, $elp_sent_group);
  208. $i = 1;
  209. $count = 0;
  210. if(count($subscribers) > 0)
  211. {
  212. echo "<table border='0' cellspacing='0'><tr>";
  213. $col=3;
  214. foreach ($subscribers as $subscriber)
  215. {
  216. $to = $subscriber['elp_email_mail'];
  217. $id = $subscriber['elp_email_id'];
  218. //$ToAddress = trim($to) . '<||>' . trim($id);
  219. if($to <> "")
  220. {
  221. echo "<td style='padding-top:4px;padding-bottom:4px;padding-right:10px;'>";
  222. ?>
  223. <input class="radio" type="checkbox" checked="checked" value='<?php echo $id; ?>' id="eemail_checked[]" name="eemail_checked[]">
  224. <?php echo $to; ?> (<?php echo $id; ?>)
  225. <?php
  226. if($col > 1)
  227. {
  228. $col=$col-1;
  229. echo "</td><td>";
  230. }
  231. elseif($col = 1)
  232. {
  233. $col=$col-1;
  234. echo "</td></tr><tr>";;
  235. $col=3;
  236. }
  237. $count = $count + 1;
  238. }
  239. }
  240. echo "</tr></table>";
  241. }
  242. else
  243. {
  244. $message = __('Oops.. There is no email starts with ', 'email-posts-to-subscribers');
  245. echo $message . " " . $elp_search_query . "<br>";
  246. }
  247. ?>
  248. </td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. <div>
  253. <br />
  254. <?php wp_nonce_field('elp_form_submit'); ?>
  255. <input type="hidden" name="sendmailsubmit" id="sendmailsubmit" value=""/>
  256. <input type="hidden" name="elp_search_query" id="elp_search_query" value="<?php echo $elp_search_query; ?>"/>
  257. <input type="hidden" name="wp_create_nonce" id="wp_create_nonce" value="<?php echo wp_create_nonce( 'sendmail-nonce' ); ?>"/>
  258.  
  259. <input type="submit" name="Submit" id="Submit" class="button add-new-h2" value="<?php _e('Send Email', 'email-posts-to-subscribers'); ?>" style="width:160px;" />&nbsp;&nbsp;
  260. <input name="publish" lang="publish" class="button add-new-h2" onclick="_elp_redirect()" value="<?php _e('Cancel', 'email-posts-to-subscribers'); ?>" type="button" />&nbsp;&nbsp;
  261. <input name="Help" lang="publish" class="button add-new-h2" onclick="_elp_help()" value="<?php _e('Help', 'email-posts-to-subscribers'); ?>" type="button" />
  262. </div>
  263. </form>
  264. </div><br />
  265. <p class="description"><?php echo ELP_OFFICIAL; ?></p>
  266. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement