PageRenderTime 61ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/mail.php

https://bitbucket.org/flth/xtcm
PHP | 276 lines | 234 code | 18 blank | 24 comment | 24 complexity | db2e1b5ed65000939c6e44c9f8453789 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /* --------------------------------------------------------------
  3. $Id: mail.php 955 2005-05-19 09:58:02Z novalis $
  4. XT-Commerce - community made shopping
  5. http://www.xt-commerce.com
  6. Copyright (c) 2003 XT-Commerce
  7. --------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommerce(mail.php,v 1.30 2002/03/16 01:07:28); www.oscommerce.com
  11. (c) 2003 nextcommerce (mail.php,v 1.11 2003/08/18); www.nextcommerce.org
  12. Released under the GNU General Public License
  13. --------------------------------------------------------------
  14. Third Party contribution:
  15. Customers Status v3.x (c) 2002-2003 Copyright Elari elari@free.fr | www.unlockgsm.com/dload-osc/ | CVS : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/elari/?sortby=date#dirlist
  16. Released under the GNU General Public License
  17. --------------------------------------------------------------*/
  18. require('includes/application_top.php');
  19. require_once(DIR_FS_CATALOG.DIR_WS_CLASSES.'class.phpmailer.php');
  20. require_once(DIR_FS_INC . 'xtc_php_mail.inc.php');
  21. require_once(DIR_FS_INC . 'xtc_wysiwyg.inc.php');
  22. if ( ($_GET['action'] == 'send_email_to_user') && ($_POST['customers_email_address']) && (!$_POST['back_x']) ) {
  23. switch ($_POST['customers_email_address']) {
  24. case '***':
  25. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
  26. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  27. break;
  28. case '**D':
  29. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  30. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  31. break;
  32. default:
  33. if (is_numeric($_POST['customers_email_address'])) {
  34. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_status = " . $_POST['customers_email_address']);
  35. $sent_to_query = xtc_db_query("select customers_status_name from " . TABLE_CUSTOMERS_STATUS . " WHERE customers_status_id = '" . $_POST['customers_email_address'] . "' AND language_id='" . $_SESSION['languages_id'] . "'");
  36. $sent_to = xtc_db_fetch_array($sent_to_query);
  37. $mail_sent_to = $sent_to['customers_status_name'];
  38. } else {
  39. $customers_email_address = xtc_db_prepare_input($_POST['customers_email_address']);
  40. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . xtc_db_input($customers_email_address) . "'");
  41. $mail_sent_to = $_POST['customers_email_address'];
  42. }
  43. break;
  44. }
  45. $from = xtc_db_prepare_input($_POST['from']);
  46. $subject = xtc_db_prepare_input($_POST['subject']);
  47. $message = xtc_db_prepare_input($_POST['message']);
  48. while ($mail = xtc_db_fetch_array($mail_query)) {
  49. xtc_php_mail(EMAIL_SUPPORT_ADDRESS,
  50. EMAIL_SUPPORT_NAME,
  51. $mail['customers_email_address'] ,
  52. $mail['customers_firstname'] . ' ' . $mail['customers_lastname'] ,
  53. '',
  54. EMAIL_SUPPORT_REPLY_ADDRESS,
  55. EMAIL_SUPPORT_REPLY_ADDRESS_NAME,
  56. '',
  57. '',
  58. $subject,
  59. $message,
  60. $message);
  61. }
  62. xtc_redirect(xtc_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
  63. }
  64. if ( ($_GET['action'] == 'preview') && (!$_POST['customers_email_address']) ) {
  65. $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  66. }
  67. if ($_GET['mail_sent_to']) {
  68. $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']), 'notice');
  69. }
  70. ?>
  71. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  72. <html <?php echo HTML_PARAMS; ?>>
  73. <?php if (USE_WYSIWYG=='true') {
  74. if (!isset($_GET['action'])) {
  75. $query=xtc_db_query("SELECT code FROM ". TABLE_LANGUAGES ." WHERE languages_id='".$_SESSION['languages_id']."'");
  76. $data=xtc_db_fetch_array($query);
  77. echo xtc_wysiwyg('mail',$data['code']);
  78. }
  79. } ?>
  80. <head>
  81. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
  82. <title><?php echo TITLE; ?></title>
  83. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  84. </head>
  85. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
  86. <!-- header //-->
  87. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  88. <!-- header_eof //-->
  89. <!-- body //-->
  90. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  91. <tr>
  92. <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  93. <!-- left_navigation //-->
  94. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  95. <!-- left_navigation_eof //-->
  96. </table></td>
  97. <!-- body_text //-->
  98. <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  99. <tr>
  100. <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  101. <tr>
  102. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  103. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  104. </tr>
  105. </table></td>
  106. </tr>
  107. <tr>
  108. <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  109. <?php
  110. if ( ($_GET['action'] == 'preview') && ($_POST['customers_email_address']) ) {
  111. switch ($_POST['customers_email_address']) {
  112. case '***':
  113. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  114. break;
  115. case '**D':
  116. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  117. break;
  118. default:
  119. if (is_numeric($_POST['customers_email_address'])) {
  120. echo "hier bin ich";
  121. $sent_to_query = xtc_db_query("select customers_status_name from " . TABLE_CUSTOMERS_STATUS . " WHERE customers_status_id = '" . $_POST['customers_email_address'] . "' AND language_id='" . $_SESSION['languages_id'] . "'");
  122. $sent_to = xtc_db_fetch_array($sent_to_query);
  123. $mail_sent_to = $sent_to['customers_status_name'];
  124. } else {
  125. $mail_sent_to = $_POST['customers_email_address'];
  126. }
  127. break;
  128. }
  129. ?>
  130. <tr><?php echo xtc_draw_form('mail', FILENAME_MAIL, 'action=send_email_to_user'); ?>
  131. <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
  132. <tr>
  133. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  134. </tr>
  135. <tr>
  136. <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br /><?php echo $mail_sent_to; ?></td>
  137. </tr>
  138. <tr>
  139. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  140. </tr>
  141. <tr>
  142. <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td>
  143. </tr>
  144. <tr>
  145. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  146. </tr>
  147. <tr>
  148. <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td>
  149. </tr>
  150. <tr>
  151. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  152. </tr>
  153. <tr>
  154. <td class="smallText"><b><?php echo TEXT_MESSAGE; ?></b><br /><?php echo nl2br(htmlspecialchars(stripslashes($_POST['message']))); ?></td>
  155. </tr>
  156. <tr>
  157. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  158. </tr>
  159. <tr>
  160. <td><?php
  161. // Re-Post all POST'ed variables
  162. reset($_POST);
  163. while (list($key, $value) = each($_POST)) {
  164. if (!is_array($_POST[$key])) {
  165. echo xtc_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
  166. }
  167. }
  168. ?>
  169. <table border="0" width="100%" cellpadding="0" cellspacing="2">
  170. <tr>
  171. <td><input type="submit" class="button" onclick="return confirm('<?php echo SAVE_ENTRY; ?>')" value="<?php echo BUTTON_BACK; ?>" name="back"></td>
  172. <td align="right"><?php echo '<a class="button" href="' . xtc_href_link(FILENAME_MAIL) . '">' . BUTTON_CANCEL . '</a> <input type="submit" class="button" value="'.BUTTON_SEND_EMAIL.'">' ?></td>
  173. </tr>
  174. </table></td>
  175. </tr>
  176. </table></td>
  177. </form></tr>
  178. <?php
  179. } else {
  180. ?>
  181. <tr><?php echo xtc_draw_form('mail', FILENAME_MAIL, 'action=preview'); ?>
  182. <td><table border="0" cellpadding="0" cellspacing="2">
  183. <tr>
  184. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  185. </tr>
  186. <?php
  187. $customers = array();
  188. $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
  189. $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
  190. $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
  191. // Customers Status 1.x
  192. // $customers_statuses_array = xtc_get_customers_statuses();
  193. $customers_statuses_array = xtc_db_query("select customers_status_id , customers_status_name from " . TABLE_CUSTOMERS_STATUS . " WHERE language_id='" . $_SESSION['languages_id'] . "' order by customers_status_name");
  194. while ($customers_statuses_value = xtc_db_fetch_array($customers_statuses_array)) {
  195. $customers[] = array('id' => $customers_statuses_value['customers_status_id'],
  196. 'text' => $customers_statuses_value['customers_status_name']);
  197. }
  198. // End customers Status 1.x
  199. $mail_query = xtc_db_query("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
  200. while($customers_values = xtc_db_fetch_array($mail_query)) {
  201. $customers[] = array('id' => $customers_values['customers_email_address'],
  202. 'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')');
  203. }
  204. ?>
  205. <tr>
  206. <td class="main"><?php echo TEXT_CUSTOMER; ?></td>
  207. <td><?php echo xtc_draw_pull_down_menu('customers_email_address', $customers, $_GET['customer']);?></td>
  208. </tr>
  209. <tr>
  210. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  211. </tr>
  212. <tr>
  213. <td class="main"><?php echo TEXT_FROM; ?></td>
  214. <td><?php echo xtc_draw_input_field('from', EMAIL_FROM); ?></td>
  215. </tr>
  216. <tr>
  217. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  218. </tr>
  219. <tr>
  220. <td class="main"><?php echo TEXT_SUBJECT; ?></td>
  221. <td><?php echo xtc_draw_input_field('subject'); ?></td>
  222. </tr>
  223. <tr>
  224. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  225. </tr>
  226. <tr>
  227. <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td>
  228. <td><?php echo xtc_draw_textarea_field('message', 'soft', '100%', '30'); ?></td>
  229. </tr>
  230. <tr>
  231. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  232. </tr>
  233. <tr>
  234. <td colspan="2" align="right"><input type="submit" class="button" value="<?php echo BUTTON_SEND_EMAIL; ?>"></td>
  235. </tr>
  236. </table></td>
  237. </form></tr>
  238. <?php
  239. }
  240. ?>
  241. <!-- body_text_eof //-->
  242. </table></td>
  243. </tr>
  244. </table></td>
  245. </tr>
  246. </table>
  247. <!-- body_eof //-->
  248. <!-- footer //-->
  249. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  250. <!-- footer_eof //-->
  251. <br />
  252. </body>
  253. </html>
  254. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>