[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> gv_mail.php (source)

   1  <?php
   2  /*

   3  $Id: gv_mail.php 14 2006-07-28 17:42:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14    require (DIR_FCKEDITOR . 'fckeditor.php');
  15    require (DIR_WS_CLASSES . 'currencies.php');
  16    $currencies = new currencies();
  17  
  18    if ( ($HTTP_GET_VARS['action'] == 'send_email_to_user') && ($HTTP_POST_VARS['customers_email_address'] || $HTTP_POST_VARS['email_to']) && (!$HTTP_POST_VARS['back_x']) ) {
  19      switch ($HTTP_POST_VARS['customers_email_address']) {
  20        case '***':
  21          $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
  22          $mail_sent_to = TEXT_ALL_CUSTOMERS;
  23          break;
  24        case '**D':
  25          $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  26          $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  27          break;
  28        default:
  29          $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
  30  
  31          $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) . "'");
  32          $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
  33          if ($HTTP_POST_VARS['email_to']) {
  34            $mail_sent_to = $HTTP_POST_VARS['email_to'];
  35          }
  36          break;
  37      }
  38  
  39      $from = tep_db_prepare_input($HTTP_POST_VARS['from']);
  40      $subject = tep_db_prepare_input($HTTP_POST_VARS['subject']);
  41      while ($mail = tep_db_fetch_array($mail_query)) {
  42        $id1 = create_coupon_code($mail['customers_email_address']);
  43        $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  44        $message .= "\n\n" . TEXT_GV_WORTH  . $currencies->format($HTTP_POST_VARS['amount']) . "\n\n";
  45        $message .= TEXT_TO_REDEEM;
  46        $message .= TEXT_WHICH_IS . $id1 . TEXT_IN_CASE . "\n\n";
  47        if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
  48          $message .= HTTP_SERVER  . DIR_WS_CATALOG . 'gv_redeem.php' . '/gv_no,'.$id1 . "\n\n";
  49        } else {
  50          $message .= HTTP_SERVER  . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1 . "\n\n";
  51        }
  52        $message .= TEXT_OR_VISIT . HTTP_SERVER  . DIR_WS_CATALOG . TEXT_ENTER_CODE;
  53  
  54        //Let's build a message object using the email class

  55        $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  56        // add the message to the object

  57  // MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Email when WYSIWYG Disabled)

  58      if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable') {
  59      $mimemessage->add_text($message);
  60      } else {
  61      $mimemessage->add_html($message);
  62      }
  63  // MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send HTML Email when WYSIWYG Enabled)

  64        $mimemessage->build_message();
  65  
  66        $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
  67        // Now create the coupon main and email entry

  68        $insert_query = tep_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $id1 . "', 'G', '" . $HTTP_POST_VARS['amount'] . "', now())");
  69        $insert_id = tep_db_insert_id($insert_query);
  70        $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $mail['customers_email_address'] . "', now() )");
  71      }
  72      if ($HTTP_POST_VARS['email_to']) {
  73        $id1 = create_coupon_code($HTTP_POST_VARS['email_to']);
  74        $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  75        $message .= "\n\n" . TEXT_GV_WORTH  . "$nbsp" . $currencies->format($HTTP_POST_VARS['amount']) . "\n\n";
  76        $message .= TEXT_TO_REDEEM;
  77        $message .= TEXT_WHICH_IS . "$nbsp\:" . $id1 . TEXT_IN_CASE . "\n\n";
  78        if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
  79          $message .= HTTP_SERVER  . DIR_WS_CATALOG . 'gv_redeem.php' . '/gv_no,'.$id1 . "\n\n";
  80        } else {
  81          $message .= HTTP_SERVER  . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1 . "\n\n";
  82        }
  83        $message .= TEXT_OR_VISIT . HTTP_SERVER  . DIR_WS_CATALOG  . TEXT_ENTER_CODE;
  84  
  85        //Let's build a message object using the email class

  86        $mimemessage = new email(array('X-Mailer: osCMax 2.0'));
  87        // add the message to the object

  88  
  89      if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable') {
  90      $mimemessage->add_text($message);
  91      } else {
  92      $mimemessage->add_html($message);
  93      }
  94        $mimemessage->build_message();
  95        $mimemessage->send('Friend', $HTTP_POST_VARS['email_to'], '', $from, $subject);
  96        // Now create the coupon email entry

  97        $insert_query = tep_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $id1 . "', 'G', '" . $HTTP_POST_VARS['amount'] . "', now())");
  98        $insert_id = tep_db_insert_id($insert_query);
  99        $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $HTTP_POST_VARS['email_to'] . "', now() )");
 100      }
 101      tep_redirect(tep_href_link(FILENAME_GV_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to)));
 102    }
 103  
 104    if ( ($HTTP_GET_VARS['action'] == 'preview') && (!$HTTP_POST_VARS['customers_email_address']) && (!$HTTP_POST_VARS['email_to']) ) {
 105      $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
 106    }
 107  
 108    if ( ($HTTP_GET_VARS['action'] == 'preview') && (!$HTTP_POST_VARS['amount']) ) {
 109      $messageStack->add(ERROR_NO_AMOUNT_SELECTED, 'error');
 110    }
 111  
 112    if ($HTTP_GET_VARS['mail_sent_to']) {
 113      $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'notice');
 114    }
 115  ?>
 116  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 117  <html <?php echo HTML_PARAMS; ?>>
 118  <head>
 119  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 120  <title><?php echo TITLE; ?></title>
 121  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 122         <script language="JavaScript">
 123  <!-- Begin
 124         function init() {
 125  define('customers_email_address', 'string', 'Customer or Newsletter Group');
 126  }
 127  //  End -->

 128  </script>
 129  </head>
 130  <body OnLoad="init()" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
 131  <!-- header //-->
 132  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 133  <!-- header_eof //-->
 134  
 135  <!-- body //-->
 136  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 137    <tr>
 138      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 139  <!-- left_navigation //-->
 140  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 141  <!-- left_navigation_eof //-->
 142      </table></td>
 143  <!-- body_text //-->
 144      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 145        <tr>
 146          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 147            <tr>
 148              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 149              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 150            </tr>
 151          </table></td>
 152        </tr>
 153        <tr>
 154          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 155  <?php
 156    if ( ($HTTP_GET_VARS['action'] == 'preview') && ($HTTP_POST_VARS['customers_email_address'] || $HTTP_POST_VARS['email_to']) ) {
 157      switch ($HTTP_POST_VARS['customers_email_address']) {
 158        case '***':
 159          $mail_sent_to = TEXT_ALL_CUSTOMERS;
 160          break;
 161        case '**D':
 162          $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
 163          break;
 164        default:
 165          $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
 166          if ($HTTP_POST_VARS['email_to']) {
 167            $mail_sent_to = $HTTP_POST_VARS['email_to'];
 168          }
 169          break;
 170      }
 171  ?>
 172            <tr><?php echo tep_draw_form('mail', FILENAME_GV_MAIL, 'action=send_email_to_user'); ?>
 173              <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
 174                <tr>
 175                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 176                </tr>
 177                <tr>
 178                  <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br><?php echo $mail_sent_to; ?></td>
 179                </tr>
 180                <tr>
 181                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 182                </tr>
 183                <tr>
 184                  <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['from'])); ?></td>
 185                </tr>
 186                <tr>
 187                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 188                </tr>
 189                <tr>
 190                  <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['subject'])); ?></td>
 191                </tr>
 192                <tr>
 193                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 194                </tr>
 195                <tr>
 196                  <td class="smallText"><b><?php echo TEXT_AMOUNT; ?></b><br><?php echo nl2br(htmlspecialchars(stripslashes($HTTP_POST_VARS['amount']))); ?></td>
 197                </tr>
 198                <tr>
 199                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 200                </tr>
 201                <tr>
 202                  <td class="smallText"><b>  <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable') { echo (stripslashes($HTTP_POST_VARS['message'])); } else { echo htmlspecialchars(stripslashes($HTTP_POST_VARS['message'])); } ?></td>
 203                </tr>
 204                <tr>
 205                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 206                </tr>
 207                <tr>
 208                  <td>
 209  <?php
 210  /* Re-Post all POST'ed variables */

 211      reset($HTTP_POST_VARS);
 212      while (list($key, $value) = each($HTTP_POST_VARS)) {
 213        if (!is_array($HTTP_POST_VARS[$key])) {
 214          echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 215        }
 216      }
 217  ?>
 218                  <table border="0" width="100%" cellpadding="0" cellspacing="2">
 219                    <tr>
 220  
 221                       <tr>
 222                      <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_GV_MAIL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
 223                      </tr>
 224                      <td class="smallText">
 225                  <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable'){echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="back"');
 226                  } ?><?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable') {echo(TEXT_EMAIL_BUTTON_HTML);
 227                   } else { echo(TEXT_EMAIL_BUTTON_TEXT); } ?>
 228                      </td>
 229                    </tr>
 230                  </table></td>
 231                </tr>
 232              </table></td>
 233            </form></tr>
 234  <?php
 235    } else {
 236  ?>
 237            <tr><?php echo tep_draw_form('mail', FILENAME_GV_MAIL, 'action=preview'); ?>
 238              <td><table border="0" cellpadding="0" cellspacing="2">
 239                <tr>
 240                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 241                </tr>
 242  <?php
 243      $customers = array();
 244      $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
 245      $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
 246      $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
 247      $mail_query = tep_db_query("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
 248      while($customers_values = tep_db_fetch_array($mail_query)) {
 249        $customers[] = array('id' => $customers_values['customers_email_address'],
 250                             'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')');
 251      }
 252  ?>
 253                <tr>
 254                  <td class="main"><?php echo TEXT_CUSTOMER; ?></td>
 255                  <td><?php echo tep_draw_pull_down_menu('customers_email_address', $customers, $HTTP_GET_VARS['customer']);?></td>
 256                </tr>
 257                <tr>
 258                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 259                </tr>
 260                 <tr>
 261                  <td class="main"><?php echo TEXT_TO; ?></td>
 262                  <td><?php echo tep_draw_input_field('email_to'); ?><?php echo '&nbsp;&nbsp;' . TEXT_SINGLE_EMAIL; ?></td>
 263                </tr>
 264                <tr>
 265                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 266                </tr>
 267               <tr>
 268                  <td class="main"><?php echo TEXT_FROM; ?></td>
 269                  <td><?php echo tep_draw_input_field('from', EMAIL_FROM); ?></td>
 270                </tr>
 271                <tr>
 272                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 273                </tr>
 274                <tr>
 275                  <td class="main"><?php echo TEXT_SUBJECT; ?></td>
 276                  <td><?php echo tep_draw_input_field('subject'); ?></td>
 277                </tr>
 278                <tr>
 279                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 280                </tr>
 281                <tr>
 282                  <td valign="top" class="main"><?php echo TEXT_AMOUNT; ?></td>
 283                  <td><?php echo tep_draw_input_field('amount'); ?></td>
 284                </tr>
 285                <tr>
 286                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 287                </tr>
 288                <tr>
 289                  <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td>
 290                  <td><?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable') {
 291  // Line Changed - MOD: Ajustable Editor Window

 292                      echo tep_draw_fckeditor('message', HTML_AREA_WYSIWYG_EDITOR_WIDTH, HTML_AREA_WYSIWYG_EDITOR_HEIGHT, ' ') .'</td>';
 293                  } else { echo tep_draw_textarea_field('message', 'soft', '60', '15') .'</td>';
 294                  }
 295                  ?>
 296                </tr>
 297                <tr>
 298                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 299                </tr>
 300                <tr>
 301                   <td colspan="2" align="right">
 302                   <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable'){ echo tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL, 'onClick="validate();return returnVal;"');
 303                     } else {
 304                  echo tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); }?>
 305                  </td>
 306                </tr>
 307              </table></td>
 308            </form></tr>
 309  <?php
 310    }
 311  ?>
 312  <!-- body_text_eof //-->
 313          </table></td>
 314        </tr>
 315      </table></td>
 316    </tr>
 317  </table>
 318  <!-- body_eof //-->
 319  
 320  <!-- footer //-->
 321  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 322  <!-- footer_eof //-->
 323  <br>
 324  </body>
 325  </html>
 326  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7