[ 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_viewtopic.php,v $ 14 | $Revision: 1.72 $ 15 | $Date: 2006/11/19 22:41:55 $ 16 | $Author: mcfly_e107 $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 require_once ('../../class2.php'); 21 22 include_once e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_viewtopic.php'; 23 include_once e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php'; 24 include_once(e_PLUGIN.'forum/forum_class.php'); 25 26 27 if (file_exists(THEME.'forum_design.php')) 28 { 29 include_once(THEME.'forum_design.php'); 30 } 31 32 $forum = new e107forum; 33 if (isset($_POST['fjsubmit'])) 34 { 35 header("location:".e_PLUGIN."forum/forum_viewforum.php?".$_POST['forumjump']); 36 exit; 37 } 38 $highlight_search = FALSE; 39 if (isset($_POST['highlight_search'])) 40 { 41 $highlight_search = TRUE; 42 } 43 44 if (!e_QUERY) 45 { 46 //No paramters given, redirect to forum home 47 header("Location:".e_PLUGIN."forum/forum.php"); 48 exit; 49 } 50 else 51 { 52 $tmp = explode(".", e_QUERY); 53 $thread_id = varset($tmp[0]); 54 $topic_from = varset($tmp[1], 0); 55 $action = varset($tmp[2]); 56 if (!$thread_id || !is_numeric($thread_id)) 57 { 58 header("Location:".e_PLUGIN."forum/forum.php"); 59 exit; 60 } 61 } 62 63 if($topic_from === 'post') 64 { 65 if($thread_id) 66 { 67 $post_num = $forum->thread_postnum($thread_id); 68 $pages = ceil(($post_num['post_num']+1)/$pref['forum_postspage']); 69 $topic_from = ($pages-1) * $pref['forum_postspage']; 70 if($post_num['parent'] != $thread_id) 71 { 72 header("location: ".e_SELF."?{$post_num['parent']}.{$topic_from}#post_{$thread_id}"); 73 exit; 74 } 75 } 76 else 77 { 78 header("Location:".e_PLUGIN."forum/forum.php"); 79 exit; 80 } 81 } 82 83 require_once(e_PLUGIN.'forum/forum_shortcodes.php'); 84 85 if ($action == "track" && USER) 86 { 87 $forum->track($thread_id); 88 header("location:".e_SELF."?{$thread_id}.{$topic_from}"); 89 exit; 90 } 91 92 if ($action == "untrack" && USER) 93 { 94 $forum->untrack($thread_id); 95 header("location:".e_SELF."?{$thread_id}.{$topic_from}"); 96 exit; 97 } 98 99 if ($action == "next") 100 { 101 $next = $forum->thread_getnext($thread_id, $topic_from); 102 if ($next) 103 { 104 header("location:".e_SELF."?{$next}"); 105 exit; 106 } 107 else 108 { 109 require_once(HEADERF); 110 $ns->tablerender('', LAN_405, array('forum_viewtopic', '405')); 111 require_once(FOOTERF); 112 exit; 113 } 114 } 115 116 if ($action == "prev") { 117 $prev = $forum->thread_getprev($thread_id, $topic_from); 118 if ($prev) { 119 header("location:".e_SELF."?{$prev}"); 120 exit; 121 } else { 122 require_once(HEADERF); 123 $ns->tablerender('', LAN_404, array('forum_viewtopic', '404')); 124 require_once(FOOTERF); 125 exit; 126 } 127 128 } 129 130 if ($action == "report") { 131 $thread_info = $forum->thread_get_postinfo($thread_id, TRUE); 132 133 if (isset($_POST['report_thread'])) { 134 $report_add = $tp -> toDB($_POST['report_add']); 135 if ($pref['reported_post_email']) { 136 require_once(e_HANDLER."mail.php"); 137 $report = LAN_422.SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/").$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_id.".post\n".LAN_425.USERNAME."\n".$report_add; 138 $subject = LAN_421." ".SITENAME; 139 sendemail(SITEADMINEMAIL, $subject, $report); 140 } 141 $sql->db_Insert('generic', "0, 'reported_post', ".time().", '".USERID."', '{$thread_info['head']['thread_name']}', ".intval($thread_id).", '{$report_add}'"); 142 define("e_PAGETITLE", LAN_01." / ".LAN_428); 143 require_once(HEADERF); 144 $text = LAN_424."<br /><br /><a href='forum_viewtopic.php?".$thread_id.".post'>".LAN_429."</a"; 145 $ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report')); 146 } else { 147 $thread_name = $tp -> toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'); 148 define("e_PAGETITLE", LAN_01." / ".LAN_426." ".$thread_name); 149 require_once(HEADERF); 150 $text = "<form action='".e_PLUGIN."forum/forum_viewtopic.php?".e_QUERY."' method='post'> <table style='width:100%'> 151 <tr> 152 <td style='width:50%' > 153 ".LAN_415.": ".$thread_name." <a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_id.".post'><span class='smalltext'>".LAN_420." </span> 154 </a> 155 </td> 156 <td style='text-align:center;width:50%'> 157 </td> 158 </tr> 159 <tr> 160 <td>".LAN_417."<br />".LAN_418." 161 </td> 162 <td style='text-align:center;'> 163 <textarea cols='40' rows='10' class='tbox' name='report_add'></textarea> 164 </td> 165 </tr> 166 <tr> 167 <td colspan='2' style='text-align:center;'><br /> 168 <input class='button' type='submit' name='report_thread' value='".LAN_419."' /> 169 </td> 170 </tr> 171 </table>"; 172 $ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2')); 173 } 174 require_once(FOOTERF); 175 exit; 176 } 177 $pm_installed = ($pref['pm_title'] ? TRUE : FALSE); 178 179 $replies = $forum->thread_count($thread_id)-1; 180 if ($topic_from === 'last') { 181 $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); 182 $pages = ceil(($replies+1)/$pref['forum_postspage']); 183 $topic_from = ($pages-1) * $pref['forum_postspage']; 184 } 185 $gen = new convert; 186 $thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']); 187 188 if(intval($thread_info['head']['thread_forum_id']) == 0) 189 { 190 require_once(HEADERF); 191 $ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104')); 192 require_once(FOOTERF); 193 exit; 194 } 195 $forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']); 196 197 198 if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) { 199 header("Location:".e_PLUGIN."forum/forum.php"); 200 exit; 201 } 202 203 $forum->thread_incview($thread_id); 204 205 define("e_PAGETITLE", LAN_01." / ".$tp->toHTML($forum_info['forum_name'], TRUE, 'no_hook, emotes_off')." / ".$tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off')); 206 //define("MODERATOR", (preg_match("/".preg_quote(ADMINNAME)."/", $forum_info['forum_moderators']) && getperms('A') ? TRUE : FALSE)); 207 define("MODERATOR", $forum_info['forum_moderators'] != "" && check_class($forum_info['forum_moderators'])); 208 $modArray = $forum->forum_getmods($forum_info['forum_moderators']); 209 210 $message = ''; 211 if (MODERATOR) 212 { 213 if ($_POST) 214 { 215 require_once(e_PLUGIN.'forum/forum_mod.php'); 216 $message = forum_thread_moderate($_POST); 217 $thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']); 218 } 219 } 220 221 require_once(HEADERF); 222 require_once(e_HANDLER."level_handler.php"); 223 if ($message) 224 { 225 $ns->tablerender("", $message, array('forum_viewtopic', 'msg')); 226 } 227 228 if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]")) 229 { 230 if(!defined("POLLCLASS")) 231 { 232 require(e_PLUGIN."poll/poll_class.php"); 233 } 234 $_qry = "SELECT * FROM #polls WHERE `poll_datestamp` = '{$thread_info['head']['thread_id']}'"; 235 $poll = new poll; 236 $pollstr = "<div class='spacer'>".$poll->render_poll($_qry, "forum", "query", TRUE)."</div>"; 237 } 238 //Load forum templates 239 240 if (!$FORUMSTART) { 241 if (file_exists(THEME."forum_viewtopic_template.php")) 242 { 243 require_once(THEME."forum_viewtopic_template.php"); 244 } 245 else if (file_exists(THEME."forum_template.php")) 246 { 247 require_once(THEME."forum_template.php"); 248 } 249 else 250 { 251 require_once(e_PLUGIN."forum/templates/forum_viewtopic_template.php"); 252 } 253 } 254 255 $forum_info['forum_name'] = $tp -> toHTML($forum_info['forum_name'], TRUE,'no_hook,emotes_off'); 256 257 // get info for main thread ------------------------------------------------------------------------------------------------------------------------------------------------------------------- 258 259 $forum->set_crumb(TRUE); // Set $BREADCRUMB (and BACKLINK) 260 $THREADNAME = $tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'); 261 $NEXTPREV = "<< <a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.prev'>".LAN_389."</a>"; 262 $NEXTPREV .= " | "; 263 $NEXTPREV .= "<a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.next'>".LAN_390."</a> >>"; 264 265 if ($pref['forum_track'] && USER) 266 { 267 $TRACK = (strpos(USERREALM, "-".$thread_id."-") !== FALSE ? "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."untrack'>".LAN_392."</a></span>" : "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."track'>".LAN_391."</a></span>"); 268 } 269 270 $MODERATORS = LAN_321.implode(", ", $modArray); 271 272 $THREADSTATUS = (!$thread_info['head']['thread_active'] ? LAN_66 : ""); 273 274 $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10); 275 $pages = ceil(($replies+1)/$pref['forum_postspage']); 276 if ($pages > 1) 277 { 278 $parms = ($replies+1).",{$pref['forum_postspage']},{$topic_from},".e_SELF.'?'.$thread_id.'.[FROM],off'; 279 $GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}"); 280 } 281 282 if ((check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass'])) || MODERATOR) 283 { 284 if ($thread_info['head']['thread_active']) 285 { 286 $BUTTONS = "<a href='".e_PLUGIN."forum/forum_post.php?rp.".e_QUERY."'>".IMAGE_reply."</a>"; 287 } 288 $BUTTONS .= "<a href='".e_PLUGIN."forum/forum_post.php?nt.".$forum_info['forum_id']."'>".IMAGE_newthread."</a>"; 289 } 290 291 $POLL = $pollstr; 292 293 $FORUMJUMP = forumjump(); 294 295 $forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART); 296 297 unset($forrep); 298 if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE; 299 $alt = FALSE; 300 for($i = 0; $i < count($thread_info)-1; $i++) 301 { 302 unset($post_info); 303 $post_info = $thread_info[$i]; 304 $loop_uid = intval($post_info['user_id']); 305 if (!$post_info['thread_user']) 306 { 307 // guest 308 $tmp = explode(chr(1), $post_info['thread_anon']); 309 $ip = $tmp[1]; 310 $host = $e107->get_host_name($ip); 311 $post_info['iphost'] = "<div class='smalltext' style='text-align:right'>IP: <a href='".e_ADMIN."userinfo.php?$ip'>$ip ( $host )</a></div>"; 312 $post_info['anon'] = TRUE; 313 } 314 else 315 { 316 $post_info['anon'] = FALSE; 317 } 318 $e_hide_query = "SELECT thread_id FROM #forum_t WHERE (`thread_parent` = {$thread_id} OR `thread_id` = {$thread_id}) AND SUBSTRING_INDEX(thread_user,'.',1) = ".USERID; 319 $e_hide_hidden = FORLAN_HIDDEN; 320 $e_hide_allowed = USER; 321 322 if($post_info['thread_parent']) 323 { 324 $alt = !$alt; 325 if(isset($FORUMREPLYSTYLE_ALT) && $alt) 326 { 327 $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE_ALT, TRUE, $forum_shortcodes)."\n"; 328 } 329 else 330 { 331 $forrep .= $tp->parseTemplate($FORUMREPLYSTYLE, TRUE, $forum_shortcodes)."\n"; 332 } 333 } 334 else 335 { 336 $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, TRUE, $forum_shortcodes)."\n"; 337 } 338 } 339 unset($loop_uid); 340 341 if (((check_class($forum_info['forum_postclass']) && check_class($forum_info['parent_postclass'])) || MODERATOR) && $thread_info['head']['thread_active'] ) 342 { 343 if (!$forum_quickreply) 344 { 345 $QUICKREPLY = "<form action='".e_PLUGIN."forum/forum_post.php?rp.".e_QUERY."' method='post'>\n<p>\n".LAN_393.":<br /><textarea cols='60' rows='4' class='tbox' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea><br /><input type='submit' name='fpreview' value='".LAN_394."' class='button' /> \n<input type='submit' name='reply' value='".LAN_395."' class='button' />\n<input type='hidden' name='thread_id' value='$thread_parent' />\n</p>\n</form>"; 346 } 347 else 348 { 349 $QUICKREPLY = $forum_quickreply; 350 } 351 } 352 353 $forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND); 354 $forumstring = $forstr.$forthr.$forrep.$forend; 355 356 357 if ($thread_info['head']['thread_lastpost'] > USERLV && (strpos(USERVIEWED, ".{$thread_info['head']['thread_id']}.") === FALSE)) { 358 $tst = $forum->thread_markasread($thread_info['head']['thread_id']); 359 } 360 361 if ($pref['forum_enclose']) { 362 $ns->tablerender(LAN_01, $forumstring, array('forum_viewtopic', 'main')); 363 } else { 364 echo $forumstring; 365 } 366 367 368 // end ------------------------------------------------------------------------------------------------------------------------------------------------------------------- 369 370 echo "<script type=\"text/javascript\"> 371 function confirm_(mode, forum_id, thread_id, thread) { 372 if (mode == 'thread') { 373 return confirm(\"".$tp->toJS(LAN_409)."\"); 374 } else { 375 return confirm(\"".$tp->toJS(LAN_410)." [ ".$tp->toJS(LAN_411)."\" + thread + \" ]\"); 376 } 377 } 378 </script>"; 379 require_once(FOOTERF); 380 381 function showmodoptions() 382 { 383 global $thread_id; 384 global $thread_info; 385 global $forum_info; 386 global $post_info; 387 $forum_id = $forum_info['forum_id']; 388 if ($post_info['thread_parent'] == FALSE) 389 { 390 $type = 'thread'; 391 $ret = "<form method='post' action='".e_PLUGIN."forum/forum_viewforum.php?{$forum_id}' id='frmMod_{$forum_id}_{$post_info['thread_id']}'>"; 392 } 393 else 394 { 395 $type = 'reply'; 396 $ret = "<form method='post' action='".e_SELF."?".e_QUERY."' id='frmMod_{$forum_id}_{$post_info['thread_id']}'>"; 397 } 398 399 $ret .= " 400 <div> 401 <a href='".e_PLUGIN."forum/forum_post.php?edit.{$post_info['thread_id']}.{$topic_from}'>".IMAGE_admin_edit."</a> 402 <input type='image' ".IMAGE_admin_delete." name='delete_{$post_info['thread_id']}' value='thread_action' onclick=\"return confirm_('{$type}', {$forum_id}, {$thread_id}, '{$post_info['user_name']}')\" /> 403 "; 404 if ($type == 'thread') 405 { 406 $ret .= "<a href='".e_PLUGIN."forum/forum_conf.php?move.{$thread_id}'>".IMAGE_admin_move2."</a>"; 407 } 408 $ret .= " 409 </div> 410 </form>"; 411 return $ret; 412 } 413 414 function forumjump() 415 { 416 417 global $forum; 418 $jumpList = $forum->forum_get_allowed(); 419 $text = "<form method='post' action='".e_SELF."'><p>".LAN_65.": <select name='forumjump' class='tbox'>"; 420 foreach($jumpList as $key => $val) 421 { 422 $text .= "\n<option value='".$key."'>".$val."</option>"; 423 } 424 $text .= "</select> <input class='button' type='submit' name='fjsubmit' value='".LAN_03."' /> <a href='".e_SELF."?".e_QUERY."#top' onclick=\"window.scrollTo(0,0);\">".LAN_10."</a></p></form>"; 425 return $text; 426 } 427 428 function rpg($user_join, $user_forums) 429 { 430 global $FORUMTHREADSTYLE; 431 if (strpos($FORUMTHREADSTYLE, '{RPG}') == FALSE) 432 { 433 return ''; 434 } 435 // rpg mod by Ikari ( kilokan1@yahoo.it | http://artemanga.altervista.org ) 436 437 $lvl_post_mp_cost = 2.5; 438 $lvl_mp_regen_per_day = 4; 439 $lvl_avg_ppd = 5; 440 $lvl_bonus_redux = 5; 441 $lvl_user_days = max(1, round((time() - $user_join ) / 86400 )); 442 $lvl_ppd = $user_forums / $lvl_user_days; 443 if ($user_forums < 1) { 444 $lvl_level = 0; 445 } else { 446 $lvl_level = floor(pow(log10($user_forums ), 3 ) ) + 1; 447 } 448 if ($lvl_level < 1) { 449 $lvl_hp = "0 / 0"; 450 $lvl_hp_percent = 0; 451 } else { 452 $lvl_max_hp = floor((pow($lvl_level, (1/4) ) ) * (pow(10, pow($lvl_level+2, (1/3) ) ) ) / (1.5) ); 453 454 if ($lvl_ppd >= $lvl_avg_ppd) { 455 $lvl_hp_percent = floor((.5 + (($lvl_ppd - $lvl_avg_ppd) / ($lvl_bonus_redux * 2)) ) * 100); 456 } else { 457 $lvl_hp_percent = floor($lvl_ppd / ($lvl_avg_ppd / 50) ); 458 } 459 if ($lvl_hp_percent > 100) { 460 $lvl_max_hp += floor(($lvl_hp_percent - 100) * pi() ); 461 $lvl_hp_percent = 100; 462 } else { 463 $lvl_hp_percent = max(0, $lvl_hp_percent); 464 } 465 $lvl_cur_hp = floor($lvl_max_hp * ($lvl_hp_percent / 100) ); 466 $lvl_cur_hp = max(0, $lvl_cur_hp); 467 $lvl_cur_hp = min($lvl_max_hp, $lvl_cur_hp); 468 $lvl_hp = $lvl_cur_hp . '/' . $lvl_max_hp; 469 } 470 if ($lvl_level < 1) { 471 $lvl_mp = '0 / 0'; 472 $lvl_mp_percent = 0; 473 } else { 474 $lvl_max_mp = floor((pow($lvl_level, (1/4) ) ) * (pow(10, pow($lvl_level+2, (1/3) ) ) ) / (pi()) ); 475 $lvl_mp_cost = $user_forums * $lvl_post_mp_cost; 476 $lvl_mp_regen = max(1, $lvl_user_days * $lvl_mp_regen_per_day); 477 $lvl_cur_mp = floor($lvl_max_mp - $lvl_mp_cost + $lvl_mp_regen); 478 $lvl_cur_mp = max(0, $lvl_cur_mp); 479 $lvl_cur_mp = min($lvl_max_mp, $lvl_cur_mp); 480 $lvl_mp = $lvl_cur_mp . '/' . $lvl_max_mp; 481 $lvl_mp_percent = floor($lvl_cur_mp / $lvl_max_mp * 100 ); 482 } 483 if ($lvl_level < 1) { 484 $lvl_exp = "0 / 0"; 485 $lvl_exp_percent = 100; 486 } else { 487 $lvl_posts_for_next = floor(pow(10, pow($lvl_level, (1/3) ) ) ); 488 if ($lvl_level == 1) { 489 $lvl_posts_for_this = max(1, floor(pow (10, (($lvl_level - 1) ) ) ) ); 490 } else { 491 $lvl_posts_for_this = max(1, floor(pow (10, pow(($lvl_level - 1), (1/3) ) ) ) ); 492 } 493 $lvl_exp = ($user_forums - $lvl_posts_for_this) . "/" . ($lvl_posts_for_next - $lvl_posts_for_this); 494 $lvl_exp_percent = floor((($user_forums - $lvl_posts_for_this) / max(1, ($lvl_posts_for_next - $lvl_posts_for_this ) ) ) * 100); 495 } 496 497 $bar_image = THEME."images/bar.jpg"; 498 if(!is_readable($bar_image)) 499 { 500 $bar_image = e_PLUGIN."forum/images/".IMODE."/bar.jpg"; 501 } 502 503 $rpg_info .= "<div style='padding:2px; white-space:nowrap'>"; 504 $rpg_info .= "<b>Level = ".$lvl_level."</b><br />"; 505 $rpg_info .= "HP = ".$lvl_hp."<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:".$lvl_hp_percent."%'><br />"; 506 $rpg_info .= "EXP = ".$lvl_exp."<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:".$lvl_exp_percent."%'><br />"; 507 $rpg_info .= "MP = ".$lvl_mp."<br /><img src='{$bar_image}' alt='' style='border:#345487 1px solid; height:10px; width:".$lvl_mp_percent."%'><br />"; 508 $rpg_info .= "</div>"; 509 return $rpg_info; 510 } 511 512 ?>
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 |