From fdf5910af2ee1a6a55924e165ef5b9a0864344c2 Mon Sep 17 00:00:00 2001 From: e107steved Date: Thu, 3 Sep 2009 19:32:33 +0000 Subject: [PATCH] Start tidying things up --- e107_admin/mailout.php | 750 +++++++++++++++++++++-------------------- 1 file changed, 376 insertions(+), 374 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index fba51df11..a517b8d91 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $ -| $Revision: 1.17 $ -| $Date: 2009-08-28 16:10:53 $ -| $Author: marj_nl_fr $ +| $Revision: 1.18 $ +| $Date: 2009-09-03 19:32:33 $ +| $Author: e107steved $ | | Work in progress - supplementary mailer plugin | @@ -466,15 +466,16 @@ Table data: //. Update Preferences. -if (isset($_POST['updateprefs']) && getperms("0")) +if (isset($_POST['updateprefs']) && getperms('0')) { unset($temp); + if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) $_POST['mailer'] = 'php'; $temp['mailer'] = $_POST['mailer']; // Allow qmail as an option as well - works much as sendmail - if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) $temp['sendmail'] = $_POST['sendmail']; - $temp['smtp_server'] = $tp->toDB($_POST['smtp_server']); - $temp['smtp_username'] = $tp->toDB($_POST['smtp_username']); - $temp['smtp_password'] = $tp->toDB($_POST['smtp_password']); + if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) $temp['sendmail'] = $e107->tp->toDB($_POST['sendmail']); + $temp['smtp_server'] = $e107->tp->toDB($_POST['smtp_server']); + $temp['smtp_username'] = $e107->tp->toDB($_POST['smtp_username']); + $temp['smtp_password'] = $e107->tp->toDB($_POST['smtp_password']); $smtp_opts = array(); switch (trim($_POST['smtp_options'])) @@ -492,18 +493,15 @@ if (isset($_POST['updateprefs']) && getperms("0")) if (varsettrue($_POST['smtp_keepalive'])) $smtp_opts[] = 'keepalive'; if (varsettrue($_POST['smtp_useVERP'])) $smtp_opts[] = 'useVERP'; - $temp['smtp_pop3auth'] = in_array('pop3auth',$smpt_opts); // This will go! - $temp['smtp_keepalive'] = $_POST['smtp_keepalive']; // This will go! - $temp['smtp_options'] = implode(',',$smtp_opts); $temp['mail_pause'] = intval($_POST['mail_pause']); $temp['mail_pausetime'] = intval($_POST['mail_pausetime']); - $temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email']); - $temp['mail_bounce_pop3'] = $tp->toDB($_POST['mail_bounce_pop3']); - $temp['mail_bounce_user'] = $tp->toDB($_POST['mail_bounce_user']); - $temp['mail_bounce_pass'] = $tp->toDB($_POST['mail_bounce_pass']); - $temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']); + $temp['mail_bounce_email'] = $e107->tp->toDB($_POST['mail_bounce_email']); + $temp['mail_bounce_pop3'] = $e107->tp->toDB($_POST['mail_bounce_pop3']); + $temp['mail_bounce_user'] = $e107->tp->toDB($_POST['mail_bounce_user']); + $temp['mail_bounce_pass'] = $e107->tp->toDB($_POST['mail_bounce_pass']); + $temp['mail_bounce_type'] = $e107->tp->toDB($_POST['mail_bounce_type']); $temp['mail_bounce_delete'] = intval($_POST['mail_bounce_delete']); $temp['mailout_enabled'] = implode(',',$_POST['mail_mailer_enabled']); @@ -535,27 +533,27 @@ if (isset($message)) if (!varsettrue($action)) $action = 'makemail'; switch ($action) { - case "prefs" : - if (getperms("0")) - { - show_prefs(); - } - break; + case "prefs" : + if (getperms("0")) + { + show_prefs(); + } + break; - case 'makemail' : - show_mailform($foo); - break; + case 'makemail' : + show_mailform($foo); + break; - case "list" : - showList(); - break; + case "list" : + showList(); + break; - case 'debug' : - showList($sub_par); - break; + case 'debug' : + showList($sub_par); + break; - case 'mailouts' : - showMailouts($sub_par,$mail_id); + case 'mailouts' : + showMailouts($sub_par,$mail_id); } require_once(e_ADMIN."footer.php"); @@ -567,153 +565,153 @@ require_once(e_ADMIN."footer.php"); //--------------------------------------------- function showMailouts($sub_par,$mail_id) { - - global $sql,$ns,$tp, $images_path; + global $images_path; + $e107 = e107::getInstance(); // gen_datestamp int(10) unsigned NOT NULL default '0', - Mail ID code - to match the destination address records // gen_user_id int(10) unsigned NOT NULL default '0', - User ID of current author // gen_ip varchar(80) NOT NULL default '', - Email subject // gen_intdata int(10) unsigned NOT NULL default '0', - Initially set to zero - set to number of emails initially added - $message = ''; - if ($sub_par && $mail_id) - { - switch ($sub_par) + $message = ''; + if ($sub_par && $mail_id) { - case 'delete' : - if ($sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) + switch ($sub_par) { - $message = $sql->db_Delete('generic',"`gen_datestamp`={$mail_id} AND (`gen_type`='sendmail' OR `gen_type`='savemail')") ? LAN_DELETED : LAN_DELETED_FAILED; - $admin_log->log_event('MAIL_04',$mail_id,E_LOG_INFORMATIVE,''); - } - else - { // Should only happen if people fiddle! - $message = "Error - database record not found"; - echo "DB error
"; - } - break; + case 'delete' : + if ($e107->sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) + { + $message = $e107->sql->db_Delete('generic',"`gen_datestamp`={$mail_id} AND (`gen_type`='sendmail' OR `gen_type`='savemail')") ? LAN_DELETED : LAN_DELETED_FAILED; + $e107->admin_log->log_event('MAIL_04',$mail_id,E_LOG_INFORMATIVE,''); + } + else + { // Should only happen if people fiddle! + $message = "Error - database record not found"; + echo "DB error
"; + } + break; - case 'detail' : // Show the detail of an email run above the main list - if ($sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) - { - $row = $sql->db_Fetch(); - // Display a little bit of the email - $mail = unserialize($row['gen_chardata']); - $text = " - - - - - \n - - - - \n - - - - \n"; - if ($sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) - { - $text .= "\n"; - } - $text .= " -
".LAN_MAILOUT_51."".$mail['email_subject']."
".LAN_MAILOUT_103."".(isset($mail['send_results']) ? implode('
',$mail['send_results']) : LAN_MAILOUT_104)."
".LAN_MAILOUT_105.""; - $spacer = ''; - $i = 0; - while (($row = $sql->db_Fetch()) && ($i < 10)) - { - $this_mail = unserialize($row['gen_chardata']); - if (isset($this_mail['send_result'])) - { - $text .= $spacer.LAN_MAILOUT_03.' '.$this_mail['user_name'].' '.LAN_MAILOUT_107.' '.$this_mail['user_email'].' '.LAN_MAILOUT_108.' '.$this_mail['send_result']; - $spacer = '
'; - $i++; - } - } - $text .= "
- "; - $ns->tablerender(LAN_MAILOUT_102,$text); + case 'detail' : // Show the detail of an email run above the main list + if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) + { + $row = $e107->sql->db_Fetch(); + // Display a little bit of the email + $mail = unserialize($row['gen_chardata']); + $text = " + + + + + \n + + + + \n + + + + \n"; + if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) + { + $text .= "\n"; + } + $text .= " +
".LAN_MAILOUT_51."".$mail['email_subject']."
".LAN_MAILOUT_103."".(isset($mail['send_results']) ? implode('
',$mail['send_results']) : LAN_MAILOUT_104)."
".LAN_MAILOUT_105.""; + $spacer = ''; + $i = 0; + while (($row = $e107->sql->db_Fetch()) && ($i < 10)) + { + $this_mail = unserialize($row['gen_chardata']); + if (isset($this_mail['send_result'])) + { + $text .= $spacer.LAN_MAILOUT_03.' '.$this_mail['user_name'].' '.LAN_MAILOUT_107.' '.$this_mail['user_email'].' '.LAN_MAILOUT_108.' '.$this_mail['send_result']; + $spacer = '
'; + $i++; + } + } + $text .= "
+ "; + $e107->ns->tablerender(LAN_MAILOUT_102,$text); + } + else + { // Should only happen if people fiddle! + $message = "Error - database record not found"; + echo "DB error
"; + } + break; + + case 'resend' : + // Echo "resend: {$mail_id}
"; + if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) + { // Put up confirmation + $row = $e107->sql->db_Fetch(); + + $debug = (e_MENU == "debug") ? "[debug]" : ""; + $mailer_url = e_HANDLER."phpmailer/mailout_process.php?".$debug."{$row['gen_datestamp']}.{$row['gen_id']}"; + + $c = $e107->sql->db_Count('generic','(*)',"WHERE `gen_datestamp`={$mail_id} AND `gen_type`='sendmail'"); // Count of mails to go + + $text = "
+
+ "; + $text .= "
{$c} ".LAN_MAILOUT_24."
"; + + $text .= "

+ +
"; + $text .= "


"; + $e107->ns->tablerender(LAN_MAILOUT_99,$text); + + // Display a little bit of the email + $mail = unserialize($row['gen_chardata']); + $text = " + + + + + \n + + + + \n + + + + \n +
".LAN_MAILOUT_51."".$mail['email_subject']."
".LAN_MAILOUT_100."".$mail['email_body']."
+ "; + $e107->ns->tablerender(LAN_MAILOUT_101,$text); + + return; + } + else + { // Should only happen if people fiddle! + $message = "Error - database record not found"; + echo "DB error
"; + } + break; + case 'orphans' : // Delete any orphaned emails + if ($e107->sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) + { + $message = $e107->sql->db_Delete('generic',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'") ? LAN_DELETED : LAN_DELETED_FAILED; + $e107->admin_log->log_event('MAIL_04',$mail_id,E_LOG_INFORMATIVE,''); + } + else + { // Should only happen if people fiddle! + $message = "Error - database record not found"; + echo "DB error
"; + } + break; + default : + echo "Invalid parameter: {$sub_par}
"; } - else - { // Should only happen if people fiddle! - $message = "Error - database record not found"; - echo "DB error
"; - } - break; - - case 'resend' : -// Echo "resend: {$mail_id}
"; - if ($sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) - { // Put up confirmation - $row = $sql->db_Fetch(); - - $debug = (e_MENU == "debug") ? "[debug]" : ""; - $mailer_url = e_HANDLER."phpmailer/mailout_process.php?".$debug."{$row['gen_datestamp']}.{$row['gen_id']}"; - - $c = $sql->db_Count('generic','(*)',"WHERE `gen_datestamp`={$mail_id} AND `gen_type`='sendmail'"); // Count of mails to go - - $text = "
-
- "; - $text .= "
{$c} ".LAN_MAILOUT_24."
"; - - $text .= "

- -
"; - $text .= "


"; - $ns->tablerender(LAN_MAILOUT_99,$text); - - // Display a little bit of the email - $mail = unserialize($row['gen_chardata']); - $text = " - - - - - \n - - - - \n - - - - \n -
".LAN_MAILOUT_51."".$mail['email_subject']."
".LAN_MAILOUT_100."".$mail['email_body']."
- "; - $ns->tablerender(LAN_MAILOUT_101,$text); - - return; - } - else - { // Should only happen if people fiddle! - $message = "Error - database record not found"; - echo "DB error
"; - } - break; - case 'orphans' : // Delete any orphaned emails - if ($sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) - { - $message = $sql->db_Delete('generic',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'") ? LAN_DELETED : LAN_DELETED_FAILED; - $admin_log->log_event('MAIL_04',$mail_i5,E_LOG_INFORMATIVE,''); - } - else - { // Should only happen if people fiddle! - $message = "Error - database record not found"; - echo "DB error
"; - } - break; - default : - echo "Invalid parameter: {$sub_par}
"; } - } - if ($message) $ns -> tablerender("
".LAN_MAILOUT_78."
", $message); + if ($message) $e107->ns -> tablerender("
".LAN_MAILOUT_78."
", $message); -// Need to select main email entries; count number of addresses attached to each - $gen = new convert; - $qry = "SELECT + // Need to select main email entries; count number of addresses attached to each + $gen = new convert; + $qry = "SELECT u.user_name, g.*, COUNT(m.gen_datestamp) AS pending FROM `#generic` AS g @@ -722,21 +720,21 @@ function showMailouts($sub_par,$mail_id) WHERE g.gen_type='savemail' GROUP BY g.gen_datestamp ORDER BY g.gen_id ASC"; - $count = $sql -> db_Select_gen($qry); + $count = $e107->sql -> db_Select_gen($qry); - $emails_found = array(); // Log ID and count for later + $emails_found = array(); // Log ID and count for later - $text = "
"; + $text = "
"; - if (!$count) - { - $text = "
".LAN_MAILOUT_79."
"; - $ns -> tablerender("
".LAN_MAILOUT_78."
", $text); - require_once(e_ADMIN."footer.php"); - exit; - } + if (!$count) + { + $text = "
".LAN_MAILOUT_79."
"; + $e107->ns -> tablerender("
".LAN_MAILOUT_78."
", $text); + require_once(e_ADMIN."footer.php"); + exit; + } - $text .= " + $text .= "
@@ -759,81 +757,81 @@ function showMailouts($sub_par,$mail_id) "; - while ($row = $sql->db_Fetch()) - { - $datestamp = $gen->convert_date($row['gen_datestamp'], "short"); - - if ($row['pending']) $emails_found[$row['gen_datestamp']] = $row['pending']; // Log the mailshot in a list if any emails to go - $text .= " - - - - - - - - - "; - } + $datestamp = $gen->convert_date($row['gen_datestamp'], "short"); - $text .= "
".$row['gen_datestamp'] ."".$datestamp."".$row['user_name']."".$row['gen_ip']."".$row['gen_intdata']."".$row['pending']." -
"; - $text .= "".LAN_MAILOUT_109.""; - if ($row['pending']) + while ($row = $e107->sql->db_Fetch()) { - $text .= "".LAN_MAILOUT_86.""; - } - $text .= " - ".LAN_DELETE." -
-
\n



"; - $ns -> tablerender("
".LAN_MAILOUT_78."
", $text); + if ($row['pending']) $emails_found[$row['gen_datestamp']] = $row['pending']; // Log the mailshot in a list if any emails to go + $text .= " + ".$row['gen_datestamp'] ." + ".$datestamp." + ".$row['user_name']." + ".$row['gen_ip']." + ".$row['gen_intdata']." + ".$row['pending']." + +
"; + $text .= "".LAN_MAILOUT_109.""; + if ($row['pending']) + { + $text .= "".LAN_MAILOUT_86.""; + } + $text .= " + ".LAN_DELETE." +
+ + + "; + } + + $text .= "\n


"; + $e107->ns -> tablerender("
".LAN_MAILOUT_78."
", $text); - // Now see if we can find any 'orphaned' mailout entries - $qry = "SELECT + // Now see if we can find any 'orphaned' mailout entries + $qry = "SELECT g.gen_datestamp, COUNT(g.gen_datestamp) AS pending FROM `#generic` AS g WHERE g.gen_type='sendmail' GROUP BY g.gen_datestamp ORDER BY g.gen_id ASC"; - $count = $sql -> db_Select_gen($qry); -// Echo "There are {$count} groups of unsent emails: ".count($emails_found)." in previous table
"; - if ($count > count($emails_found)) - { - $text = " -
- - - - - - - - - - - \n - "; - while ($row = $sql->db_Fetch()) + $count = $e107->sql -> db_Select_gen($qry); + // Echo "There are {$count} groups of unsent emails: ".count($emails_found)." in previous table
"; + if ($count > count($emails_found)) { - if (!isset($emails_found[$row['gen_datestamp']])) - { - $text .= " - - - + $text = " + +
".LAN_MAILOUT_84."".LAN_MAILOUT_83."".LAN_OPTIONS."
".$row['gen_datestamp'] ."".$row['pending']." - -
+ + + + + + + + + \n "; - } -// echo "ID: {$row['gen_datestamp']} Unsent: {$row['pending']}"; - } - $text .= "
".LAN_MAILOUT_84."".LAN_MAILOUT_83."".LAN_OPTIONS."
\n



"; - $ns -> tablerender("
".LAN_MAILOUT_98."
", $text); + while ($row = $e107->sql->db_Fetch()) + { + if (!isset($emails_found[$row['gen_datestamp']])) + { + $text .= " + ".$row['gen_datestamp'] ." + ".$row['pending']." + +
+ toJS(LAN_CONFIRMDEL." [".$row['gen_datestamp']."]")."') \">".LAN_DELETE." +
+ + \n + "; + } + // echo "ID: {$row['gen_datestamp']} Unsent: {$row['pending']}"; + } + $text .= "\n


"; + $e107->ns -> tablerender("
".LAN_MAILOUT_98."
", $text); } } @@ -845,101 +843,102 @@ function showMailouts($sub_par,$mail_id) function show_mailform($foo="") { - global $ns,$sql,$tp,$pref,$HANDLERS_DIRECTORY; + global $pref,$HANDLERS_DIRECTORY; global $mail_handlers; + $e107 = e107::getInstance(); $email_subject = $foo['gen_ip']; - $email_body = $tp->toForm($foo['gen_chardata']); + $email_body = $e107->tp->toForm($foo['gen_chardata']); $email_id = $foo['gen_id']; $text = ""; if(strpos($_SERVER['SERVER_SOFTWARE'],"mod_gzip") && !is_readable(e_HANDLER."phpmailer/.htaccess")) { $warning = LAN_MAILOUT_40." ".$HANDLERS_DIRECTORY."phpmailer/ ".LAN_MAILOUT_41; - $ns -> tablerender(LAN_MAILOUT_42, $warning); + $e107->ns -> tablerender(LAN_MAILOUT_42, $warning); } $debug = (e_MENU == "debug") ? "?[debug]" : ""; $text .= "
-
- - - - - - - - - "; + +
".LAN_MAILOUT_01.": - -
+ + + + + + + + "; $text .=" - - - - "; + + + + "; // Add in the core and any plugin selectors here foreach ($mail_handlers as $m) { - if ($m->mailer_enabled) - { - $text .= ""; - } + if ($m->mailer_enabled) + { + $text .= ""; + } } // CC, BCC $text .= " - - - - + + + + - - - - "; + + + + "; // Close one table, open another - to give a boundary between addressees and content $text .= "
".LAN_MAILOUT_01.": + +
".LAN_MAILOUT_02.": - -
".LAN_MAILOUT_02.": + +
".$m->mailer_name."".$m->show_select(TRUE)."
".$m->mailer_name."".$m->show_select(TRUE)."
".LAN_MAILOUT_04.": - -
".LAN_MAILOUT_04.": + +
".LAN_MAILOUT_05.": - -
".LAN_MAILOUT_05.": + +
- - - - - "; +
+ + + + "; // Subject $text .= " - - - - "; + + + + "; // Attachment. $text .= " - - + - - - + + + + - - - "; + + + "; $text .=" - - + - + +
".LAN_MAILOUT_51.": - -
".LAN_MAILOUT_51.": + +
".LAN_MAILOUT_07.": "; + ".LAN_MAILOUT_07.": "; $text .= "
".LAN_MAILOUT_09.": - -
".LAN_MAILOUT_09.": + +
- -
+ +
-
"; +
+
"; global $eplug_bb; $eplug_bb[] = array( - "name" => 'shortcode', - "onclick" => 'expandit', - "onclick_var" => "sc_selector", - "icon" => e_IMAGE."generic/bbcode/shortcode.png", - "helptext" => LAN_MAILOUT_11, - "function" => "sc_Select", - "function_var" => "sc_selector" + 'name' => 'shortcode', + 'onclick' => 'expandit', + 'onclick_var' => 'sc_selector', + 'icon' => e_IMAGE.'generic/bbcode/shortcode.png', + 'helptext' => LAN_MAILOUT_11, + 'function' => 'sc_Select', + 'function_var' => 'sc_selector' ); - $text .= display_help("helpb",'mailout'); + $text .= display_help('helpb','mailout'); if(e_WYSIWYG) { @@ -993,16 +992,19 @@ function show_mailform($foo="") } $text .=" -
"; $text .= "
"; - if(isset($_POST['edit'])){ + if(isset($_POST['edit'])) + { $text .= ""; $text .= ""; - }else{ + } + else + { $text .= ""; } @@ -1013,8 +1015,7 @@ function show_mailform($foo="")
"; - $ns->tablerender(LAN_MAILOUT_15, $text); - + $e107->ns->tablerender(LAN_MAILOUT_15, $text); } //---------------------------------------------------- @@ -1023,31 +1024,33 @@ function show_mailform($foo="") function show_prefs() { - global $pref,$ns; -$text = " -
-
- - - - - - - - - + global $pref; + $e107 = e107::getInstance(); - - -
".LAN_MAILOUT_110."
  - -
".LAN_MAILOUT_115."
".LAN_MAILOUT_116."
- + + + + + + + + + + + + + +
".LAN_MAILOUT_110."
  + +
".LAN_MAILOUT_115."
".LAN_MAILOUT_116."
+
"; @@ -1059,30 +1062,30 @@ $text = " $text .= "
"; $text .= " - - - + + + - - - - + + + + - - - - + + + + - - + "; $text .= " - - "; + + "; $checked = (in_array('useVERP',$smtp_opts) ? "checked='checked'" : ""); $text .= " - - -
".LAN_MAILOUT_87.":   - -
".LAN_MAILOUT_87.":   + +
".LAN_MAILOUT_88.": (".LAN_OPTIONAL.")   - -
".LAN_MAILOUT_88.": (".LAN_OPTIONAL.")   + +
".LAN_MAILOUT_89.": (".LAN_OPTIONAL.")   - -
".LAN_MAILOUT_89.": (".LAN_OPTIONAL.")   + +
".LAN_MAILOUT_90.":  -
".LAN_MAILOUT_90.":  + \n
".LAN_MAILOUT_94."
".LAN_MAILOUT_57.":  - "; + ".LAN_MAILOUT_57.":  + "; $checked = (varsettrue($pref['smtp_keepalive']) ) ? "checked='checked'" : ""; $text .= " -
".LAN_MAILOUT_95.":  -
"; +
"; // Sendmail. --------------> @@ -1196,7 +1198,7 @@ $text = " "; $caption = LAN_PREFS; - $ns->tablerender($caption, $text); + $e107->ns->tablerender($caption, $text); }