Index: src/admin/gv_mail.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- src/admin/gv_mail.php (revision 1d196a603dfc7125088077eac810d0a4c4dfe743) +++ src/admin/gv_mail.php (revision ) @@ -66,20 +66,24 @@ $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS; break; default: + + if ($_POST['email_to']) { + $mail_sent_to = $_POST['email_to']; + } + else { - $customers_email_address = xtc_db_prepare_input($_POST['customers_email_address']); + $customers_email_address = xtc_db_prepare_input($_POST['customers_email_address']); - $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) . "'"); - $mail_sent_to = $_POST['customers_email_address']; + $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) . "'"); + $mail_sent_to = $_POST['customers_email_address']; - if ($_POST['email_to']) { - $mail_sent_to = $_POST['email_to']; } break; } $from = xtc_db_prepare_input($_POST['from']); - while ($mail = xtc_db_fetch_array($mail_query)) { - $id1 = create_coupon_code($mail['customers_email_address']); + if ($_POST['email_to']) { + $id1 = create_coupon_code($_POST['email_to']); + // assign language to template for caching $smarty->assign('language', $_SESSION['language']); $smarty->caching = false; @@ -91,15 +95,19 @@ $smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/'); $smarty->assign('logo_path',HTTP_SERVER . DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/'); + $smarty->assign('AMMOUNT', $currencies->format($_POST['amount'])); + $smarty->assign('MESSAGE', gm_prepare_string($_POST['message'], true)); $smarty->assign('GIFT_ID', $id1); $smarty->assign('WEBSITE', HTTP_SERVER . DIR_WS_CATALOG); - + if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { + $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '/gv_no,'.$id1; + } else { - $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1; + $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1; + } - $smarty->assign('GIFT_LINK',$link); // bof gm $gm_logo_mail = MainFactory::create_object('GMLogoManager', array("gm_logo_mail")); @@ -108,65 +116,63 @@ } // eof gm $html_mail = fetch_email_template($smarty, 'send_gift', 'html'); - // BOF GM_MOD - $link = str_replace('&', '&', $link); - $smarty->assign('GIFT_LINK', $link); - // EOF GM_MOD $txt_mail = fetch_email_template($smarty, 'send_gift', 'txt'); - xtc_php_mail(EMAIL_BILLING_ADDRESS,EMAIL_BILLING_NAME, $mail['customers_email_address'] , $mail['customers_firstname'] . ' ' . $mail['customers_lastname'] , '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $subject, $html_mail , $txt_mail); + xtc_php_mail(EMAIL_BILLING_ADDRESS,EMAIL_BILLING_NAME, $_POST['email_to'] , '' , '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $subject, $html_mail , $txt_mail); - + - // Now create the coupon main and email entry + // Now create the coupon email entry $insert_query = xtc_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())"); $insert_id = xtc_db_insert_id($insert_query); - $insert_query = xtc_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() )"); + $insert_query = xtc_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $_POST['email_to'] . "', now() )"); } - if ($_POST['email_to']) { - $id1 = create_coupon_code($_POST['email_to']); + else { + while ($mail = xtc_db_fetch_array($mail_query)) { + $id1 = create_coupon_code($mail['customers_email_address']); - // assign language to template for caching - $smarty->assign('language', $_SESSION['language']); - $smarty->caching = false; + // assign language to template for caching + $smarty->assign('language', $_SESSION['language']); + $smarty->caching = false; - // set dirs manual - $smarty->template_dir=DIR_FS_CATALOG.'templates'; - $smarty->compile_dir=DIR_FS_CATALOG.'templates_c'; - $smarty->config_dir=DIR_FS_CATALOG.'lang'; + // set dirs manual + $smarty->template_dir=DIR_FS_CATALOG.'templates'; + $smarty->compile_dir=DIR_FS_CATALOG.'templates_c'; + $smarty->config_dir=DIR_FS_CATALOG.'lang'; - $smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/'); - $smarty->assign('logo_path',HTTP_SERVER . DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/'); + $smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/'); + $smarty->assign('logo_path',HTTP_SERVER . DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/'); - - $smarty->assign('AMMOUNT', $currencies->format($_POST['amount'])); + $smarty->assign('AMMOUNT', $currencies->format($_POST['amount'])); - - $smarty->assign('MESSAGE', gm_prepare_string($_POST['message'], true)); - $smarty->assign('GIFT_ID', $id1); - $smarty->assign('WEBSITE', HTTP_SERVER . DIR_WS_CATALOG); + $smarty->assign('MESSAGE', gm_prepare_string($_POST['message'], true)); + $smarty->assign('GIFT_ID', $id1); + $smarty->assign('WEBSITE', HTTP_SERVER . DIR_WS_CATALOG); - if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { - $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '/gv_no,'.$id1; - } else { + - $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1; + $link = HTTP_SERVER . DIR_WS_CATALOG . 'gv_redeem.php' . '?gv_no='.$id1; - } + - $smarty->assign('GIFT_LINK',$link); - // bof gm - $gm_logo_mail = MainFactory::create_object('GMLogoManager', array("gm_logo_mail")); - if($gm_logo_mail->logo_use == '1') { - $smarty->assign('gm_logo_mail', $gm_logo_mail->get_logo()); - } - // eof gm - $html_mail = fetch_email_template($smarty, 'send_gift', 'html'); + $smarty->assign('GIFT_LINK',$link); + // bof gm + $gm_logo_mail = MainFactory::create_object('GMLogoManager', array("gm_logo_mail")); + if($gm_logo_mail->logo_use == '1') { + $smarty->assign('gm_logo_mail', $gm_logo_mail->get_logo()); + } + // eof gm + $html_mail = fetch_email_template($smarty, 'send_gift', 'html'); + // BOF GM_MOD + $link = str_replace('&', '&', $link); + $smarty->assign('GIFT_LINK', $link); + // EOF GM_MOD - $txt_mail = fetch_email_template($smarty, 'send_gift', 'txt'); + $txt_mail = fetch_email_template($smarty, 'send_gift', 'txt'); - xtc_php_mail(EMAIL_BILLING_ADDRESS,EMAIL_BILLING_NAME, $_POST['email_to'] , '' , '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $subject, $html_mail , $txt_mail); + xtc_php_mail(EMAIL_BILLING_ADDRESS,EMAIL_BILLING_NAME, $mail['customers_email_address'] , $mail['customers_firstname'] . ' ' . $mail['customers_lastname'] , '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $subject, $html_mail , $txt_mail); - + - // Now create the coupon email entry + // Now create the coupon main and email entry - $insert_query = xtc_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())"); - $insert_id = xtc_db_insert_id($insert_query); + $insert_query = xtc_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', now())"); + $insert_id = xtc_db_insert_id($insert_query); - $insert_query = xtc_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id ."', '0', 'Admin', '" . $_POST['email_to'] . "', now() )"); + $insert_query = xtc_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() )"); + } - } + } xtc_redirect(xtc_href_link(FILENAME_GV_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to))); } elseif ( ($_GET['action'] == 'preview') && ($_POST['customers_email_address'] || $_POST['email_to']) ) { \ No newline at end of file