| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:03:52 2008 ] | [ PluggedOut Nexus 0.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 #=========================================================================== 4 #= Project : PluggedOut Nexus 5 #= Version : 0.1 6 #= Author : Jonathan Beckett 7 #= Email : jonbeckett@pluggedout.com 8 #= Home : http://www.pluggedout.com/index.php?pk=dev_nexus 9 #= Support : http://www.pluggedout.com/development/forums/viewforum.php?f=24 10 #=========================================================================== 11 #= Copyright (c) 2005 Jonathan Beckett 12 #= You are free to use and modify this script as long as this header 13 #= section stays intact. This file is part of PluggedOut Nexus. 14 #= 15 #= This program is free software; you can redistribute it and/or modify 16 #= it under the terms of the GNU General Public License as published by 17 #= the Free Software Foundation; either version 2 of the License, or 18 #= (at your option) any later version. 19 #= 20 #= This program is distributed in the hope that it will be useful, 21 #= but WITHOUT ANY WARRANTY; without even the implied warranty of 22 #= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 #= GNU General Public License for more details. 24 #= 25 #= You should have received a copy of the GNU General Public License 26 #= along with BLOG files; if not, write to the Free Software 27 #= Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 #=========================================================================== 29 */ 30 31 32 include "./lib/session.php"; 33 include "./lib/config.php"; 34 include "./lib/database.php"; 35 include "./lib/misc.php"; 36 include "./lib/html.php"; 37 38 39 $html = html_page_start("Forums"); 40 41 // left hand side 42 $html .= html_menu_side(); 43 44 $html .= html_page_sep(); 45 46 // content 47 $html .= "<table border='0' cellspacing='0' cellpadding='0'><tr>" 48 ."<td><img src='images/forums.png' width='48' height='48' title='".$site_long_name." Forums'></td>" 49 ."<td width='5'> </td>" 50 ."<td><div class='title'>".$site_long_name." Forums (Prototype)</div></td>\n" 51 ."</tr></table>\n" 52 ."<p class='body'>Welcome to the Forums, where you can take part in public online discussions.</p>\n"; 53 54 55 // if action is not set, show the front page 56 if ($_GET["action"]==""){ 57 58 $html .= "<div style='padding:20px;'>\n"; 59 60 // list the forums themselves 61 $con = db_connect(); 62 $sql = "SELECT f.nSort,f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" 63 ." FROM nexus_forums f" 64 ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" 65 ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" 66 ." ORDER BY nSort DESC,cTitle"; 67 68 // start the common border 69 $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#aabbaa'>\n" 70 ."<tr><td bgcolor='#aabbaa' class='small'><b>Forum List</b></td></tr>\n" 71 ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; 72 73 $result = mysql_query($sql,$con); 74 if ($result!=false){ 75 if (mysql_num_rows($result)>0){ 76 77 $html .= "<table width='100%' border='0' cellspacing='1' cellpadding='3' bgcolor='#aabbaa'>\n"; 78 79 while ($row =@ mysql_fetch_array($result)){ 80 $html .= "<tr><td bgcolor='#ffffff'>\n" 81 ."<div class='large'><a class='link' href='forums.php?action=view_forum&forumid=".$row["nForumId"]."'>".stripslashes($row["cTitle"])."</a></div>\n" 82 ."<div class='small' style='padding-left:10px;'>Owner : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" 83 ."<div class='small' style='padding-left:10px;'>".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> on ".$row["dLastPost"]." <a href='forums.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" 84 ."<div class='normal' style='padding-left:10px;'>".stripslashes($row["cSummary"])."</div>\n" 85 ."<div class='small' style='padding-left:10px;'>Click <a href='forums.php?action=view_forum&forumid=".$row["nForumId"]."'>here</a> to visit the forum.</div>\n" 86 ."</td></tr>\n"; 87 } 88 89 $html .= "</table>\n"; 90 91 } else { 92 // no forums to list 93 } 94 } else { 95 $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; 96 } 97 98 // finish the common border 99 $html .= "</div></td></tr>\n" 100 ."</table>\n"; 101 102 103 $html .= "</div>\n"; 104 } 105 106 // if action is 'view_forum' show the topics in a forum 107 if ($_GET["action"]=="view_forum"){ 108 109 $con = db_connect(); 110 111 // get the user membertype 112 if ($_SESSION["nexus_userid"]!=""){ 113 $sql = "SELECT cType FROM nexus_forummembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$_GET["forumid"]; 114 $result = mysql_query($sql,$con); 115 if ($result!=false){ 116 if (mysql_num_rows($result)>0){ 117 $row = mysql_fetch_array($result); 118 $member_type = $row["cType"]; 119 } else { 120 // no records 121 $member_type=""; 122 } 123 } else { 124 // problem with SQL 125 $html .= "<div class='small'>Problem with SQL [".$sql."]</div>\n"; 126 } 127 } 128 129 130 // start putting the page together 131 $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#aabbaa'>\n" 132 ."<tr><td bgcolor='#aabbaa' class='small'><b>Forum Description</b></td></tr>\n" 133 ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; 134 135 // show the forum name 136 $sql = "SELECT f.nForumId,f.cType,f.cStatus,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" 137 ." FROM nexus_forums f" 138 ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" 139 ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" 140 ." WHERE nForumId=".$_GET["forumid"]; 141 142 $result = mysql_query($sql,$con); 143 if ($result!=false){ 144 if (mysql_num_rows($result)>0){ 145 146 $row = mysql_fetch_array($result); 147 148 switch($member_type){ 149 case "owner": 150 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post New Topic</b></a></div>"; 151 break; 152 case "moderator": 153 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post New Topic</b></a></div>"; 154 break; 155 case "member": 156 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$_GET["forumid"]."'><b>Post New Topic</b></a></div>"; 157 break; 158 case "pending": 159 $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>Your membership of this forum is pending approval of its owner.</div>"; 160 break; 161 case "banned": 162 $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</div>"; 163 break; 164 default: 165 switch($row["cType"]){ 166 case "open": // user is joined immediately on join request 167 $html_newtopic = "<div class='normal'><a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is an open forum<br>just click 'Join' to join.</div>"; 168 break; 169 case "managed": // user is added as pending on join request 170 $html_newtopic = "<div class='normal'><a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is a managed forum<br>click 'Join' to request membership.</div>"; 171 break; 172 } 173 break; 174 } 175 176 // figure out if the forum is open or not 177 if ($row["cStatus"]=="live"){ 178 179 $html .= "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td>"; 180 181 $html .= "<div class='large'>".stripslashes($row["cTitle"])." Forum</div>\n" 182 ."<div class='normal'>Owner : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" 183 ."<div class='small'> </div>\n" 184 ."<div class='normal'>".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> on ".$row["dLastPost"]." <a href='forums.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" 185 ."<div class='small'> </div>\n" 186 ."<div class='normal'>".stripslashes($row["cSummary"])."</div>\n"; 187 188 $html .= "</td><td align='center' valign='bottom' width='150'>"; 189 190 if ($_SESSION["nexus_userid"]!=""){ 191 $html .= $html_newtopic; 192 } else { 193 $html .= "<div class='normal'><b>Login Required</b><br>You need to login before you can post to the forums.</div>\n"; 194 } 195 196 $html .= "</td></tr></table>\n"; 197 198 } 199 200 if ($row["cStatus"]=="pending"){ 201 $html .= "<div class='large'>".stripslashes($row["cTitle"])." Forum</div>\n" 202 ."<div class='normal' style='padding:20px;'>This forum has been requested for creation, but has not been enabled yet. Please contact the administrator if you have any questions, or would just like to lean on him a bit :)</div>\n"; 203 } 204 205 if ($row["cStatus"]=="closed"){ 206 $html .= "<div class='large'>".stripslashes($row["cTitle"])." Forum</div>\n" 207 ."<div class='normal' style='padding:20px;'>This forum has been closed. Please contact the administrator if you have any questions.</div>\n"; 208 } 209 210 } else { 211 // no forums to list 212 } 213 } else { 214 $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; 215 } 216 217 $html .= "</div></td></tr><tr><td bgcolor='#eeeeee'><div style='padding:5px;'>\n"; 218 219 if ($row["cStatus"]=="live"){ 220 221 // get the posts 222 $sql = "SELECT t.nTopicId,t.cTitle AS cTopicTitle,t.nForumId,f.cTitle AS cForumTitle,t.nFirstPostId,t.nLastPostId,uf.cUsername AS cFirstPostBy,ul.cUsername AS cLastPostBy,t.nFirstPostBy,t.nLastPostBy,t.dFirstPost,t.dLastPost,t.nPosts,t.nViews" 223 ." FROM nexus_topics t" 224 ." INNER JOIN nexus_forums f ON t.nForumId=f.nForumId" 225 ." INNER JOIN nexus_users uf ON t.nFirstPostBy=uf.nUserId" 226 ." INNER JOIN nexus_users ul ON t.nLastPostBy=ul.nUserId" 227 ." WHERE t.nForumId=".$_GET["forumid"] 228 ." ORDER BY t.dLastPost DESC;"; 229 230 $result = mysql_query($sql,$con); 231 if ($result!=false){ 232 $html .= "<table border='0' cellspacing='1' cellpadding='2' bgcolor='#aabbaa' width='100%'>" 233 ."<tr><td colspan='6' bgcolor='#aabbaa' class='small'><b>Topics</b></td></tr>" 234 ."<tr>" 235 ."<td bgcolor='#bbccbb' class='small' width='20'> </td>" 236 ."<td bgcolor='#bbccbb' class='small'>Topic Title</td>" 237 ."<td bgcolor='#bbccbb' class='small' width='40'>Views</td>" 238 ."<td bgcolor='#bbccbb' class='small' width='40'>Posts</td>" 239 ."<td bgcolor='#bbccbb' class='small' width='150'>First Post</td>" 240 ."<td bgcolor='#bbccbb' class='small' width='150'>Last Post</td>" 241 ."</tr>\n"; 242 if (mysql_num_rows($result)>0){ 243 244 while ($row =@ mysql_fetch_array($result)){ 245 $html .= "<tr>" 246 ."<td bgcolor='#ffffff' class='small' width='20'> </td>\n" 247 ."<td bgcolor='#ffffff' class='normal'><a href='forums.php?action=view_topic&topicid=".$row["nTopicId"]."'><b>".$row["cTopicTitle"]."</b></a></td>\n" 248 ."<td bgcolor='#ffffff' class='normal' width='40'>".$row["nViews"]."</td>\n" 249 ."<td bgcolor='#ffffff' class='normal' width='40'>".$row["nPosts"]."</td>\n" 250 ."<td bgcolor='#ffffff' class='small' width='150'><a class='link' href='user_view.php?userid=".$row["nFirstPostBy"]."'>".stripslashes($row["cFirstPostBy"])."</a><br>".$row["dFirstPost"]." <a href='forums.php?action=view_topic&postid=".$row["nFirstPostId"]."#".$row["nFirstPostId"]."' title='Read Post'>»</a></td>\n" 251 ."<td bgcolor='#ffffff' class='small' width='150'><a class='link' href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPostBy"])."</a><br>".$row["dLastPost"]." <a href='forums.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></td>\n" 252 ."</tr>\n"; 253 } 254 255 } else { 256 257 $html .= "<tr><td bgcolor='#ffffff' class='small' align='center' colspan='6'>No Topics in this forum yet.<hr size='1'>".$html_newtopic."</td></tr>\n"; 258 259 } 260 $html .= "</table>\n"; 261 262 } else { 263 // no forum to show 264 $html .= "<p align='center' class='small'>Problem with the SQL [".$sql."]</p>\n"; 265 } 266 267 } else { 268 269 // forum is not live 270 $html .= "<div class='normal' style='text-align:center;'>The forum contents cannot be shown while it's status is not 'live'.</div>"; 271 } 272 273 $html .= "</div></td></tr>\n" 274 ."</table>\n"; 275 } 276 277 // if action is 'view_topic' show a single topic in a forum 278 if ($_GET["action"]=="view_topic"){ 279 280 $con = db_connect(); 281 282 // see if we were given a postid (i.e. we will need to find out the topic from it 283 $postid = $_GET["postid"]; 284 if($postid!=""){ 285 $sql = "SELECT nTopicId FROM nexus_posts WHERE nPostId=".$postid; 286 $result = mysql_query($sql,$con); 287 if ($result!=false) { 288 if (mysql_num_rows($result)>0){ 289 $row = mysql_fetch_array($result); 290 $topicid = $row["nTopicId"]; 291 } else { 292 // no such post 293 } 294 } else { 295 // problem with SQL 296 } 297 298 } else { 299 $topicid = $_GET["topicid"]; 300 } 301 302 // update the view stats for the topic 303 $sql = "UPDATE nexus_topics SET nViews=nViews+1 WHERE nTopicId=".$topicid; 304 $result = mysql_query($sql,$con); 305 306 // get the topic name, forumid and forumtype (use forum type to influence buttons available) 307 $sql = "SELECT t.cTitle,t.nForumId,f.cType AS cForumType" 308 ." FROM nexus_topics t" 309 ." INNER JOIN nexus_forums f ON t.nForumId=f.nForumId" 310 ." WHERE t.nTopicId=".$topicid; 311 312 $result = mysql_query($sql,$con); 313 if ($result!=false){ 314 if (mysql_num_rows($result)>0){ 315 316 $row = mysql_fetch_array($result); 317 318 // store the title of the topic away for use at the top of the thread of messages 319 $forumid = $row["nForumId"]; 320 $topic_title = stripslashes($row["cTitle"]); 321 $forum_type = $row["cForumType"]; 322 323 // get the user membertype for the forum 324 if ($_SESSION["nexus_userid"]!=""){ 325 $sql = "SELECT cType FROM nexus_forummembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$row["nForumId"]; 326 $result = mysql_query($sql,$con); 327 if ($result!=false){ 328 if (mysql_num_rows($result)>0){ 329 $row = mysql_fetch_array($result); 330 $member_type = $row["cType"]; 331 } else { 332 // no records 333 $member_type=""; 334 } 335 } else { 336 // problem with SQL 337 338 } 339 } 340 341 // now figure out what to show for addtopic and reply links 342 // (make them context sensitive to the type of forum and the membership status of the user) 343 switch($member_type){ 344 case "owner": 345 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post New Topic</b></a></div>"; 346 $html_reply = "<span class='normal'><a href='forums.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Reply</b></a></span>"; 347 break; 348 case "moderator": 349 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post New Topic</b></a></div>"; 350 $html_reply = "<span class='normal'><a href='forums.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Reply</b></a></span>"; 351 break; 352 case "member": 353 $html_newtopic = "<div class='normal'><a href='forums.php?action=new_topic&forumid=".$row["nForumId"]."'><b>Post New Topic</b></a></div>"; 354 $html_reply = "<span class='normal'><a href='forums.php?action=reply&forumid=[forumid]&topicid=[topicid]&postid=[postid]'><b>Reply</b></a></span>"; 355 break; 356 case "pending": 357 $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>Your membership of this forum is pending approval of its owner.</div>"; 358 $html_reply = "<span class='normal'>Membership Pending - <b>Cannot Reply</b></span>"; 359 break; 360 case "banned": 361 $html_newtopic = "<div class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</div>"; 362 $html_reply = "<span class='normal'><b>You Cannot Post</b><br>You have been banned from posting to this forum.</span>"; 363 break; 364 case "": 365 switch($forum_type){ 366 case "open": // user is joined immediately on join request 367 $html_newtopic = "<div class='normal'><a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is an open forum<br>just click 'Join' to join.</div>"; 368 $html_reply = "<span class='normal'><a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b> to Reply</a></span>"; 369 break; 370 case "managed": // user is added as pending on join request 371 $html_newtopic = "<div class='normal'><a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b></a><br>This is a managed forum<br>click 'Join' to request membership.</div>"; 372 $html_reply = "<span class='normal'>Managed Forum - <a href='forums_exec.php?action=join_forum&forumid=".$row["nForumId"]."'><b>Join</b> to Reply</a></span>"; 373 break; 374 } 375 break; 376 } 377 378 379 //$html .= "<div class='large'>NEW [".$html_newtopic."]</div>\n"; 380 381 // start putting the page together 382 $html .= "<table border='0' cellspacing='1' cellpadding='2' width='100%' bgcolor='#aabbaa'>\n" 383 ."<tr><td bgcolor='#aabbaa' class='small'><b>Forum Description</b></td></tr>\n" 384 ."<tr><td bgcolor='#ffffff'><div style='padding:5px;'>\n"; 385 386 // show the forum name 387 $sql = "SELECT f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" 388 ." FROM nexus_forums f" 389 ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" 390 ." INNER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" 391 ." WHERE nForumId=".$forumid; 392 393 $result = mysql_query($sql,$con); 394 if ($result!=false){ 395 if (mysql_num_rows($result)>0){ 396 $row = mysql_fetch_array($result); 397 398 $html .= "<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td>"; 399 400 $html .= "<div class='large'><a href='forums.php?action=view_forum.php?forumid=".$row["nForumId"]."' class='link'>".stripslashes($row["cTitle"])." Forum</a></div>\n" 401 ."<div class='normal'>Owner : <a href='user_view.php?userid=".$row["nOwnerId"]."'>".stripslashes($row["cOwner"])."</a></div>\n" 402 ."<div class='small'> </div>\n" 403 ."<div class='normal'>".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by <a href='user_view.php?userid=".$row["nLastPostBy"]."'>".stripslashes($row["cLastPoster"])."</a> on ".$row["dLastPost"]." <a href='forums.php?action=view_topic&postid=".$row["nLastPostId"]."#".$row["nLastPostId"]."' title='Read Post'>»</a></div>\n" 404 ."<div class='small'> </div>\n" 405 ."<div class='normal'>".stripslashes($row["cSummary"])."</div>\n"; 406 407 $html .= "</td><td align='center' valign='bottom' width='150'>"; 408 409 if ($_SESSION["nexus_userid"]!=""){ 410 $html .= $html_newtopic; 411 } else { 412 $html .= "<div class='normal'><b>Login Required</b><br>You need to login before you can post to the forums.</div>\n"; 413 } 414 415 $html .= "</td></tr></table>\n"; 416 417 } else { 418 // no forums to list 419 } 420 } else { 421 $html .= "<div class='small'>problem with SQL [".$sql."]</div>\n"; 422 } 423 424 $html .= "</div></td></tr><tr><td bgcolor='#eeeeee'><div style='padding:5px;'>\n"; 425 426 $html .= "<div class='large' style='padding-bottom:10px;'>Topic : ".$topic_title."</div>\n"; 427 428 // get the posts in the topic 429 $sql = "SELECT p.nPostId,p.nForumId,p.nTopicId,p.nUserId,u.cUsername,p.cTitle,p.cBody,p.dAdded,p.dEdited,u.nPosts,u.cGender,u.cChatYahoo,u.cChatMSN,u.cChatAIM,u.cChatICQ" 430 ." FROM nexus_posts p" 431 ." INNER JOIN nexus_users u ON p.nUserId=u.nUserId" 432 ." WHERE nTopicId=".$topicid." ORDER BY nPostId"; 433 434 $result = mysql_query($sql,$con); 435 436 if ($result!=false){ 437 $html .= "<table border='0' cellspacing='0' cellpadding='5' width='100%'>"; 438 439 while ($row =@ mysql_fetch_array($result)){ 440 441 if ($row["cTitle"]!="") { 442 $title = stripslashes($row["cTitle"]); 443 } else { 444 $title = "... (<i>untitled</i>)"; 445 } 446 $body = stripslashes($row["cBody"]); 447 $username = stripslashes($row["cUsername"]); 448 $userid = stripslashes($row["nUserId"]); 449 $dateadded = stripslashes($row["dEdited"]); 450 $posts = stripslashes($row["nPosts"]); 451 452 // sort out a thumbnail 453 if (file_exists("pictures/".$row["nUserId"]."t.jpg")){ 454 $picture = "pictures/".$row["nUserId"]."t.jpg"; 455 } else { 456 switch ($row["cGender"]){ 457 case "": 458 $picture = "pictures/no_thumb.jpg"; 459 break; 460 case "m": 461 $picture = "pictures/no_thumb_male.jpg"; 462 break; 463 case "f": 464 $picture = "pictures/no_thumb_female.jpg"; 465 break; 466 } 467 } 468 469 // prepare the chat icons 470 if ($_SESSION["nexus_userid"]!=""){ 471 if ($row["cChatYahoo"]!="") { 472 $chat_yahoo = "<img src='images/icon_yahoo.png' width='16' height='16' title='".$row["cChatYahoo"]." on Yahoo Messenger'>"; 473 } 474 if ($row["cChatMSN"]!="") { 475 $chat_msn = "<img src='images/icon_msn.png' width='16' height='16' title='".$row["cChatMSN"]." on MSN'>"; 476 } 477 if ($row["cChatAIM"]!="") { 478 $chat_aim = "<img src='images/icon_aim.png' width='16' height='16' title='".$row["cChatAIM"]." on AOL Instant Messenger'>"; 479 } 480 if ($row["cChatICQ"]!="") { 481 $chat_icq = "<img src='images/icon_icq.png' width='16' height='16' title='".$row["cChatICQ"]." on ICQ'>"; 482 } 483 $chat = $chat_yahoo.$chat_msn.$chat_aim.$chat_icq; 484 } else { 485 $chat = "login for more info"; 486 } 487 488 // prepare the reply html 489 if ($_SESSION["nexus_userid"]!=""){ 490 $html_reply = str_replace("[topicid]",$row["nTopicId"],$html_reply); 491 $html_reply = str_replace("[forumid]",$row["nForumId"],$html_reply); 492 $html_reply = str_replace("[postid]",$row["nPostId"],$html_reply); 493 } else { 494 $html_reply = "<span class='small'>Login to <b>Reply</b></span>"; 495 } 496 497 $html .= "<tr><td><a name='".$row["nPostId"]."'></a>" 498 ."<table width='100%' cellspacing='1' cellpadding='0' border='0' bgcolor='#aabbaa'><tr><td>\n" 499 ."<table width='100%' cellspacing='1' cellpadding='2' border='0' bgcolor='#ffffff'>\n" 500 ."<tr>" 501 ."<td valign='top' align='center' width='120' bgcolor='#bbccbb'>" 502 ."<div style='padding:5px;'>\n" 503 ."<div align='center'><img src='".$picture."' width='64' height='64'></div>\n" 504 ."<div align='center' class='normal'><a href='user_view.php?userid=".$userid."'><b>".$username."</b></a></div>\n" 505 ."<div align='center' class='small' style='padding:2px;'>".$chat."</div>\n" 506 ."<div align='center' class='small'>".$posts." posts</div>\n" 507 ."</div>\n" 508 ."</td>\n" 509 ."<td bgcolor='#ffffff' class='normal'>" 510 ."<div class='normal' style='padding:10px;'><b>".prepare($title)."</b></div>" 511 ."<div class='normal' style='padding:20px;'>".prepare($body)."</div>" 512 ."<div class='small' style='padding:1px;border-top:1px solid #ccc;text-align:right;'>Posted by <a href='user_view.php?userid=".$userid."'>".$username."</a> on ".$dateadded.". ".$html_reply."</div>\n" 513 ."</td></tr>\n" 514 ."</table>\n" 515 ."</td></tr></table>\n" 516 ."</td></tr>\n"; 517 518 } 519 $html .= "</table>\n"; 520 521 } else { 522 $html .= "<p align='center' class='small'>Problem with the SQL [".$sql."]</p>\n"; 523 } 524 525 $html .= "</div></td></tr></table>\n"; 526 527 528 } else { 529 // no such topic 530 } 531 } else { 532 // problem with SQL 533 } 534 535 } 536 537 // if action is 'new_topic' show the entry form 538 if ($_GET["action"]=="new_topic"){ 539 540 if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ 541 542 // show the form for a new topic 543 $html .= "<form method='POST' action='forums_exec.php?action=new_topic'>\n" 544 ."<input type='hidden' name='forumid' value='".$_GET["forumid"]."'>\n" 545 ."<table border='0' cellspacing='1' cellpadding='2' bgcolor='#aabbaa'>\n" 546 ."<tr><td bgcolor='#aabbaa' class='small'>Post New Topic</td></tr>\n" 547 ."<tr><td bgcolor='#ffffff' class='small'>Title</td><td bgcolor='#ffffff'><input name='title' type='text' class='text' size='70'></td></tr>\n" 548 ."<tr><td bgcolor='#ffffff' class='small'>Body</td><td bgcolor='#ffffff'><textarea name='body' class='text' cols='80' rows='15'></textarea></td></tr>\n" 549 ."<tr><td bgcolor='#ffffff' align='right' colspan='2'><input type='submit' value='Post New Topic'></td></tr>\n" 550 ."</table>\n" 551 ."</form>\n"; 552 553 } else { 554 555 $html .= "<p class='title'>Login Required</p>\n" 556 ."<p class='normal'>You are trying to access a section of the site that requires a login. Use the form on the left to login - you will then be taken to the page you were trying to access.</p>\n" 557 ."<p class='normal'>If you get stuck, email <a href='mailto:".$admin_email."'>".$admin_email."</a> for assistance.</p>\n"; 558 559 } 560 561 } 562 563 // if action is 'reply' show the reply form 564 if ($_GET["action"]=="reply"){ 565 566 if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ 567 568 $forumid = $_GET["forumid"]; 569 $topicid =