[geeklog-cvs] geeklog-1.3/public_html/admin mail.php,1.21,1.22
dhaun at iowaoutdoors.org
dhaun at iowaoutdoors.org
Wed Jul 14 14:35:01 EDT 2004
Update of /var/cvs/geeklog-1.3/public_html/admin
In directory www:/tmp/cvs-serv19089
Modified Files:
mail.php
Log Message:
Bugfix: The From and Reply-To were ignored - emails were always sent with the site name and site mail settings.
Also did some source code cleanup and beautifying.
Index: mail.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/admin/mail.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** mail.php 17 Jan 2004 20:38:27 -0000 1.21
--- mail.php 14 Jul 2004 18:34:57 -0000 1.22
***************
*** 11,15 ****
// | Copyright (C) 2001-2004 by the following authors: |
// | |
! // | Authors: Tony Bibbs - tony at tonybibbs.com |
// +---------------------------------------------------------------------------+
// | |
--- 11,16 ----
// | Copyright (C) 2001-2004 by the following authors: |
// | |
! // | Authors: Tony Bibbs - tony at tonybibbs.com |
! // | Dirk Haun - dirk at haun-online.de |
// +---------------------------------------------------------------------------+
// | |
***************
*** 32,45 ****
// $Id$
! // Set this to true to get various debug messages from this script
! $_MAIL_VERBOSE = false;
!
! require_once('../lib-common.php');
! require_once('auth.inc.php');
$display = '';
// Make sure user has access to this page
! if (!SEC_inGroup('Mail Admin') && !SEC_hasrights('user.mail')) {
$retval .= COM_siteHeader ('menu');
$retval .= COM_startBlock ($MESSAGE[30], '',
--- 33,43 ----
// $Id$
! require_once ('../lib-common.php');
! require_once ('auth.inc.php');
$display = '';
// Make sure user has access to this page
! if (!SEC_inGroup ('Mail Admin') && !SEC_hasrights ('user.mail')) {
$retval .= COM_siteHeader ('menu');
$retval .= COM_startBlock ($MESSAGE[30], '',
***************
*** 48,52 ****
$retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
$retval .= COM_siteFooter ();
! COM_accessLog("User {$_USER['username']} tried to illegally access the mail administration screen.");
echo $retval;
exit;
--- 46,50 ----
$retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
$retval .= COM_siteFooter ();
! COM_accessLog ("User {$_USER['username']} tried to illegally access the mail administration screen.");
echo $retval;
exit;
***************
*** 57,80 ****
* you can only email an entire group.
*
*/
! function display_form()
{
! global $_CONF, $_USER, $_LANG31, $PHP_SELF, $LANG31, $_TABLES;
$retval = '';
! $mail_templates = new Template($_CONF['path_layout'] . 'admin/mail');
! $mail_templates->set_file(array('form'=>'mailform.thtml'));
! $mail_templates->set_var('site_url', $_CONF['site_url']);
! $mail_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
$mail_templates->set_var ('startblock_email', COM_startBlock ($LANG31[1],
'', COM_getBlockTemplate ('_admin_block', 'header')));
! $mail_templates->set_var('php_self', $PHP_SELF);
! $mail_templates->set_var('lang_note', $LANG31[19]);
! $mail_templates->set_var('lang_to', $LANG31[18]);
! $mail_templates->set_var('lang_selectgroup', $LANG31[25]);
$group_options = '';
$result = DB_query("SELECT grp_id, grp_name FROM {$_TABLES['groups']} WHERE grp_name <> 'All Users'");
! $nrows = DB_numRows($result);
$groups = array ();
for ($i = 0; $i < $nrows; $i++) {
--- 55,80 ----
* you can only email an entire group.
*
+ * @return string HTML for the email form
+ *
*/
! function display_form ()
{
! global $_CONF, $_TABLES, $_USER, $LANG31, $PHP_SELF;
$retval = '';
! $mail_templates = new Template ($_CONF['path_layout'] . 'admin/mail');
! $mail_templates->set_file (array ('form' => 'mailform.thtml'));
! $mail_templates->set_var ('site_url', $_CONF['site_url']);
! $mail_templates->set_var ('site_admin_url', $_CONF['site_admin_url']);
$mail_templates->set_var ('startblock_email', COM_startBlock ($LANG31[1],
'', COM_getBlockTemplate ('_admin_block', 'header')));
! $mail_templates->set_var ('php_self', $PHP_SELF);
! $mail_templates->set_var ('lang_note', $LANG31[19]);
! $mail_templates->set_var ('lang_to', $LANG31[18]);
! $mail_templates->set_var ('lang_selectgroup', $LANG31[25]);
$group_options = '';
$result = DB_query("SELECT grp_id, grp_name FROM {$_TABLES['groups']} WHERE grp_name <> 'All Users'");
! $nrows = DB_numRows ($result);
$groups = array ();
for ($i = 0; $i < $nrows; $i++) {
***************
*** 87,109 ****
. '</option>';
}
! $mail_templates->set_var('group_options', $group_options);
! $mail_templates->set_var('lang_from', $LANG31[2]);
! $mail_templates->set_var('site_name', $_CONF['site_name']);
! $mail_templates->set_var('lang_replyto', $LANG31[3]);
! $mail_templates->set_var('site_mail', $_CONF['site_mail']);
! $mail_templates->set_var('lang_subject', $LANG31[4]);
! $mail_templates->set_var('lang_body', $LANG31[5]);
! $mail_templates->set_var('lang_sendto', $LANG31[6]);
! $mail_templates->set_var('lang_allusers', $LANG31[7]);
! $mail_templates->set_var('lang_admin', $LANG31[8]);
! $mail_templates->set_var('lang_options', $LANG31[9]);
! $mail_templates->set_var('lang_HTML', $LANG31[10]);
! $mail_templates->set_var('lang_urgent', $LANG31[11]);
! $mail_templates->set_var('lang_ignoreusersettings', $LANG31[14]);
! $mail_templates->set_var('lang_send', $LANG31[12]);
$mail_templates->set_var ('end_block', COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
! $mail_templates->parse('output','form');
! $retval = $mail_templates->finish($mail_templates->get_var('output'));
return $retval;
--- 87,109 ----
. '</option>';
}
! $mail_templates->set_var ('group_options', $group_options);
! $mail_templates->set_var ('lang_from', $LANG31[2]);
! $mail_templates->set_var ('site_name', $_CONF['site_name']);
! $mail_templates->set_var ('lang_replyto', $LANG31[3]);
! $mail_templates->set_var ('site_mail', $_CONF['site_mail']);
! $mail_templates->set_var ('lang_subject', $LANG31[4]);
! $mail_templates->set_var ('lang_body', $LANG31[5]);
! $mail_templates->set_var ('lang_sendto', $LANG31[6]);
! $mail_templates->set_var ('lang_allusers', $LANG31[7]);
! $mail_templates->set_var ('lang_admin', $LANG31[8]);
! $mail_templates->set_var ('lang_options', $LANG31[9]);
! $mail_templates->set_var ('lang_HTML', $LANG31[10]);
! $mail_templates->set_var ('lang_urgent', $LANG31[11]);
! $mail_templates->set_var ('lang_ignoreusersettings', $LANG31[14]);
! $mail_templates->set_var ('lang_send', $LANG31[12]);
$mail_templates->set_var ('end_block', COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
! $mail_templates->parse ('output', 'form');
! $retval = $mail_templates->finish ($mail_templates->get_var ('output'));
return $retval;
***************
*** 113,130 ****
* This function actually sends the messages to the specified group
*
! * @vars array Is the same is $HTTP_POST_VARS and hold all the email info
*
*/
! function send_messages($vars)
{
! global $_CONF, $LANG31, $_TABLES, $LANG_CHARSET;
$retval = '';
! if (empty($vars['fra']) OR empty($vars['fraepost']) OR empty($vars['subject'])
! OR empty($vars['message']) OR empty($vars['to_group'])) {
! echo $LANG31[26];
! exit;
! }
// Urgent message!
--- 113,136 ----
* This function actually sends the messages to the specified group
*
! * @param array $vars Same as $HTTP_POST_VARS, holds all the email info
! * @return string HTML with success or error message
*
*/
! function send_messages ($vars)
{
! global $_CONF, $_TABLES, $LANG31;
$retval = '';
! if (empty ($vars['fra']) OR empty ($vars['fraepost']) OR
! empty ($vars['subject']) OR empty ($vars['message']) OR
! empty ($vars['to_group'])) {
! $retval .= COM_startBlock ($LANG31[1], '',
! COM_getBlockTemplate ('_msg_block', 'header'));
! $retval .= $LANG31[26];
! $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
!
! return $retval;
! }
// Urgent message!
***************
*** 142,203 ****
}
! // and now mail it
! if (!isset($vars['overstyr'])) {
! $sql = "SELECT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1";
! $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1";
$sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id = {$vars['to_group']}";
! }
! if (isset($vars['overstyr'])) {
! $sql = "SELECT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1";
! $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id = {$vars['to_group']}";
! }
! $sendttil = '';
! $result = DB_query($sql);
! $nrows = DB_numRows($result);
// Loop through and send the messages!
! $successes = array();
! $failures = array();
! for ($i = 1;$i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $til = '';
! if (!isset($A['fullname'])) {
! $til .= $A['username'];
! } else {
! $til .= $A['fullname'];
! }
! $til .= '<' . $A['email'] . '>';
! $sendttil .= $til . '<br>';
! if (!COM_mail ($A['email'], COM_stripslashes ($vars['subject']),
! COM_stripslashes ($vars['message']), '', $html, $priority)) {
! $failures[] .= $til;
} else {
! $successes[] = $til;
}
! }
! $failcount = count($failures);
! $successcount = count($successes);
! $mailresult = str_replace('<successcount>',$successcount,$LANG31[20]);
! $retval .= str_replace('<failcount>',$failcount,$mailresult);
! $retval .= "<h2>{$LANG31[21]}</h2>";
! for ($i = 1; $i <= count($failures); $i++) {
! $retval .= current($failures) . '<br>';
! next($failures);
! }
! if (count($failures) == 0) {
$retval .= $LANG31[23];
! }
! $retval .= "<h2>{$LANG31[22]}</h2>";
! for ($i = 1; $i <= count($successes); $i++) {
! $retval .= current($successes) . '<br>';
! next($successes);
! }
! if (count($successes) == 0) {
$retval .= $LANG31[24];
! }
return $retval;
--- 148,214 ----
}
! // and now mail it
! if (isset ($vars['overstyr'])) {
! $sql = "SELECT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1";
! $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id = {$vars['to_group']}";
! } else {
! $sql = "SELECT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1";
! $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1";
$sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id = {$vars['to_group']}";
! }
! $result = DB_query ($sql);
! $nrows = DB_numRows ($result);
! $from = $vars['fra'] . ' <' . $vars['fraepost'] . '>';
! $subject = COM_stripslashes ($vars['subject']);
! $message = COM_stripslashes ($vars['message']);
// Loop through and send the messages!
! $successes = array ();
! $failures = array ();
! for ($i = 0; $i < $nrows; $i++) {
! $A = DB_fetchArray ($result);
! $to = '';
! if (!isset ($A['fullname'])) {
! $to .= $A['username'];
! } else {
! $to .= $A['fullname'];
! }
! $to .= ' <' . $A['email'] . '>';
! if (!COM_mail ($to, $subject, $message, $from, $html, $priority)) {
! $failures[] .= $to;
} else {
! $successes[] = $to;
}
! }
! $retval .= COM_startBlock ($LANG31[1]);
!
! $failcount = count ($failures);
! $successcount = count ($successes);
! $mailresult = str_replace ('<successcount>', $successcount, $LANG31[20]);
! $retval .= str_replace ('<failcount>', $failcount, $mailresult);
!
! $retval .= '<h2>' . $LANG31[21] . '</h2>';
! for ($i = 0; $i < count ($failures); $i++) {
! $retval .= current ($failures) . '<br>';
! next ($failures);
! }
! if (count ($failures) == 0) {
$retval .= $LANG31[23];
! }
!
! $retval .= '<h2>' . $LANG31[22] . '</h2>';
! for ($i = 0; $i < count ($successes); $i++) {
! $retval .= current ($successes) . '<br>';
! next ($successes);
! }
! if (count ($successes) == 0) {
$retval .= $LANG31[24];
! }
!
! $retval .= COM_endBlock ();
return $retval;
***************
*** 206,218 ****
// MAIN
! $display .= COM_siteHeader();
if (isset ($HTTP_POST_VARS['mail']) && ($HTTP_POST_VARS['mail'] == 'mail')) {
! $display .= send_messages($HTTP_POST_VARS);
} else {
! $display .= display_form();
}
! $display .= COM_siteFooter();
echo $display;
--- 217,229 ----
// MAIN
! $display .= COM_siteHeader ();
if (isset ($HTTP_POST_VARS['mail']) && ($HTTP_POST_VARS['mail'] == 'mail')) {
! $display .= send_messages ($HTTP_POST_VARS);
} else {
! $display .= display_form ();
}
! $display .= COM_siteFooter ();
echo $display;
More information about the geeklog-cvs
mailing list