1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-24 07:03:06 +02:00

Start tidying things up

This commit is contained in:
e107steved
2009-09-03 19:32:33 +00:00
parent 7aa8bc694d
commit fdf5910af2

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $
| $Revision: 1.17 $ | $Revision: 1.18 $
| $Date: 2009-08-28 16:10:53 $ | $Date: 2009-09-03 19:32:33 $
| $Author: marj_nl_fr $ | $Author: e107steved $
| |
| Work in progress - supplementary mailer plugin | Work in progress - supplementary mailer plugin
| |
@@ -466,15 +466,16 @@ Table data:
//. Update Preferences. //. Update Preferences.
if (isset($_POST['updateprefs']) && getperms("0")) if (isset($_POST['updateprefs']) && getperms('0'))
{ {
unset($temp); unset($temp);
if (!in_array($_POST['mailer'], array('smtp', 'sendmail', 'php'))) $_POST['mailer'] = 'php';
$temp['mailer'] = $_POST['mailer']; $temp['mailer'] = $_POST['mailer'];
// Allow qmail as an option as well - works much as sendmail // 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']; if ((strpos($_POST['sendmail'],'sendmail') !== FALSE) || (strpos($_POST['sendmail'],'qmail') !== FALSE)) $temp['sendmail'] = $e107->tp->toDB($_POST['sendmail']);
$temp['smtp_server'] = $tp->toDB($_POST['smtp_server']); $temp['smtp_server'] = $e107->tp->toDB($_POST['smtp_server']);
$temp['smtp_username'] = $tp->toDB($_POST['smtp_username']); $temp['smtp_username'] = $e107->tp->toDB($_POST['smtp_username']);
$temp['smtp_password'] = $tp->toDB($_POST['smtp_password']); $temp['smtp_password'] = $e107->tp->toDB($_POST['smtp_password']);
$smtp_opts = array(); $smtp_opts = array();
switch (trim($_POST['smtp_options'])) 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_keepalive'])) $smtp_opts[] = 'keepalive';
if (varsettrue($_POST['smtp_useVERP'])) $smtp_opts[] = 'useVERP'; 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['smtp_options'] = implode(',',$smtp_opts);
$temp['mail_pause'] = intval($_POST['mail_pause']); $temp['mail_pause'] = intval($_POST['mail_pause']);
$temp['mail_pausetime'] = intval($_POST['mail_pausetime']); $temp['mail_pausetime'] = intval($_POST['mail_pausetime']);
$temp['mail_bounce_email'] = $tp->toDB($_POST['mail_bounce_email']); $temp['mail_bounce_email'] = $e107->tp->toDB($_POST['mail_bounce_email']);
$temp['mail_bounce_pop3'] = $tp->toDB($_POST['mail_bounce_pop3']); $temp['mail_bounce_pop3'] = $e107->tp->toDB($_POST['mail_bounce_pop3']);
$temp['mail_bounce_user'] = $tp->toDB($_POST['mail_bounce_user']); $temp['mail_bounce_user'] = $e107->tp->toDB($_POST['mail_bounce_user']);
$temp['mail_bounce_pass'] = $tp->toDB($_POST['mail_bounce_pass']); $temp['mail_bounce_pass'] = $e107->tp->toDB($_POST['mail_bounce_pass']);
$temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']); $temp['mail_bounce_type'] = $e107->tp->toDB($_POST['mail_bounce_type']);
$temp['mail_bounce_delete'] = intval($_POST['mail_bounce_delete']); $temp['mail_bounce_delete'] = intval($_POST['mail_bounce_delete']);
$temp['mailout_enabled'] = implode(',',$_POST['mail_mailer_enabled']); $temp['mailout_enabled'] = implode(',',$_POST['mail_mailer_enabled']);
@@ -567,8 +565,8 @@ require_once(e_ADMIN."footer.php");
//--------------------------------------------- //---------------------------------------------
function showMailouts($sub_par,$mail_id) function showMailouts($sub_par,$mail_id)
{ {
global $images_path;
global $sql,$ns,$tp, $images_path; $e107 = e107::getInstance();
// gen_datestamp int(10) unsigned NOT NULL default '0', - Mail ID code - to match the destination address records // 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_user_id int(10) unsigned NOT NULL default '0', - User ID of current author
// gen_ip varchar(80) NOT NULL default '', - Email subject // gen_ip varchar(80) NOT NULL default '', - Email subject
@@ -580,10 +578,10 @@ function showMailouts($sub_par,$mail_id)
switch ($sub_par) switch ($sub_par)
{ {
case 'delete' : case 'delete' :
if ($sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) if ($e107->sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'"))
{ {
$message = $sql->db_Delete('generic',"`gen_datestamp`={$mail_id} AND (`gen_type`='sendmail' OR `gen_type`='savemail')") ? LAN_DELETED : LAN_DELETED_FAILED; $message = $e107->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,''); $e107->admin_log->log_event('MAIL_04',$mail_id,E_LOG_INFORMATIVE,'');
} }
else else
{ // Should only happen if people fiddle! { // Should only happen if people fiddle!
@@ -593,9 +591,9 @@ function showMailouts($sub_par,$mail_id)
break; break;
case 'detail' : // Show the detail of an email run above the main list 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'")) if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'"))
{ {
$row = $sql->db_Fetch(); $row = $e107->sql->db_Fetch();
// Display a little bit of the email // Display a little bit of the email
$mail = unserialize($row['gen_chardata']); $mail = unserialize($row['gen_chardata']);
$text = " $text = "
@@ -612,12 +610,12 @@ function showMailouts($sub_par,$mail_id)
<td>".LAN_MAILOUT_103."</td> <td>".LAN_MAILOUT_103."</td>
<td>".(isset($mail['send_results']) ? implode('<br />',$mail['send_results']) : LAN_MAILOUT_104)."</td> <td>".(isset($mail['send_results']) ? implode('<br />',$mail['send_results']) : LAN_MAILOUT_104)."</td>
</tr>\n"; </tr>\n";
if ($sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'"))
{ {
$text .= "<tr><td>".LAN_MAILOUT_105."</td><td>"; $text .= "<tr><td>".LAN_MAILOUT_105."</td><td>";
$spacer = ''; $spacer = '';
$i = 0; $i = 0;
while (($row = $sql->db_Fetch()) && ($i < 10)) while (($row = $e107->sql->db_Fetch()) && ($i < 10))
{ {
$this_mail = unserialize($row['gen_chardata']); $this_mail = unserialize($row['gen_chardata']);
if (isset($this_mail['send_result'])) if (isset($this_mail['send_result']))
@@ -632,7 +630,7 @@ function showMailouts($sub_par,$mail_id)
$text .= " $text .= "
</table> </table>
"; ";
$ns->tablerender(LAN_MAILOUT_102,$text); $e107->ns->tablerender(LAN_MAILOUT_102,$text);
} }
else else
{ // Should only happen if people fiddle! { // Should only happen if people fiddle!
@@ -643,14 +641,14 @@ function showMailouts($sub_par,$mail_id)
case 'resend' : case 'resend' :
// Echo "resend: {$mail_id}<br />"; // Echo "resend: {$mail_id}<br />";
if ($sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'")) if ($e107->sql->db_Select('generic','gen_id,gen_datestamp,gen_chardata',"`gen_datestamp`={$mail_id} AND `gen_type`='savemail'"))
{ // Put up confirmation { // Put up confirmation
$row = $sql->db_Fetch(); $row = $e107->sql->db_Fetch();
$debug = (e_MENU == "debug") ? "[debug]" : ""; $debug = (e_MENU == "debug") ? "[debug]" : "";
$mailer_url = e_HANDLER."phpmailer/mailout_process.php?".$debug."{$row['gen_datestamp']}.{$row['gen_id']}"; $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 $c = $e107->sql->db_Count('generic','(*)',"WHERE `gen_datestamp`={$mail_id} AND `gen_type`='sendmail'"); // Count of mails to go
$text = "<div style='text-align:center'> $text = "<div style='text-align:center'>
<form method='post' action='{$mailer_url}' name='mailform' onsubmit=\"open('', 'popup','width=230,height=170,resizable=1,scrollbars=0');this.target = 'popup';return true;\" > <form method='post' action='{$mailer_url}' name='mailform' onsubmit=\"open('', 'popup','width=230,height=170,resizable=1,scrollbars=0');this.target = 'popup';return true;\" >
@@ -661,7 +659,7 @@ function showMailouts($sub_par,$mail_id)
<input class='button' type='submit' name='cancel_emails' value='".LAN_MAILOUT_38."' /> <input class='button' type='submit' name='cancel_emails' value='".LAN_MAILOUT_38."' />
</div>"; </div>";
$text .= "</form><br /><br /></div>"; $text .= "</form><br /><br /></div>";
$ns->tablerender(LAN_MAILOUT_99,$text); $e107->ns->tablerender(LAN_MAILOUT_99,$text);
// Display a little bit of the email // Display a little bit of the email
$mail = unserialize($row['gen_chardata']); $mail = unserialize($row['gen_chardata']);
@@ -681,7 +679,7 @@ function showMailouts($sub_par,$mail_id)
</tr>\n </tr>\n
</table> </table>
"; ";
$ns->tablerender(LAN_MAILOUT_101,$text); $e107->ns->tablerender(LAN_MAILOUT_101,$text);
return; return;
} }
@@ -692,10 +690,10 @@ function showMailouts($sub_par,$mail_id)
} }
break; break;
case 'orphans' : // Delete any orphaned emails case 'orphans' : // Delete any orphaned emails
if ($sql->db_Select('generic','gen_datestamp',"`gen_datestamp`={$mail_id} AND `gen_type`='sendmail'")) if ($e107->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; $message = $e107->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,''); $e107->admin_log->log_event('MAIL_04',$mail_id,E_LOG_INFORMATIVE,'');
} }
else else
{ // Should only happen if people fiddle! { // Should only happen if people fiddle!
@@ -709,7 +707,7 @@ function showMailouts($sub_par,$mail_id)
} }
if ($message) $ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $message); if ($message) $e107->ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $message);
// Need to select main email entries; count number of addresses attached to each // Need to select main email entries; count number of addresses attached to each
$gen = new convert; $gen = new convert;
@@ -722,7 +720,7 @@ function showMailouts($sub_par,$mail_id)
WHERE g.gen_type='savemail' WHERE g.gen_type='savemail'
GROUP BY g.gen_datestamp GROUP BY g.gen_datestamp
ORDER BY g.gen_id ASC"; 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
@@ -731,7 +729,7 @@ function showMailouts($sub_par,$mail_id)
if (!$count) if (!$count)
{ {
$text = "<div class='forumheader2' style='text-align:center'>".LAN_MAILOUT_79."</div>"; $text = "<div class='forumheader2' style='text-align:center'>".LAN_MAILOUT_79."</div>";
$ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $text); $e107->ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $text);
require_once(e_ADMIN."footer.php"); require_once(e_ADMIN."footer.php");
exit; exit;
} }
@@ -759,7 +757,7 @@ function showMailouts($sub_par,$mail_id)
</tr> </tr>
"; ";
while ($row = $sql->db_Fetch()) while ($row = $e107->sql->db_Fetch())
{ {
$datestamp = $gen->convert_date($row['gen_datestamp'], "short"); $datestamp = $gen->convert_date($row['gen_datestamp'], "short");
@@ -787,7 +785,7 @@ function showMailouts($sub_par,$mail_id)
} }
$text .= "</table>\n</form><br /><br /><br /></div>"; $text .= "</table>\n</form><br /><br /><br /></div>";
$ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $text); $e107->ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_78."</div>", $text);
// Now see if we can find any 'orphaned' mailout entries // Now see if we can find any 'orphaned' mailout entries
$qry = "SELECT $qry = "SELECT
@@ -797,7 +795,7 @@ function showMailouts($sub_par,$mail_id)
WHERE g.gen_type='sendmail' WHERE g.gen_type='sendmail'
GROUP BY g.gen_datestamp GROUP BY g.gen_datestamp
ORDER BY g.gen_id ASC"; ORDER BY g.gen_id ASC";
$count = $sql -> db_Select_gen($qry); $count = $e107->sql -> db_Select_gen($qry);
// Echo "There are {$count} groups of unsent emails: ".count($emails_found)." in previous table<br />"; // Echo "There are {$count} groups of unsent emails: ".count($emails_found)." in previous table<br />";
if ($count > count($emails_found)) if ($count > count($emails_found))
{ {
@@ -815,7 +813,7 @@ function showMailouts($sub_par,$mail_id)
<td class='fcaption'>".LAN_OPTIONS."</td> <td class='fcaption'>".LAN_OPTIONS."</td>
</tr>\n </tr>\n
"; ";
while ($row = $sql->db_Fetch()) while ($row = $e107->sql->db_Fetch())
{ {
if (!isset($emails_found[$row['gen_datestamp']])) if (!isset($emails_found[$row['gen_datestamp']]))
{ {
@@ -833,7 +831,7 @@ function showMailouts($sub_par,$mail_id)
// echo "ID: {$row['gen_datestamp']} Unsent: {$row['pending']}"; // echo "ID: {$row['gen_datestamp']} Unsent: {$row['pending']}";
} }
$text .= "</table>\n</form><br /><br /><br /></div>"; $text .= "</table>\n</form><br /><br /><br /></div>";
$ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_98."</div>", $text); $e107->ns -> tablerender("<div style='text-align:center'>".LAN_MAILOUT_98."</div>", $text);
} }
} }
@@ -845,19 +843,20 @@ function showMailouts($sub_par,$mail_id)
function show_mailform($foo="") function show_mailform($foo="")
{ {
global $ns,$sql,$tp,$pref,$HANDLERS_DIRECTORY; global $pref,$HANDLERS_DIRECTORY;
global $mail_handlers; global $mail_handlers;
$e107 = e107::getInstance();
$email_subject = $foo['gen_ip']; $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']; $email_id = $foo['gen_id'];
$text = ""; $text = "";
if(strpos($_SERVER['SERVER_SOFTWARE'],"mod_gzip") && !is_readable(e_HANDLER."phpmailer/.htaccess")) if(strpos($_SERVER['SERVER_SOFTWARE'],"mod_gzip") && !is_readable(e_HANDLER."phpmailer/.htaccess"))
{ {
$warning = LAN_MAILOUT_40." ".$HANDLERS_DIRECTORY."phpmailer/ ".LAN_MAILOUT_41; $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]" : ""; $debug = (e_MENU == "debug") ? "?[debug]" : "";
@@ -938,8 +937,8 @@ function show_mailform($foo="")
<td >"; <td >";
$text .= "<select class='tbox' name='email_attachment' > $text .= "<select class='tbox' name='email_attachment' >
<option value=''>&nbsp;</option>\n"; <option value=''>&nbsp;</option>\n";
$sql->db_Select("download", "download_url,download_name", "download_id !='' ORDER BY download_name"); $e107->sql->db_Select("download", "download_url,download_name", "download_id !='' ORDER BY download_name");
while ($row = $sql->db_Fetch()) while ($row = $e107->sql->db_Fetch())
{ {
extract($row); extract($row);
$selected = ($_POST['email_attachment'] == $download_url) ? "selected='selected'" : $selected = ($_POST['email_attachment'] == $download_url) ? "selected='selected'" :
@@ -974,16 +973,16 @@ function show_mailform($foo="")
global $eplug_bb; global $eplug_bb;
$eplug_bb[] = array( $eplug_bb[] = array(
"name" => 'shortcode', 'name' => 'shortcode',
"onclick" => 'expandit', 'onclick' => 'expandit',
"onclick_var" => "sc_selector", 'onclick_var' => 'sc_selector',
"icon" => e_IMAGE."generic/bbcode/shortcode.png", 'icon' => e_IMAGE.'generic/bbcode/shortcode.png',
"helptext" => LAN_MAILOUT_11, 'helptext' => LAN_MAILOUT_11,
"function" => "sc_Select", 'function' => 'sc_Select',
"function_var" => "sc_selector" 'function_var' => 'sc_selector'
); );
$text .= display_help("helpb",'mailout'); $text .= display_help('helpb','mailout');
if(e_WYSIWYG) if(e_WYSIWYG)
{ {
@@ -999,10 +998,13 @@ function show_mailform($foo="")
$text .= "<div class='buttons-bar center'>"; $text .= "<div class='buttons-bar center'>";
if(isset($_POST['edit'])){ if(isset($_POST['edit']))
{
$text .= "<input type='hidden' name='update_id' value='".$email_id."' />"; $text .= "<input type='hidden' name='update_id' value='".$email_id."' />";
$text .= "<input class='button' type='submit' name='update_email' value=\"".LAN_UPDATE."\" />"; $text .= "<input class='button' type='submit' name='update_email' value=\"".LAN_UPDATE."\" />";
}else{ }
else
{
$text .= "<input class='button' type='submit' name='save_email' value=\"".LAN_SAVE."\" />"; $text .= "<input class='button' type='submit' name='save_email' value=\"".LAN_SAVE."\" />";
} }
@@ -1013,8 +1015,7 @@ function show_mailform($foo="")
</form> </form>
</div>"; </div>";
$ns->tablerender(LAN_MAILOUT_15, $text); $e107->ns->tablerender(LAN_MAILOUT_15, $text);
} }
//---------------------------------------------------- //----------------------------------------------------
@@ -1023,7 +1024,9 @@ function show_mailform($foo="")
function show_prefs() function show_prefs()
{ {
global $pref,$ns; global $pref;
$e107 = e107::getInstance();
$text = " $text = "
<form method='post' action='".e_SELF."?".e_QUERY."' id='mailsettingsform'> <form method='post' action='".e_SELF."?".e_QUERY."' id='mailsettingsform'>
<div id='mail'> <div id='mail'>
@@ -1043,7 +1046,7 @@ $text = "
<td style='vertical-align:top'>".LAN_MAILOUT_115."<br /><span class='smalltext'>".LAN_MAILOUT_116."</span></td> <td style='vertical-align:top'>".LAN_MAILOUT_115."<br /><span class='smalltext'>".LAN_MAILOUT_116."</span></td>
<td style='text-align:right'> <td style='text-align:right'>
<select class='tbox' name='mailer' onchange='disp(this.value)'>\n"; <select class='tbox' name='mailer' onchange='disp(this.value)'>\n";
$mailers = array("php","smtp","sendmail"); $mailers = array('php','smtp','sendmail');
foreach($mailers as $opt) foreach($mailers as $opt)
{ {
$sel = ($pref['mailer'] == $opt) ? "selected='selected'" : ""; $sel = ($pref['mailer'] == $opt) ? "selected='selected'" : "";
@@ -1105,7 +1108,6 @@ $text = "
<input type='checkbox' name='smtp_useVERP' value='1' {$checked} /> <input type='checkbox' name='smtp_useVERP' value='1' {$checked} />
</td> </td>
</tr> </tr>
</table></div>"; </table></div>";
@@ -1196,7 +1198,7 @@ $text = "
</div></form>"; </div></form>";
$caption = LAN_PREFS; $caption = LAN_PREFS;
$ns->tablerender($caption, $text); $e107->ns->tablerender($caption, $text);
} }