[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/pm/pm.php,v $ 14 | $Revision: 1.22 $ 15 | $Date: 2006/12/30 12:41:34 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 $retrieve_prefs[] = 'pm_prefs'; 21 require_once ("../../class2.php"); 22 require_once(e_PLUGIN."pm/pm_class.php"); 23 require_once(e_PLUGIN."pm/pm_func.php"); 24 $lan_file = e_PLUGIN."pm/languages/".e_LANGUAGE.".php"; 25 include_once(is_readable($lan_file) ? $lan_file : e_PLUGIN."pm/languages/English.php"); 26 27 define("ATTACHMENT_ICON", "<img src='".e_PLUGIN."pm/images/attach.png' alt='' />"); 28 29 $qs = explode(".", e_QUERY); 30 $action = $qs[0]; 31 if($action == "") { $action = 'inbox'; } 32 $pm_prefs = $sysprefs->getArray("pm_prefs"); 33 34 if(!isset($pm_prefs['pm_class']) || !check_class($pm_prefs['pm_class'])) 35 { 36 require_once(HEADERF); 37 $ns->tablerender(LAN_PM, LAN_PM_12); 38 require_once(FOOTERF); 39 exit; 40 } 41 42 $pm =& new private_message; 43 $message = ""; 44 $pm_prefs['perpage'] = intval($pm_prefs['perpage']); 45 if($pm_prefs['perpage'] == 0) 46 { 47 $pm_prefs['perpage'] = 10; 48 } 49 //Auto-delete message, if timeout set in admin 50 $del_qry = array(); 51 $read_timeout = intval($pm_prefs['read_timeout']); 52 $unread_timeout = intval($pm_prefs['unread_timeout']); 53 if($read_timeout > 0) 54 { 55 $timeout = time()-($read_timeout * 60); 56 $del_qry[] = "(pm_sent < {$timeout} AND pm_read > 0)"; 57 } 58 if($unread_timeout > 0) 59 { 60 $timeout = time()-($unread_timeout * 60); 61 $del_qry[] = "(pm_sent < {$timeout} AND pm_read = 0)"; 62 } 63 if(count($del_qry) > 0) 64 { 65 $qry = implode(" OR ", $del_qry); 66 if($sql->db_Select("private_msg", "pm_id", $qry)) 67 { 68 $delList = $sql->db_getList(); 69 foreach($delList as $p) 70 { 71 $pm->del($p['pm_id']); 72 } 73 } 74 } 75 76 if("del" == $action || isset($_POST['pm_delete_selected'])) 77 { 78 if(isset($_POST['pm_delete_selected'])) 79 { 80 foreach(array_keys($_POST['selected_pm']) as $id) 81 { 82 $message .= LAN_PM_24.": $id <br />"; 83 $message .= $pm->del($id); 84 } 85 } 86 if('del' == $action) 87 { 88 $message = $pm->del(intval($qs[1])); 89 } 90 if($qs[2] != "") 91 { 92 $action = $qs[2]; 93 } 94 else 95 { 96 if(substr($_SERVER['HTTP_REFERER'], -5) == "inbox") 97 { 98 $action = "inbox"; 99 } 100 if(substr($_SERVER['HTTP_REFERER'], -6) == "outbox") 101 { 102 $action = "outbox"; 103 } 104 } 105 unset($qs); 106 } 107 108 if('block' == $action) 109 { 110 $message = $pm->block_add(intval($qs[1])); 111 $action = 'inbox'; 112 } 113 114 if('unblock' == $action) 115 { 116 $message = $pm->block_del(intval($qs[1])); 117 $action = 'inbox'; 118 } 119 120 if("get" == $action) 121 { 122 $pm->send_file(intval($qs[1]), intval($qs[2])); 123 exit; 124 } 125 126 require_once(HEADERF); 127 128 if(isset($_POST['postpm'])) 129 { 130 $message = post_pm(); 131 $action = 'outbox'; 132 } 133 134 if($message != "") 135 { 136 $ns->tablerender("", $message); 137 } 138 139 if("send" == $action) 140 { 141 $ns->tablerender(LAN_PM, show_send(intval($qs[1]))); 142 } 143 144 if("reply" == $action) 145 { 146 $pmid = intval($qs[1]); 147 if($pm_info = $pm->pm_get($pmid)) 148 { 149 if($pm_info['pm_to'] != USERID) 150 { 151 $ns->tablerender(LAN_PM, LAN_PM_56); 152 } 153 else 154 { 155 $ns->tablerender(LAN_PM, show_send()); 156 } 157 } 158 else 159 { 160 $ns->tablerender(LAN_PM, LAN_PM_57); 161 } 162 } 163 164 if("inbox" == $action) 165 { 166 $ns->tablerender(LAN_PM." - ".LAN_PM_25, show_inbox(intval($qs[1])), "PM"); 167 } 168 169 if("outbox" == $action) 170 { 171 $ns->tablerender(LAN_PM." - ".LAN_PM_26, show_outbox(intval($qs[1])), "PM"); 172 } 173 174 if("show" == $action) 175 { 176 show_pm(intval($qs[1])); 177 } 178 179 require_once(FOOTERF); 180 exit; 181 182 function show_send($to_uid) 183 { 184 global $tp, $pm_info; 185 $pm_outbox = pm_getInfo('outbox'); 186 if($to_uid) 187 { 188 $sql2 =& new db; 189 if($sql2->db_Select('user', 'user_name', "user_id = '".intval($to_uid)."'")) 190 { 191 $row=$sql2->db_Fetch(); 192 $pm_info['from_name'] = $row['user_name']; 193 } 194 } 195 196 if($pm_outbox['outbox']['filled'] >= 100) 197 { 198 return str_replace('{PERCENT}', $pm_outbox['outbox']['filled'], LAN_PM_13); 199 } 200 require_once(e_PLUGIN."pm/pm_shortcodes.php"); 201 $tpl_file = THEME."pm_template.php"; 202 include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN."pm/pm_template.php"); 203 $enc = (check_class($pm_prefs['attach_class']) ? "enctype='multipart/form-data'" : ""); 204 $text = "<form {$enc} method='post' action='".e_SELF."' id='dataform'> 205 <div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />". 206 $tp->parseTemplate($PM_SEND_PM, TRUE, $pm_shortcodes). 207 "</div></form>"; 208 return $text; 209 } 210 211 function show_inbox($start = 0) 212 { 213 global $pm, $tp, $pm_shortcodes, $pm_info, $pm_blocks, $pmlist, $pm_start, $pm_prefs; 214 $pm_start = $start; 215 require_once(e_PLUGIN."pm/pm_shortcodes.php"); 216 $tpl_file = THEME."pm_template.php"; 217 include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN."pm/pm_template.php"); 218 $pm_blocks = $pm->block_get(); 219 $pmlist = $pm->pm_get_inbox(USERID, $pm_start, $pm_prefs['perpage']); 220 $txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>"; 221 $txt .= $tp->parseTemplate($PM_INBOX_HEADER, true, $pm_shortcodes); 222 if($pmlist['total_messages']) 223 { 224 foreach($pmlist['messages'] as $rec) 225 { 226 if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = "[".LAN_PM_61."]"; } 227 $pm_info = $rec; 228 $txt .= $tp->parseTemplate($PM_INBOX_TABLE, true, $pm_shortcodes); 229 } 230 } 231 else 232 { 233 $txt .= $tp->parseTemplate($PM_INBOX_EMPTY, true, $pm_shortcodes); 234 } 235 $txt .= $tp->parseTemplate($PM_INBOX_FOOTER, true, $pm_shortcodes); 236 $txt .= "</form>"; 237 return $txt; 238 } 239 240 function show_outbox($start = 0) 241 { 242 global $pm, $tp, $pm_shortcodes, $pm_info, $pm_start, $pm_prefs, $pmlist; 243 $pm_start = $start; 244 require_once(e_PLUGIN."pm/pm_shortcodes.php"); 245 $tpl_file = THEME."pm_template.php"; 246 include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN."pm/pm_template.php"); 247 $pmlist = $pm->pm_get_outbox(USERID, $pm_start, $pm_prefs['perpage']); 248 $txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>"; 249 $txt .= $tp->parseTemplate($PM_OUTBOX_HEADER, true, $pm_shortcodes); 250 if($pmlist['total_messages']) 251 { 252 foreach($pmlist['messages'] as $rec) 253 { 254 if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = "[".LAN_PM_61."]"; } 255 $pm_info = $rec; 256 $txt .= $tp->parseTemplate($PM_OUTBOX_TABLE, true, $pm_shortcodes); 257 } 258 } 259 else 260 { 261 $txt .= $tp->parseTemplate($PM_OUTBOX_EMPTY, true, $pm_shortcodes); 262 } 263 $txt .= $tp->parseTemplate($PM_OUTBOX_FOOTER, true, $pm_shortcodes); 264 $txt .= "</form>"; 265 return $txt; 266 } 267 268 function show_pm($pmid) 269 { 270 global $pm, $tp, $pm_shortcodes, $pm_info, $ns; 271 require_once(e_PLUGIN."pm/pm_shortcodes.php"); 272 $tpl_file = THEME."pm_template.php"; 273 include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN."pm/pm_template.php"); 274 $pm_info = $pm->pm_get($pmid); 275 if($pm_info['pm_to'] != USERID && $pm_info['pm_from'] != USERID) 276 { 277 $ns->tablerender(LAN_PM, LAN_PM_60); 278 require_once(FOOTERF); 279 exit; 280 } 281 if($pm_info['pm_read'] == 0 && $pm_info['pm_to'] == USERID) 282 { 283 $now = time(); 284 $pm_info['pm_read'] = $now; 285 $pm->pm_mark_read($pmid, $pm_info); 286 } 287 $txt .= $tp->parseTemplate($PM_SHOW, true, $pm_shortcodes); 288 $ns -> tablerender(LAN_PM, $txt); 289 if($pm_info['pm_from'] == USERID) { 290 $ns->tablerender(LAN_PM." - ".LAN_PM_26, show_outbox(intval($qs[1])), "PM"); 291 } 292 else 293 { 294 $ns->tablerender(LAN_PM." - ".LAN_PM_25, show_inbox(intval($qs[1])), "PM"); 295 } 296 } 297 298 function post_pm() 299 { 300 global $pm_prefs, $pm, $pref, $sql, $tp; 301 if(!check_class($pm_prefs['pm_class'])) 302 { 303 return LAN_PM_12; 304 } 305 306 $pm_info = pm_getInfo('outbox'); 307 if($pm_info['outbox']['total'] != $_POST['numsent']) 308 { 309 return LAN_PM_14; 310 } 311 312 if(isset($_POST['user'])) 313 { 314 $_POST['pm_to'] = $_POST['user']; 315 } 316 if(isset($_POST['pm_to'])) 317 { 318 $msg = ""; 319 if(isset($_POST['to_userclass']) && $_POST['to_userclass']) 320 { 321 if(!$pm_prefs['allow_userclass']) 322 { 323 return LAN_PM_15; 324 } 325 elseif(!check_class($_POST['pm_userclass']) && !ADMIN) 326 { 327 return LAN_PM_16; 328 } 329 } 330 else 331 { 332 $to_array = explode("\n", trim($_POST['pm_to'])); 333 foreach($to_array as $k => $v) 334 { 335 $to_array[$k] = trim($v); 336 } 337 $to_array = array_unique($to_array); 338 if(count($to_array) == 1) 339 { 340 $_POST['pm_to'] = $to_array[0]; 341 } 342 if(check_class($pm_prefs['multi_class']) && count($to_array) > 1) 343 { 344 foreach($to_array as $to) 345 { 346 if($to_info = $pm->pm_getuid($to)) 347 { 348 if(!$sql->db_Update("private_msg_block","pm_block_count=pm_block_count+1 WHERE pm_block_from = '".USERID."' AND pm_block_to = '".$tp -> toDB($to)."'")) 349 { 350 $_POST['to_array'][] = $to_info; 351 } 352 } 353 } 354 } 355 else 356 { 357 if($to_info = $pm->pm_getuid($_POST['pm_to'])) 358 { 359 $_POST['to_info'] = $to_info; 360 } 361 else 362 { 363 return LAN_PM_17; 364 } 365 366 if($sql->db_Update("private_msg_block","pm_block_count=pm_block_count+1 WHERE pm_block_from = '".USERID."' AND pm_block_to = '{$to_info['user_id']}'")) 367 { 368 return LAN_PM_18.$to_info['user_name']; 369 } 370 } 371 } 372 373 if(isset($_POST['receipt'])) 374 { 375 if(!check_class($pm_prefs['receipt_class'])) 376 { 377 unset($_POST['receipt']); 378 } 379 } 380 $totalsize = strlen($_POST['pm_message']); 381 $maxsize = intval($pm_prefs['attach_size']) * 1024; 382 foreach(array_keys($_FILES['file_userfile']['size']) as $fid) 383 { 384 if($maxsize > 0 && $_FILES['file_userfile']['size'][$fid] > $maxsize) 385 { 386 $msg .= str_replace("{FILENAME}", $_FILES['file_userfile']['name'][$fid], LAN_PM_62)."<br />"; 387 $_FILES['file_userfile']['size'][$fid] = 0; 388 } 389 $totalsize += $_FILES['file_userfile']['size'][$fid]; 390 } 391 392 if(intval($pref['pm_limit']) > 0) 393 { 394 if($pref['pm_limit'] == '1') 395 { 396 if($pm_info['outbox']['total'] == $pm_info['outbox']['limit']) 397 { 398 return LAN_PM_19; 399 } 400 } 401 else 402 { 403 if($pm_info['outbox']['size'] + $totalsize > $pm_info['outbox']['limit']) 404 { 405 return LAN_PM_21; 406 } 407 } 408 } 409 410 if($_FILES['file_userfile']['name'][0]) 411 { 412 if(check_class($pm_prefs['attach_class'])) 413 { 414 require_once(e_HANDLER."upload_handler.php"); 415 $randnum = rand(1000, 9999); 416 $_POST['uploaded'] = file_upload(e_PLUGIN."pm/attachments", "attachment", $randnum."_"); 417 if($_POST['uploaded'] == FALSE) 418 { 419 unset($_POST['uploaded']); 420 $msg .= LAN_PM_22."<br />"; 421 } 422 } 423 else 424 { 425 $msg .= LAN_PM_23."<br />"; 426 unset($_POST['uploaded']); 427 } 428 } 429 $_POST['from_id'] = USERID; 430 return $msg.$pm->add($_POST); 431 } 432 } 433 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |