[ Index ] |
|
Code source de Phorum 5.1.25 |
1 <?php 2 3 //////////////////////////////////////////////////////////////////////////////// 4 // // 5 // Copyright (C) 2006 Phorum Development Team // 6 // http://www.phorum.org // 7 // // 8 // This program is free software. You can redistribute it and/or modify // 9 // it under the terms of either the current Phorum License (viewable at // 10 // phorum.org) or the Phorum License that was distributed with this file // 11 // // 12 // This program is distributed in the hope that it will be useful, // 13 // but WITHOUT ANY WARRANTY, without even the implied warranty of // 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // 15 // // 16 // You should have received a copy of the Phorum License // 17 // along with this program. // 18 //////////////////////////////////////////////////////////////////////////////// 19 20 if(!defined("PHORUM")) return; 21 22 function phorum_valid_email($email){ 23 $PHORUM = $GLOBALS["PHORUM"]; 24 25 $ret = false; 26 27 $email = trim($email); 28 29 if(preg_match('/^([a-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+(\.[a-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+)*)@(((([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))\.)*((([-a-z0-9]*[a-z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))$/i', $email)){ 30 if(!$PHORUM["dns_lookup"]){ 31 // format is valid 32 // don't look up mail server 33 $ret = true; 34 } elseif(function_exists('checkdnsrr')) { 35 36 $fulldomain = substr(strstr($email, "@"), 1)."."; 37 // check if a mailserver exists for the domain 38 if(checkdnsrr($fulldomain, "MX")) { 39 $ret = true; 40 } 41 42 // some hosts don't have an MX record, but accept mail themselves 43 if(!$ret){ 44 // default timeout of 60 seconds makes the user way too long 45 // in case of problems. 46 ini_set('default_socket_timeout', 10); 47 if(@fsockopen($fulldomain, 25)){ 48 $ret = true; 49 } 50 } 51 } else { 52 // bah, you must be using windows and we can't run real checks 53 $ret = true; 54 } 55 } 56 57 return $ret; 58 } 59 60 /** 61 * function for sending email to users, gets addresses-array and data-array 62 */ 63 function phorum_email_user($addresses, $data) 64 { 65 $PHORUM = $GLOBALS['PHORUM']; 66 67 if(!isset($data['from_address'])) { 68 $data['from_address'] = "\"".$PHORUM['system_email_from_name']."\" <".$PHORUM['system_email_from_address'].">"; 69 } 70 71 $mailmessage = $data['mailmessage']; 72 unset($data['mailmessage']); 73 $mailsubject = $data['mailsubject']; 74 unset($data['mailsubject']); 75 76 if(is_array($data) && count($data)) { 77 foreach(array_keys($data) as $key){ 78 if ($data[$key] === NULL || is_array($data[$key])) continue; 79 $mailmessage = str_replace("%$key%", $data[$key], $mailmessage); 80 $mailsubject = str_replace("%$key%", $data[$key], $mailsubject); 81 } 82 } 83 84 $num_addresses = count($addresses); 85 $from_address = $data['from_address']; 86 87 $hook_data = array( 88 'addresses' => $addresses, 89 'from' => $from_address, 90 'subject' => $mailsubject, 91 'body' => $mailmessage, 92 'bcc' => $PHORUM['use_bcc'] 93 ); 94 95 $send_messages = phorum_hook("send_mail", $hook_data); 96 97 if(isset($data["msgid"])){ 98 $msgid="\nMessage-ID: {$data['msgid']}"; 99 } else { 100 $msgid=""; 101 } 102 103 if($send_messages != 0 && $num_addresses > 0){ 104 $phorum_major_version = substr(PHORUM, 0, strpos(PHORUM, '.')); 105 $mailer = "Phorum" . $phorum_major_version; 106 $mailheader ="Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding: {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: $mailer$msgid\n"; 107 108 if(isset($PHORUM['use_bcc']) && $PHORUM['use_bcc'] && $num_addresses > 3){ 109 mail(" ", $mailsubject, $mailmessage, $mailheader."From: $from_address\nBCC: " . implode(",", $addresses)); 110 } else { 111 foreach($addresses as $address){ 112 mail($address, $mailsubject, $mailmessage, $mailheader."From: $from_address"); 113 } 114 } 115 } 116 117 return $num_addresses; 118 } 119 120 function phorum_email_pm_notice($message, $langusers) 121 { 122 $mail_data = array( 123 "pm_message_id" => $message["pm_message_id"], 124 "author" => $message["from_username"], 125 "subject" => $message["subject"], 126 "full_body" => $message["message"], 127 "plain_body" => wordwrap(phorum_strip_body($message["message"]),72), 128 "read_url" => phorum_get_url(PHORUM_PM_URL, "page=read", "pm_id=" . $message["pm_message_id"]), 129 ); 130 131 if (isset($_POST[PHORUM_SESSION_LONG_TERM])) { 132 // strip any auth info from the read url 133 $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]); 134 } 135 136 foreach ($langusers as $language => $users) 137 { 138 $PHORUM = $GLOBALS["PHORUM"]; 139 140 $language = basename($language); 141 142 if ( file_exists( "./include/lang/$language.php" ) ) { 143 include( "./include/lang/$language.php" ); 144 } else { 145 include("./include/lang/{$PHORUM['language']}.php"); 146 } 147 148 $mail_data["mailmessage"] = $PHORUM["DATA"]["LANG"]['PMNotifyMessage']; 149 $mail_data["mailsubject"] = $PHORUM["DATA"]["LANG"]['PMNotifySubject']; 150 151 $addresses = array(); 152 foreach ($users as $user) { 153 $addresses[] = $user["email"]; 154 } 155 156 phorum_email_user($addresses, $mail_data); 157 } 158 } 159 160 function phorum_email_notice($message) 161 { 162 $PHORUM=$GLOBALS["PHORUM"]; 163 164 // do we allow email-notification for that forum? 165 if(!$PHORUM['allow_email_notify']) { 166 return; 167 } 168 169 include_once ("./include/format_functions.php"); 170 171 $mail_users_full = phorum_db_get_subscribed_users($PHORUM['forum_id'], $message['thread'], PHORUM_SUBSCRIPTION_MESSAGE); 172 173 if (count($mail_users_full)) { 174 $mail_data = array( 175 "forumname" => strip_tags($PHORUM["DATA"]["NAME"]), 176 "forum_id" => $PHORUM['forum_id'], 177 "message_id" => $message['message_id'], 178 "author" => $message['author'], 179 "subject" => $message['subject'], 180 "full_body" => $message['body'], 181 "plain_body" => phorum_strip_body($message['body']), 182 "read_url" => phorum_get_url(PHORUM_READ_URL, $message['thread'], $message['message_id']), 183 "remove_url" => phorum_get_url(PHORUM_FOLLOW_URL, $message['thread'], "stop=1"), 184 "noemail_url" => phorum_get_url(PHORUM_FOLLOW_URL, $message['thread'], "noemail=1"), 185 "followed_threads_url" => phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_SUBSCRIPTION_THREADS), 186 "msgid" => $message["msgid"] 187 ); 188 if (isset($_POST[PHORUM_SESSION_LONG_TERM])) { 189 // strip any auth info from the read url 190 $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]); 191 $mail_data["remove_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["remove_url"]); 192 $mail_data["noemail_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["noemail_url"]); 193 $mail_data["followed_threads_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["followed_threads_url"]); 194 } 195 // go through the user-languages and send mail with their set lang 196 foreach($mail_users_full as $language => $mail_users) 197 { 198 $language = basename($language); 199 200 if ( file_exists( "./include/lang/$language.php" ) ) { 201 include( "./include/lang/$language.php" ); 202 } else { 203 include("./include/lang/{$PHORUM['language']}.php"); 204 } 205 $mail_data["mailmessage"] = $PHORUM["DATA"]["LANG"]['NewReplyMessage']; 206 $mail_data["mailsubject"] = $PHORUM["DATA"]["LANG"]['NewReplySubject']; 207 phorum_email_user($mail_users, $mail_data); 208 209 } 210 } 211 } 212 213 function phorum_email_moderators($message) 214 { 215 $PHORUM=$GLOBALS["PHORUM"]; 216 217 $mail_users = phorum_user_get_moderators($PHORUM['forum_id'],false,true); 218 219 if (count($mail_users)) { 220 include_once ("./include/format_functions.php"); 221 if($message["status"] > 0) { // just notification of a new message 222 $mailtext = $PHORUM["DATA"]["LANG"]['NewUnModeratedMessage']; 223 } else { // posts needing approval 224 $mailtext = $PHORUM["DATA"]["LANG"]['NewModeratedMessage']; 225 } 226 $mail_data = array( 227 "mailmessage" => $mailtext, 228 "mailsubject" => $PHORUM["DATA"]["LANG"]['NewModeratedSubject'], 229 "forumname" => strip_tags($PHORUM["DATA"]["NAME"]), 230 "forum_id" => $PHORUM['forum_id'], 231 "message_id" => $message['message_id'], 232 "author" => $message['author'], 233 "subject" => $message['subject'], 234 "full_body" => $message['body'], 235 "plain_body" => phorum_strip_body($message['body']), 236 "approve_url" => phorum_get_url(PHORUM_PREPOST_URL), 237 "read_url" => phorum_get_url(PHORUM_READ_URL, $message['thread'], $message['message_id']) 238 ); 239 if (isset($_POST[PHORUM_SESSION_LONG_TERM])) { 240 // strip any auth info from the read url 241 $mail_data["read_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["read_url"]); 242 $mail_data["approve_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["approve_url"]); 243 } 244 phorum_email_user($mail_users, $mail_data); 245 } 246 } 247 248 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:22:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |