|
ZenCart_Documentation
1.5.0
http://www.collinsharper.com
|
00001 <?php 00010 require('includes/application_top.php'); 00011 00012 //DEBUG: // these defines will become configuration switches in ADMIN in a future version. 00013 //DEBUG: // right now, attachments aren't working right unless only sending HTML messages with NO text-only version supplied. 00014 if (!defined('EMAIL_ATTACHMENTS_ENABLED')) define('EMAIL_ATTACHMENTS_ENABLED',false); 00015 if (!defined('EMAIL_ATTACHMENT_UPLOADS_ENABLED')) define('EMAIL_ATTACHMENT_UPLOADS_ENABLED',false); 00016 00017 00018 $action = (isset($_GET['action']) ? $_GET['action'] : ''); 00019 00020 if ($action == 'set_editor') { 00021 // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly. 00022 $action=''; 00023 zen_redirect(zen_href_link(FILENAME_MAIL)); 00024 } 00025 00026 if ( ($action == 'send_email_to_user') && isset($_POST['customers_email_address']) && !isset($_POST['back_x']) ) { 00027 $audience_select = get_audience_sql_query(zen_db_input($_POST['customers_email_address']), 'email'); 00028 $mail = $db->Execute($audience_select['query_string']); 00029 $mail_sent_to = $audience_select['query_name']; 00030 if ($_POST['email_to']) { 00031 $mail_sent_to = zen_db_prepare_input($_POST['email_to']); 00032 } 00033 00034 // error message if no email address 00035 if (empty($mail_sent_to)) { 00036 $messageStack->add_session(ERROR_NO_CUSTOMER_SELECTED, 'error'); 00037 $_GET['action']=''; 00038 zen_redirect(zen_href_link(FILENAME_MAIL)); 00039 } 00040 00041 $from = zen_db_prepare_input($_POST['from']); 00042 $subject = zen_db_prepare_input($_POST['subject']); 00043 $message = zen_db_prepare_input($_POST['message']); 00044 $html_msg['EMAIL_MESSAGE_HTML'] = zen_db_prepare_input($_POST['message_html']); 00045 $attachment_file = $_POST['attachment_file']; 00046 $attachment_fname = basename($_POST['attachment_file']); 00047 $attachment_filetype = $_POST['attachment_filetype']; 00048 00049 // demo active test 00050 if (zen_admin_demo()) { 00051 $_GET['action']= ''; 00052 $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); 00053 zen_redirect(zen_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to))); 00054 } 00055 00056 //send message using the zen email function 00057 //echo'EOF-attachments_list='.$attachment_file.'->'.$attachment_filetype; 00058 $recip_count=0; 00059 while (!$mail->EOF) { 00060 $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname']; 00061 $html_msg['EMAIL_LAST_NAME'] = $mail->fields['customers_lastname']; 00062 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, 'name' => basename($attachment_file), 'mime_type'=>$attachment_filetype) ); 00063 $recip_count++; 00064 $mail->MoveNext(); 00065 } 00066 if ($recip_count > 0) { 00067 $messageStack->add_session(sprintf(NOTICE_EMAIL_SENT_TO, $mail_sent_to . ' (' . $recip_count . ')'), 'success'); 00068 } else { 00069 $messageStack->add_session(sprintf(NOTICE_EMAIL_FAILED_SEND, $mail_sent_to . ' (' . $recip_count . ')'), 'error'); 00070 } 00071 zen_redirect(zen_href_link(FILENAME_MAIL, 'mail_sent_to=' . urlencode($mail_sent_to) . '&recip_count='. $recip_count )); 00072 } 00073 00074 if ( EMAIL_ATTACHMENTS_ENABLED && $action == 'preview') { 00075 // PROCESS UPLOAD ATTACHMENTS 00076 if (isset($_FILES['upload_file']) && zen_not_null($_FILES['upload_file']) && ($_POST['upload_file'] != 'none')) { 00077 if ($attachments_obj = new upload('upload_file')) { 00078 $attachments_obj->set_destination(DIR_WS_ADMIN_ATTACHMENTS . $_POST['attach_dir']); 00079 if ($attachments_obj->parse() && $attachments_obj->save()) { 00080 $attachment_file = $_POST['attach_dir'] . $attachments_obj->filename; 00081 $attachment_fname = $attachments_obj->filename; 00082 $attachment_filetype= $_FILES['upload_file']['type']; 00083 } 00084 } 00085 } 00086 00087 //DEBUG: 00088 //$messageStack->add('EOF-attachments_list='.$attachment_file.'->'.$attachment_filetype, 'caution'); 00089 } //end attachments upload 00090 00091 // error detection 00092 if ($action == 'preview') { 00093 if (!isset($_POST['customers_email_address']) ) { 00094 $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error'); 00095 } 00096 00097 if ( !$_POST['subject'] ) { 00098 $messageStack->add(ERROR_NO_SUBJECT, 'error'); 00099 } 00100 00101 if ( !$_POST['message'] && !$_POST['message_html'] ) { 00102 $messageStack->add(ENTRY_NOTHING_TO_SEND, 'error'); 00103 } 00104 } 00105 00106 ?> 00107 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 00108 <html <?php echo HTML_PARAMS; ?>> 00109 <head> 00110 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 00111 <title><?php echo TITLE; ?></title> 00112 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 00113 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS"> 00114 <script language="javascript" src="includes/menu.js"></script> 00115 <script type="text/javascript"> 00116 <!-- 00117 function init() 00118 { 00119 cssjsmenu('navbar'); 00120 if (document.getElementById) 00121 { 00122 var kill = document.getElementById('hoverJS'); 00123 kill.disabled = true; 00124 } 00125 if (typeof _editor_url == "string") HTMLArea.replace('message_html'); 00126 } 00127 // --> 00128 </script> 00129 <?php if ($editor_handler != '') include ($editor_handler); ?> 00130 <script language="javascript" type="text/javascript"><!-- 00131 var form = ""; 00132 var submitted = false; 00133 var error = false; 00134 var error_message = ""; 00135 00136 function check_select(field_name, field_default, message) { 00137 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) { 00138 var field_value = form.elements[field_name].value; 00139 00140 if (field_value == field_default) { 00141 error_message = error_message + "* " + message + "\n"; 00142 error = true; 00143 } 00144 } 00145 } 00146 function check_message(msg) { 00147 if (form.elements['message'] && form.elements['message_html']) { 00148 var field_value1 = form.elements['message'].value; 00149 var field_value2 = form.elements['message_html'].value; 00150 00151 if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) { 00152 error_message = error_message + "* " + msg + "\n"; 00153 error = true; 00154 } 00155 } 00156 } 00157 function check_input(field_name, field_size, message) { 00158 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) { 00159 var field_value = form.elements[field_name].value; 00160 00161 if (field_value == '' || field_value.length < field_size) { 00162 error_message = error_message + "* " + message + "\n"; 00163 error = true; 00164 } 00165 } 00166 } 00167 function check_attachments(message) { 00168 if (form.elements['upload_file'] && (form.elements['upload_file'].type != "hidden") && form.elements['attachment_file'] && (form.elements['attachment_file'].type != "hidden")) { 00169 var field_value_upload = form.elements['upload_file'].value; 00170 var field_value_file = form.elements['attachment_file'].value; 00171 00172 if (field_value_upload != '' && field_value_file != '') { 00173 error_message = error_message + "* " + message + "\n"; 00174 error = true; 00175 } 00176 } 00177 } 00178 function check_form(form_name) { 00179 if (submitted == true) { 00180 alert("<?php echo JS_ERROR_SUBMITTED; ?>"); 00181 return false; 00182 } 00183 error = false; 00184 form = form_name; 00185 error_message = "<?php echo JS_ERROR; ?>"; 00186 00187 check_select("customers_email_address", "", "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>"); 00188 check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>"); 00189 // check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>"); 00190 check_attachments("<?php echo ERROR_ATTACHMENTS; ?>"); 00191 00192 if (error == true) { 00193 alert(error_message); 00194 return false; 00195 } else { 00196 submitted = true; 00197 return true; 00198 } 00199 } 00200 //--></script> 00201 </head> 00202 <body onLoad="init()"> 00203 <!-- header //--> 00204 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 00205 <!-- header_eof //--> 00206 00207 <!-- body //--> 00208 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 00209 <tr> 00210 <!-- body_text //--> 00211 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 00212 <tr> 00213 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 00214 <tr> 00215 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 00216 <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 00217 <td class="main"> 00218 <?php 00219 // toggle switch for editor 00220 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();"') . 00221 zen_hide_session_id() . 00222 zen_draw_hidden_field('action', 'set_editor') . 00223 '</form>'; 00224 ?> 00225 </td> 00226 </tr> 00227 </table></td> 00228 </tr> 00229 <tr> 00230 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 00231 <?php 00232 if ( ($action == 'preview') && isset($_POST['customers_email_address']) ) { 00233 $audience_select = get_audience_sql_query(zen_db_input($_POST['customers_email_address'])); 00234 $mail_sent_to = $audience_select['query_name']; 00235 ?> 00236 <tr> 00237 <td><table border="0" width="100%" cellpadding="0" cellspacing="2"> 00238 <tr> 00239 <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b> <?php echo $mail_sent_to; ?></td> 00240 </tr> 00241 <tr> 00242 <td class="smallText"><b><?php echo TEXT_FROM; ?></b> <?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td> 00243 </tr> 00244 <tr> 00245 <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b> <?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td> 00246 </tr> 00247 <tr> 00248 <td class="smallText"><b><hr /><?php echo strip_tags(TEXT_MESSAGE_HTML); ?></b></td> 00249 </tr> 00250 <tr> 00251 <td width="500"> 00252 <?php if (EMAIL_USE_HTML != 'true') echo TEXT_WARNING_HTML_DISABLED.'<br />'; ?> 00253 <?php $html_preview = stripslashes($_POST['message_html']); echo (stristr($html_preview, '<br') ? $html_preview : nl2br($html_preview)); ?><hr /></td> 00254 </tr> 00255 <tr> 00256 <td class="smallText"><b><?php echo strip_tags(TEXT_MESSAGE); ?></b><br /></td> 00257 </tr> 00258 <tr> 00259 <td> 00260 <?php 00261 $message_preview = ((is_null($_POST['message']) || $_POST['message']=='') ? $_POST['message_html'] : $_POST['message'] ); 00262 $message_preview = (stristr($message_preview, '<br') ? $message_preview : nl2br($message_preview)); 00263 $message_preview = str_replace(array('<br>','<br />'), "<br />\n", $message_preview); 00264 $message_preview = str_replace('</p>', "</p>\n", $message_preview); 00265 echo '<tt>' . nl2br(htmlspecialchars(stripslashes(strip_tags($message_preview))) ) . '</tt>'; 00266 ?> 00267 <hr /> 00268 </td> 00269 </tr> 00270 <?php if (EMAIL_ATTACHMENTS_ENABLED && ($upload_file_name != '' || $attachment_file != '')) { ?> 00271 <tr> 00272 <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> 00273 </tr> 00274 <?php } ?> 00275 <tr> 00276 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00277 </tr> 00278 <tr><?php echo zen_draw_form('mail', FILENAME_MAIL, 'action=send_email_to_user'); ?> 00279 <td> 00280 <?php 00281 /* Re-Post all POST'ed variables */ 00282 reset($_POST); 00283 while (list($key, $value) = each($_POST)) { 00284 if (!is_array($_POST[$key])) { 00285 echo zen_draw_hidden_field($key, stripslashes($value)); 00286 } 00287 } 00288 echo zen_draw_hidden_field('upload_file', stripslashes($upload_file_name)); 00289 echo zen_draw_hidden_field('attachment_file', $attachment_file); 00290 echo zen_draw_hidden_field('attachment_filetype', $attachment_filetype); 00291 ?> 00292 <table border="0" width="100%" cellpadding="0" cellspacing="2"> 00293 <tr> 00294 <td><?php echo zen_image_submit('button_back.gif', IMAGE_BACK, 'name="back"'); ?></td> 00295 <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> 00296 </tr> 00297 </table></td> 00298 </tr> 00299 </table></td> 00300 </form></tr> 00301 <?php 00302 } else { 00303 ?> 00304 <tr><?php echo zen_draw_form('mail', FILENAME_MAIL,'action=preview','post', 'onsubmit="return check_form(mail);" enctype="multipart/form-data"'); ?> 00305 <td><table border="0" cellpadding="0" cellspacing="2"> 00306 <tr> 00307 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00308 </tr> 00309 <?php 00310 $customers = get_audiences_list('email'); 00311 ?> 00312 <tr> 00313 <td class="main"><?php echo TEXT_CUSTOMER; ?></td> 00314 <td><?php echo zen_draw_pull_down_menu('customers_email_address', $customers, (isset($_GET['customer']) ? $_GET['customer'] : '')); //, 'multiple' ?></td> 00315 </tr> 00316 <tr> 00317 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00318 </tr> 00319 <tr> 00320 <td class="main"><?php echo TEXT_FROM; ?></td> 00321 <td><?php echo zen_draw_input_field('from', htmlspecialchars(EMAIL_FROM, ENT_COMPAT, CHARSET, TRUE), 'size="50"'); ?></td> 00322 </tr> 00323 <tr> 00324 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00325 </tr> 00326 <tr> 00327 <td class="main"><?php echo TEXT_SUBJECT; ?></td> 00328 <td><?php echo zen_draw_input_field('subject', htmlspecialchars($_POST['subject'], ENT_COMPAT, CHARSET, TRUE), 'size="50"'); ?></td> 00329 </tr> 00330 <tr> 00331 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00332 </tr> 00333 <tr> 00334 <td valign="top" class="main"><?php echo TEXT_MESSAGE_HTML; //HTML version?></td> 00335 <td class="main" width="750"> 00336 <?php if (EMAIL_USE_HTML != 'true') echo TEXT_WARNING_HTML_DISABLED; ?> 00337 <?php if (EMAIL_USE_HTML == 'true') { 00338 echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', htmlspecialchars(stripslashes($_POST['message_html']), ENT_COMPAT, CHARSET, TRUE), 'id="message_html"'); 00339 } ?> 00340 </td> 00341 </tr> 00342 <tr> 00343 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00344 </tr> 00345 <tr> 00346 <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td> 00347 <td><?php echo zen_draw_textarea_field('message', 'soft', '100%', '15', htmlspecialchars($_POST['message'], ENT_COMPAT, CHARSET, TRUE)); ?></td> 00348 </tr> 00349 00350 <?php if (defined('EMAIL_ATTACHMENTS_ENABLED') && EMAIL_ATTACHMENTS_ENABLED === true && defined('DIR_WS_ADMIN_ATTACHMENTS') && is_dir(DIR_WS_ADMIN_ATTACHMENTS) && is_writable(DIR_WS_ADMIN_ATTACHMENTS) ) { ?> 00351 <tr> 00352 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00353 </tr> 00354 <?php if (defined('EMAIL_ATTACHMENT_UPLOADS_ENABLED') && EMAIL_ATTACHMENT_UPLOADS_ENABLED === true) { ?> 00355 <?php 00356 $dir = @dir(DIR_WS_ADMIN_ATTACHMENTS); 00357 $dir_info[] = array('id' => '', 'text' => "admin-attachments"); 00358 while ($file = $dir->read()) { 00359 if (is_dir(DIR_WS_ADMIN_ATTACHMENTS . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { 00360 $dir_info[] = array('id' => $file . '/', 'text' => $file); 00361 } 00362 } 00363 $dir->close(); 00364 ?> 00365 <tr> 00366 <td class="main" valign="top"><?php echo TEXT_SELECT_ATTACHMENT_TO_UPLOAD; ?></td> 00367 <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 /> 00368 <?php echo TEXT_ATTACHMENTS_DIR; ?> <?php echo zen_draw_pull_down_menu('attach_dir', $dir_info); ?></td> 00369 </tr> 00370 <tr> 00371 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00372 </tr> 00373 <?php } // end uploads-enabled dialog ?> 00374 <?php 00375 $dir = @dir(DIR_WS_ADMIN_ATTACHMENTS); 00376 $file_list[] = array('id' => '', 'text' => "(none)"); 00377 while ($file = $dir->read()) { 00378 if (is_file(DIR_WS_ADMIN_ATTACHMENTS . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { 00379 $file_list[] = array('id' => $file , 'text' => $file); 00380 } 00381 } 00382 $dir->close(); 00383 ?> 00384 <tr> 00385 <td class="main" valign="top"><?php echo TEXT_SELECT_ATTACHMENT; ?></td> 00386 <td class="main"><?php echo zen_draw_pull_down_menu('attachment_file', $file_list, $_POST['attachment_file']); ?></td> 00387 </tr> 00388 <?php } // end attachments fields ?> 00389 <tr> 00390 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00391 </tr> 00392 <?php 00393 if (isset($_GET['origin'])) { 00394 $origin = $_GET['origin']; 00395 } else { 00396 $origin = FILENAME_DEFAULT; 00397 } 00398 if (isset($_GET['mode']) && $_GET['mode'] == 'SSL') { 00399 $mode = 'SSL'; 00400 } else { 00401 $mode = 'NONSSL'; 00402 } 00403 ?> 00404 <tr> 00405 <td colspan="2" align="right"><?php echo zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' ' . 00406 '<a href="' . zen_href_link($origin, 'cID=' . zen_db_prepare_input($_GET['cID']), $mode) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 00407 </tr> 00408 </table></td> 00409 </form></tr> 00410 <?php 00411 } 00412 ?> 00413 <!-- body_text_eof //--> 00414 </table></td> 00415 </tr> 00416 </table></td> 00417 </tr> 00418 </table> 00419 <!-- body_eof //--> 00420 00421 <!-- footer //--> 00422 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 00423 <!-- footer_eof //--> 00424 <br /> 00425 </body> 00426 </html> 00427 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>