[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 3 /* Reminder: always indent with 4 spaces (no tabs). */ 4 // +---------------------------------------------------------------------------+ 5 // | Geeklog 1.4 | 6 // +---------------------------------------------------------------------------+ 7 // | mail.php | 8 // | | 9 // | Geeklog mail administration page. | 10 // +---------------------------------------------------------------------------+ 11 // | Copyright (C) 2001-2006 by the following authors: | 12 // | | 13 // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | 14 // | Dirk Haun - dirk AT haun-online DOT de | 15 // +---------------------------------------------------------------------------+ 16 // | | 17 // | This program is free software; you can redistribute it and/or | 18 // | modify it under the terms of the GNU General Public License | 19 // | as published by the Free Software Foundation; either version 2 | 20 // | of the License, or (at your option) any later version. | 21 // | | 22 // | This program is distributed in the hope that it will be useful, | 23 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 24 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 25 // | GNU General Public License for more details. | 26 // | | 27 // | You should have received a copy of the GNU General Public License | 28 // | along with this program; if not, write to the Free Software Foundation, | 29 // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 30 // | | 31 // +---------------------------------------------------------------------------+ 32 // 33 // $Id: mail.php,v 1.32 2006/02/26 18:12:10 dhaun Exp $ 34 35 require_once ('../lib-common.php'); 36 require_once ('auth.inc.php'); 37 38 $display = ''; 39 40 // Make sure user has access to this page 41 if (!SEC_inGroup ('Mail Admin') && !SEC_hasrights ('user.mail')) { 42 $retval .= COM_siteHeader ('menu', $MESSAGE[30]); 43 $retval .= COM_startBlock ($MESSAGE[30], '', 44 COM_getBlockTemplate ('_msg_block', 'header')); 45 $retval .= $MESSAGE[39]; 46 $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer')); 47 $retval .= COM_siteFooter (); 48 COM_accessLog ("User {$_USER['username']} tried to illegally access the mail administration screen."); 49 echo $retval; 50 exit; 51 } 52 53 /** 54 * Shows the form the admin uses to send Geeklog members a message. Right now 55 * you can only email an entire group. 56 * 57 * @return string HTML for the email form 58 * 59 */ 60 function display_form () 61 { 62 global $_CONF, $_TABLES, $_USER, $LANG31; 63 64 $retval = ''; 65 66 $mail_templates = new Template ($_CONF['path_layout'] . 'admin/mail'); 67 $mail_templates->set_file (array ('form' => 'mailform.thtml')); 68 $mail_templates->set_var ('site_url', $_CONF['site_url']); 69 $mail_templates->set_var ('site_admin_url', $_CONF['site_admin_url']); 70 $mail_templates->set_var ('layout_url', $_CONF['layout_url']); 71 $mail_templates->set_var ('startblock_email', COM_startBlock ($LANG31[1], 72 '', COM_getBlockTemplate ('_admin_block', 'header'))); 73 $mail_templates->set_var ('php_self', $_CONF['site_admin_url'] 74 . '/mail.php'); 75 $mail_templates->set_var ('lang_note', $LANG31[19]); 76 $mail_templates->set_var ('lang_to', $LANG31[18]); 77 $mail_templates->set_var ('lang_selectgroup', $LANG31[25]); 78 $group_options = ''; 79 $result = DB_query("SELECT grp_id, grp_name FROM {$_TABLES['groups']} WHERE grp_name <> 'All Users'"); 80 $nrows = DB_numRows ($result); 81 $groups = array (); 82 for ($i = 0; $i < $nrows; $i++) { 83 $A = DB_fetchArray ($result); 84 $groups[$A['grp_id']] = ucwords ($A['grp_name']); 85 } 86 asort ($groups); 87 foreach ($groups as $groupID => $groupName) { 88 $group_options .= '<option value="' . $groupID . '">' . $groupName 89 . '</option>'; 90 } 91 $mail_templates->set_var ('group_options', $group_options); 92 $mail_templates->set_var ('lang_from', $LANG31[2]); 93 $mail_templates->set_var ('site_name', $_CONF['site_name']); 94 $mail_templates->set_var ('lang_replyto', $LANG31[3]); 95 $mail_templates->set_var ('site_mail', $_CONF['site_mail']); 96 $mail_templates->set_var ('lang_subject', $LANG31[4]); 97 $mail_templates->set_var ('lang_body', $LANG31[5]); 98 $mail_templates->set_var ('lang_sendto', $LANG31[6]); 99 $mail_templates->set_var ('lang_allusers', $LANG31[7]); 100 $mail_templates->set_var ('lang_admin', $LANG31[8]); 101 $mail_templates->set_var ('lang_options', $LANG31[9]); 102 $mail_templates->set_var ('lang_HTML', $LANG31[10]); 103 $mail_templates->set_var ('lang_urgent', $LANG31[11]); 104 $mail_templates->set_var ('lang_ignoreusersettings', $LANG31[14]); 105 $mail_templates->set_var ('lang_send', $LANG31[12]); 106 $mail_templates->set_var ('end_block', COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'))); 107 108 $mail_templates->parse ('output', 'form'); 109 $retval = $mail_templates->finish ($mail_templates->get_var ('output')); 110 111 return $retval; 112 } 113 114 /** 115 * This function actually sends the messages to the specified group 116 * 117 * @param array $vars Same as $_POST, holds all the email info 118 * @return string HTML with success or error message 119 * 120 */ 121 function send_messages ($vars) 122 { 123 global $_CONF, $_TABLES, $LANG31; 124 125 $retval = ''; 126 127 if (empty ($vars['fra']) OR empty ($vars['fraepost']) OR 128 empty ($vars['subject']) OR empty ($vars['message']) OR 129 empty ($vars['to_group'])) { 130 $retval .= COM_startBlock ($LANG31[1], '', 131 COM_getBlockTemplate ('_msg_block', 'header')); 132 $retval .= $LANG31[26]; 133 $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer')); 134 135 return $retval; 136 } 137 138 // Urgent message! 139 if (isset ($vars['priority'])) { 140 $priority = 1; 141 } else { 142 $priority = 0; 143 } 144 145 // If you want to send html mail 146 if (isset ($vars['html'])) { 147 $html = true; 148 } else { 149 $html = false; 150 } 151 152 // and now mail it 153 if (isset ($vars['overstyr'])) { 154 $sql = "SELECT username,fullname,email FROM {$_TABLES['users']},{$_TABLES['group_assignments']} WHERE uid > 1"; 155 $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))"; 156 $sql .= " AND {$_TABLES['users']}.uid = ug_uid AND ug_main_grp_id = {$vars['to_group']}"; 157 } else { 158 $sql = "SELECT username,fullname,email,emailfromadmin FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['group_assignments']} WHERE {$_TABLES['users']}.uid > 1"; 159 $sql .= " AND {$_TABLES['users']}.status = 3 AND ((email is not null) and (email != ''))"; 160 $sql .= " AND {$_TABLES['users']}.uid = {$_TABLES['userprefs']}.uid AND emailfromadmin = 1"; 161 $sql .= " AND ug_uid = {$_TABLES['users']}.uid AND ug_main_grp_id = {$vars['to_group']}"; 162 } 163 164 $result = DB_query ($sql); 165 $nrows = DB_numRows ($result); 166 167 $from = COM_formatEmailAddress ($vars['fra'], $vars['fraepost']); 168 $subject = COM_stripslashes ($vars['subject']); 169 $message = COM_stripslashes ($vars['message']); 170 171 // Loop through and send the messages! 172 $successes = array (); 173 $failures = array (); 174 for ($i = 0; $i < $nrows; $i++) { 175 $A = DB_fetchArray ($result); 176 if (empty ($A['fullname'])) { 177 $to = COM_formatEmailAddress ($A['username'], $A['email']); 178 } else { 179 $to = COM_formatEmailAddress ($A['fullname'], $A['email']); 180 } 181 182 if (!COM_mail ($to, $subject, $message, $from, $html, $priority)) { 183 $failures[] = htmlspecialchars ($to); 184 } else { 185 $successes[] = htmlspecialchars ($to); 186 } 187 } 188 189 $retval .= COM_startBlock ($LANG31[1]); 190 191 $failcount = count ($failures); 192 $successcount = count ($successes); 193 $mailresult = str_replace ('<successcount>', $successcount, $LANG31[20]); 194 $retval .= str_replace ('<failcount>', $failcount, $mailresult); 195 196 $retval .= '<h2>' . $LANG31[21] . '</h2>'; 197 for ($i = 0; $i < count ($failures); $i++) { 198 $retval .= current ($failures) . '<br>'; 199 next ($failures); 200 } 201 if (count ($failures) == 0) { 202 $retval .= $LANG31[23]; 203 } 204 205 $retval .= '<h2>' . $LANG31[22] . '</h2>'; 206 for ($i = 0; $i < count ($successes); $i++) { 207 $retval .= current ($successes) . '<br>'; 208 next ($successes); 209 } 210 if (count ($successes) == 0) { 211 $retval .= $LANG31[24]; 212 } 213 214 $retval .= COM_endBlock (); 215 216 return $retval; 217 } 218 219 // MAIN 220 221 $display .= COM_siteHeader ('menu', $LANG31[1]); 222 223 if (isset ($_POST['mail']) && ($_POST['mail'] == 'mail')) { 224 $display .= send_messages ($_POST); 225 } else { 226 $display .= display_form (); 227 } 228 229 $display .= COM_siteFooter (); 230 231 echo $display; 232 233 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |