PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/osC/admin/mail.php

https://github.com/severnaya99/Sg-2010
PHP | 224 lines | 201 code | 10 blank | 13 comment | 17 complexity | 7a47bc2477c10ce0ca4c79d9d9d9b275 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0
  1. <?php
  2. /*
  3. $Id: mail.php 38 2005-11-14 16:35:43Z Michael $
  4. osCommerce, Open Source E-Commerce Solutions
  5. http://www.oscommerce.com
  6. Copyright (c) 2003 osCommerce
  7. Released under the GNU General Public License
  8. */
  9. include '../../../include/cp_header.php';
  10. require('includes/application_top.php');
  11. $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  12. if ( ($action == 'send_email_to_user') && isset($HTTP_POST_VARS['customers_email_address']) && !isset($HTTP_POST_VARS['back_x']) ) {
  13. switch ($HTTP_POST_VARS['customers_email_address']) {
  14. case '***':
  15. $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
  16. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  17. break;
  18. case '**D':
  19. $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  20. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  21. break;
  22. default:
  23. $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
  24. $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "'");
  25. $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
  26. break;
  27. }
  28. $from = tep_db_prepare_input($HTTP_POST_VARS['from']);
  29. $subject = tep_db_prepare_input($HTTP_POST_VARS['subject']);
  30. $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  31. //Let's build a message object using the email class
  32. $mimemessage = new email(array('X-Mailer: osCommerce'));
  33. // add the message to the object
  34. $mimemessage->add_text($message);
  35. $mimemessage->build_message();
  36. while ($mail = tep_db_fetch_array($mail_query)) {
  37. $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
  38. }
  39. tep_redirect(tep_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
  40. }
  41. if ( ($action == 'preview') && !isset($HTTP_POST_VARS['customers_email_address']) ) {
  42. $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  43. }
  44. if (isset($HTTP_GET_VARS['mail_sent_to'])) {
  45. $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'success');
  46. }
  47. xoops_cp_header();
  48. ?>
  49. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  50. <html <?php echo HTML_PARAMS; ?>>
  51. <head>
  52. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  53. <title><?php echo TITLE; ?></title>
  54. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  55. </head>
  56. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
  57. <!-- header //-->
  58. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  59. <!-- header_eof //-->
  60. <!-- body //-->
  61. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  62. <tr>
  63. <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  64. <!-- left_navigation //-->
  65. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  66. <!-- left_navigation_eof //-->
  67. </table></td>
  68. <!-- body_text //-->
  69. <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  70. <tr>
  71. <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  72. <tr>
  73. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  74. <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  75. </tr>
  76. </table></td>
  77. </tr>
  78. <tr>
  79. <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  80. <?php
  81. if ( ($action == 'preview') && isset($HTTP_POST_VARS['customers_email_address']) ) {
  82. switch ($HTTP_POST_VARS['customers_email_address']) {
  83. case '***':
  84. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  85. break;
  86. case '**D':
  87. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  88. break;
  89. default:
  90. $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
  91. break;
  92. }
  93. ?>
  94. <tr><?php echo tep_draw_form('mail', FILENAME_MAIL, 'action=send_email_to_user'); ?>
  95. <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
  96. <tr>
  97. <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  98. </tr>
  99. <tr>
  100. <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br><?php echo $mail_sent_to; ?></td>
  101. </tr>
  102. <tr>
  103. <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  104. </tr>
  105. <tr>
  106. <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['from'])); ?></td>
  107. </tr>
  108. <tr>
  109. <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  110. </tr>
  111. <tr>
  112. <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['subject'])); ?></td>
  113. </tr>
  114. <tr>
  115. <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  116. </tr>
  117. <tr>
  118. <td class="smallText"><b><?php echo TEXT_MESSAGE; ?></b><br><?php echo nl2br(htmlspecialchars(stripslashes($HTTP_POST_VARS['message']))); ?></td>
  119. </tr>
  120. <tr>
  121. <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  122. </tr>
  123. <tr>
  124. <td>
  125. <?php
  126. /* Re-Post all POST'ed variables */
  127. reset($HTTP_POST_VARS);
  128. while (list($key, $value) = each($HTTP_POST_VARS)) {
  129. if (!is_array($HTTP_POST_VARS[$key])) {
  130. echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
  131. }
  132. }
  133. ?>
  134. <table border="0" width="100%" cellpadding="0" cellspacing="2">
  135. <tr>
  136. <td><?php echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="back"'); ?></td>
  137. <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_MAIL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
  138. </tr>
  139. </table></td>
  140. </tr>
  141. </table></td>
  142. </form></tr>
  143. <?php
  144. } else {
  145. ?>
  146. <tr><?php echo tep_draw_form('mail', FILENAME_MAIL, 'action=preview'); ?>
  147. <td><table border="0" cellpadding="0" cellspacing="2">
  148. <tr>
  149. <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  150. </tr>
  151. <?php
  152. $customers = array();
  153. $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
  154. $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
  155. $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
  156. $mail_query = tep_db_query("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
  157. while($customers_values = tep_db_fetch_array($mail_query)) {
  158. $customers[] = array('id' => $customers_values['customers_email_address'],
  159. 'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')');
  160. }
  161. ?>
  162. <tr>
  163. <td class="main"><?php echo TEXT_CUSTOMER; ?></td>
  164. <td><?php echo tep_draw_pull_down_menu('customers_email_address', $customers, (isset($HTTP_GET_VARS['customer']) ? $HTTP_GET_VARS['customer'] : ''));?></td>
  165. </tr>
  166. <tr>
  167. <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  168. </tr>
  169. <tr>
  170. <td class="main"><?php echo TEXT_FROM; ?></td>
  171. <td><?php echo tep_draw_input_field('from', EMAIL_FROM); ?></td>
  172. </tr>
  173. <tr>
  174. <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  175. </tr>
  176. <tr>
  177. <td class="main"><?php echo TEXT_SUBJECT; ?></td>
  178. <td><?php echo tep_draw_input_field('subject'); ?></td>
  179. </tr>
  180. <tr>
  181. <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  182. </tr>
  183. <tr>
  184. <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td>
  185. <td><?php echo tep_draw_textarea_field('message', 'soft', '60', '15'); ?></td>
  186. </tr>
  187. <tr>
  188. <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  189. </tr>
  190. <tr>
  191. <td colspan="2" align="right"><?php echo tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
  192. </tr>
  193. </table></td>
  194. </form></tr>
  195. <?php
  196. }
  197. ?>
  198. <!-- body_text_eof //-->
  199. </table></td>
  200. </tr>
  201. </table></td>
  202. </tr>
  203. </table>
  204. <!-- body_eof //-->
  205. <!-- footer //-->
  206. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  207. <!-- footer_eof //-->
  208. <br>
  209. </body>
  210. </html>
  211. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>