| [ 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/forum/forum.php,v $ 14 | $Revision: 1.39 $ 15 | $Date: 2006/11/07 16:19:10 $ 16 | $Author: lisa_ $ 17 +----------------------------------------------------------------------------+ 18 */ 19 if(!defined("e107_INIT")) { 20 require_once ("../../class2.php"); 21 } 22 23 include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum.php'); 24 25 require_once(e_PLUGIN.'forum/forum_class.php'); 26 $forum = new e107forum; 27 28 if (strstr(e_QUERY, "untrack")) 29 { 30 $tmp1 = explode(".", e_QUERY); 31 $tmp = str_replace("-".$tmp1[1]."-", "", USERREALM); 32 $sql->db_Update("user", "user_realm='".$tp -> toDB($tmp, true)."' WHERE user_id='".USERID."' "); 33 header("location:".e_SELF."?track"); 34 exit; 35 } 36 37 //Mark all threads as read 38 if (e_QUERY == "mark.all.as.read") 39 { 40 $forum->forum_markasread('all'); 41 header("location:".e_SELF); 42 exit; 43 } 44 45 //Mark all threads in specific forum as read 46 if (strstr(e_QUERY, 'mfar')) 47 { 48 $tmp = explode(".", e_QUERY); 49 $forum_id = intval($tmp[1]); 50 $forum->forum_markasread($forum_id); 51 header("location:".e_SELF); 52 exit; 53 } 54 55 if (e_QUERY == 'rules') 56 { 57 include_once(HEADERF); 58 forum_rules('show'); 59 include_once(FOOTERF); 60 exit; 61 } 62 63 $gen = new convert; 64 65 $FORUMTITLE = LAN_46; 66 $THREADTITLE = LAN_47; 67 $REPLYTITLE = LAN_48; 68 $LASTPOSTITLE = LAN_49; 69 $INFOTITLE = LAN_191; 70 $LOGO = IMAGE_e; 71 $NEWTHREADTITLE = LAN_424; 72 $POSTEDTITLE = LAN_423; 73 $NEWIMAGE = IMAGE_new_small; 74 $TRACKTITLE = LAN_397; 75 76 $rules_text = forum_rules('check'); 77 $USERINFO = "<a href='".e_BASE."top.php?0.top.forum.10'>".LAN_429."</a> | <a href='".e_BASE."top.php?0.active'>".LAN_430."</a>"; 78 if(USER) 79 { 80 $USERINFO .= " | <a href='".e_BASE."userposts.php?0.forums.".USERID."'>".LAN_431."</a> | <a href='".e_BASE."usersettings.php'>".LAN_432."</a> | <a href='".e_BASE."user.php?id.".USERID."'>".LAN_435."</a>"; 81 if($pref['forum_attach'] && (check_class($pref['upload_class']) || getperms('0'))) 82 { 83 $USERINFO .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".FORLAN_442."</a>"; 84 } 85 } 86 if($rules_text != '') 87 { 88 $USERINFO .= " | <a href='".e_PLUGIN."forum/forum.php?rules'>".LAN_433."</a>"; 89 } 90 $total_topics = $sql->db_Count("forum_t", "(*)", " WHERE thread_parent='0' "); 91 $total_replies = $sql->db_Count("forum_t", "(*)", " WHERE thread_parent!='0' "); 92 $total_members = $sql->db_Count("user"); 93 $newest_member = $sql->db_Select("user", "*", "user_ban='0' ORDER BY user_join DESC LIMIT 0,1"); 94 list($nuser_id, $nuser_name) = $sql->db_Fetch(); 95 if(!defined("e_TRACKING_DISABLED")) 96 { 97 $member_users = $sql->db_Select("online", "*", "online_location REGEXP('forum.php') AND online_user_id!='0' "); 98 $guest_users = $sql->db_Select("online", "*", "online_location REGEXP('forum.php') AND online_user_id='0' "); 99 $users = $member_users+$guest_users; 100 $USERLIST = LAN_426; 101 global $listuserson; 102 $c = 0; 103 if(is_array($listuserson)) 104 { 105 foreach($listuserson as $uinfo => $pinfo) 106 { 107 list($oid, $oname) = explode(".", $uinfo, 2); 108 $c ++; 109 $USERLIST .= "<a href='".e_BASE."user.php?id.$oid'>$oname</a>".($c == MEMBERS_ONLINE ? "." :", "); 110 } 111 } 112 $USERLIST .= "<br /><a rel='external' href='".e_BASE."online.php'>".LAN_427."</a> ".LAN_436; 113 } 114 $STATLINK = "<a href='".e_PLUGIN."forum/forum_stats.php'>".LAN_441."</a>\n"; 115 $ICONKEY = " 116 <table style='width:100%'>\n<tr> 117 <td style='width:2%'>".IMAGE_new_small."</td> 118 <td style='width:10%'><span class='smallblacktext'>".LAN_79."</span></td> 119 <td style='width:2%'>".IMAGE_nonew_small."</td> 120 <td style='width:10%'><span class='smallblacktext'>".LAN_80."</span></td> 121 <td style='width:2%'>".IMAGE_closed_small."</td> 122 <td style='width:10%'><span class='smallblacktext'>".LAN_394."</span></td> 123 </tr>\n</table>\n"; 124 125 $SEARCH = " 126 <form method='get' action='".e_BASE."search.php'> 127 <p> 128 <input class='tbox' type='text' name='q' size='20' value='' maxlength='50' /> 129 <input type='hidden' name='r' value='0' /> 130 <input type='hidden' name='ref' value='forum' /> 131 <input class='button' type='submit' name='s' value='".LAN_180."' /> 132 </p> 133 </form>\n"; 134 135 $PERMS = (USER == TRUE || ANON == TRUE ? LAN_204." - ".LAN_206." - ".LAN_208 : LAN_205." - ".LAN_207." - ".LAN_209); 136 137 $INFO = ""; 138 if (USER == TRUE) 139 { 140 $total_new_threads = $sql->db_Count('forum_t', '(*)', "WHERE thread_datestamp>'".USERLV."' "); 141 if (USERVIEWED != "") 142 { 143 $tmp = explode("..", USERVIEWED); 144 $total_read_threads = count($tmp); 145 } 146 else 147 { 148 $total_read_threads = 0; 149 } 150 151 $INFO = LAN_30." ".USERNAME."<br />"; 152 $lastvisit_datestamp = $gen->convert_date(USERLV, 'long'); 153 $datestamp = $gen->convert_date(time(), "long"); 154 if (!$total_new_threads) 155 { 156 $INFO .= LAN_31; 157 } 158 elseif($total_new_threads == 1) 159 { 160 $INFO .= LAN_32; 161 } 162 else 163 { 164 $INFO .= LAN_33." ".$total_new_threads." ".LAN_34." "; 165 } 166 $INFO .= LAN_35; 167 if ($total_new_threads == $total_read_threads && $total_new_threads != 0 && $total_read_threads >= $total_new_threads) 168 { 169 $INFO .= LAN_198; 170 $allread = TRUE; 171 } 172 elseif($total_read_threads != 0) 173 { 174 $INFO .= " (".LAN_196.$total_read_threads.LAN_197.")"; 175 } 176 177 $INFO .= "<br /> 178 ".LAN_36." ".$lastvisit_datestamp."<br /> 179 ".LAN_37." ".$datestamp; 180 } 181 else 182 { 183 $INFO .= ""; 184 if (ANON == TRUE) 185 { 186 $INFO .= LAN_410."<br />".LAN_44." <a href='".e_SIGNUP."'>".LAN_437."</a> ".LAN_438; 187 } 188 elseif(USER == FALSE) 189 { 190 $INFO .= LAN_410."<br />".LAN_45." <a href='".e_SIGNUP."'>".LAN_439."</a> ".LAN_440; 191 } 192 } 193 194 if (USER && $allread != TRUE && $total_new_threads && $total_new_threads >= $total_read_threads) 195 { 196 $INFO .= "<br /><a href='".e_SELF."?mark.all.as.read'>".LAN_199."</a>".(e_QUERY != "new" ? ", <a href='".e_SELF."?new'>".LAN_421."</a>" : ""); 197 } 198 199 if (USER && USERREALM && e_QUERY != "track") 200 { 201 $INFO .= "<br /><a href='".e_SELF."?track'>".LAN_393."</a>"; 202 } 203 204 $FORUMINFO = LAN_192.($total_topics+$total_replies)." ".LAN_404." ($total_topics ".($total_topics == 1 ? LAN_411 : LAN_413).", $total_replies ".($total_replies == 1 ? LAN_412 : LAN_414).").".(!defined("e_TRACKING_DISABLED") ? "" : "<br />".$users." ".($users == 1 ? LAN_415 : LAN_416)." (".$member_users." ".($member_users == 1 ? LAN_417 : LAN_419).", ".$guest_users." ".($guest_users == 1 ? LAN_418 : LAN_420).")<br />".LAN_42.$total_members."<br />".LAN_41."<a href='".e_BASE."user.php?id.".$nuser_id."'>".$nuser_name."</a>.\n"); 205 206 if (!isset($FORUM_MAIN_START)) 207 { 208 if (file_exists(THEME."forum_template.php")) 209 { 210 include_once(THEME."forum_template.php"); 211 } 212 } 213 include(e_PLUGIN."forum/templates/forum_template.php"); 214 require_once(HEADERF); 215 216 $parent_list = $forum->forum_getparents(); 217 $forum_list = $forum->forum_getforums(); 218 $sub_list = $forum->forum_getsubs(); 219 $newflag_list = $forum->forum_newflag_list(); 220 221 if (!$parent_list) 222 { 223 $ns->tablerender(PAGE_NAME, "<div style='text-align:center'>".LAN_51."</div>", array('forum', '51')); 224 require_once(FOOTERF); 225 exit; 226 } 227 228 $forum_string = ""; 229 foreach ($parent_list as $parent) { 230 $status = parse_parent($parent); 231 $PARENTSTATUS = $status[0]; 232 if ($status[1]) { 233 $PARENTNAME = $parent['forum_name']; 234 $forum_string .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_PARENT); 235 // $forums = $forum->forum_getforums($parent['forum_id']); 236 if (!count($forum_list[$parent['forum_id']])) 237 { 238 $text .= "<td colspan='5' style='text-align:center' class='forumheader3'>".LAN_52."</td>"; 239 } 240 else 241 { 242 foreach($forum_list[$parent['forum_id']] as $f) 243 { 244 if ($f['forum_class'] == e_UC_ADMIN && ADMIN) 245 { 246 $forum_string .= parse_forum($f, LAN_406); 247 } 248 elseif($f['forum_class'] == e_UC_MEMBER && USER) 249 { 250 $forum_string .= parse_forum($f, LAN_407); 251 } 252 elseif($f['forum_class'] == e_UC_READONLY) 253 { 254 $forum_string .= parse_forum($f, LAN_408); 255 } 256 elseif($f['forum_class'] && check_class($f['forum_class'])) 257 { 258 $forum_string .= parse_forum($f, LAN_409); 259 } 260 elseif(!$f['forum_class']) 261 { 262 $forum_string .= parse_forum($f); 263 } 264 } 265 if (isset($FORUM_MAIN_PARENT_END)) 266 { 267 $forum_string .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_PARENT_END); 268 } 269 } 270 } 271 } 272 273 function parse_parent($parent) 274 { 275 if(check_class($parent['forum_class'])) 276 { 277 $status[0]=""; 278 $status[1] = TRUE; 279 if(!check_class($parent['forum_postclass'])) 280 { 281 $status[0] = "( ".LAN_405." )"; 282 } 283 } 284 else 285 { 286 $status[1] = FALSE; 287 } 288 return $status; 289 } 290 291 function parse_forum($f, $restricted_string = "") 292 { 293 global $FORUM_MAIN_FORUM, $gen, $forum, $tp, $newflag_list, $sub_list; 294 295 if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list)) 296 { 297 $NEWFLAG = "<a href='".e_SELF."?mfar.{$f['forum_id']}'>".IMAGE_new."</a>"; 298 } 299 else 300 { 301 $NEWFLAG = IMAGE_nonew; 302 } 303 304 if(substr($f['forum_name'], 0, 1) == "*") 305 { 306 $f['forum_name'] = substr($f['forum_name'], 1); 307 } 308 $f['forum_name'] = $tp -> toHTML($f['forum_name'], TRUE, "no_hook"); 309 $f['forum_description'] = $tp -> toHTML($f['forum_description'], TRUE, "no_hook"); 310 311 $FORUMNAME = "<a href='".e_PLUGIN."forum/forum_viewforum.php?{$f['forum_id']}'>{$f['forum_name']}</a>"; 312 $FORUMDESCRIPTION = $f['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : ""); 313 $THREADS = $f['forum_threads']; 314 $REPLIES = $f['forum_replies']; 315 $FORUMSUBFORUMS = ""; 316 317 if(is_array($sub_list[$f['forum_parent']][$f['forum_id']])) 318 { 319 list($lastpost_datestamp, $lastpost_thread) = explode(".", $f['forum_lastpost_info']); 320 $ret = parse_subs($sub_list[$f['forum_parent']][$f['forum_id']], $lastpost_datestamp); 321 $FORUMSUBFORUMS = "<br /><div class='smalltext'>".FORLAN_444.": {$ret['text']}</div>"; 322 $THREADS += $ret['threads']; 323 $REPLIES += $ret['replies']; 324 if(isset($ret['lastpost_info'])) 325 { 326 $f['forum_lastpost_info'] = $ret['lastpost_info']; 327 $f['user_name'] = $ret['user_name']; 328 } 329 } 330 331 if ($f['forum_lastpost_user']) 332 { 333 list($lastpost_datestamp, $lastpost_thread) = explode(".", $f['forum_lastpost_info']); 334 $tmp = explode(".", $f['forum_lastpost_user'], 2); 335 if ($f['user_name']) 336 { 337 $lastpost_name = "<a href='".e_BASE."user.php?id.{$tmp[0]}'>{$f['user_name']}</a>"; 338 } 339 else 340 { 341 if(!$tmp[1]) 342 { 343 $lastpost_name = FORLAN_443; 344 } 345 else 346 { 347 $lastpost_name = $tp->toHTML($tmp[1]); 348 } 349 } 350 $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); 351 $LASTPOST = $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".e_PLUGIN."forum/forum_viewtopic.php?{$lastpost_thread}.last'>".IMAGE_post2.'</a>'; 352 } 353 else 354 { 355 $LASTPOST = "-"; 356 } 357 return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_FORUM)); 358 } 359 360 function parse_subs($subList, $lastpost_datestamp) 361 { 362 $ret = array(); 363 $ret['text'] = ""; 364 foreach($subList as $sub) 365 { 366 $ret['text'] .= ($ret['text'] ? ", " : ""); 367 $ret['text'] .= "<a href='".e_PLUGIN."forum/forum_viewforum.php?{$sub['forum_id']}'>{$sub['forum_name']}</a>"; 368 $ret['threads'] += $sub['forum_threads']; 369 $ret['replies'] += $sub['forum_replies']; 370 $tmp = explode(".", $sub['forum_lastpost_info']); 371 if($tmp[0] > $lastpost_datestamp) 372 { 373 $ret['lastpost_info'] = $sub['forum_lastpost_info']; 374 $ret['user_name'] = $sub['user_name']; 375 $lastpost_datestamp = $tmp[0]; 376 } 377 } 378 return $ret; 379 } 380 381 if (e_QUERY == "track") 382 { 383 $sql2 = new db; 384 $tmp = explode("-", USERREALM); 385 foreach($tmp as $key => $value) 386 { 387 if ($value) 388 { 389 if($sql->db_Select("forum_t", "thread_id, thread_datestamp, thread_name", "thread_id='".intval($value)."' ")) 390 { 391 $row = $sql->db_Fetch(); 392 //extract($row); 393 $NEWIMAGE = IMAGE_nonew_small; 394 if ($row['thread_datestamp'] > USERLV && (strpos(USERVIEWED, ".".$row['thread_id'].".") === FALSE)) 395 { 396 $NEWIMAGE = IMAGE_new_small; 397 } 398 elseif($sql2->db_SELECT("forum_t", "thread_id", "thread_parent='{$row['thread_id']}' AND thread_datestamp > '".USERLV."' ")) 399 { 400 while ($xrow = $sql2->db_Fetch()) 401 { 402 if (strpos(USERVIEWED, ".".$xrow['thread_id'].".") === FALSE) 403 { 404 $NEWIMAGE = IMAGE_new_small; 405 } 406 } 407 } 408 $result = preg_split("/\]/", $row['thread_name']); 409 $TRACKPOSTNAME = (($result[1] && $row['thread_name']{0} == "[") ? $result[0]."] <a href='".e_PLUGIN."forum/forum_viewtopic.php?{$row['thread_id']}'>".preg_replace("/\[.*\]/", "", $row['thread_name'])."</a>" : "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$row['thread_id']}'>".$row['thread_name']."</a>"); 410 $UNTRACK = "<a href='".e_SELF."?untrack.".$row['thread_id']."'>".LAN_392."</a>"; 411 $forum_trackstring .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_MAIN); 412 } 413 } 414 } 415 416 $forum_track_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_START); 417 $forum_track_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_TRACK_END); 418 419 if ($pref['forum_enclose']) 420 { 421 $ns->tablerender($pref['forum_title'], $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1')); 422 } 423 else 424 { 425 echo $forum_track_start.$forum_trackstring.$forum_track_end; 426 } 427 } 428 429 if (e_QUERY == "new") 430 { 431 $newpostList = $forum->post_getnew(10); 432 foreach($newpostList as $post) 433 { 434 list($author_id, $author_info) = explode(".", $post['thread_user'], 2); 435 list($author_name, $tmp) = explode(chr(1), $author_info); 436 $datestamp = $gen->convert_date($post['thread_datestamp'], "forum"); 437 if($author_id == 0) 438 { 439 $STARTERTITLE = $author_name."<br />".$datestamp; 440 } 441 else 442 { 443 $STARTERTITLE = "<a href='".e_BASE."user.php?id.$author_id'>$author_name</a><br />".$datestamp; 444 } 445 if($post['post_subject']) 446 { 447 $NEWSPOSTNAME = "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$post['thread_id']}.post'>".LAN_425.$tp->toHTML($post['post_subject'], TRUE, 'no_make_clickable, no_hook')."</a>"; 448 } 449 else 450 { 451 $NEWSPOSTNAME = "<a href='".e_PLUGIN."forum/forum_viewtopic.php?{$post['thread_id']}'>".$tp->toHTML($post['thread_name'], TRUE, 'no_make_clickable, no_hook')."</a>"; 452 } 453 454 $forum_newstring .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_MAIN); 455 } 456 457 if (!$newpostList) 458 { 459 $NEWSPOSTNAME = LAN_198; 460 $forum_newstring = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_MAIN); 461 } 462 $forum_new_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_START); 463 $forum_new_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_NEWPOSTS_END); 464 465 if ($pref['forum_enclose']) 466 { 467 $ns->tablerender($pref['forum_title'], $forum_new_start.$forum_newstring.$forum_new_end, array('forum', 'main2')); 468 } 469 else 470 { 471 echo $forum_new_start.$forum_newstring.$forum_new_end; 472 } 473 } 474 475 $forum_main_start = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_START); 476 $forum_main_end = preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_END); 477 if ($pref['forum_enclose']) 478 { 479 $ns->tablerender($pref['forum_title'], $forum_main_start.$forum_string.$forum_main_end, array('forum', 'main3')); 480 } 481 else 482 { 483 echo $forum_main_start.$forum_string.$forum_main_end; 484 } 485 require_once(FOOTERF); 486 487 function forum_rules($action = 'check') 488 { 489 global $tp, $sql, $ns; 490 if (ADMIN == TRUE) 491 { 492 $type = 'forum_rules_admin'; 493 } 494 elseif(USER == TRUE) 495 { 496 $type = 'forum_rules_member'; 497 } 498 else 499 { 500 $type = 'forum_rules_guest'; 501 } 502 $result = $sql->db_Select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1"); 503 if ($action == 'check') 504 { 505 if ($result) 506 { 507 return TRUE; 508 } 509 else 510 { 511 return FALSE; 512 } 513 } 514 if ($result) 515 { 516 $row = $sql->db_Fetch(); 517 $rules_text = $tp->toHTML($row['gen_chardata'], TRUE); 518 } 519 else 520 { 521 $rules_text = FORLAN_441; 522 } 523 $ns->tablerender(LAN_433, "<div style='text-align:center'>{$rules_text}</div>", array('forum', 'forum_rules')); 524 } 525 ?>
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 |