PROBLEMA CON NEWSLETTER AIUTOOO
Inviato: 04/02/2009, 22:56
Volevo solo chiedere una soluzione ad un problema che ho nell'inviare le newsletters ai rivenditori
Dopo che ho composto la newsletter la invio, ma cosa succede, il refresh della pagina và all'infinito, e non mi dà il messaggio "inviato"
ma la cosa strana e che compare l'avanzamento dell'invio dell'email con la scritta 3 di 1 mail are sent quando io per prova ho selezionato solo un rivenditore.
Il provider del dominio mi blocca l'ip per spamming
e mi risponde:
Il suo client di posta apre troppe connessioni. Il numero massimo di connessioni ammissibili è 2. la sua connessione ne ha aperte più di 400
87.3.144.189 # lfd: (CT) IP 87.3.144.189 found to have 429 connections - Wed Jan 28 18:35:16 2009
Chiedevo è un problema di configurazione oppure ciò è da imputare a qualcos'altro?
Grazie per la risposta
allego il file
<?php
/*
$Id: newsletters.php,v 1.17 2003/06/29 22:50:52 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
//newsletter products
$prod_for_row = 2;
//newsletter products
//currenices class required for price display in newsletter
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
//end newsletter products
$customers_group_array[] = array(
'id' => '0',
'text' => TEXT_ALL_GROUPS
);
$customers_group_array[] = array(
'id' => '-1',
'text' => TEXT_GUEST
);
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_name");
while ($customers_group = tep_db_fetch_array($customers_group_query)) {
$customers_group_array[] = array(
'id' => $customers_group['customers_group_id'],
'text' => $customers_group['customers_group_name']
);
}
if ($dir = dir(DIR_FS_TEMPLATES)) {
while ($file = $dir->read()) {
if (!is_dir(DIR_FS_TEMPLATES . $file)) {
if (substr($file, strrpos($file, '.')) == '.php') {
$template_array[] = array('id' => $file,
'text' => $file);
}
}
}
if (tep_not_null($template_array)) {
sort($template_array);
}
$dir->close();
}
if (isset($_POST['module']) && ($_POST['module'] == 'newsletter_products')){
if (!tep_not_null($template_array)) {
$messageStack->add_session(NO_TEMPLATE_ERROR, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] : ''));
}
}
if (isset($_POST['action']) && tep_not_null($_POST['action'])) {
$action = $_POST['action'];
} elseif(isset($_GET['action']) && tep_not_null($_GET['action'])) {
$action = $_GET['action'];
}
if (tep_not_null($action)) {
switch ($action) {
case 'lock':
case 'unlock':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$status = (($action == 'lock') ? '1' : '0');
tep_db_query("update " . TABLE_NEWSLETTERS . " set locked = '" . $status . "' where newsletters_id = '" . (int)$newsletter_id . "'");
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
break;
case 'insert':
case 'update':
if (isset($HTTP_POST_VARS['newsletter_id'])) $newsletter_id = tep_db_prepare_input($HTTP_POST_VARS['newsletter_id']);
$newsletter_module = tep_db_prepare_input($HTTP_POST_VARS['module']);
$title = tep_db_prepare_input($HTTP_POST_VARS['title']);
$content = tep_db_prepare_input($HTTP_POST_VARS['content']);
$header = tep_db_prepare_input($HTTP_POST_VARS['header']);
$footer = tep_db_prepare_input($HTTP_POST_VARS['footer']);
$customer_group_id = tep_db_prepare_input($HTTP_POST_VARS['customer_group_id']);
//newsletter plus
$products = $HTTP_POST_VARS['chosen'];
//end newsletter plus
$newsletter_error = false;
if (empty($title)) {
$messageStack->add(ERROR_NEWSLETTER_TITLE, 'error');
$newsletter_error = true;
}
if (empty($module)) {
$messageStack->add(ERROR_NEWSLETTER_MODULE, 'error');
$newsletter_error = true;
}
if ($newsletter_error == false) {
//newsletter products
$template = $_POST['template_id'];
$sql_data_array = array(
'title' => $title,
'content' => $content,
'module' => $newsletter_module,
'header' => $header,
'footer' => $footer,
'template' => $template,
'customers_group_id' => $customer_group_id
);
//end newsletter products
if ($action == 'insert') {
$sql_data_array['date_added'] = 'now()';
$sql_data_array['status'] = '0';
$sql_data_array['locked'] = '0';
tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array);
$newsletter_id = tep_db_insert_id();
//newsletter products
if(!empty($products)){
for($i=0, $n=sizeof($products); $i<$n; $i++){
tep_db_query("insert into " . TABLE_NEWSLETTERS_TO_PRODUCTS . " (newsletters_id, products_id) values (" . $newsletter_id . ", " . $products[$i] . ")");
}
}
//end newsletter products
} elseif ($action == 'update') {
tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array, 'update', "newsletters_id = '" . (int)$newsletter_id . "'");
//newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$newsletter_id . "'");
if(!empty($products) && $newsletter_module == 'newsletter_products'){
for($i=0, $n=sizeof($products); $i<$n; $i++){
tep_db_query("insert into " . TABLE_NEWSLETTERS_TO_PRODUCTS . " (newsletters_id, products_id) values (" . $newsletter_id . ", " . $products[$i] . ")");
}
}
//end newsletter products
}
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'nID=' . $newsletter_id));
} else {
$action = 'new';
}
break;
case 'deleteconfirm':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$newsletter_id . "'");
//end newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page']));
break;
case 'delete':
case 'new': if (!isset($HTTP_GET_VARS['nID'])) break;
case 'send':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['locked'] < 1) {
switch ($action) {
case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;
case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;
case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
}
$messageStack->add_session($error, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
}
break;
case 'confirm_send':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['locked'] < 1) {
switch ($action) {
case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;
case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;
case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
}
$messageStack->add_session($error, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
} else {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
$newsletter_query = tep_db_query("select newsletters_id, title, content, customers_group_id, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter products
//--- Beginning of addition: Ultimate HTML Emails ---//
if (EMAIL_USE_HTML == 'true') {
$HTMLNewsletterContents = $newsletter['content'];
require(DIR_FS_CATALOG_MODULES . 'UHtmlEmails/'. ULTIMATE_HTML_EMAIL_LAYOUT .'/newsletters.php');
$newsletter['content'] = $html_email;
if(ULTIMATE_HTML_EMAIL_DEVELOPMENT_MODE === 'true'){
//Save the contents of the generated html email to the harddrive in .htm file. This can be practical when developing a new layout.
$TheFileName = DIR_FS_CATALOG . 'Last_mail_from_newsletters.php.htm';
$TheFileHandle = fopen($TheFileName, 'w') or die("can't open error log file");
fwrite($TheFileHandle, $newsletter['content']);
fclose($TheFileHandle);
}
}
//--- End of addition: Ultimate HTML Emails ---//
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//newsletter products
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
} elseif ($nInfo->module == 'newsletter') {
$module = new $module_name($nInfo->title, $nInfo->content);
} else{
$module = new $module_name($nInfo->title, $nInfo->content);
}
//end newsletter products
$uhtml_received_count_query = tep_db_query("select count(*) as count from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
$uhtml_received_count_query_array = tep_db_fetch_array($uhtml_received_count_query);
$uhtml_received_count = $uhtml_received_count_query_array['count'];
$uhtml_want_count = $module->mail_count();
$uhtml_bar_percent = round($uhtml_received_count/$uhtml_want_count*100,0);
//--- Beginning of adittion: Ultimate HTML Emails ---//
if(($module_name == 'newsletter') || ($module_name == 'newsletter_products')){
//Do it the UHTML way! ---------------------------------------------------------------------------------------------------
//Create the function to draw the progressbar based on "how many customers have received it"/"How many customers wan't newsletters"
if($uhtml_received_count != $uhtml_want_count ){
//Send a pack of emails
tep_set_time_limit(0);
flush();
$module->send($nInfo->newsletters_id);
$refresh = true;
} else {
$refresh = false;
}
}
}
break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php if ($refresh) echo '<meta http-equiv="refresh" content="0; url=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '"/>'; ?>
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<?php if (KTML_WEB_EDITOR == 'true') include(DIR_WS_INCLUDES . 'ktml/ktml.js.php'); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<?php
if ($action == 'new') {
$form_action = 'insert';
$parameters = array('title' => '',
'header' => '',
'footer' => '',
'content' => '',
'module' => '',
'products' => array(),
'template' => '',
'customers_group_id' => '');
//end newsletter products
$nInfo = new objectInfo($parameters);
if (isset($HTTP_GET_VARS['nID'])) {
$form_action = 'update';
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
$newsletter_query = tep_db_query("select title, customers_group_id, content, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter products
$nInfo->objectInfo($newsletter);
} elseif ($HTTP_POST_VARS) {
$nInfo->objectInfo($HTTP_POST_VARS);
}
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<?php
//newsletter products
echo tep_draw_form('newsletter', FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'action=' . $form_action, 'post', ' enctype="multipart/form-data" onSubmit="return selectAll(\'newsletter\', \'chosen[]\')"'); if ($form_action == 'update') echo tep_draw_hidden_field('newsletter_id', $nID);
//end newsletter products
?>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td align=left class="main"><nobr><?php echo TEXT_NEWSLETTER_MODULE; ?></nobr></td>
<td class="main"><b><?php echo strtoupper($nInfo->module) . tep_draw_hidden_field('module', $nInfo->module); ?></b></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td align=left width="80px" class="main"><nobr><?php echo TEXT_NEWSLETTER_TITLE; ?></nobr></td>
<td class="main"><?php echo tep_draw_input_field('title', $nInfo->title, '', true); ?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<?php if ($nInfo->module != 'newsletter_products') { ?>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_CONTENT; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'content';
$field_text = $nInfo->content;
$fieldID = 'text_newsletter_content';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->content);
}
?></td>
</tr>
<?php
} else {
$products = new newsletter_products('','', '', '', '', '', '');
?>
<tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
<tr><td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><nobr><?php echo TEXT_NEWSLETTER_SELECT_GROUP; ?> </nobr></td>
<td class="main" valign="top"><?php echo tep_draw_pull_down_menu_mod('customer_group_id', $customers_group_array, $nInfo->customers_group_id);?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr><td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><nobr><?php echo TEXT_NEWSLETTER_SELECT_TEMPLATE; ?> </nobr></td>
<td class="main" valign="top"><?php echo tep_draw_pull_down_menu_mod('template_id', $template_array, $nInfo->template);?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_PROD_HEADER; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'header';
$field_text = $nInfo->header;
$fieldID = 'html_text_newsletter_header';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->header);
}
?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main"><?php echo $products->choose_products(); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_PROD_FOOTER; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'footer';
$field_text = $nInfo->footer;
$fieldID = 'html_text_newsletter_footer';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->footer);
}
?></td>
</tr>
<tr>
<td colspan="2"><?php tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main" align=center><?php echo (($form_action == 'insert') ? tep_image_submit('button_save.gif', IMAGE_SAVE) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></td>
</form></tr>
<?php
} elseif ($action == 'preview') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter plus
$newsletter_query = tep_db_query("select title, customers_group_id, content, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter['products'] = $news_products;
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
?>
<tr>
<td align=center><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
if($nInfo->module == 'newsletter_products'){
$module = new newsletter_products($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer);
?>
<tr>
<td class=main><b><?php
echo TEXT_TITLE . $nInfo->title;
?></b></td>
</tr>
<tr>
<td class=main><b><?php
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" . $nInfo->customers_group_id . "' order by customers_group_name");
$customers_group = tep_db_fetch_array($customers_group_query);
if ($nInfo->customers_group_id == '0') {
$customers_group_id = $module->get_retailprice_group_id();
echo TEXT_SEND_TO_GROUPS . TEXT_ALL_GROUPS;
} elseif ($nInfo->customers_group_id == '-1') {
$customers_group_id = $module->get_retailprice_group_id();
echo TEXT_SEND_TO_GROUPS . TEXT_GUEST;
} elseif ($nInfo->customers_group_id > 0) {
$customers_group_id = $nInfo->customers_group_id;
echo TEXT_SEND_TO_GROUPS . $customers_group['customers_group_name'];
}
?></b></td>
</tr>
<tr>
<td><?php
$html_content = $module->html_content($prod_for_row);
echo $html_content[$customers_group_id];
?></td>
</tr>
<?php
}else{
?>
<tr>
<td><tt><?php echo nl2br($nInfo->content); ?></tt></td>
</tr>
<?php
}
//end newsletter plus
?>
<tr>
<td align="center"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
} elseif ($action == 'send') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter plus
$newsletter_query = tep_db_query("select title, content, customers_group_id, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter plus
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//newsletter plus
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
tep_db_query("delete from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
} elseif($nInfo->module == 'newsletter'){
$module = new $module_name($nInfo->title, $nInfo->content);
tep_db_query("delete from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
} else {
$module = new $module_name($nInfo->title, $nInfo->content);
}
//end newsletter plus
?>
<tr>
<td align=left><?php if ($module->show_choose_audience) { echo $module->choose_audience(); } else { echo $module->confirm(); } ?></td>
</tr>
<?php
} elseif ($action == 'confirm') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$newsletter_query = tep_db_query("select title, content, customers_group_id, header, footer, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
}else{
$module = new $module_name($nInfo->title, $nInfo->content);
}?>
<tr>
<td><?php echo $module->confirm(); ?></td>
</tr>
<?php
} elseif ($action == 'confirm_send') {
//--- Beginning of adittion: Ultimate HTML Emails ---//
if(($module_name == 'newsletter') || ($module_name == 'newsletter_products')){ //Do it the UHTML way! ---------------------------------------------------------------------------------------------------
//Create the function to draw the progressbar based on "how many customers have received it"/"How many customers wan't newsletters"
if($uhtml_received_count != $uhtml_want_count ){
?>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main" valign="middle" colspan="2"><?php draw_progress_bar($uhtml_bar_percent, 400, 30); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main" valign="middle" colspan="2"><p>The sending of the newsletters is in progress. Please wait untill it is finnished.</p><p>If the process is interrupted somehow, there is no need to worry. Just try to send the newsletter again and the process will continue where it was interrupted. No customer will receive duplets of emails as which emails are sent is logged in the database.</p></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td align="center"><?php echo '<a href=' .tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nID) . '>' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<br>
</body>
</html>
<?php exit; ?>
<?php
}else{ //All emails are sent!
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . (int)$nID . "'"); //Mark the newsletter as sent
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
}
}else{ //Do it the standard way for product notifications ---------------------------------------------------------------------------------------------------
//--- End of addition: Ultimate HTML Emails ---//
?>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main" valign="middle"><?php echo tep_image(DIR_WS_IMAGES . 'ani_send_email.gif', IMAGE_ANI_SEND_EMAIL); ?></td>
<td class="main" valign="middle"><b><?php echo TEXT_PLEASE_WAIT; ?></b></td>
</tr>
</table></td>
</tr>
<?php
tep_set_time_limit(0);
flush();
$module->send($nInfo->newsletters_id);
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td align=center><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
//--- Beginning of adittion: Ultimate HTML Emails ---//
}
//--- End of addition: Ultimate HTML Emails ---//
} else {
?>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NEWSLETTERS; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_MODULE; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_SENT; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
</tr>
<?php
$newsletters_query_raw = "select newsletters_id, title, length(content) as content_length, module, date_added, date_sent, status, locked from " . TABLE_NEWSLETTERS . " order by date_added desc";
$newsletters_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $newsletters_query_raw, $newsletters_query_numrows);
$newsletters_query = tep_db_query($newsletters_query_raw);
while ($newsletters = tep_db_fetch_array($newsletters_query)) {
if ((!isset($HTTP_GET_VARS['nID']) || (isset($HTTP_GET_VARS['nID']) && ($HTTP_GET_VARS['nID'] == $newsletters['newsletters_id']))) && !isset($nInfo) && (substr($action, 0, 3) != 'new')) {
$nInfo = new objectInfo($newsletters);
}
if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) {
echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '\'">' . "\n";
} else {
echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '\'">' . "\n";
}
?>
<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id'] . '&action=preview') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $newsletters['title']; ?></td>
<td class="dataTableContent" align="right"><?php echo $newsletters['module']; ?></td>
<td class="dataTableContent" align="center"><?php if ($newsletters['status'] == '1') { echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK); } else { echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS); } ?></td>
<td class="dataTableContent" align="center"><?php if ($newsletters['locked'] > 0) { echo tep_image(DIR_WS_ICONS . 'locked.gif', ICON_LOCKED); } else { echo tep_image(DIR_WS_ICONS . 'unlocked.gif', ICON_UNLOCKED); } ?></td>
<td class="dataTableContent" align="right"><?php if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
</tr>
<?php
}
$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
if ($dir = dir(DIR_WS_MODULES . 'newsletters/')) {
while ($file = $dir->read()) {
if (!is_dir(DIR_WS_MODULES . 'newsletters/' . $file)) {
if ( (substr($file, strrpos($file, '.')) == $file_extension) && ($file != 'affiliate_newsletter.php') ) {
$directory_array[] = $file;
}
}
}
sort($directory_array);
$dir->close();
}
for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
$modules_array[] = array('id' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')), 'text' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')));
}
echo tep_draw_form('new_newsletters', FILENAME_NEWSLETTERS . '', '', 'post');
?>
<tr>
<td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $newsletters_split->display_count($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_NEWSLETTERS); ?></td>
<td class="smallText" align="right"><?php echo $newsletters_split->display_links($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
</tr>
<tr>
<td align="right" colspan="2"><table border="0" cellspacing="0" cellpadding="2"><tr>
<td align="right" class="main"><?php
echo tep_draw_hidden_field('action', 'new');
echo TEXT_NEWSLETTER_MODULE;
?></td>
<td align="center" class="main"><?php echo tep_draw_pull_down_menu_mod('module', $modules_array); ?></td>
<td align="center"><?php echo tep_image_submit('button_new_newsletter.gif', IMAGE_NEW_NEWSLETTER); ?></td>
</tr></table></td></tr>
</table></td>
</tr></form>
</table></td>
<?php
$heading = array();
$contents = array();
switch ($action) {
case 'delete':
$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');
$contents = array('form' => tep_draw_form('newsletters', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=deleteconfirm'));
$contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
$contents[] = array('text' => '<br><b>' . $nInfo->title . '</b>');
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
default:
if (is_object($nInfo)) {
$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');
if ($nInfo->locked > 0) {
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=new') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=unlock') . '">' . tep_image_button('button_unlock.gif', IMAGE_UNLOCK) . '</a>');
} else {
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=lock') . '">' . tep_image_button('button_lock.gif', IMAGE_LOCK) . '</a>');
}
$contents[] = array('text' => '<br>' . TEXT_NEWSLETTER_DATE_ADDED . ' ' . tep_date_short($nInfo->date_added));
if ($nInfo->status == '1') $contents[] = array('text' => TEXT_NEWSLETTER_DATE_SENT . ' ' . tep_date_short($nInfo->date_sent));
}
break;
}
if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo ' <td width="25%" valign="top">' . "\n";
$box = new box;
echo $box->infoBox($heading, $contents);
echo ' </td>' . "\n";
}
?>
</tr>
</table></td>
</tr>
<?php
}
?>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
Dopo che ho composto la newsletter la invio, ma cosa succede, il refresh della pagina và all'infinito, e non mi dà il messaggio "inviato"
ma la cosa strana e che compare l'avanzamento dell'invio dell'email con la scritta 3 di 1 mail are sent quando io per prova ho selezionato solo un rivenditore.
Il provider del dominio mi blocca l'ip per spamming
e mi risponde:
Il suo client di posta apre troppe connessioni. Il numero massimo di connessioni ammissibili è 2. la sua connessione ne ha aperte più di 400
87.3.144.189 # lfd: (CT) IP 87.3.144.189 found to have 429 connections - Wed Jan 28 18:35:16 2009
Chiedevo è un problema di configurazione oppure ciò è da imputare a qualcos'altro?
Grazie per la risposta
allego il file
<?php
/*
$Id: newsletters.php,v 1.17 2003/06/29 22:50:52 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
//newsletter products
$prod_for_row = 2;
//newsletter products
//currenices class required for price display in newsletter
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
//end newsletter products
$customers_group_array[] = array(
'id' => '0',
'text' => TEXT_ALL_GROUPS
);
$customers_group_array[] = array(
'id' => '-1',
'text' => TEXT_GUEST
);
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_name");
while ($customers_group = tep_db_fetch_array($customers_group_query)) {
$customers_group_array[] = array(
'id' => $customers_group['customers_group_id'],
'text' => $customers_group['customers_group_name']
);
}
if ($dir = dir(DIR_FS_TEMPLATES)) {
while ($file = $dir->read()) {
if (!is_dir(DIR_FS_TEMPLATES . $file)) {
if (substr($file, strrpos($file, '.')) == '.php') {
$template_array[] = array('id' => $file,
'text' => $file);
}
}
}
if (tep_not_null($template_array)) {
sort($template_array);
}
$dir->close();
}
if (isset($_POST['module']) && ($_POST['module'] == 'newsletter_products')){
if (!tep_not_null($template_array)) {
$messageStack->add_session(NO_TEMPLATE_ERROR, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] : ''));
}
}
if (isset($_POST['action']) && tep_not_null($_POST['action'])) {
$action = $_POST['action'];
} elseif(isset($_GET['action']) && tep_not_null($_GET['action'])) {
$action = $_GET['action'];
}
if (tep_not_null($action)) {
switch ($action) {
case 'lock':
case 'unlock':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$status = (($action == 'lock') ? '1' : '0');
tep_db_query("update " . TABLE_NEWSLETTERS . " set locked = '" . $status . "' where newsletters_id = '" . (int)$newsletter_id . "'");
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
break;
case 'insert':
case 'update':
if (isset($HTTP_POST_VARS['newsletter_id'])) $newsletter_id = tep_db_prepare_input($HTTP_POST_VARS['newsletter_id']);
$newsletter_module = tep_db_prepare_input($HTTP_POST_VARS['module']);
$title = tep_db_prepare_input($HTTP_POST_VARS['title']);
$content = tep_db_prepare_input($HTTP_POST_VARS['content']);
$header = tep_db_prepare_input($HTTP_POST_VARS['header']);
$footer = tep_db_prepare_input($HTTP_POST_VARS['footer']);
$customer_group_id = tep_db_prepare_input($HTTP_POST_VARS['customer_group_id']);
//newsletter plus
$products = $HTTP_POST_VARS['chosen'];
//end newsletter plus
$newsletter_error = false;
if (empty($title)) {
$messageStack->add(ERROR_NEWSLETTER_TITLE, 'error');
$newsletter_error = true;
}
if (empty($module)) {
$messageStack->add(ERROR_NEWSLETTER_MODULE, 'error');
$newsletter_error = true;
}
if ($newsletter_error == false) {
//newsletter products
$template = $_POST['template_id'];
$sql_data_array = array(
'title' => $title,
'content' => $content,
'module' => $newsletter_module,
'header' => $header,
'footer' => $footer,
'template' => $template,
'customers_group_id' => $customer_group_id
);
//end newsletter products
if ($action == 'insert') {
$sql_data_array['date_added'] = 'now()';
$sql_data_array['status'] = '0';
$sql_data_array['locked'] = '0';
tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array);
$newsletter_id = tep_db_insert_id();
//newsletter products
if(!empty($products)){
for($i=0, $n=sizeof($products); $i<$n; $i++){
tep_db_query("insert into " . TABLE_NEWSLETTERS_TO_PRODUCTS . " (newsletters_id, products_id) values (" . $newsletter_id . ", " . $products[$i] . ")");
}
}
//end newsletter products
} elseif ($action == 'update') {
tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array, 'update', "newsletters_id = '" . (int)$newsletter_id . "'");
//newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$newsletter_id . "'");
if(!empty($products) && $newsletter_module == 'newsletter_products'){
for($i=0, $n=sizeof($products); $i<$n; $i++){
tep_db_query("insert into " . TABLE_NEWSLETTERS_TO_PRODUCTS . " (newsletters_id, products_id) values (" . $newsletter_id . ", " . $products[$i] . ")");
}
}
//end newsletter products
}
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'nID=' . $newsletter_id));
} else {
$action = 'new';
}
break;
case 'deleteconfirm':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$newsletter_id . "'");
//end newsletter products
tep_db_query("delete from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page']));
break;
case 'delete':
case 'new': if (!isset($HTTP_GET_VARS['nID'])) break;
case 'send':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['locked'] < 1) {
switch ($action) {
case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;
case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;
case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
}
$messageStack->add_session($error, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
}
break;
case 'confirm_send':
$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['locked'] < 1) {
switch ($action) {
case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;
case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;
case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
}
$messageStack->add_session($error, 'error');
tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
} else {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
$newsletter_query = tep_db_query("select newsletters_id, title, content, customers_group_id, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter products
//--- Beginning of addition: Ultimate HTML Emails ---//
if (EMAIL_USE_HTML == 'true') {
$HTMLNewsletterContents = $newsletter['content'];
require(DIR_FS_CATALOG_MODULES . 'UHtmlEmails/'. ULTIMATE_HTML_EMAIL_LAYOUT .'/newsletters.php');
$newsletter['content'] = $html_email;
if(ULTIMATE_HTML_EMAIL_DEVELOPMENT_MODE === 'true'){
//Save the contents of the generated html email to the harddrive in .htm file. This can be practical when developing a new layout.
$TheFileName = DIR_FS_CATALOG . 'Last_mail_from_newsletters.php.htm';
$TheFileHandle = fopen($TheFileName, 'w') or die("can't open error log file");
fwrite($TheFileHandle, $newsletter['content']);
fclose($TheFileHandle);
}
}
//--- End of addition: Ultimate HTML Emails ---//
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//newsletter products
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
} elseif ($nInfo->module == 'newsletter') {
$module = new $module_name($nInfo->title, $nInfo->content);
} else{
$module = new $module_name($nInfo->title, $nInfo->content);
}
//end newsletter products
$uhtml_received_count_query = tep_db_query("select count(*) as count from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
$uhtml_received_count_query_array = tep_db_fetch_array($uhtml_received_count_query);
$uhtml_received_count = $uhtml_received_count_query_array['count'];
$uhtml_want_count = $module->mail_count();
$uhtml_bar_percent = round($uhtml_received_count/$uhtml_want_count*100,0);
//--- Beginning of adittion: Ultimate HTML Emails ---//
if(($module_name == 'newsletter') || ($module_name == 'newsletter_products')){
//Do it the UHTML way! ---------------------------------------------------------------------------------------------------
//Create the function to draw the progressbar based on "how many customers have received it"/"How many customers wan't newsletters"
if($uhtml_received_count != $uhtml_want_count ){
//Send a pack of emails
tep_set_time_limit(0);
flush();
$module->send($nInfo->newsletters_id);
$refresh = true;
} else {
$refresh = false;
}
}
}
break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<?php if ($refresh) echo '<meta http-equiv="refresh" content="0; url=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '"/>'; ?>
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<?php if (KTML_WEB_EDITOR == 'true') include(DIR_WS_INCLUDES . 'ktml/ktml.js.php'); ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>
</table></td>
</tr>
<?php
if ($action == 'new') {
$form_action = 'insert';
$parameters = array('title' => '',
'header' => '',
'footer' => '',
'content' => '',
'module' => '',
'products' => array(),
'template' => '',
'customers_group_id' => '');
//end newsletter products
$nInfo = new objectInfo($parameters);
if (isset($HTTP_GET_VARS['nID'])) {
$form_action = 'update';
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter products
$newsletter_query = tep_db_query("select title, customers_group_id, content, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter products
$nInfo->objectInfo($newsletter);
} elseif ($HTTP_POST_VARS) {
$nInfo->objectInfo($HTTP_POST_VARS);
}
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<?php
//newsletter products
echo tep_draw_form('newsletter', FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'action=' . $form_action, 'post', ' enctype="multipart/form-data" onSubmit="return selectAll(\'newsletter\', \'chosen[]\')"'); if ($form_action == 'update') echo tep_draw_hidden_field('newsletter_id', $nID);
//end newsletter products
?>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td align=left class="main"><nobr><?php echo TEXT_NEWSLETTER_MODULE; ?></nobr></td>
<td class="main"><b><?php echo strtoupper($nInfo->module) . tep_draw_hidden_field('module', $nInfo->module); ?></b></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td align=left width="80px" class="main"><nobr><?php echo TEXT_NEWSLETTER_TITLE; ?></nobr></td>
<td class="main"><?php echo tep_draw_input_field('title', $nInfo->title, '', true); ?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<?php if ($nInfo->module != 'newsletter_products') { ?>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_CONTENT; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'content';
$field_text = $nInfo->content;
$fieldID = 'text_newsletter_content';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->content);
}
?></td>
</tr>
<?php
} else {
$products = new newsletter_products('','', '', '', '', '', '');
?>
<tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
<tr><td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><nobr><?php echo TEXT_NEWSLETTER_SELECT_GROUP; ?> </nobr></td>
<td class="main" valign="top"><?php echo tep_draw_pull_down_menu_mod('customer_group_id', $customers_group_array, $nInfo->customers_group_id);?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr><td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><nobr><?php echo TEXT_NEWSLETTER_SELECT_TEMPLATE; ?> </nobr></td>
<td class="main" valign="top"><?php echo tep_draw_pull_down_menu_mod('template_id', $template_array, $nInfo->template);?></td>
</tr></table></td></tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_PROD_HEADER; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'header';
$field_text = $nInfo->header;
$fieldID = 'html_text_newsletter_header';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->header);
}
?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main"><?php echo $products->choose_products(); ?></td>
</tr>
<tr>
<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
<tr>
<td colspan="2" class="main" valign="top"><?php echo TEXT_NEWSLETTER_PROD_FOOTER; ?></td>
</tr>
<tr>
<td colspan="2" class="main">
<?php
if (KTML_WEB_EDITOR == 'true') {
$field_name = 'footer';
$field_text = $nInfo->footer;
$fieldID = 'html_text_newsletter_footer';
include(DIR_WS_INCLUDES . 'ktml/ktml_draw_editor.php');
} else {
echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->footer);
}
?></td>
</tr>
<tr>
<td colspan="2"><?php tep_draw_separator('pixel_trans.gif' , '1', '10'); ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
?>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main" align=center><?php echo (($form_action == 'insert') ? tep_image_submit('button_save.gif', IMAGE_SAVE) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></td>
</form></tr>
<?php
} elseif ($action == 'preview') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter plus
$newsletter_query = tep_db_query("select title, customers_group_id, content, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter['products'] = $news_products;
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
?>
<tr>
<td align=center><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
if($nInfo->module == 'newsletter_products'){
$module = new newsletter_products($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer);
?>
<tr>
<td class=main><b><?php
echo TEXT_TITLE . $nInfo->title;
?></b></td>
</tr>
<tr>
<td class=main><b><?php
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" . $nInfo->customers_group_id . "' order by customers_group_name");
$customers_group = tep_db_fetch_array($customers_group_query);
if ($nInfo->customers_group_id == '0') {
$customers_group_id = $module->get_retailprice_group_id();
echo TEXT_SEND_TO_GROUPS . TEXT_ALL_GROUPS;
} elseif ($nInfo->customers_group_id == '-1') {
$customers_group_id = $module->get_retailprice_group_id();
echo TEXT_SEND_TO_GROUPS . TEXT_GUEST;
} elseif ($nInfo->customers_group_id > 0) {
$customers_group_id = $nInfo->customers_group_id;
echo TEXT_SEND_TO_GROUPS . $customers_group['customers_group_name'];
}
?></b></td>
</tr>
<tr>
<td><?php
$html_content = $module->html_content($prod_for_row);
echo $html_content[$customers_group_id];
?></td>
</tr>
<?php
}else{
?>
<tr>
<td><tt><?php echo nl2br($nInfo->content); ?></tt></td>
</tr>
<?php
}
//end newsletter plus
?>
<tr>
<td align="center"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
} elseif ($action == 'send') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
//newsletter plus
$newsletter_query = tep_db_query("select title, content, customers_group_id, header, footer, module, template from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
//end newsletter plus
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//newsletter plus
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
tep_db_query("delete from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
} elseif($nInfo->module == 'newsletter'){
$module = new $module_name($nInfo->title, $nInfo->content);
tep_db_query("delete from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
} else {
$module = new $module_name($nInfo->title, $nInfo->content);
}
//end newsletter plus
?>
<tr>
<td align=left><?php if ($module->show_choose_audience) { echo $module->choose_audience(); } else { echo $module->confirm(); } ?></td>
</tr>
<?php
} elseif ($action == 'confirm') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);
$newsletter_query = tep_db_query("select title, content, customers_group_id, header, footer, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
$newsletter_products_query = tep_db_query("select products_id from " . TABLE_NEWSLETTERS_TO_PRODUCTS . " where newsletters_id = '" . (int)$nID . "'");
while($newsletter_products = tep_db_fetch_array($newsletter_products_query)){
$news_products[] = $newsletter_products['products_id'];
}
$newsletter = tep_db_fetch_array($newsletter_query);
$newsletter['products'] = $news_products;
$nInfo = new objectInfo($newsletter);
include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
if($nInfo->module == 'newsletter_products'){
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->products, $nInfo->template, $nInfo->header, $nInfo->footer, $nInfo->customers_group_id);
}else{
$module = new $module_name($nInfo->title, $nInfo->content);
}?>
<tr>
<td><?php echo $module->confirm(); ?></td>
</tr>
<?php
} elseif ($action == 'confirm_send') {
//--- Beginning of adittion: Ultimate HTML Emails ---//
if(($module_name == 'newsletter') || ($module_name == 'newsletter_products')){ //Do it the UHTML way! ---------------------------------------------------------------------------------------------------
//Create the function to draw the progressbar based on "how many customers have received it"/"How many customers wan't newsletters"
if($uhtml_received_count != $uhtml_want_count ){
?>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main" valign="middle" colspan="2"><?php draw_progress_bar($uhtml_bar_percent, 400, 30); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main" valign="middle" colspan="2"><p>The sending of the newsletters is in progress. Please wait untill it is finnished.</p><p>If the process is interrupted somehow, there is no need to worry. Just try to send the newsletter again and the process will continue where it was interrupted. No customer will receive duplets of emails as which emails are sent is logged in the database.</p></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td align="center"><?php echo '<a href=' .tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nID) . '>' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<br>
</body>
</html>
<?php exit; ?>
<?php
}else{ //All emails are sent!
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . (int)$nID . "'"); //Mark the newsletter as sent
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
}
}else{ //Do it the standard way for product notifications ---------------------------------------------------------------------------------------------------
//--- End of addition: Ultimate HTML Emails ---//
?>
<tr>
<td><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td class="main" valign="middle"><?php echo tep_image(DIR_WS_IMAGES . 'ani_send_email.gif', IMAGE_ANI_SEND_EMAIL); ?></td>
<td class="main" valign="middle"><b><?php echo TEXT_PLEASE_WAIT; ?></b></td>
</tr>
</table></td>
</tr>
<?php
tep_set_time_limit(0);
flush();
$module->send($nInfo->newsletters_id);
?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
<td align=center><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
</tr>
<?php
//--- Beginning of adittion: Ultimate HTML Emails ---//
}
//--- End of addition: Ultimate HTML Emails ---//
} else {
?>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NEWSLETTERS; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_MODULE; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_SENT; ?></td>
<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
</tr>
<?php
$newsletters_query_raw = "select newsletters_id, title, length(content) as content_length, module, date_added, date_sent, status, locked from " . TABLE_NEWSLETTERS . " order by date_added desc";
$newsletters_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $newsletters_query_raw, $newsletters_query_numrows);
$newsletters_query = tep_db_query($newsletters_query_raw);
while ($newsletters = tep_db_fetch_array($newsletters_query)) {
if ((!isset($HTTP_GET_VARS['nID']) || (isset($HTTP_GET_VARS['nID']) && ($HTTP_GET_VARS['nID'] == $newsletters['newsletters_id']))) && !isset($nInfo) && (substr($action, 0, 3) != 'new')) {
$nInfo = new objectInfo($newsletters);
}
if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) {
echo ' <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '\'">' . "\n";
} else {
echo ' <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '\'">' . "\n";
}
?>
<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id'] . '&action=preview') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $newsletters['title']; ?></td>
<td class="dataTableContent" align="right"><?php echo $newsletters['module']; ?></td>
<td class="dataTableContent" align="center"><?php if ($newsletters['status'] == '1') { echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK); } else { echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS); } ?></td>
<td class="dataTableContent" align="center"><?php if ($newsletters['locked'] > 0) { echo tep_image(DIR_WS_ICONS . 'locked.gif', ICON_LOCKED); } else { echo tep_image(DIR_WS_ICONS . 'unlocked.gif', ICON_UNLOCKED); } ?></td>
<td class="dataTableContent" align="right"><?php if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
</tr>
<?php
}
$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
if ($dir = dir(DIR_WS_MODULES . 'newsletters/')) {
while ($file = $dir->read()) {
if (!is_dir(DIR_WS_MODULES . 'newsletters/' . $file)) {
if ( (substr($file, strrpos($file, '.')) == $file_extension) && ($file != 'affiliate_newsletter.php') ) {
$directory_array[] = $file;
}
}
}
sort($directory_array);
$dir->close();
}
for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
$modules_array[] = array('id' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')), 'text' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')));
}
echo tep_draw_form('new_newsletters', FILENAME_NEWSLETTERS . '', '', 'post');
?>
<tr>
<td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="smallText" valign="top"><?php echo $newsletters_split->display_count($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_NEWSLETTERS); ?></td>
<td class="smallText" align="right"><?php echo $newsletters_split->display_links($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
</tr>
<tr>
<td align="right" colspan="2"><table border="0" cellspacing="0" cellpadding="2"><tr>
<td align="right" class="main"><?php
echo tep_draw_hidden_field('action', 'new');
echo TEXT_NEWSLETTER_MODULE;
?></td>
<td align="center" class="main"><?php echo tep_draw_pull_down_menu_mod('module', $modules_array); ?></td>
<td align="center"><?php echo tep_image_submit('button_new_newsletter.gif', IMAGE_NEW_NEWSLETTER); ?></td>
</tr></table></td></tr>
</table></td>
</tr></form>
</table></td>
<?php
$heading = array();
$contents = array();
switch ($action) {
case 'delete':
$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');
$contents = array('form' => tep_draw_form('newsletters', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=deleteconfirm'));
$contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
$contents[] = array('text' => '<br><b>' . $nInfo->title . '</b>');
$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;
default:
if (is_object($nInfo)) {
$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');
if ($nInfo->locked > 0) {
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=new') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=unlock') . '">' . tep_image_button('button_unlock.gif', IMAGE_UNLOCK) . '</a>');
} else {
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=lock') . '">' . tep_image_button('button_lock.gif', IMAGE_LOCK) . '</a>');
}
$contents[] = array('text' => '<br>' . TEXT_NEWSLETTER_DATE_ADDED . ' ' . tep_date_short($nInfo->date_added));
if ($nInfo->status == '1') $contents[] = array('text' => TEXT_NEWSLETTER_DATE_SENT . ' ' . tep_date_short($nInfo->date_sent));
}
break;
}
if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo ' <td width="25%" valign="top">' . "\n";
$box = new box;
echo $box->infoBox($heading, $contents);
echo ' </td>' . "\n";
}
?>
</tr>
</table></td>
</tr>
<?php
}
?>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>