[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * @package admin 4 * @copyright Copyright 2003-2006 Zen Cart Development Team 5 * @copyright Portions Copyright 2003 osCommerce 6 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 7 * @version $Id: mail.php 4704 2006-10-08 04:43:50Z drbyte $ 8 */ 9 10 require ('includes/application_top.php'); 11 12 //DEBUG: // these defines will become configuration switches in ADMIN in a future version. 13 //DEBUG: // right now, attachments aren't working right unless only sending HTML messages with NO text-only version supplied. 14 if (!defined('EMAIL_ATTACHMENTS_ENABLED')) define(EMAIL_ATTACHMENTS_ENABLED,false); 15 if (!defined('EMAIL_ATTACHMENT_UPLOADS_ENABLED')) define(EMAIL_ATTACHMENT_UPLOADS_ENABLED,false); 16 17 18 $action = (isset($_GET['action']) ? $_GET['action'] : ''); 19 20 if ($action == 'set_editor') { 21 // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly. 22 $action=''; 23 zen_redirect(zen_href_link(FILENAME_MAIL)); 24 } 25 26 if ( ($action == 'send_email_to_user') && isset($_POST['customers_email_address']) && !isset($_POST['back_x']) ) { 27 $audience_select = get_audience_sql_query(zen_db_input($_POST['customers_email_address']), 'email'); 28 $mail = $db->Execute($audience_select['query_string']); 29 $mail_sent_to = $audience_select['query_name']; 30 if ($_POST['email_to']) { 31 $mail_sent_to = zen_db_prepare_input($_POST['email_to']); 32 } 33 34 // error message if no email address 35 if (empty($mail_sent_to)) { 36 $messageStack->add_session(ERROR_NO_CUSTOMER_SELECTED, 'error'); 37 $_GET['action']=''; 38 zen_redirect(zen_href_link(FILENAME_MAIL)); 39 } 40 41 $from = zen_db_prepare_input($_POST['from']); 42 $subject = zen_db_prepare_input($_POST['subject']); 43 $message = zen_db_prepare_input($_POST['message']); 44 $html_msg['EMAIL_MESSAGE_HTML'] = zen_db_prepare_input($_POST['message_html']); 45 $attachment_file = $_POST['attachment_file']; 46 $attachment_filetype = $_POST['attachment_filetype']; 47 48 // demo active test 49 if (zen_admin_demo()) { 50 $_GET['action']= ''; 51 $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); 52 zen_redirect(zen_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to))); 53 } 54 55 //send message using the zen email function 56 //echo'EOF-attachments_list='.$attachment_file.'->'.$attachment_filetype; 57 $recip_count=0; 58 while (!$mail->EOF) { 59 $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname']; 60 $html_msg['EMAIL_LAST_NAME'] = $mail->fields['customers_lastname']; 61 zen_mail($mail->fields['customers_firstname'] . ' ' . $mail->fields['customers_lastname'], $mail->fields['customers_email_address'], $subject, $message, STORE_NAME, $from, $html_msg, 'direct_email', array('file' => $attachment_file, 'file_type'=>$attachment_filetype) ); 62 $recip_count++; 63 $mail->MoveNext(); 64 } 65 66 $messageStack->add_session(sprintf(NOTICE_EMAIL_SENT_TO, $mail_sent_to . ' (' . $recip_count . ')'), 'success'); 67 zen_redirect(zen_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to) . '&recip_count='. $recip_count )); 68 } 69 70 if ( EMAIL_ATTACHMENTS_ENABLED && $action == 'preview') { 71 // PROCESS UPLOAD ATTACHMENTS 72 if (isset($_FILES['upload_file']) && zen_not_null($_FILES['upload_file']) && ($_POST['upload_file'] != 'none')) { 73 if ($attachments_obj = new upload('upload_file')) { 74 $attachments_obj->set_destination(DIR_WS_ADMIN_ATTACHMENTS . $_POST['attach_dir']); 75 if ($attachments_obj->parse() && $attachments_obj->save()) { 76 $attachment_file = $_POST['attach_dir'] . $attachments_obj->filename; 77 $attachment_filetype= $_FILES['upload_file']['type']; 78 } 79 } 80 } 81 82 //DEBUG: 83 //$messageStack->add('EOF-attachments_list='.$attachment_file.'->'.$attachment_filetype, 'caution'); 84 } //end attachments upload 85 86 // error detection 87 if ($action == 'preview') { 88 if (!isset($_POST['customers_email_address']) ) { 89 $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error'); 90 } 91 92 if ( !$_POST['subject'] ) { 93 $messageStack->add(ERROR_NO_SUBJECT, 'error'); 94 } 95 96 if ( !$_POST['message'] && !$_POST['message_html'] ) { 97 $messageStack->add(ENTRY_NOTHING_TO_SEND, 'error'); 98 } 99 } 100 101 ?> 102 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 103 <html <?php echo HTML_PARAMS; ?>> 104 <head> 105 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 106 <title><?php echo TITLE; ?></title> 107 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 108 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS"> 109 <script language="javascript" src="includes/menu.js"></script> 110 <script type="text/javascript"> 111 <!-- 112 function init() 113 { 114 cssjsmenu('navbar'); 115 if (document.getElementById) 116 { 117 var kill = document.getElementById('hoverJS'); 118 kill.disabled = true; 119 } 120 if (typeof _editor_url == "string") HTMLArea.replace('message_html'); 121 } 122 // --> 123 </script> 124 <?php if ($editor_handler != '') include ($editor_handler); ?> 125 <script language="javascript" type="text/javascript"><!-- 126 var form = ""; 127 var submitted = false; 128 var error = false; 129 var error_message = ""; 130 131 function check_select(field_name, field_default, message) { 132 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) { 133 var field_value = form.elements[field_name].value; 134 135 if (field_value == field_default) { 136 error_message = error_message + "* " + message + "\n"; 137 error = true; 138 } 139 } 140 } 141 function check_message(msg) { 142 if (form.elements['message'] && form.elements['message_html']) { 143 var field_value1 = form.elements['message'].value; 144 var field_value2 = form.elements['message_html'].value; 145 146 if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) { 147 error_message = error_message + "* " + msg + "\n"; 148 error = true; 149 } 150 } 151 } 152 function check_input(field_name, field_size, message) { 153 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) { 154 var field_value = form.elements[field_name].value; 155 156 if (field_value == '' || field_value.length < field_size) { 157 error_message = error_message + "* " + message + "\n"; 158 error = true; 159 } 160 } 161 } 162 function check_attachments(message) { 163 if (form.elements['upload_file'] && (form.elements['upload_file'].type != "hidden") && form.elements['attachment_file'] && (form.elements['attachment_file'].type != "hidden")) { 164 var field_value_upload = form.elements['upload_file'].value; 165 var field_value_file = form.elements['attachment_file'].value; 166 167 if (field_value_upload != '' && field_value_file != '') { 168 error_message = error_message + "* " + message + "\n"; 169 error = true; 170 } 171 } 172 } 173 function check_form(form_name) { 174 if (submitted == true) { 175 alert("<?php echo JS_ERROR_SUBMITTED; ?>"); 176 return false; 177 } 178 error = false; 179 form = form_name; 180 error_message = "<?php echo JS_ERROR; ?>"; 181 182 check_select("customers_email_address", "", "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>"); 183 check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>"); 184 // check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>"); 185 check_attachments("<?php echo ERROR_ATTACHMENTS; ?>"); 186 187 if (error == true) { 188 alert(error_message); 189 return false; 190 } else { 191 submitted = true; 192 return true; 193 } 194 } 195 //--></script> 196 </head> 197 <body onLoad="init()"> 198 <!-- header //--> 199 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 200 <!-- header_eof //--> 201 202 <!-- body //--> 203 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 204 <tr> 205 <!-- body_text //--> 206 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 207 <tr> 208 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 209 <tr> 210 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 211 <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 212 <td class="main"> 213 <?php 214 // toggle switch for editor 215 echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_MAIL, '', 'get') . ' ' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') . 216 zen_hide_session_id() . 217 zen_draw_hidden_field('action', 'set_editor') . 218 '</form>'; 219 ?> 220 </td> 221 </tr> 222 </table></td> 223 </tr> 224 <tr> 225 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 226 <?php 227 if ( ($action == 'preview') && isset($_POST['customers_email_address']) ) { 228 $audience_select = get_audience_sql_query(zen_db_input($_POST['customers_email_address'])); 229 $mail_sent_to = $audience_select['query_name']; 230 ?> 231 <tr> 232 <td><table border="0" width="100%" cellpadding="0" cellspacing="2"> 233 <tr> 234 <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b> <?php echo $mail_sent_to; ?></td> 235 </tr> 236 <tr> 237 <td class="smallText"><b><?php echo TEXT_FROM; ?></b> <?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td> 238 </tr> 239 <tr> 240 <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b> <?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td> 241 </tr> 242 <tr> 243 <td class="smallText"><b><hr /><?php echo strip_tags(TEXT_MESSAGE_HTML); ?></b></td> 244 </tr> 245 <tr> 246 <td width="500"> 247 <?php if (EMAIL_USE_HTML != 'true') echo TEXT_WARNING_HTML_DISABLED.'<br />'; ?> 248 <?php echo stripslashes($_POST['message_html']); ?><hr /></td> 249 </tr> 250 <tr> 251 <td class="smallText"><b><?php echo strip_tags(TEXT_MESSAGE); ?></b><br /></td> 252 </tr> 253 <tr> 254 <td> 255 <?php 256 $message_preview = ((is_null($_POST['message']) || $_POST['message']=='') ? $_POST['message_html'] : $_POST['message'] ); 257 $message_preview = str_replace('<br[[:space:]]*/?[[:space:]]*>', "@CRLF", $message_preview); 258 $message_preview = str_replace('</p>', '</p>@CRLF', $message_preview); 259 echo '<tt>' . str_replace('@CRLF', '<br />', htmlspecialchars(stripslashes(strip_tags($message_preview))) ) . '</tt>'; 260 ?> 261 <hr /> 262 </td> 263 </tr> 264 <?php if (EMAIL_ATTACHMENTS_ENABLED) { ?> 265 <tr> 266 <td class="smallText"><b><?php echo TEXT_ATTACHMENTS_LIST; ?></b><?php echo ' ' . ((EMAIL_ATTACHMENT_UPLOADS_ENABLED && zen_not_null($upload_file_name)) ? $upload_file_name : $attachment_file) ; ?></td> 267 </tr> 268 <?php } ?> 269 <tr> 270 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 271 </tr> 272 <tr><?php echo zen_draw_form('mail', FILENAME_MAIL, 'action=send_email_to_user'); ?> 273 <td> 274 <?php 275 /* Re-Post all POST'ed variables */ 276 reset($_POST); 277 while (list($key, $value) = each($_POST)) { 278 if (!is_array($_POST[$key])) { 279 // echo zen_draw_hidden_field($key, htmlspecialchars(stripslashes($value))); 280 echo zen_draw_hidden_field($key, stripslashes($value)); 281 } 282 } 283 echo zen_draw_hidden_field('upload_file', stripslashes($upload_file_name)); 284 echo zen_draw_hidden_field('attachment_file', $attachment_file); 285 echo zen_draw_hidden_field('attachment_filetype', $attachment_filetype); 286 ?> 287 <table border="0" width="100%" cellpadding="0" cellspacing="2"> 288 <tr> 289 <td><?php echo zen_image_submit('button_back.gif', IMAGE_BACK, 'name="back"'); ?></td> 290 <td align="right"><?php echo '<a href="' . zen_href_link(FILENAME_MAIL) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . zen_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td> 291 </tr> 292 </table></td> 293 </tr> 294 </table></td> 295 </form></tr> 296 <?php 297 } else { 298 ?> 299 <tr><?php echo zen_draw_form('mail', FILENAME_MAIL,'action=preview','post', 'onsubmit="return check_form(mail);" enctype="multipart/form-data"'); ?> 300 <td><table border="0" cellpadding="0" cellspacing="2"> 301 <tr> 302 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 303 </tr> 304 <?php 305 $customers = get_audiences_list('email'); 306 ?> 307 <tr> 308 <td class="main"><?php echo TEXT_CUSTOMER; ?></td> 309 <td><?php echo zen_draw_pull_down_menu('customers_email_address', $customers, (isset($_GET['customer']) ? $_GET['customer'] : '')); //, 'multiple' ?></td> 310 </tr> 311 <tr> 312 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 313 </tr> 314 <tr> 315 <td class="main"><?php echo TEXT_FROM; ?></td> 316 <td><?php echo zen_draw_input_field('from', EMAIL_FROM, 'size="50"'); ?></td> 317 </tr> 318 <tr> 319 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 320 </tr> 321 <tr> 322 <td class="main"><?php echo TEXT_SUBJECT; ?></td> 323 <td><?php echo zen_draw_input_field('subject', $_POST['subject'], 'size="50"'); ?></td> 324 </tr> 325 <tr> 326 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 327 </tr> 328 <tr> 329 <td valign="top" class="main"><?php echo TEXT_MESSAGE_HTML; //HTML version?></td> 330 <td class="main" width="750"> 331 <?php if (EMAIL_USE_HTML != 'true') echo TEXT_WARNING_HTML_DISABLED; ?> 332 <?php if (EMAIL_USE_HTML == 'true') { 333 if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") { 334 $oFCKeditor = new FCKeditor('message_html') ; 335 $oFCKeditor->Value = stripslashes($_POST['message_html']) ; 336 $oFCKeditor->Width = '97%' ; 337 $oFCKeditor->Height = '350' ; 338 // $oFCKeditor->Create() ; 339 $output = $oFCKeditor->CreateHtml() ; echo $output; 340 } else { // using HTMLAREA or just raw "source" 341 echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', stripslashes($_POST['message_html']), 'id="message_html"'); 342 } 343 } ?> 344 </td> 345 </tr> 346 <tr> 347 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 348 </tr> 349 <tr> 350 <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td> 351 <td><?php echo zen_draw_textarea_field('message', 'soft', '100%', '15', $_POST['message']); ?></td> 352 </tr> 353 354 <?php if (EMAIL_ATTACHMENTS_ENABLED) { ?> 355 <tr> 356 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 357 </tr> 358 <?php if (EMAIL_ATTACHMENT_UPLOADS_ENABLED) { ?> 359 <?php 360 $dir = @dir(DIR_WS_ADMIN_ATTACHMENTS); 361 $dir_info[] = array('id' => '', 'text' => "admin-attachments"); 362 while ($file = $dir->read()) { 363 if (is_dir(DIR_WS_ADMIN_ATTACHMENTS . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { 364 $dir_info[] = array('id' => $file . '/', 'text' => $file); 365 } 366 } 367 ?> 368 <tr> 369 <td class="main" valign="top"><?php echo TEXT_SELECT_ATTACHMENT_TO_UPLOAD; ?></td> 370 <td class="main"><?php echo zen_draw_file_field('upload_file') . '<br />' . stripslashes($_POST['upload_file']) . zen_draw_hidden_field('prev_upload_file', stripslashes( $_POST['upload_file']) ); ?><br /> 371 <?php echo TEXT_ATTACHMENTS_DIR; ?> <?php echo zen_draw_pull_down_menu('attach_dir', $dir_info); ?></td> 372 </tr> 373 <tr> 374 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 375 </tr> 376 <?php } // end upload dialog ?> 377 <?php 378 $dir = @dir(DIR_WS_ADMIN_ATTACHMENTS); 379 $file_list[] = array('id' => '', 'text' => "(none)"); 380 while ($file = $dir->read()) { 381 if (is_file(DIR_WS_ADMIN_ATTACHMENTS . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { 382 $file_list[] = array('id' => $file , 'text' => $file); 383 } 384 } 385 ?> 386 <tr> 387 <td class="main" valign="top"><?php echo TEXT_SELECT_ATTACHMENT; ?></td> 388 <td class="main"><?php echo zen_draw_pull_down_menu('attachment_file', $file_list, $_POST['attachment_file']); ?></td> 389 </tr> 390 <?php } // end attachments fields ?> 391 <tr> 392 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 393 </tr> 394 <?php 395 if (isset($_GET['origin'])) { 396 $origin = $_GET['origin']; 397 } else { 398 $origin = FILENAME_DEFAULT; 399 } 400 if (isset($_GET['mode']) && $_GET['mode'] == 'SSL') { 401 $mode = 'SSL'; 402 } else { 403 $mode = 'NONSSL'; 404 } 405 ?> 406 <tr> 407 <td colspan="2" align="right"><?php echo zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' ' . 408 '<a href="' . zen_href_link($origin, 'cID=' . zen_db_prepare_input($_GET['cID']), $mode) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 409 </tr> 410 </table></td> 411 </form></tr> 412 <?php 413 } 414 ?> 415 <!-- body_text_eof //--> 416 </table></td> 417 </tr> 418 </table></td> 419 </tr> 420 </table> 421 <!-- body_eof //--> 422 423 <!-- footer //--> 424 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 425 <!-- footer_eof //--> 426 <br /> 427 </body> 428 </html> 429 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |