Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "include/bittorrent.php";
- dbconn(false);
- maxsysop ();
- loggedinorreturn();
- $wherethisuser = where ($_SERVER["SCRIPT_FILENAME"],$CURUSER["id"]);
- parked();
- $action = $HTTP_GET_VARS["action"];
- function catch_up($topics="all")
- {
- //die("This feature is currently unavailable.");
- global $CURUSER;
- $userid = $CURUSER["id"];
- $res = mysql_query("SELECT id, lastpost FROM topics") or sqlerr(__FILE__, __LINE__);
- while ($arr = mysql_fetch_assoc($res))
- {
- $topicid = $arr["id"];
- $postid = $arr["lastpost"];
- if ($topicid == $topics || $topics == "all") {
- $r = mysql_query("SELECT id,lastpostread FROM readposts WHERE userid=$userid and topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($r) == 0)
- mysql_query("INSERT INTO readposts (userid, topicid, lastpostread) VALUES($userid, $topicid, $postid)") or sqlerr(__FILE__, __LINE__);
- else
- {
- $a = mysql_fetch_assoc($r);
- if ($a["lastpostread"] < $postid)
- mysql_query("UPDATE readposts SET lastpostread=$postid WHERE id=" . $a["id"]) or sqlerr(__FILE__, __LINE__);
- }
- }
- }
- }
- //-------- Returns the minimum read/write class levels of a forum
- function get_forum_access_levels($forumid)
- {
- $res = mysql_query("SELECT minclassread, minclasswrite, minclasscreate FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- return false;
- $arr = mysql_fetch_assoc($res);
- return array("read" => $arr["minclassread"], "write" => $arr["minclasswrite"], "create" => $arr["minclasscreate"]);
- }
- //-------- Returns the forum ID of a topic, or false on error
- function get_topic_forum($topicid)
- {
- $res = mysql_query("SELECT forumid FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- return false;
- $arr = mysql_fetch_row($res);
- return $arr[0];
- }
- //-------- Returns the ID of the last post of a forum
- function update_topic_last_post($topicid)
- {
- $res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res) or die("No post found");
- $postid = $arr[0];
- mysql_query("UPDATE topics SET lastpost=$postid WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- }
- function get_forum_last_post($forumid)
- {
- $res = mysql_query("SELECT lastpost FROM topics WHERE forumid=$forumid ORDER BY lastpost DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res);
- $postid = $arr[0];
- if ($postid)
- return $postid;
- else
- return 0;
- }
- //-------- Inserts a quick jump menu
- function insert_quick_jump_menu($currentforum = 0)
- {
- print("<p align=center><form method=get action=? name=jump>\n");
- print("<input type=hidden name=action value=viewforum>\n");
- print("Quick jump: ");
- print("<select name=forumid onchange=\"if(this.options[this.selectedIndex].value != -1){ forms['jump'].submit() }\">\n");
- $res = mysql_query("SELECT * FROM forums ORDER BY name") or sqlerr(__FILE__, __LINE__);
- while ($arr = mysql_fetch_assoc($res))
- {
- if (get_user_class() >= $arr["minclassread"])
- print("<option value=" . $arr["id"] . ($currentforum == $arr["id"] ? " selected>" : ">") . $arr["name"] . "\n");
- }
- print("</select>\n");
- print("<input type=submit value='Go!'>\n");
- print("</form>\n</p>");
- }
- //-------- Insert A Fast Reply Frame
- function insert_fastreply_frame($id)
- {
- print("<center> \n");
- print("<br>");
- print("<span onClick=\"expandcontent('sc1')\" style=\"cursor:hand; cursor:pointer\"><h2><b><font color=white>Fast Reply Box</font></b></h2></span>");
- print("<div id=\"sc1\" class=\"switchcontent\"><form method=post name=compose action=?action=post>\n");
- print("<input type=hidden name=topicid value=$id>\n");
- begin_table();
- print("<tr><td class=rowhead>Body</td><td align=left style='padding: 0px'>" .
- "<textarea name=body cols=100 rows=10 style='border: 0px'>".
- "</textarea></td></tr>\n");
- print("<form method=post name=compose>\n");
- print("<tr><td colspan=2 align=center><input type=button value=Submit name=button1 onclick='return Post();'> <input type=button value=Preview name=button2 onclick='return Preview();'></td></tr>\n");
- end_table();
- print("</form></div>\n");
- print("<br>");
- }
- //-------- Inserts a compose frame
- function insert_compose_frame($id, $newtopic = true, $quote = false, $forid, $body ='' , $subject='')
- {
- global $maxsubjectlength, $CURUSER;
- if ($newtopic)
- {
- $res = mysql_query("SELECT name FROM forums WHERE id=$id") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die("Bad forum id");
- $forumname = $arr["name"];
- print("<p align=center>New topic in <a href=?action=viewforum&forumid=$id>$forumname</a> forum</p>\n");
- }
- else
- {
- $res = mysql_query("SELECT * FROM topics WHERE id=$id") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or stderr("Forum error", "Topic not found.");
- if (get_user_class() < $arr['minclassread'])
- stderr('Permission Denied','You are not allowed to post in this thread.');
- $subject = htmlspecialchars($arr["subject"]);
- print("<p align=center>Reply to topic: <a href=?action=viewtopic&topicid=$id>$subject</a></p>");
- }
- begin_frame("Compose", true);
- // New Code
- print("<form method=post name=\"compose\" action=?action=post>\n");
- //print("<form class=embedded method=post action='?action=post'>\n");
- if ($newtopic){
- print("<input type=hidden name=forumid value=$id>\n");
- print("<input type=hidden name=subject value=$subject>\n");
- print("<input type=hidden name=posttopic value='yes'>\n");
- }
- else
- print("<input type=hidden name=topicid value=$id>\n");
- begin_table();
- //print("<table class=message cellspacing=0 cellpadding=$padding>\n");
- if ($newtopic)
- print("<tr><td class=rowhead>Subject</td>" .
- "<td align=left style='padding: 0px'><input type=text size=100 maxlength=$maxsubjectlength name=subject " .
- "value='$subject' style='border: 0px; height: 19px'></td></tr>\n");
- if ($quote)
- {
- $postid = $_GET["postid"];
- if (!is_valid_id($postid))
- die;
- $res = mysql_query("SELECT posts.*, users.username FROM posts JOIN users ON posts.userid = users.id WHERE posts.id=$postid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- stderr("Error", "No post with ID $postid.");
- $arr = mysql_fetch_assoc($res);
- }
- print("<tr><td class=rowhead>Body</td><td align=left style='padding: 0px'>"); textbbcode("compose","body",($quote?(("[quote=".htmlspecialchars($arr["username"])."]".htmlspecialchars(unesc($arr["body"]))."[/quote]")):""));
- print("<tr><td colspan=2 align=center><input type=button value=Submit name=button1 onclick='return Post();'> <input type=button value=Preview name=button2 onclick='return Preview();'></td></tr>\n");
- print("</td></tr>");
- end_table();
- print("</form>\n");
- end_frame();
- //------ Get 10 last posts if this is a reply
- if (!$newtopic)
- {
- $postres = mysql_query("SELECT * , UNIX_TIMESTAMP(added) as utadded FROM posts WHERE topicid=$id ORDER BY id DESC LIMIT 10") or sqlerr(__FILE__, __LINE__);
- begin_frame("10 last posts, in reverse order");
- while ($post = mysql_fetch_assoc($postres))
- {
- //-- Get poster details
- $userres = mysql_query("SELECT * FROM users WHERE id=" . $post["userid"] . " LIMIT 1") or sqlerr(__FILE__, __LINE__);
- $user = mysql_fetch_assoc($userres);
- $avatar = $user["avatar"];
- if (!$avatar || $off_avatar)
- $avatar = "/pic/default_avatar.gif";
- print("<p class=sub>#" . $post["id"] . " by " . $user["username"] . " at " . get_date_time($post["utadded"] , $CURUSER[tzoffset] ) . " GMT</p>");
- begin_table(true);
- print("<tr valign=top><td width=150 align=center style='padding: 0px'>" . ($avatar ? "<img width=150 src=$avatar>" : "").
- "</td><td class=comment>" . format_comment($post["body"]) . "</td></tr>\n");
- end_table();
- }
- end_frame();
- }
- insert_quick_jump_menu();
- }
- //-------- Global variables
- $maxsubjectlength = 60;
- $postsperpage = $CURUSER["postsperpage"];
- if (!$postsperpage) $postsperpage = 25;
- //-------- Action: Edit Forum
- if ($action == "editforum")
- {
- if (get_user_class() <= UC_MODERATOR) {
- stderr("Forum Error", "Not yet implemented.");
- die();
- }
- stdhead("Edit forum");
- ?>
- <center>
- <?php
- begin_frame("Edit Forum", "center");
- $forumid = 0 + $_GET["forumid"];
- $res = mysql_query("SELECT * FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- $forum = mysql_fetch_assoc($res);
- print("<form method=post action=?action=updateforum&forumid=$forumid>\n");
- begin_table();
- print("<tr><td class=rowhead>Forum name</td>" .
- "<td align=left style='padding: 0px'><input type=text size=60 maxlength=$maxsubjectlength name=name " .
- "style='border: 0px; height: 19px' value=\"$forum[name]\"></td></tr>\n".
- "<tr><td class=rowhead>Description</td>" .
- "<td align=left style='padding: 0px'><textarea name=description cols=68 rows=3 style='border: 0px'>$forum[description]</textarea></td></tr>\n".
- "<tr><td class=rowhead></td><td align=left style='padding: 0px'> Minimum <select name=readclass>");
- for ($i = 0; $i <= UC_SYSOP; ++$i)
- print("<option value=$i" . ($i == $forum['minclassread'] ? " selected" : "") . ">" . get_user_class_name($i) . "</option>\n");
- print("</select> Class required to View<br>\n Minimum <select name=writeclass>");
- for ($i = 0; $i <= UC_SYSOP; ++$i)
- print("<option value=$i" . ($i == $forum['minclasswrite'] ? " selected" : "") . ">" . get_user_class_name($i) . "</option>\n");
- print("</select> Class required to Post<br>\n Minimum <select name=createclass>");
- for ($i = 0; $i <= UC_SYSOP; ++$i)
- print("<option value=$i" . ($i == $forum['minclasscreate'] ? " selected" : "") . ">" . get_user_class_name($i) . "</option>\n");
- print("</select> Class required to Create Topics</td></tr>\n".
- "<tr><td colspan=2 align=center><input type=submit value='Submit'></td></tr>\n");
- end_table();
- print("</form>\n");
- end_frame();
- stdfoot();
- die;
- }
- //-------- Action: Update Forum
- if ($action == "updateforum")
- {
- $forumid = $_GET["forumid"];
- $name = $_POST["name"];
- $description = $_POST["description"];
- $minclassread = 0 + $_POST["readclass"];
- $minclasswrite = 0 + $_POST["writeclass"];
- $minclasscreate = 0 + $_POST["createclass"];
- if(!$forumid)
- stderr("Error", "Forum ID not found.");
- if(!$name)
- stderr("Error", "You must specify a name for the forum.");
- if(!$description)
- stderr("Error", "You must provide a description for the forum.");
- $name = sqlesc($name);
- $description = sqlesc($description);
- mysql_query("UPDATE forums SET ".
- "name=$name, ".
- "description=$description, ".
- "minclassread=$minclassread, ".
- "minclasswrite=$minclasswrite, ".
- "minclasscreate=$minclasscreate ".
- "WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- header("Location: $BASEURL/forums.php");
- }
- //-------- Action: Delete Forum
- if ($action == "deleteforum")
- {
- $forumid = 0 + $_GET["forumid"];
- $confirmed = 0 + $_GET["confirmed"];
- if(!$forumid)
- stderr("Error", "Forum ID not found.");
- if(!$confirmed)
- {
- $rf = mysql_query("SELECT name FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- $forum = mysql_fetch_assoc($rf);
- $rt = mysql_query("SELECT id FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__);
- $topics = mysql_num_rows($rt);
- $posts = 0;
- while($topic = mysql_fetch_assoc($rt))
- {
- $rp = mysql_query("SELECT * FROM posts WHERE topicid=$topic[id]") or sqlerr(__FILE__, __LINE__);
- $posts += mysql_num_rows($rp);
- }
- stdhead("Delete forum");
- ?>
- <center>
- <?php
- begin_frame("** WARNING! **");
- print("Deleting forum ID $forumid ($forum[name]) will also delete $posts posts in $topics topics. ".
- "[<a class=altlink href=?action=deleteforum&forumid=$forumid&confirmed=1>ACCEPT</a>] ".
- "[<a class=altlink href=forums.php>CANCEL</a>]");
- end_frame();
- stdfoot();
- die;
- }
- if ($CURUSER['class']>=UC_MODERATOR)
- {
- $rt = mysql_query("SELECT id FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__);
- while($topic = mysql_fetch_assoc($rt))
- mysql_query("DELETE FROM posts WHERE topicid=$topic[id]") or sqlerr(__FILE__, __LINE__);
- mysql_query("DELETE FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__);
- mysql_query("DELETE FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- header("Location: $BASEURL/forums.php");
- }
- else
- stderr("Error", "You are not authorised to perform this action!");
- die;
- }
- //-------- Action: New auto topic
- if($_POST['topicgen']=="yes" && $action=="new") {
- if (get_user_class() >= UC_ADMINISTRATOR) {stderr("Error", "You are not authorised to perform this action!"); }
- $userid="1"; // AutoPoster account
- }
- //-------- Action: New topic
- if ($action == "newtopic")
- {
- $forumid = 0 + $_GET["forumid"];
- if (!is_valid_id($forumid))
- die;
- stdhead("New topic");
- ?>
- <center>
- <?php
- insert_compose_frame($forumid, true, false, $forid);
- stdfoot();
- die;
- }
- //-------- Action: Post
- if ($action == "post")
- {
- //session_start();
- //$buttonval = $_POST["buttonval"];
- $forumid = 0 + $_POST["forumid"];
- $topicid = 0 + $_POST["topicid"];
- $subject = $_POST["subject"];
- $forid = $_GET["forid"];
- $body = trim($_POST["body"]);
- if ($buttonval == "Preview") {
- stdhead("Preview");
- ?>
- <center>
- <?php
- //if (!is_valid_id($topicid))
- // die;
- //if (!is_valid_id($forumid))
- // die;
- if ($forumid)
- insert_compose_frame($forumid, true, false, $forid, $body, $subject);
- else
- insert_compose_frame($topicid, false, false, $forid, $body, $subject);
- stdfoot();
- die;
- }
- if (!is_valid_id($forumid) && !is_valid_id($topicid))
- stderr("Error", "Bad forum or topic ID.");
- $newtopic = $forumid > 0;
- if ($newtopic)
- {
- $subject = trim($subject);
- if (!$subject)
- stderr("Error", "You must enter a subject.");
- if (strlen($subject) > $maxsubjectlength)
- stderr("Error", "Subject is limited to $maxsubjectlength characters.");
- }
- else
- $forumid = get_topic_forum($topicid) or die("Bad topic ID");
- if ($CURUSER["forumpost"] == 'no')
- {
- stdhead();
- ?>
- <center>
- <?php
- stdmsg("Sorry...", "You are not authorized to Post. (See <a href=\"inbox.php#up\">Read Inbox</a>)");
- stdfoot();
- exit;
- }
- //------ Make sure sure user has write access in forum
- $arr = get_forum_access_levels($forumid) or die("Bad forum ID");
- if ($CURUSER["forumpost"] == 'no')
- {
- stdhead();
- ?>
- <center>
- <?php
- stdmsg("Sorry...", "You are not authorized to Post. (See <a href=\"inbox.php#up\">Read Inbox</a>)");
- stdfoot();
- exit;
- }
- if ((get_user_class() < $arr["write"]) || ($CURUSER["forumpost"] == 'no'))
- stderr("Error", "Permission denied.");
- if ($body == "")
- stderr("Error", "No body text.");
- $userid = $CURUSER["id"];
- if ($newtopic)
- {
- //---- Create topic
- $subject = sqlesc($subject);
- mysql_query("INSERT INTO topics (userid, forumid, subject) VALUES($userid, $forumid, $subject)") or sqlerr(__FILE__, __LINE__);
- $topicid = mysql_insert_id() or stderr("Error", "No topic ID returned");
- }
- else
- {
- //---- Make sure topic exists and is unlocked
- $res = mysql_query("SELECT * FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die("Topic id n/a");
- if ($arr["locked"] == 'yes' && get_user_class() < UC_MODERATOR)
- stderr("Error", "This topic is locked.");
- //=== PM subscribed peeps
- $res_sub = mysql_query("SELECT userid FROM subscriptions WHERE topicid = $topicid") or sqlerr(__FILE__, __LINE__);
- while($row = mysql_fetch_assoc($res_sub)) {
- $res_yes = mysql_query("SELECT subscription_pm, username FROM users WHERE id = $row[userid]") or sqlerr(__FILE__, __LINE__);
- $arr_yes = mysql_fetch_array($res_yes);
- $msg = "Hey there!!! \n a thread you subscribed to: [b]".$arr["subject"]."[/b] has had a new post!\n click [url=".$BASEURL."/forums.php?action=viewtopic&topicid=".$topicid."&page=last][b]HERE[/b][/url] to read it!\n\nTo view your subscriptions, or un-subscribe, click [url=".$BASEURL."/subscriptions.php][b]HERE[/b][/url].\n\ncheers.";
- if ($arr_yes["subscription_pm"] == 'yes' && $row["userid"] != $CURUSER["id"])
- mysql_query("INSERT INTO messages (sender, subject, receiver, added, msg) VALUES(0, 'New post in subscribed thread!', $row[userid], '" . get_date_time() . "', " . sqlesc($msg) . ")") or sqlerr(__FILE__, __LINE__);
- }
- //===end
- //---- Get forum ID
- $forumid = $arr["forumid"];
- }
- //------ Insert post
- $added = "'" . get_date_time() . "'";
- $body = sqlesc($body);
- $minutes = 1;
- $limit = 2;
- $res = mysql_query("SELECT COUNT(*) FROM posts WHERE userid = $CURUSER[id] AND added > '".get_date_time(gmtime() - ($minutes * 60))."'") or sqlerr(__FILE__,__LINE__);
- $row = mysql_fetch_row($res);
- if ($row[0] > $limit)
- stderr("<b>Flood</b>", "<b><font color=red>More than $limit posts in the last $minutes minutes</font></b>.");
- mysql_query("INSERT INTO posts (topicid, userid, added, body) " .
- "VALUES($topicid, $userid, $added, $body)") or sqlerr(__FILE__, __LINE__);
- $postid = mysql_insert_id() or die("Post id n/a");
- //------ Check if someone is subscribing to this thread and send a pm V2
- $res1 = mysql_query("SELECT userid FROM subscriptions WHERE userid != " . $CURUSER["id"] . " AND topicid = ".sqlesc($topicid)."") or sqlerr(__FILE__, __LINE__);
- $subject = sqlesc("Subscribed topic - new post");
- $pm_msg = sqlesc("A new post has been made in the topic [b]".$arr[subject]."[/b] wich you are subscribed to.\nClick [url=$DEFAULTBASEURL/forums.php?action=viewtopic&topicid=$topicid][b]Here[/b][/url] to get to the post.\n");
- while($row = mysql_fetch_assoc($res1)) {
- mysql_query("INSERT INTO messages (sender, receiver, added, subject, msg) VALUES(0, $row[userid], '" . get_date_time() . "', $subject, $pm_msg)") or sqlerr(__FILE__, __LINE__);
- }
- //------ End to check if someone is subscribing to this thread and send a pm V2
- //------ Update topic last post
- update_topic_last_post($topicid);
- //------ All done, redirect user to the post
- $headerstr = "Location: $BASEURL/forums.php?action=viewtopic&topicid=$topicid&page=last";
- if ($newtopic)
- header($headerstr);
- else
- header("$headerstr#$postid");
- die;
- }
- //-------- Action: View topic
- if ($action == "viewtopic")
- {
- $highlight = $_GET["highlight"];
- $topicid = $_GET["topicid"];
- $page = $_GET["page"];
- $forid = $_GET["forid"];
- if (!is_valid_id($topicid))
- die;
- $userid = $CURUSER["id"];
- // Get last post UserID
- $res = mysql_query("SELECT userid FROM posts WHERE topicid = $topicid ORDER BY id DESC") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_array($res);
- $lastpostid = $arr["userid"];
- //------ Get topic info
- $res = mysql_query("SELECT * FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or stderr("Forum error", "Topic not found");
- if ($arr["numratings"] != 0)
- $rating = ROUND($arr["ratingsum"] / $arr["numratings"], 1);
- $rpic = ratingpic($rating);
- $locked = $arr["locked"];
- $subject = $arr["subject"];
- $sticky = $arr["sticky"] == "yes";
- $forumid = $arr["forumid"];
- //------ Update hits column
- mysql_query("UPDATE topics SET views = views + 1 WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- //------ Get forum
- $res = mysql_query("SELECT * FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die("Forum = NULL");
- $forum = $arr["name"];
- $forid = $arr["forid"];
- if ($CURUSER["class"] < $arr["minclassread"])
- stderr("Error", "You are not permitted to view this topic.");
- //------ Get post count
- $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res);
- $postcount = $arr[0];
- //------ Make page menu
- $pagemenu = "<p>\n";
- $perpage = $postsperpage;
- $pages = ceil($postcount / $perpage);
- if ($page[0] == "p")
- {
- $findpost = substr($page, 1);
- $res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid ORDER BY added") or sqlerr(__FILE__, __LINE__);
- $i = 1;
- while ($arr = mysql_fetch_row($res))
- {
- if ($arr[0] == $findpost)
- break;
- ++$i;
- }
- $page = ceil($i / $perpage);
- }
- if ($page == "last")
- $page = $pages;
- else
- {
- if($page < 1)
- $page = 1;
- elseif ($page > $pages)
- $page = $pages;
- }
- $offset = $page * $perpage - $perpage;
- for ($i = 1; $i <= $pages; ++$i)
- {
- if ($i == $page)
- $pagemenu .= "<font class=gray><b>$i</b></font>\n";
- else
- $pagemenu .= "<a href=?action=viewtopic&topicid=$topicid&page=$i><b>$i</b></a>\n";
- }
- if ($page == 1)
- $pagemenu .= "<br><font class=gray><b><< Prev</b></font>";
- else
- $pagemenu .= "<br><a href=?action=viewtopic&topicid=$topicid&page=" . ($page - 1) .
- "><b><< Prev</b></a>";
- $pagemenu .= " ";
- if ($page == $pages)
- $pagemenu .= "<font class=gray><b>Next >></b></font></p>\n";
- else
- $pagemenu .= "<a href=?action=viewtopic&topicid=$topicid&page=" . ($page + 1) .
- "><b>Next >></b></a></p>\n";
- //------ Get posts
- $res = mysql_query("SELECT * FROM posts WHERE topicid=$topicid ORDER BY id LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__);
- stdhead("View topic");
- ?>
- <center>
- <?php
- print("<h1><a href=?action=viewforum&forumid=$forumid>$forum</a> > $subject</h1>\n");
- print("<br><a href=subscriptions.php?topicid=$topicid&subscribe=1><b><font color=lime>Subscribe to Forum</font></b></a>");
- print($pagemenu);
- $lastpostidje = get_forum_last_post($forumid);
- $postidje = $arrtje[0];
- print('<p>Go to last post:<a href=forums.php?action=viewtopic&topicid='.$topicid.'&page=p'.$lastpostidje.'#'.$lastpostidje.'><img border=0 src=/pic/last_post.gif></a></p>');
- //------ Print table
- ?>
- <form name="jump_to_rate">
- <select name="rate_me" OnChange="location.href=jump_to_rate.rate_me.options[selectedIndex].value">
- <option selected> Rate this Topic!
- <option value="takerate.php?topic_id=<?=$topicid?>&rate_me=5">5- the best!
- <option value="takerate.php?topic_id=<?=$topicid?>&rate_me=4">4- great
- <option value="takerate.php?topic_id=<?=$topicid?>&rate_me=3">3- fair
- <option value="takerate.php?topic_id=<?=$topicid?>&rate_me=2">2- bad
- <option value="takerate.php?topic_id=<?=$topicid?>&rate_me=1">1- stinks
- </select><b>Topic Rating:</b> <?=$rpic?></form>
- <?php
- begin_frame();
- $pc = mysql_num_rows($res);
- $pn = 0;
- $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=" . $CURUSER["id"] . " AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_row($r);
- $lpr = $a[0];
- if (!$lpr)
- mysql_query("INSERT INTO readposts (userid, topicid) VALUES($userid, $topicid)") or sqlerr(__FILE__, __LINE__);
- while ($arr = mysql_fetch_assoc($res))
- {
- ++$pn;
- $postid = $arr["id"];
- $posterid = $arr["userid"];
- $added = display_date_time($arr["added"]) . " (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
- //---- Get poster details
- $dt = gmtime() - 180;
- $dt = sqlesc(get_date_time($dt));
- $res2 = sql_query("SELECT username,class,avatar,donor,title,simpaty,enabled,warned,uploaded,downloaded,signature,last_access FROM users WHERE id=$posterid") or sqlerr(__FILE__, __LINE__);
- $arr2 = mysql_fetch_assoc($res2);
- $uploaded = mksize($arr2["uploaded"]);
- $downloaded = mksize($arr2["downloaded"]);
- if ($arr2["downloaded"] > 0)
- {
- $ratio = $arr2['uploaded'] / $arr2['downloaded'];
- $ratio = number_format($ratio, 3);
- $color = get_ratio_color($ratio);
- if ($color)
- $ratio = "<font color=$color>$ratio</font>";
- }
- else
- if ($arr2["uploaded"] > 0)
- $ratio = "Inf.";
- else
- $ratio = "---";
- $reputation=$arr2[simpaty];
- $rem = sql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $posterid) or sqlerr();
- $arr25 = mysql_fetch_row($rem);
- $forumposts = $arr25[0];
- $signature = $arr2[signature];
- $signature = ($CURUSER["signatures"] == "yes" ? htmlspecialchars($arr2["signature"]) : "");
- $postername = $arr2["username"];
- if ($postername == "")
- {
- $by = "unknown[$posterid]";
- $avatar = "";
- }
- else
- {
- // if ($arr2["enabled"] == "yes")
- $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($arr2["avatar"]) : "");
- // else
- // $avatar = "pic/disabled_avatar.gif";
- $title = $arr2["title"];
- if (!$title)
- $title = get_user_class_name($arr2["class"]);
- $UC = array("Staff Leader" => "pic/sitestaff.png",
- "Owner" => "pic/sitestaff.png",
- "Coder" => "pic/sitestaff.png",
- "1337" => "pic/sitestaff.png",
- "SysOp" => "pic/sitestaff.png",
- "Administrator" => "pic/sitestaff.png",
- "Moderator" => "pic/sitestaff.png",
- "Fast Uploader" => "pic/uploaderq.png",
- "Uploader" => "pic/uploaderq.png",
- "VIP" => "pic/vipdon.png",
- "Community VIP" => "pic/comvip.png",
- "Heavyweight" => "pic/hvw.png",
- "Light Heavyweight" => "pic/lhw.png",
- "Middleweight" => "pic/mdw.png",
- "Welterweight" => "pic/wtw.png",
- "Lightweight" => "pic/lgw.png");
- $uclass = $UC[get_user_class_name($arr2["class"])];
- $by = "<a href=userdetails.php?id=$posterid><b>$postername</b></a>" . ($arr2["donor"] == "yes" ? "<img src=".
- "pic/star.gif alt='Donor'>" : "") . ($arr2["enabled"] == "no" ? "<img src=".
- "pic/disabled.gif alt=\"This account is disabled\" style='margin-left: 2px'>" : ($arr2["warned"] == "yes" ? "<a href=rules.php#warning class=altlink><img src=pic/warned.gif alt=\"Warned\" border=0></a>" : "")) . " ";
- }
- if (!$avatar)
- $avatar = "pic/default_avatar.gif";
- print("<a name=$postid></a>\n");
- if ($pn == $pc)
- {
- print("<a name=last></a>\n");
- if ($postid > $lpr)
- sql_query("UPDATE readposts SET lastpostread=$postid WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- }
- print("<p class=sub><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded width=99%>#$postid by $by ($title) at $added");
- print("</td><td class=embedded width=1%><a href=#><img src=pic/p_up.gif border=0 alt='Top'></a></td></tr>");
- print("</table></p>\n");
- begin_table(true);
- $body = format_comment($arr["body"]);
- //---------------------------------
- //---- Search Highlight v0.1 by xam
- //---------------------------------
- if ($highlight){
- $body = highlight($highlight,$body);
- }
- //---------------------------------
- //---- Search Highlight v0.1 by xam
- //---------------------------------
- if (is_valid_id($arr['editedby']))
- {
- $res2 = sql_query("SELECT username FROM users WHERE id=$arr[editedby]");
- if (mysql_num_rows($res2) == 1)
- {
- $arr2 = mysql_fetch_assoc($res2);
- $body .= "<p><font size=1 class=small>Last edited by <a href=userdetails.php?id=$arr[editedby]><b>$arr2[username]</b></a> at $arr[editedat] GMT</font></p>\n";
- }
- }
- if ($signature)
- $body .= "<p style='vertical-align:bottom'><br>____________________<br>" . format_comment($signature) . "</p>";
- "</td>";
- $stats = "<br>"." Reputation: $reputation<br>"." Posts: $forumposts<br>"." UL: $uploaded <br>"." DL: $downloaded<br>"." Ratio.: $ratio";
- print("<tr valign=top><td width=150 align=left style='padding: 0px'><br>"." " .
- ($avatar ? " <img width=100 src=\"$avatar\">": ""). "<br>"." <img src=$uclass>$stats<br><br></td><td class=comment>$body</td></tr>\n");
- print("<tr><td> ".
- ("'".$arr2['last_access']."'">$dt?"<img src=pic/user_online.gif border=0 alt=\"Online\">":"<img src=pic/user_offline.gif border=0 alt=\"Offline\">" )." <a href=\"sendmessage.php?receiver=".htmlspecialchars($posterid)."\"><img src=\"pic/pm.gif\" border=\"0\" alt=\"Send message to ".htmlspecialchars($postername)."\"></a> <a href=report.php?type=Post&id=$postid&id_2=$topicid><img src=\"pic/report.gif\" border=\"0\" alt=\"Report this post\"></a></td>");
- print("<td align=right>");
- if (!$locked || get_user_class() >= UC_LIGHT_WEIGHT)
- print("<a href=?action=quotepost&topicid=$topicid&postid=$postid><img src=\"pic/p_quote.gif\" border=\"0\" alt=\"Reply with Quote\"></a>");
- $arr = get_forum_access_levels($forumid) or die;
- if (get_user_class() >= $arr["write"])
- $maypost = true;
- if ($maypost)
- {
- print("<a href=?action=reply&topicid=$topicid><img src=\"pic/p_reply.gif\" border=\"0\" alt=\"Reply directly to this post\"></a>");
- }
- if (get_user_class() >= UC_MODERATOR)
- print("<a href=?action=deletepost&postid=$postid><img src=\"pic/p_delete.gif\" border=\"0\" alt=\"Delete Post\"></a>");
- if (($CURUSER["id"] == $posterid && !$locked) || get_user_class() >= UC_LIGHT_WEIGHT)
- print("<a href=?action=editpost&postid=$postid><img src=\"pic/p_edit.gif\" border=\"0\" alt=\"Edit Post\"></a>");
- print("</td></tr>");
- end_table();
- }
- //------ Fast Reply Begin
- if ((get_user_class() >= $arr["write"]) && ($CURUSER["forumpost"] == 'yes') && ($lastpostid != $CURUSER["id"]) && ($locked=='no'))
- insert_fastreply_frame($topicid);
- //------ Fast Reply End
- //------ Mod options
- if (get_user_class() >= UC_MODERATOR)
- {
- // Ensure that Mods cannot tamper with a post set higher than they are.
- if (get_user_class() >= $arr1["write"]) {
- attach_frame();
- $res = mysql_query("SELECT id,name,minclasswrite FROM forums ORDER BY name") or sqlerr(__FILE__, __LINE__);
- print("<center><h2>Forum Moderator Options</h2></center>");
- print("<table border=0 align=center cellspacing=0 cellpadding=0>\n");
- //print("<table border=0 cellspacing=0 cellpadding=0>\n");
- print("<form method=post action=?action=setsticky>\n");
- print("<input type=hidden name=topicid value=$topicid>\n");
- print("<input type=hidden name=returnto value=$BASEURL$HTTP_SERVER_VARS[REQUEST_URI]>\n");
- print("<tr><td class=embedded align=right>Sticky:</td>\n");
- print("<td class=embedded><input type=radio name=sticky value='yes' " . ($sticky ? " checked" : "") . "> Yes <input type=radio name=sticky value='no' " . (!$sticky ? " checked" : "") . "> No\n");
- print("<input type=submit value='Set'></td></tr>");
- print("</form>\n");
- print("<form method=post action=?action=setlocked>\n");
- print("<input type=hidden name=topicid value=$topicid>\n");
- print("<input type=hidden name=returnto value=$BASEURL$_SERVER[REQUEST_URI]>\n");
- print("<tr><td class=embedded align=right>Locked:</td>\n");
- print("<td class=embedded><input type=text name=lockreason size=30>\n\n\n<input type=radio name=locked value='yes' " . ($locked ? " checked" : "") . "> Yes <input type=radio name=locked value='no' " . (!$locked ? " checked" : "") . "> No\n");
- print("<input type=submit value='Set'></td></tr>");
- print("</form>\n");
- print("<form method=post action=?action=renametopic>\n");
- print("<input type=hidden name=topicid value=$topicid>\n");
- print("<input type=hidden name=returnto value=$BASEURL$HTTP_SERVER_VARS[REQUEST_URI]>\n");
- print("<tr><td class=embedded align=right>Rename topic:</td><td class=embedded><input type=text name=subject size=60 maxlength=$maxsubjectlength value=\"" . htmlspecialchars($subject) . "\">\n");
- print("<input type=submit value='Okay'></td></tr>");
- print("</form>\n");
- print("<form method=post action=?action=movetopic&topicid=$topicid>\n");
- print("<tr><td class=embedded>Move this thread to: </td><td class=embedded><select name=forumid>");
- while ($arr = mysql_fetch_assoc($res))
- if ($arr["id"] != $forumid && get_user_class() >= $arr["minclasswrite"])
- print("<option value=" . $arr["id"] . ">" . $arr["name"] . "\n");
- print("</select> <input type=submit value='Okay'></form></td></tr>\n");
- print("<tr><td class=embedded>Delete topic</td><td class=embedded>\n");
- print("<form method=get action=$BASEURL/forums.php>\n");
- print("<input type=hidden name=action value=deletetopic>\n");
- print("<input type=hidden name=topicid value=$topicid>\n");
- print("<input type=submit value='Okay'>\n");
- print("</form>\n");
- print("</td></tr>\n");
- print("</table>\n"); }
- }
- end_frame();
- print($pagemenu);
- if ($locked=='yes')
- print("<p><b><font color=red>This Topic Is Locked And No New Posts Are Allowed.</b></font></p>\n");
- else
- {
- $arr = get_forum_access_levels($forumid) or die;
- if (get_user_class() < $arr["write"])
- print("<p><i>You are not permitted to post in this forum.</i></p>\n");
- elseif ($CURUSER["forumpost"] == 'no')
- print("<p><i>Your posting privilege has been revoked.</i></p>\n");
- elseif ((get_user_class() < UC_MODERATOR) && ($lastpostid == $CURUSER["id"]))
- print("<p><i>You cannot double post. Please edit your last post.</i></p>\n");
- else
- $maypost = true;
- }
- //------ "View unread" / "Add reply" buttons
- print("<p><table class=main border=0 cellspacing=0 cellpadding=0><tr>\n");
- if ($maypost)
- {
- print("<td class=embedded ><form method=get action=?>\n");
- print("<input type=hidden name=action value=reply>\n");
- print("<input type=hidden name=topicid value=$topicid>\n");
- print("<input type=submit value='Add Reply' >\n");
- print("</form></td>\n");
- }
- print("</tr></table></p>\n");
- //------ Forum quick jump drop-down
- insert_quick_jump_menu($forumid);
- stdfoot();
- die;
- }
- //-------- Action: Quote
- if ($action == "quotepost")
- {
- $topicid = $_GET["topicid"];
- if (!is_valid_id($topicid))
- stderr("Error", "Invalid topic ID $topicid.");
- stdhead("Post reply");
- ?>
- <center>
- <?
- insert_compose_frame($topicid, false, true, $forid);
- stdfoot();
- die;
- }
- //-------- Action: Reply
- if ($action == "reply")
- {
- $topicid = $_GET["topicid"];
- $forid = $_GET["forid"];
- if (!is_valid_id($topicid))
- die;
- stdhead("Post reply");
- ?>
- <center>
- <?
- insert_compose_frame($topicid, false, false, $forid);
- stdfoot();
- die;
- }
- //-------- Action: Move topic
- if ($action == "movetopic")
- {
- $forumid = $_POST["forumid"];
- $topicid = $_GET["topicid"];
- if (!is_valid_id($forumid) || !is_valid_id($topicid) || get_user_class() < UC_MODERATOR)
- die;
- // Make sure topic and forum is valid
- $res = @mysql_query("SELECT minclasswrite FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- stderr("Error", "Forum not found.");
- $arr = mysql_fetch_row($res);
- if (get_user_class() < $arr[0])
- die;
- $res = @mysql_query("SELECT subject,forumid FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- stderr("Error", "Topic not found.");
- $arr = mysql_fetch_assoc($res);
- if ($arr["forumid"] != $forumid)
- @mysql_query("UPDATE topics SET forumid=$forumid WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- // Redirect to forum page
- header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid");
- die;
- }
- //-------- Action: Delete topic
- if ($action == "deletetopic")
- {
- $topicid = $_GET["topicid"];
- if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR)
- die;
- $sure = $_GET["sure"];
- if (!$sure)
- {
- stderr("Delete topic", "Sanity check: You are about to delete a topic. Click\n" .
- "<a href=?action=deletetopic&topicid=$topicid&sure=1><u>here</u></a> if you are sure.");
- }
- mysql_query("DELETE FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- mysql_query("DELETE FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- //--- to be added to delete thread ---//
- mysql_query("DELETE FROM subscriptions WHERE topicid='$topicid'") or sqlerr(__FILE__, __LINE__);
- //--- end ---//
- header("Location: $BASEURL/forums.php");
- die;
- }
- //-------- Action: Edit post
- if ($action == "editpost")
- {
- $postid = $HTTP_GET_VARS["postid"];
- if (!is_valid_id($postid))
- die;
- $res = mysql_query("SELECT * FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) != 1)
- stderr("Error", "No post with ID $postid.");
- $arr = mysql_fetch_assoc($res);
- $res2 = mysql_query("SELECT locked FROM topics WHERE id = " . $arr["topicid"]) or sqlerr(__FILE__, __LINE__);
- $arr2 = mysql_fetch_assoc($res2);
- if (mysql_num_rows($res) != 1)
- stderr("Error", "No topic associated with post ID $postid.");
- $locked = ($arr2["locked"] == 'yes');
- if (($CURUSER["id"] != $arr["userid"] || $locked) && get_user_class() < UC_MODERATOR)
- stderr("Error", "Denied!");
- if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == 'POST')
- {
- $body = $HTTP_POST_VARS['body'];
- if ($body == "")
- stderr("Error", "Body cannot be empty!");
- $body = unesc($body);
- $body = sqlesc($body);
- $editedat = sqlesc(get_date_time());
- mysql_query("UPDATE posts SET body=$body, editedat=$editedat, editedby=$CURUSER[id] WHERE id=$postid") or sqlerr(__FILE__, __LINE__);
- $returnto = $HTTP_POST_VARS["returnto"];
- // print $returnto;
- if ($returnto != "")
- {
- $returnto .= "#$postid";
- header("Location: $returnto");
- }
- else
- stderr("Success", "Post was edited successfully.");
- }
- stdhead();
- ?>
- <center>
- <?
- print("<h1>Edit Post</h1>\n");
- print("<form name=edit method=post action=?action=editpost&postid=$postid>\n");
- $pos = strrpos($HTTP_SERVER_VARS["HTTP_REFERER"], "#");
- if ($pos) { $returnto = substr($HTTP_SERVER_VARS["HTTP_REFERER"],0,$pos); } else { $returnto = $HTTP_SERVER_VARS["HTTP_REFERER"]; }
- print("<input type=hidden name=returnto value=\"" . htmlspecialchars($returnto) . "\">\n");
- print("<p align=center><table border=1 cellspacing=1>\n");
- print("<tr><td>".BODY."</td><td align=center>\n");
- textbbcode("edit","body",htmlspecialchars(unesc($arr["body"])));
- print("</td></tr>\n");
- print("<tr><td align=center colspan=2><input type=submit value='".Okay."' ></td></tr>\n");
- print("</table>\n</p>");
- print("</form>\n");
- stdfoot();
- die;
- }
- //-------- Action: Delete post
- if ($action == "deletepost")
- {
- $postid = $_GET["postid"];
- $sure = $_GET["sure"];
- if (get_user_class() < UC_MODERATOR || !is_valid_id($postid))
- die;
- //------- Get topic id
- $res = mysql_query("SELECT topicid FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res) or stderr("Error", "Post not found");
- $topicid = $arr[0];
- //------- We can not delete the post if it is the only one of the topic
- $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res);
- if ($arr[0] < 2)
- stderr("Error", "Can't delete post; it is the only post of the topic. You should\n" .
- "<a href=?action=deletetopic&topicid=$topicid&sure=1>delete the topic</a> instead.\n");
- //------- Get the id of the last post before the one we're deleting
- $res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid AND id < $postid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) == 0)
- $redirtopost = "";
- else
- {
- $arr = mysql_fetch_row($res);
- $redirtopost = "&page=p$arr[0]#$arr[0]";
- }
- //------- Make sure we know what we do :-)
- if (!$sure)
- {
- stderr("Delete post", "Sanity check: You are about to delete a post. Click\n" .
- "<a href=?action=deletepost&postid=$postid&sure=1><u>here</u></a> if you are sure.");
- }
- //------- Delete post
- if ($sure) { mysql_query("DELETE FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__); }
- //------- Update topic
- update_topic_last_post($topicid);
- header("Location: $BASEURL/forums.php?action=viewtopic&topicid=$topicid");
- die;
- }
- //-------- Action: Lock topic
- if ($action == "locktopic")
- {
- $forumid = $_GET["forumid"];
- $topicid = $_GET["topicid"];
- $page = $_GET["page"];
- if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR)
- die;
- mysql_query("UPDATE topics SET locked='yes' WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid&page=$page");
- die;
- }
- //-------- Action: Unlock topic
- if ($action == "unlocktopic")
- {
- $forumid = $_GET["forumid"];
- $topicid = $_GET["topicid"];
- $page = $_GET["page"];
- if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR)
- die;
- mysql_query("UPDATE topics SET locked='no' WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid&page=$page");
- die;
- }
- //-------- Action: Set locked on/off
- ///// Add reason to locked code - TBDev - Dokty /////
- if ($action == "setlocked")
- {
- $topicid = 0 + $_POST["topicid"];
- if (!$topicid || get_user_class() < UC_MODERATOR)
- die;
- $res2345 = mysql_query("SELECT locked FROM topics WHERE id = " . $topicid) or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res2345) != 1)
- die("Error - No topic with this ID.");
- $arr2345 = mysql_fetch_assoc($res2345);
- $locked = sqlesc($_POST["locked"]);
- mysql_query("UPDATE topics SET locked=$locked WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- if ($locked != $arr2345["locked"]) {
- $whichoption = ($_POST["locked"] == "yes" ? "L" : "Unl");
- $body = sqlesc("Topic ".$whichoption."ocked by ".$CURUSER['username']."\nReason: ".$_POST["lockreason"].".");
- mysql_query("INSERT INTO posts (topicid, userid, added, body) VALUES($topicid, ".$CURUSER['id'].", '" . get_date_time() . "', $body)") or sqlerr(__FILE__, __LINE__);
- $postid = mysql_insert_id() or die("Post id n/a");
- update_topic_last_post($topicid);
- }
- $returnto = str_replace ('&', '&', htmlentities($_POST["returnto"]));
- header("Location: ".$returnto);
- die;
- }
- //-------- Action: Set sticky on/off
- if ($action == "setsticky")
- {
- $topicid = 0 + $HTTP_POST_VARS["topicid"];
- if (!topicid || get_user_class() < UC_MODERATOR)
- die;
- $sticky = sqlesc($HTTP_POST_VARS["sticky"]);
- mysql_query("UPDATE topics SET sticky=$sticky WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
- header("Location: $HTTP_POST_VARS[returnto]");
- die;
- }
- //-------- Action: Rename topic
- if ($action == 'renametopic')
- {
- if (get_user_class() < UC_MODERATOR)
- die;
- $topicid = $HTTP_POST_VARS['topicid'];
- if (!is_valid_id($topicid))
- die;
- $subject = $HTTP_POST_VARS['subject'];
- if ($subject == '')
- stderr('Error', 'You must enter a new title!');
- $subject = sqlesc($subject);
- mysql_query("UPDATE topics SET subject=$subject WHERE id=$topicid") or sqlerr();
- $returnto = $HTTP_POST_VARS['returnto'];
- if ($returnto)
- header("Location: $returnto");
- die;
- }
- //-------- Action: View forum
- if ($action == "viewforum")
- {
- $forumid = $_GET["forumid"];
- if (!is_valid_id($forumid))
- die;
- $page = $_GET["page"];
- $userid = $CURUSER["id"];
- //------ Get forum name
- $res = mysql_query("SELECT * FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die;
- $forumname = $arr["name"];
- $forid = $arr["forid"];
- if (get_user_class() < $arr["minclassread"])
- die("Not permitted");
- //------ Get overforum name
- $res = mysql_query("SELECT name FROM overforums WHERE id=$forid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die;
- $mforumname = $arr["name"];
- //------ Page links
- //------ Get topic count
- $perpage = $CURUSER["topicsperpage"];
- if (!$perpage) $perpage = 17;
- $res = mysql_query("SELECT COUNT(*) FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res);
- $num = $arr[0];
- if ($page == 0)
- $page = 1;
- $first = ($page * $perpage) - $perpage + 1;
- $last = $first + $perpage - 1;
- if ($last > $num)
- $last = $num;
- $pages = floor($num / $perpage);
- if ($perpage * $pages < $num)
- ++$pages;
- //------ Build menu
- $menu = "<p align=center><b>\n";
- $lastspace = false;
- for ($i = 1; $i <= $pages; ++$i)
- {
- if ($i == $page)
- $menu .= "<font class=gray>$i</font>\n";
- elseif ($i > 3 && ($i < $pages - 2) && ($page - $i > 3 || $i - $page > 3))
- {
- if ($lastspace)
- continue;
- $menu .= "... \n";
- $lastspace = true;
- }
- else
- {
- $menu .= "<a href=?action=viewforum&forumid=$forumid&page=$i>$i</a>\n";
- $lastspace = false;
- }
- if ($i < $pages)
- $menu .= "</b>|<b>\n";
- }
- $menu .= "<br>\n";
- if ($page == 1)
- $menu .= "<font class=gray><< Prev</font>";
- else
- $menu .= "<a href=?action=viewforum&forumid=$forumid&page=" . ($page - 1) . "><< Prev</a>";
- $menu .= " ";
- if ($last == $num)
- $menu .= "<font class=gray>Next >></font>";
- else
- $menu .= "<a href=?action=viewforum&forumid=$forumid&page=" . ($page + 1) . ">Next >></a>";
- $menu .= "</b></p>\n";
- $offset = $first - 1;
- //------ Get topics data
- $topicsres = mysql_query("SELECT * FROM topics WHERE forumid=$forumid ORDER BY sticky, lastpost DESC LIMIT $offset,$perpage") or
- stderr("SQL Error", mysql_error());
- stdhead("Forum");
- ?>
- <center>
- <?
- $numtopics = mysql_num_rows($topicsres);
- print("<h1><a href=forums.php?action=forumview&forid=$forid>$mforumname</a> -> $forumname</h1>\n");
- if ($numtopics > 0)
- {
- print($menu);
- print("<table border=1 cellspacing=0 cellpadding=5>");
- print("<tr><td class=colhead align=left>Topic</td><td class=colhead>Replies</td><td class=colhead>Views</td>\n" .
- "<td class=colhead align=left>Author</td><td class=colhead align=left>Last post</td>\n");
- print("</tr>\n");
- while ($topicarr = mysql_fetch_assoc($topicsres))
- {
- $topicid = $topicarr["id"];
- if ($topicarr["numratings"] != 0)
- $rating = round($topicarr["ratingsum"] / $topicarr["numratings"], 1);
- $rpic = ratingpic($rating);
- $topic_userid = $topicarr["userid"];
- $topic_views = $topicarr["views"];
- $views = number_format($topic_views);
- $locked = $topicarr["locked"];
- $sticky = $topicarr["sticky"] == "yes";
- //---- Get reply count
- $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_row($res);
- $posts = $arr[0];
- $replies = max(0, $posts - 1);
- $tpages = floor($posts / $postsperpage);
- if ($tpages * $postsperpage != $posts)
- ++$tpages;
- if ($tpages > 1)
- {
- $topicpages = " (<img src=".$pic_base_url."multipage.gif>";
- for ($i = 1; $i <= $tpages; ++$i)
- $topicpages .= " <a href=?action=viewtopic&topicid=$topicid&page=$i>$i</a>";
- $topicpages .= ")";
- }
- else
- $topicpages = "";
- //---- Get userID and date of last post
- $res = mysql_query("SELECT * , UNIX_TIMESTAMP(added) as utadded FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res);
- $lppostid = 0 + $arr["id"];
- $lpuserid = 0 + $arr["userid"];
- $lpadded = "<nobr>" . get_date_time($arr["utadded"] , $CURUSER[tzoffset] ) . "</nobr>";
- //------ Get name of last poster
- $res = mysql_query("SELECT * FROM users WHERE id=$lpuserid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) == 1)
- {
- $arr = mysql_fetch_assoc($res);
- $lpusername = "<a href=userdetails.php?id=$lpuserid><b>$arr[username]</b></a>";
- }
- else
- $lpusername = "unknown[$topic_userid]";
- //------ Get author
- $res = mysql_query("SELECT username FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) == 1)
- {
- $arr = mysql_fetch_assoc($res);
- $lpauthor = "<a href=userdetails.php?id=$topic_userid><b>$arr[username]</b></a>";
- }
- else
- $lpauthor = "unknown[$topic_userid]";
- //---- Print row
- $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_row($r);
- $new = !$a || $lppostid > $a[0];
- $topicpic = ($locked=='yes' ? ($new ? "lockednew" : "locked") : ($new ? "unlockednew" : "unlocked"));
- $subject = ($sticky ? "<img src=$pic_base_url/sticky.gif />" : "").($topicpoll ? "<img src=pic/poll.gif alt=\"Poll:\"> " : "").($subscriptions ? "<img src=pic/subscribed.gif alt=\"Subscribed\"> " : ""). "<a href=?action=viewtopic&topicid=$topicid><b>" . encodehtml($topicarr["subject"]) . "</b></a> " .($topicarr["numratings"] ? " $rpic " : ""). " $topicpages<br><small>" . ($topicarr["sub"]) . "</small>";
- print("<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr>" .
- "<td class=embedded style='padding-right: 5px'><img src=$pic_base_url$topicpic.gif>" .
- "</td><td class=embedded align=left>\n" .
- "$subject</td></tr></table></td><td align=right>$replies</td>\n" .
- "<td align=right>$views</td><td align=left>$lpauthor</td>\n" .
- "<td align=left>$lpadded<br>by $lpusername</td>\n");
- print("</tr>\n");
- } // while
- print("</table>\n");
- print($menu);
- } // if
- else
- print("<p align=center>No topics found</p>\n");
- print("<p><table class=main border=0 cellspacing=0 cellpadding=0><tr valing=center>\n");
- print("<td class=embedded><img src=".$pic_base_url."unlockednew.gif style='margin-right: 5px'></td><td class=embedded>New posts</td>\n");
- print("<td class=embedded><img src=".$pic_base_url."locked.gif style='margin-left: 10px; margin-right: 5px'>" .
- "</td><td class=embedded>Locked topic</td>\n");
- print("</tr></table></p>\n");
- $arr = get_forum_access_levels($forumid) or die;
- if (get_user_class() < $arr["create"])
- print("<p><i>You are not permitted to create a new topic in this forum.</i></p>\n");
- elseif ($CURUSER["forumpost"] == 'no')
- print("<p><i>Your posting privilege has been revoked.</i></p>\n");
- else
- $maypost = true;
- print("<p><table border=0 class=main cellspacing=0 cellpadding=0><tr>\n");
- /*
- print("<td class=embedded><form method=get action=?><input type=hidden " .
- "name=action value=viewunread><input type=submit value='View unread' ></form></td>\n");
- */
- if ($maypost)
- print("<td class=embedded><form method=get action=?><input type=hidden " .
- "name=action value=newtopic><input type=hidden name=forumid " .
- "value=$forumid><input type=submit value='New topic' style='margin-left: 10px'></form></td>\n");
- print("</tr></table></p>\n");
- insert_quick_jump_menu($forumid);
- stdfoot();
- die;
- }
- //-------- Action: View unread posts
- if ($action == "viewunread")
- {
- //die("This feature is currently unavailable.");
- $userid = $CURUSER['id'];
- $maxresults = 25;
- $res = mysql_query("SELECT id, forumid, subject, lastpost FROM topics ORDER BY lastpost") or sqlerr(__FILE__, __LINE__);
- stdhead();
- ?>
- <center>
- <?
- print("<h1>Topics with unread posts</h1>\n");
- $n = 0;
- $uc = get_user_class();
- while ($arr = mysql_fetch_assoc($res))
- {
- $topicid = $arr['id'];
- $forumid = $arr['forumid'];
- //---- Check if post is read
- $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_row($r);
- if ($a && $a[0] >= $arr['lastpost'])
- continue;
- //---- Check access & get forum name
- $r = mysql_query("SELECT name, minclassread FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_assoc($r);
- if ($uc < $a['minclassread'])
- continue;
- ++$n;
- if ($n > $maxresults)
- break;
- $forumname = $a['name'];
- if ($n == 1)
- {
- print("<table><td>Click the <u>Clear</u> next to each message to remove it from your unread list<br>or <u>Catch up</u> to remove all messages</td></table><br>");
- print("<table border=1 cellspacing=0 cellpadding=5>\n");
- print("<tr><td class=colhead align=left>Topic</td><td class=colhead align=left>Forum</td></tr>\n");
- }
- print("<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>" .
- "<img src=".$pic_base_url."unlockednew.gif style='margin-right: 5px'></td><td class=embedded>" .
- "<a href=?action=viewtopic&topicid=$topicid&page=last#last><b>" . htmlspecialchars($arr["subject"]) .
- "</b></a> / <a href=?action=catchup&topicid=$topicid>Clear</td></tr></table></td><td align=left><a href=?action=viewforum&forumid=$forumid><b>$forumname</b></a></td></tr>\n");
- }
- if ($n > 0)
- {
- print("</table>\n");
- if ($n > $maxresults)
- print("<p>More than $maxresults items found, displaying first $maxresults.</p>\n");
- print("<p><a href=?action=catchup><b>Catch up</b></a></p>\n");
- }
- else
- print("<b>Nothing found</b>");
- stdfoot();
- die;
- }
- if ($action == "search")
- {
- $maxresults = 50;
- $cats =genreforumlist();
- stdhead("Forum Search");
- ?>
- <center>
- <?
- print("<h1>Forum Search</h1>\n");
- $keywords = trim($_GET["keywords"]);
- $author= trim($_GET['author']);
- if ($author!=""){
- $queryusers= "select id from users where username=".sqlesc($author)." limit 1";
- $userquery = mysql_query($queryusers);
- $num_res = mysql_num_rows($userquery);
- if ($num_res<1){
- print("<b>Author Does not exist, please recheck you typed his username correctly... Results following exclude username filtering</b><br><br>");
- $userfilter="";
- }
- else {
- $userfilterid= mysql_fetch_assoc($userquery);
- $userfilterid= $userfilterid['id'];
- $userfilter= " AND posts.userid=".$userfilterid;
- }
- }
- $sort = (int) $_GET['sort'];
- switch ($sort){
- case 0:
- $sortSel0 = "selected=\"selected\"";
- $order_by="matchweight";
- break;
- case 1:
- $sortSel1 = "selected=\"selected\"";
- $order_by="forumid";
- break;
- case 2:
- $sortSel2 = "selected=\"selected\"";
- $order_by="subject";
- break;
- case 3:
- $sortSel3 = "selected=\"selected\"";
- $order_by="added";
- break;
- case 4:
- $sortSel4 = "selected=\"selected\"";
- $order_by="lastpost_time";
- break;
- case 5:
- $sortSel5 = "selected=\"selected\"";
- $order_by="views";
- break;
- case 6:
- $sortSel6 = "selected=\"selected\"";
- $order_by="replies";
- break;
- default:
- $sortSel0 = "selected=\"selected\"";
- $order_by="matchweight";
- }
- $sort_dir = (int) $_GET['sort_dir'];
- if ($sort_dir==1){
- $sortDirSel1 = "checked=\"checked\"";
- $sort_order= 'ASC';
- }
- else{
- $sortDirSel2 = "checked=\"checked\"";
- $sort_order= 'DESC';
- }
- $numres = (int) $_GET["numres"];
- switch ($numres){
- case 0:
- $numSel1 = "selected=\"selected\"";
- $maxresults=25;
- break;
- case 1:
- $numSel2 = "selected=\"selected\"";
- $maxresults=50;
- break;
- case 2:
- $numSel3 = "selected=\"selected\"";
- $maxresults=100;
- break;
- case 3:
- $numSel4 = "selected=\"selected\"";
- $maxresults=200;
- break;
- case 4:
- $numSel5 = "selected=\"selected\"";
- $maxresults=300;
- break;
- default:
- $numSel1 = "selected=\"selected\"";
- $maxresults=25;
- }
- $search_time = (int) $_GET["search_time"];
- switch ($search_time){
- case 0:
- $whenSel= "selected=\"selected\"";
- $searchWhen="";
- break;
- case 1:
- $whenSel1= "selected=\"selected\"";
- $dt24 = gmtime() - 24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 2:
- $whenSel2= "selected=\"selected\"";
- $dt24 = gmtime() - 2*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 3:
- $whenSel3= "selected=\"selected\"";
- $dt24 = gmtime() - 3*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 4:
- $whenSel4= "selected=\"selected\"";
- $dt24 = gmtime() - 4* 24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 5:
- $whenSel5= "selected=\"selected\"";
- $dt24 = gmtime() - 5*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 6:
- $whenSel6= "selected=\"selected\"";
- $dt24 = gmtime() - 6 *24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 7:
- $whenSel7= "selected=\"selected\"";
- $dt24 = gmtime() - 7*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 14:
- $whenSel8= "selected=\"selected\"";
- $dt24 = gmtime() - 14* 24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 30:
- $whenSel9= "selected=\"selected\"";
- $dt24 = gmtime() - 30*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 90:
- $whenSel10= "selected=\"selected\"";
- $dt24 = gmtime() - 90*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 180:
- $whenSel11= "selected=\"selected\"";
- $dt24 = gmtime() - 180* 24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- case 364:
- $whenSel12= "selected=\"selected\"";
- $dt24 = gmtime() - 364*24 * 60 * 60;
- $searchWhen=" AND added>='".get_date_time($dt24)."'";
- break;
- default:
- $whenSel= "selected=\"selected\"";
- $searchWhen="";
- }
- $category = (int) $_GET["cat"];
- if ($category) {
- if (!is_valid_id($category)) stderr( ("Error"), ("Invalid category ID") );
- $wherecatina[] = $category;
- $addparam .= "cat=".$category."&";
- }
- else {
- $all = True;
- foreach ($cats as $cat) {
- $all &= $_GET["c".$cat['id']];
- if ($_GET["c".$cat['id']]) {
- $wherecatina[] = $cat['id'];
- $addparam .= "c".$cat['id']."=1&";
- }
- }
- }
- if ($all) {
- $wherecatina = array();
- $addparam = "";
- }
- if ($sort_dir==1) $sort_dir=0;
- else $sort_dir=1;
- $addparam.= "author=".htmlspecialchars($author)."&";
- $addparam.= "sort_dir=".$sort_dir."&";
- $addparam.= "search_time=$search_time&";
- $addparam.= "numres=$numres&";
- $addparam.= "keywords=".htmlspecialchars($keywords);
- if (count($wherecatina) > 1) $wherecatin = implode(",",$wherecatina);
- elseif (count($wherecatina) == 1) $wherea[] = "forumid = ".$wherecatina[0];
- if (sizeof($wherea)!=0)
- $where = implode(" AND ", $wherea);
- print ("this is me ".$where." and this is my count".sizeof($wherea));
- if ($wherecatin) $where .= ($where ? " AND " : "") . "forumid IN(" . $wherecatin . ")";
- if ($where !="") $where = " AND ".$where;
- if (($keywords != "")||((($author!="")&&($userfilter!=""))||(($search_time<8)&&($search_time!=0))))
- {
- print("<p>Query: <b>" . htmlspecialchars($keywords) . "</b></p>\n");
- // $maxresults = 50;
- $kw = sqlesc($keywords);
- if ($keywords =="")
- $fields=" 'x'='x'";
- else{
- if (($_GET['body']==1)&&($_GET['topic']==1))
- $fields= "(subject like ".sqlesc('%'.$keywords.'%')." OR MATCH (body) AGAINST ($kw) )";
- else if ($_GET['topic']==1)
- $fields="subject like ".sqlesc('%'.$keywords.'%');
- else
- $fields="MATCH (body) AGAINST ($kw)";
- }
- $query = "SELECT posts.id,topicid,posts.userid,added ,forumid, subject, views,match(body) against ($kw) as matchweight FROM posts,topics WHERE $fields and posts.topicid=topics.id $where $searchWhen $userfilter order by $order_by $sort_order LIMIT " . ($maxresults + 1);
- // print($query);
- $res = mysql_query($query) or sqlerr(__FILE__, __LINE__);
- // search and display results...
- $num = mysql_num_rows($res);
- if ($num > $maxresults)
- {
- $num = $maxresults;
- print("<p>Found more than $maxresults posts; displaying first $num.</p>\n");
- }
- else
- print("<p>Found $num results</p>\n");
- if ($num == 0)
- print("<p><b>Sorry, nothing found!</b></p>");
- else
- {
- print("<p><table border=1 cellspacing=0 cellpadding=5>\n");
- print("<tr><td class=colhead><a href=forums.php?action=search&$addparam&sort=3>Post</a></td>".
- "<td class=colhead align=left><a href=forums.php?action=search&$addparam&sort=2>Topic</a></td>".
- "<td class=colhead align=left><a href=forums.php?action=search&$addparam&sort=1>Forum</a></td>".
- "<td class=colhead><a href=forums.php?action=search&$addparam&sort=5>Views</a></td>".
- "<td class=colhead><a href=forums.php?action=search&$addparam&sort=6>Replies</a></td>".
- "<td class=colhead align=left>Posted by</td></tr>\n");
- for ($i = 0; $i < $num; ++$i)
- {
- $post = mysql_fetch_assoc($res);
- // $res2 = do_mysql_query("SELECT forumid, subject FROM topics WHERE id=$post[topicid]") or
- // sqlerr(__FILE__, __LINE__);
- // $topic = mysql_fetch_assoc($res2);
- $res2 = mysql_query("SELECT name,minclassread FROM forums WHERE id=$post[forumid]") or
- sqlerr(__FILE__, __LINE__);
- $forum = mysql_fetch_assoc($res2);
- if ($forum["name"] == "" || $forum["minclassread"] > $CURUSER["class"])
- continue;
- $res2 = mysql_query("SELECT username,id FROM users WHERE id=$post[userid]") or
- sqlerr(__FILE__, __LINE__);
- $user = mysql_fetch_assoc($res2);
- if ($user["username"] == "")
- $user["username"] = "[$post[userid]]";
- // print("<tr><td>$post[id]</td><td align=left><a href=?action=viewtopic&topicid=$post[topicid]&page=p$post[id]#$post[id]><b>" . htmlspecialchars($topic["subject"]) . "</b></a></td><td align=left><a href=?action=viewforum&forumid=$topic[forumid]><b>" . htmlspecialchars($forum["name"]) . "</b></a><td align=left><a href=userdetails.php?id=$post[userid]><b>$user[username]</b></a><br>at $post[added]</tr>\n");
- print("<tr><td>$post[id]</td><td align=left><a href=?action=viewtopic&highlight=" .urlencode(htmlspecialchars($keywords)) . "&topicid=$post[topicid]&page=p$post[id]#$post[id]><b>" . htmlspecialchars($post["subject"]) . "</b></a></td><td align=left><a href=?action=viewforum&forumid=$post[forumid]><b>" . htmlspecialchars($forum["name"]) . "</b></a><td align=left>$post[views]</td><td align=left>$post[replies]</td><td align=left><b><a href=userdetails.php?id=$user[id]>$user[username]</a></b><br>at $post[added]</tr>\n");
- }
- print("</table></p>\n");
- print("<p><b>Search again</b></p>\n");
- }
- }
- $chtopic = ($_GET['topic']==1 ? "checked " : "");
- $chbody = ($_GET['body']==1? "checked " :"");
- print("<form method=get action=?>\n");
- print("<input type=hidden name=action value=search>\n");
- print("<table border=0 cellspacing=0 cellpadding=5>\n");
- $i = 0;
- foreach ($cats as $cat)
- {
- $catsperrow = 4;
- print(($i && $i % $catsperrow == 0) ? "</tr><tr>" : "");
- if (sizeof($wherecatina)!=0)
- $catCheck= (in_array($cat[id],$wherecatina) ? "checked " : "");
- print("<td nowrap class=bottom style=\"vertical-align:baseline;border:none; padding-bottom: 0px;padding-left: 7px;text-align:left\"><input style=\"vertical-align:middle;padding:0px;margin:0px;margin-right:3px;\" name=c$cat[id] type=\"checkbox\" " .$catCheck . "value=1><a style=\"vertical-align:middle;padding:0px;margin:0px;\" class=catlink href=".$GLOBALS['DEFAULTBASEURL']."/forums.php?action=viewforum&forumid=$cat[id]>" . htmlspecialchars($cat[name]) . "</a></td>\n");
- $i++;
- }
- print("</table><br><br><table border=1 cellspacing=0 cellpadding=5><tr><td class=rowhead>Search Term</td><td align=left><input type=text size=40 name=keywords value=\"".htmlspecialchars($keywords)."\"><br>\n" .
- "<font class=small size=-1>Enter one or more words to search for.</font></td></tr>\n");
- // Search in author
- print("<tr><td class=rowhead>Author:</td><td align=left><input type=text size=15 name=author value=\"".htmlspecialchars($author)."\"> Only display posts from this author");
- print("<tr><td colspan=2><table border=0 cellspacing=0 cellpadding=5>");
- // When to search in
- print("<tr><td class=rowhead style=\"border:none\">Search In Last:</td><td style=\"border:none\"> <select name=\"search_time\"><option value=\"0\" $whenSel>All Posts</option><option value=\"1\" $whenSel1>1 Day</option><option value=\"2\" $whenSel2>2 Days</option><option value=\"3\" $whenSel3>3 Days</option><option value=\"4\" $whenSel4>4 Days</option><option value=\"5\" $whenSel5>5 Days</option><option value=\"6\" $whenSel6>6 Days</option><option value=\"7\" $whenSel7>1 Week</option><option value=\"14\" $whenSel8>2 Weeks</option><option value=\"30\" $whenSel9>1 Month</option><option value=\"90\" $whenSel10>3 Months</option><option value=\"180\" $whenSel11>6 Months</option><option value=\"364\" $whenSel12>1 Year</option></select></td></tr>");
- // Where to search in
- print("<tr><td class=rowhead style=\"border:none\">Search In:</td>".
- "<td style=\"border:none\"><table border=0 cellspacing=0 cellpadding-5><tr>".
- "<td style=\"border:none\"><input style=\"padding:0px;margin:0px;margin-right:3px;\" name=topic type=\"checkbox\" value=1 $chtopic> Topic Title</td></tr>".
- "<tr><td style=\"border:none\"><input style=\"padding:0px;margin:0px;margin-right:3px;\" name=body type=\"checkbox\" value=1 $chbody> Post Body (default if both unchecked)</td></tr>".
- "</table></td></tr>");
- //Sorting options
- print("<tr><td class=rowhead style=\"border:none\">Sort By:</td><td style=\"border:none\">");
- print("<select name=\"sort\"><option value=\"0\" $sortSel0>Relevancy</option><option value=\"1\" $sortSel1>Forum Name</option><option value=\"2\" $sortSel2>Topic Name</option><option value=\"3\" $sortSel3>Post Time</option><option value=\"4\" $sortSel4>Last Post Time</option><option value=\"5\" $sortSel5>Topic Views</option><option value=\"6\" $sortSel6>Topic Replies</option></select> <input type=\"radio\" name=\"sort_dir\" value=\"1\" $sortDirSel1/>Ascending <input type=\"radio\" name=\"sort_dir\" value=\"0\" $sortDirSel2/> Descending</select></td></tr>");
- // Number of results
- print("<tr><td class=rowhead style=\"border:none\">Return First:</td><td style=\"border:none\">");
- print("<select name=\"numres\"><option value=\"0\" $numSel1>25</option><option value=\"1\" $numSel2>50</option><option value=\"2\" $numSel3>100</option><option value=\"3\" $numSel4>200</option><option value=\"4\" $numSel5>300</option></select> found results</td></tr>");
- //Display posts summary options/topics
- print ("</table></td></tr>");
- print("<tr><td colspan=2 align=right><input type=submit value='Search' > </td></tr>\n");
- print("</table>\n</form>\n");
- stdfoot();
- die;
- }
- if ($action == "catchup")
- {
- $topicid=0+$_GET["topicid"];
- if ($topicid) {
- catch_up("$topicid");
- header("Location: $BASEURL/forums.php?action=viewunread");
- die();
- }
- else catch_up();
- header("Location: $BASEURL/forums.php");
- die();
- }
- //-------- Default action: View forums
- //-------- Get forums
- if ($action == 'forumview')
- {
- $forid = 0+$_GET["forid"];
- // - Bleaches Edits
- mysql_query("UPDATE users SET forum_access='" . get_date_time() . "' WHERE id={$CURUSER["id"]}");// or die(mysql_error());
- $forums_res = mysql_query("SELECT * FROM forums WHERE forid=$forid ORDER BY name") or sqlerr(__FILE__, __LINE__);
- //------ Get forum name
- $res = mysql_query("SELECT name FROM overforums WHERE id=$forid") or sqlerr(__FILE__, __LINE__);
- $arr = mysql_fetch_assoc($res) or die;
- $forumname = $arr["name"];
- stdhead("Forums");
- print("<h1><b><a href=forums.php>Forums</a></b> ->".$forumname."</h1>\n");
- print("<table border=1 cellspacing=0 cellpadding=5>\n");
- print("<tr><td class=colhead align=left>Forums</td><td class=colhead align=right>Topics</td>" .
- "<td class=colhead align=right>Posts</td>" .
- "<td class=colhead align=left>Last post</td></tr>\n");
- while ($forums_arr = mysql_fetch_assoc($forums_res))
- {
- if (get_user_class() < $forums_arr["minclassread"])
- continue;
- // Set forumid
- //mysql_query("UPDATE forums SET forumid=1") or sqlerr(__FILE__, __LINE__);
- //$forums_arr["Forumid"] = 1;
- //echo ($forum_arr["$forumid"]);
- //die('test');
- //$fid = $forums_arr["forid"];
- //if ($forums_arr["forid"] != $forid)
- // continue;
- $forumid = $forums_arr["id"];
- $forumname = htmlspecialchars($forums_arr["name"]);
- $forumdescription = htmlspecialchars($forums_arr["description"]);
- $topiccount = number_format($forums_arr["topiccount"]);
- $postcount = number_format($forums_arr["postcount"]);
- /*
- while ($topicids_arr = mysql_fetch_assoc($topicids_res))
- {
- $topicid = $topicids_arr['id'];
- $postcount_res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $postcount_arr = mysql_fetch_row($postcount_res);
- $postcount += $postcount_arr[0];
- }
- $postcount = number_format($postcount);
- */
- // Find last post ID
- $lastpostid = get_forum_last_post($forumid);
- // Get last post info
- $post_res = mysql_query("SELECT UNIX_TIMESTAMP(added) as utadded,topicid,userid FROM posts WHERE id=$lastpostid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($post_res) == 1)
- {
- $post_arr = mysql_fetch_assoc($post_res) or die("Bad forum last_post");
- $lastposterid = $post_arr["userid"];
- $lastpostdate = get_date_time($post_arr["utadded"] , $CURUSER[tzoffset] );
- $lasttopicid = $post_arr["topicid"];
- $user_res = mysql_query("SELECT username FROM users WHERE id=$lastposterid") or sqlerr(__FILE__, __LINE__);
- $user_arr = mysql_fetch_assoc($user_res);
- $lastposter = htmlspecialchars($user_arr['username']);
- $topic_res = mysql_query("SELECT subject FROM topics WHERE id=$lasttopicid") or sqlerr(__FILE__, __LINE__);
- $topic_arr = mysql_fetch_assoc($topic_res);
- $lasttopic = htmlspecialchars($topic_arr['subject']);
- $lastpost = "<nobr>$lastpostdate<br>" .
- "by <a href=userdetails.php?id=$lastposterid><b>$lastposter</b></a><br>" .
- "in <a href=?action=viewtopic&topicid=$lasttopicid&page=p$lastpostid#$lastpostid><b>$lasttopic</b></a></nobr>";
- $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$CURUSER[id] AND topicid=$lasttopicid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_row($r);
- if ($a && $a[0] >= $lastpostid)
- $img = "unlocked";
- else
- $img = "unlockednew";
- }
- else
- {
- $lastpost = "N/A";
- $img = "unlocked";
- }
- print("<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded style='padding-right: 5px'><img src=".
- "/pic/$img.gif></td><td class=embedded><a href=?action=viewforum&forumid=$forumid><b>$forumname</b></a>\n" .
- ($CURUSER['class']>=UC_MODERATOR ? "<font class=small> ".
- "[<a class=altlink href=forums.php?action=editforum&forumid=$forumid>Edit</a>] ".
- "[<a class=altlink href=forums.php?action=deleteforum&forumid=$forumid>Delete</a>]</font>" : "").
- "<br>\n$forumdescription</td></tr></table></td><td align=right>$topiccount</td></td><td align=right>$postcount</td>" .
- "<td align=left>$lastpost</td></tr>\n");
- }
- // End Table Mod
- print("</table>");
- $forum_t = gmtime() - 60; //you can change this value to whatever span you want
- $forum_t = sqlesc(get_date_time($forum_t));
- $res = mysql_query("SELECT id, username, class, donor, warned FROM users WHERE forum_access >= $forum_t ORDER BY forum_access DESC") or print(mysql_error());
- while ($arr = mysql_fetch_assoc($res))
- {
- if ($forumusers) $forumusers .= ",\n";
- switch ($arr["class"])
- {
- case UC_STAFF_LEADER:
- $arr['username'] = '<font color=darkred>' . $arr['username'] . '</font>';
- break;
- case UC_SYSOP:
- $arr['username'] = '<font color=#2587A7>' . $arr['username'] . '</font>';
- break;
- case UC_ADMINISTRATOR:
- $arr['username'] = '<font color=#B000B0>' . $arr['username'] . '</font>';
- break;
- case UC_MODERATOR:
- $arr['username'] = '<font color=#7A8B8B>' . $arr['username'] . '</font>';
- break;
- case UC_MODERATOR:
- $arr['username'] = '<font color=#ff5151>' . $arr['username'] . '</font>';
- break;
- case UC_FAST_UPLOADER:
- $arr['username'] = '<font color=#6464FF>' . $arr['username'] . '</font>';
- break;
- case UC_UPLOADER:
- $arr['username'] = '<font color=#6464FF>' . $arr['username'] . '</font>';
- break;
- case UC_ELITE_VIP:
- $arr['username'] = '<font color=#FFFF00>' . $arr['username'] . '</font>';
- break;
- case UC_VIP:
- $arr['username'] = '<font color=#009F00>' . $arr['username'] . '</font>';
- break;
- case UC_POWER_USER:
- $arr['username'] = '<font color=#f9a200>' . $arr['username'] . '</font>';
- break;
- }
- $donator = $arr["donor"] === "yes";
- if ($donator)
- $forumusers .= "<nobr>";
- $warned = $arr["warned"] === "yes";
- if ($donator)
- $forumusers .= "<nobr>";
- if ($CURUSER)
- $forumusers .= "<a href=userdetails.php?id={$arr["id"]}><b>{$arr["username"]}</b></a>";
- else
- $forumusers .= "<b>{$arr["username"]}</b>";
- if ($donator)
- $forumusers .= " <img src={$pic_base_url}star.gif alt='Donated' title=\"User Donated\" style=\"vertical-align:middle\"></nobr>";
- if ($warned)
- $forumusers .= "<img src={$pic_base_url}warned.gif alt='Warned {$$arr["warned"]}'></nobr>";
- }
- if (!$forumusers)
- $forumusers = "There have been no active users in the last 15 minutes.";
- ?>
- <br>
- <table width=80% border=1 cellspacing=0 cellpadding=5><tr>
- <td class="colhead" align="left">Active Forum Users</td></tr>
- </tr><td class=text>
- <?=$forumusers?>
- </td></tr></table>
- <!--<center>
- <b><font class="medium" color="darkred">Staff Leader</font><b> |</b>
- <b><font class="medium" color="#2587A7">Sysop</font> |
- <b><font class="medium" color="#B000B0">Administator</font> |
- <b><font class="medium" color="#ff5151">Moderator</font> |
- <b><font class="medium" color="#ff5151">Forum Moderator</font> |
- <b><font class="medium" color="#6464FF">Fast Uploader</font> |
- <b><font class="medium" color="#6464FF">Uploader</font> |
- <b><font class="medium" color="#009F00">VIP</font> |
- <b><font class="medium" color="#f9a200">PowerUser</font></b> |
- <b><font class="medium" color="#000000">User</font></b>
- -->
- <br>
- <?
- print("<table width=50% border=1 cellspacing=0 cellpadding=5>\n");
- print("<tr><td class=colhead>Stats</td></tr>\n");
- // $registered = number_format(get_row_count("users", "WHERE enabled = 'yes'")); // » We have " . $registered . " users,<BR>
- $donated = number_format(get_row_count("users", "WHERE donor = 'yes'"));
- // $a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
- // if ($CURUSER) // » Our newest member is " . $latestuser . ", <BR>
- // $latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
- // else
- // $latestuser = $a['username'];
- $totalonline = number_format(get_row_count("users", "WHERE UNIX_TIMESTAMP(" . get_dt_num() . ") - UNIX_TIMESTAMP(last_access) < 60"));
- $topiccount = mysql_query("select sum(topiccount) as topiccount from forums");
- $row1 = mysql_fetch_array($topiccount);
- $topiccount = $row1[topiccount];
- $postcount = mysql_query("select sum(postcount) as postcount from forums");
- $row2 = mysql_fetch_array($postcount);
- $postcount = $row2[postcount];
- print("<tr><td>
- » Our members have made " . $postcount . " posts in " . $topiccount . " topics,<BR>
- » We have " . $donated . " donors,<BR>
- » " . $totalonline . " Users online now.</td></tr>\n");
- print("</table>");
- stdfoot();
- ///////////////////////////////
- die();
- }
- //-------- Handle unknown action
- if ($action != "")
- stderr("Forum Error", "Unknown action.");
- //-------- Get overforums --- being tested
- mysql_query("UPDATE users SET forum_access='" . get_date_time() . "' WHERE id={$CURUSER["id"]}");// or die(mysql_error());
- $forums2_res = mysql_query("SELECT * FROM overforums ORDER BY sort ASC") or sqlerr(__FILE__, __LINE__);
- stdhead("G-T-I Forums");
- ?>
- <center>
- <?
- //print("<p align=center><a href=?action=search><b><img border=0 src=pic/forumsearch.gif></b></a> <a href=?action=viewunread><b><img border=0 src=pic/viewunread.gif></b></a> <a href=?action=catchup><b><img border=0 src=pic/catchup.gif></b></a></p>");
- print("<h1>Welcome to $SITENAME Forum</h1>\n");
- // print("<h1><img src=pic/fun.gif width=644 height=44></h1>\n");
- if ($CURUSER)
- {
- // Get current poll
- $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
- if($pollok=(mysql_num_rows($res)))
- {
- $arr = mysql_fetch_assoc($res);
- $pollid = $arr["id"];
- $userid = $CURUSER["id"];
- $question = format_comment($arr["question"]);
- $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
- $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
- $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
- $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);
- // Check if user has already voted
- $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or sqlerr();
- $arr2 = mysql_fetch_assoc($res);
- }
- /*
- print("<h2><br>");
- if (get_user_class() >= UC_MODERATOR)
- {
- print("<font class=small>");
- print(" - [<a class=altlink href=makepoll.php?returnto=main><b>New</b></a>]\n");
- if($pollok) {
- print(" - [<a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main><b>Edit</b></a>]\n");
- print(" - [<a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main><b>Delete</b></a>]");
- }
- print("</font>");
- }
- print("</h2>\n");*/
- if($pollok) {
- print("<table width=80% border=1 cellspacing=0 cellpadding=10><tr><td align=center>\n");
- /* if (get_user_class() >= UC_MODERATOR)
- {
- print("<font class=small>");
- print(" <a class=altlink href=makepoll.php?returnto=main><img border=0 src=pic/newpoll.gif></a>\n");
- if($pollok) {
- print(" <a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main><img border=0 src=pic/editpoll.gif></a>\n");
- print(" <a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main><img border=0 src=pic/deletepoll.gif></a>");
- }
- print("</font><p>");
- } */
- print("<table class=main border=1 cellspacing=0 cellpadding=0><tr><td class=text>");
- print("<p align=center><b>$question</b></p>\n");
- $voted = $arr2;
- if ($voted)
- {
- // display results
- if ($arr["selection"])
- $uservote = $arr["selection"];
- else
- $uservote = -1;
- // we reserve 255 for blank vote.
- $res = mysql_query("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or sqlerr();
- $tvotes = mysql_num_rows($res);
- $vs = array(); // array of
- $os = array();
- // Count votes
- while ($arr2 = mysql_fetch_row($res))
- $vs[$arr2[0]] += 1;
- reset($o);
- for ($i = 0; $i < count($o); ++$i)
- if ($o[$i])
- $os[$i] = array($vs[$i], $o[$i]);
- function srt($a,$b)
- {
- if ($a[0] > $b[0]) return -1;
- if ($a[0] < $b[0]) return 1;
- return 0;
- }
- // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
- if ($arr["sort"] == "yes")
- usort($os, srt);
- print("<table class=main width=100% border=0 cellspacing=0 cellpadding=0>\n");
- $i = 0;
- while ($a = $os[$i])
- {
- if ($i == $uservote)
- $a[1] .= " *";
- if ($tvotes == 0)
- $p = 0;
- else
- $p = round($a[0] / $tvotes * 100);
- if ($i % 2)
- $c = "";
- else
- $c = " bgcolor=#2d2d2d";
- print("<tr><td width=1% class=embedded$c><nobr>" . $a[1] . " </nobr></td><td width=99% class=embedded$c>" .
- "<img src=/pic/bar_left.gif><img src=/pic/bar.gif height=9 width=" . ($p * 3) .
- "><img src=/pic/bar_right.gif> $p%</td></tr>\n");
- ++$i;
- }
- print("</table>\n");
- $tvotes = number_format($tvotes);
- print("<p align=center>Votes: $tvotes</p>\n");
- }
- else
- {
- print("<form method=post action=index.php>\n");
- $i = 0;
- while ($a = $o[$i])
- {
- print("<input type=radio name=choice value=$i>$a<br>\n");
- ++$i;
- }
- print("<br>");
- print("<input type=radio name=choice value=255>Blank vote (a.k.a. \"I just want to see the results!\")<br>\n");
- print("<p align=center><input type=submit value='Vote!' ></p>");
- }
- ?>
- </td></tr></table>
- <p>
- <?
- $res = mysql_query("SELECT id FROM topics WHERE forumid = 39 ORDER BY id DESC LIMIT 1") or sqlerr();
- while ($arr = mysql_fetch_assoc($res))
- {
- $topicid = $arr["id"];
- }
- if ($voted)
- if (get_user_class() >= UC_MODERATOR)
- {
- $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
- if($pollok=(mysql_num_rows($res)))
- {
- $arr = mysql_fetch_assoc($res);
- $pollid = $arr["id"];
- $userid = $CURUSER["id"];
- $question = format_comment($arr["question"]);
- $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
- $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
- $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
- $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);
- print("<font class=small>");
- print(" <a class=altlink href=makepoll.php?returnto=main><img border=0 src=pic/newpoll.gif></a>\n");
- if($pollok) {
- print(" <a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main><img border=0 src=pic/editpoll.gif></a>\n");
- print(" <a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main><img border=0 src=pic/deletepoll.gif></a>");
- }
- print("</font><p>");
- }
- print("<p align=center><font class=small><a href=?action=search><b><img border=0 src=pic/forumsearch.gif></b></a> <a href=?action=viewunread><b><img border=0 src=pic/viewunread.gif></b></a> <a href=?action=catchup><b><img border=0 src=pic/catchup.gif></b></a><a class=altlink href=polls.php><img border=0 src=pic/forumpoll.gif></a> <a class=altlink href=/forums.php?action=viewtopic&topicid=$topicid><img border=0 src=pic/discussit.gif></a></font><br>\n");
- ?>
- </td></tr></table>
- <?
- } else {
- echo "<table width=80% border=1 cellspacing=0 cellpadding=10><tr><td align=center>\n";
- echo "<table class=main border=1 cellspacing=0 cellpadding=0><tr><td class=text>";
- echo"<p align=center><H3>No Active Polls</h3></p>\n";
- echo "</td></tr></table></td></tr></table>";
- }
- }
- //print("<h1><b>gti Forums</b></h1>\n");
- // if (get_user_class() >= UC_ELITE_VIP)
- // {
- // ?>
- <!-- <center><a href="http://www.grabthe.info/forum"><img border=0 src=pic/vip-forum.gif></a> -->
- <?
- //print("<a href=http://www.grabthe.info/forum></a><img src=pic/vip-forum.jpg>");
- // }
- ?>
- <P>
- <?
- print("<table width=80% border=1 cellspacing=0 cellpadding=10>\n");
- while ($a = mysql_fetch_assoc($forums2_res))
- {
- $npost = 0;
- if (get_user_class() < $a["minclassview"])
- continue;
- $forid = $a["id"];
- $overforumname = $a["name"];
- print("<tr><td align=left class=colhead><a href=?action=forumview&forid=$forid><b><font color=white>".$overforumname."</font></b></a></td><td align=right class=colhead><font color=white><b>Topics</b></td>" .
- "<td align=right class=colhead><font color=white><b>Posts</b></font></td>" .
- "<td align=left class=colhead><font color=white><b>Last post</b></font></td></tr>\n");
- $forums_res = mysql_query("SELECT * FROM forums WHERE forid=$forid ORDER BY forid ASC") or sqlerr(__FILE__, __LINE__);
- while ($forums_arr = mysql_fetch_assoc($forums_res))
- {
- if (get_user_class() < $forums_arr["minclassread"])
- continue;
- // Set forumid
- //mysql_query("UPDATE forums SET forumid=1") or sqlerr(__FILE__, __LINE__);
- //$forums_arr["Forumid"] = 1;
- //echo ($forum_arr["$forumid"]);
- //die('test');
- //$fid = $forums_arr["forid"];
- //if ($forums_arr["forid"] != $forid)
- // continue;
- $forumid = $forums_arr["id"];
- $forumname = htmlspecialchars($forums_arr["name"]);
- $forumdescription = htmlspecialchars($forums_arr["description"]);
- $topiccount = number_format($forums_arr["topiccount"]);
- $postcount = number_format($forums_arr["postcount"]);
- /*
- while ($topicids_arr = mysql_fetch_assoc($topicids_res))
- {
- $topicid = $topicids_arr['id'];
- $postcount_res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
- $postcount_arr = mysql_fetch_row($postcount_res);
- $postcount += $postcount_arr[0];
- }
- $postcount = number_format($postcount);
- */
- // Find last post ID
- $lastpostid = get_forum_last_post($forumid);
- // Get last post info
- $post_res = mysql_query("SELECT UNIX_TIMESTAMP(added) as utadded,topicid,userid FROM posts WHERE id=$lastpostid") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($post_res) == 1)
- {
- $post_arr = mysql_fetch_assoc($post_res) or die("Bad forum last_post");
- $lastposterid = $post_arr["userid"];
- $lastpostdate = get_date_time($post_arr["utadded"] , $CURUSER[tzoffset] );
- $lasttopicid = $post_arr["topicid"];
- $user_res = mysql_query("SELECT username FROM users WHERE id=$lastposterid") or sqlerr(__FILE__, __LINE__);
- $user_arr = mysql_fetch_assoc($user_res);
- $lastposter = htmlspecialchars($user_arr['username']);
- $topic_res = mysql_query("SELECT subject FROM topics WHERE id=$lasttopicid") or sqlerr(__FILE__, __LINE__);
- $topic_arr = mysql_fetch_assoc($topic_res);
- $lasttopic = htmlspecialchars($topic_arr['subject']);
- $lastpost = "<nobr>$lastpostdate<br>" .
- "by <a href=userdetails.php?id=$lastposterid><b>$lastposter</b></a><br>" .
- "in <a href=?action=viewtopic&topicid=$lasttopicid&page=p$lastpostid#$lastpostid><b>$lasttopic</b></a></nobr>";
- $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$CURUSER[id] AND topicid=$lasttopicid") or sqlerr(__FILE__, __LINE__);
- $a = mysql_fetch_row($r);
- if ($a && $a[0] >= $lastpostid)
- $img = "unlocked";
- else
- $img = "unlockednew";
- }
- else
- {
- $lastpost = "N/A";
- $img = "unlocked";
- }
- print("<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded style='padding-right: 5px'><img src=".
- "/pic/$img.gif></td><td class=embedded><a href=?action=viewforum&forumid=$forumid><b>$forumname</b></a>\n" .
- ($CURUSER['class']>=UC_MODERATOR ? "<font class=small> ".
- "[<a class=altlink href=forums.php?action=editforum&forumid=$forumid>Edit</a>] ".
- "[<a class=altlink href=forums.php?action=deleteforum&forumid=$forumid>Delete</a>]</font>" : "").
- "<br>\n$forumdescription</td></tr></table></td><td align=right>$topiccount</td></td><td align=right>$postcount</td>" .
- "<td align=left>$lastpost</td></tr>\n");
- }
- }
- // End Table Mod
- print("</table>");
- $forum_t = gmtime() - 60; //you can change this value to whatever span you want
- $forum_t = sqlesc(get_date_time($forum_t));
- $res = mysql_query("SELECT id, username, class, donor, warned FROM users WHERE forum_access >= $forum_t ORDER BY forum_access DESC") or print(mysql_error());
- while ($arr = mysql_fetch_assoc($res))
- {
- if ($forumusers) $forumusers .= ",\n";
- switch ($arr["class"])
- {
- case UC_OWNER:
- $arr['username'] = '<font color=red>' . $arr['username'] . '</font>';
- break;
- case UC_CO_OWNER:
- $arr['username'] = '<font color=red>' . $arr['username'] . '</font>';
- break;
- case UC_SYSOP:
- $arr['username'] = '<font color=#2587A7>' . $arr['username'] . '</font>';
- break;
- case UC_ADMINISTRATOR:
- $arr['username'] = '<font color=#B000B0>' . $arr['username'] . '</font>';
- break;
- case UC_MODERATOR:
- $arr['username'] = '<font color=#7A8B8B>' . $arr['username'] . '</font>';
- break;
- case UC_FAST_UPLOADER:
- $arr['username'] = '<font color=#0000CC>' . $arr['username'] . '</font>';
- break;
- case UC_UPLOADER:
- $arr['username'] = '<font color=#6464FF>' . $arr['username'] . '</font>';
- break;
- case UC_VIP:
- $arr['username'] = '<font color=#FFFF00>' . $arr['username'] . '</font>';
- break;
- case UC_COMM_VIP:
- $arr['username'] = '<font color=#806517>' . $arr['username'] . '</font>';
- break;
- case UC_HEAVYWEIGHT:
- $arr['username'] = '<font color=#F87431>' . $arr['username'] . '</font>';
- break;
- case UC_LIGHT_HEAVYWEIGHT:
- $arr['username'] = '<font color=#C48189>' . $arr['username'] . '</font>';
- break;
- case UC_MIDDLE_WEIGHT:
- $arr['username'] = '<font color=#A74AC7>' . $arr['username'] . '</font>';
- break;
- case UC_WELTER_WEIGHT:
- $arr['username'] = '<font color=#E78A61>' . $arr['username'] . '</font>';
- break;
- case UC_LIGHT_WEIGHT:
- $arr['username'] = '<font color=#4C787E>' . $arr['username'] . '</font>';
- break;}
- $donator = $arr["donor"] === "yes";
- if ($donator)
- $forumusers .= "<nobr>";
- $warned = $arr["warned"] === "yes";
- if ($donator)
- $forumusers .= "<nobr>";
- if ($CURUSER)
- $forumusers .= "<a href=userdetails.php?id={$arr["id"]}><b>{$arr["username"]}</b></a>";
- else
- $forumusers .= "<b>{$arr["username"]}</b>";
- if ($donator)
- $forumusers .= "<img src={$pic_base_url}star.gif alt='Donated' title=\"User Donated\" style=\"vertical-align:middle\"></nobr>";
- if ($warned)
- $forumusers .= "<img src={$pic_base_url}warned.gif alt='Warned {$$arr["warned"]}'></nobr>";
- }
- if (!$forumusers)
- $forumusers = "There have been no active users in the last 15 minutes.";
- ?>
- <br>
- <table width=80% border=1 cellspacing=0 cellpadding=5><tr>
- <td class="colhead" align="left">Active Forum Users</td></tr>
- </tr><td class=text>
- <?=$forumusers?>
- </td></tr></table>
- <center>
- <b><font class="medium" color="darkred">Owner</font><b> |</b>
- <b><font class="medium" color="red">Co Owner</font><b> |
- <b><font class="medium" color="#2587A7">Sysop</font> |
- <b><font class="medium" color="#B000B0">Administator</font> |
- <b><font class="medium" color="#347235">Moderator</font> |
- <b><font class="medium" color="#0000CC">Fast Uploader</font> |
- <b><font class="medium" color="#6464FF">Uploader</font> <br>
- <b><font class="medium" color="#FFFF00">VIP<img src=pic/star.gif></font> |
- <b><font class="medium" color="#806517">Community-vip</font> |
- <b><font class="medium" color="#F87431">Heavyweight</font></b> |
- <b><font class="medium" color="#3EA99F">Light Heavyweight</font></b> |
- <b><font class="medium" color="#A74AC7">Middleweight</font></b> |
- <b><font class="medium" color="#E78A61">Welterweight</font></b> |
- <b><font class="medium" color="#FAAFBE">Lightweight(noobs)</font></b> |
- <b><font class="medium" color="#FFFF00">Donor<img src=pic/star.gif></font></b>
- <br>
- <p>
- <?
- print("<table width=50% border=1 cellspacing=0 cellpadding=5>\n");
- print("<tr><td class=colhead>Stats</td></tr>\n");
- // $registered = number_format(get_row_count("users", "WHERE enabled = 'yes'")); // » We have " . $registered . " users,<BR>
- $donated = number_format(get_row_count("users", "WHERE donor = 'yes'"));
- // $a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
- // if ($CURUSER) // » Our newest member is " . $latestuser . ", <BR>
- // $latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
- // else
- // $latestuser = $a['username'];
- $totalonline = number_format(get_row_count("users", "WHERE UNIX_TIMESTAMP(" . get_dt_num() . ") - UNIX_TIMESTAMP(last_access) < 60"));
- $topiccount = mysql_query("select sum(topiccount) as topiccount from forums");
- $row1 = mysql_fetch_array($topiccount);
- $topiccount = $row1[topiccount];
- $postcount = mysql_query("select sum(postcount) as postcount from forums");
- $row2 = mysql_fetch_array($postcount);
- $postcount = $row2[postcount];
- print("<tr><td>
- » Our members have made " . $postcount . " posts in " . $topiccount . " topics,<BR>
- » We have " . $donated . " donors,<BR>
- » " . $totalonline . " Users online now.</td></tr>\n");
- print("</table>");
- //print("<p align=center><a href=?action=search><b><img border=0 src=pic/forumsearch.gif></b></a> <a href=?action=viewunread><b><img border=0 src=pic/viewunread.gif></b></a> <a href=?action=catchup><b><img border=0 src=pic/catchup.gif></b></a></p>");
- if ($CURUSER['class']>=UC_MODERATOR)
- print("<form method=\"get\" action=\"forummanage.php#add\"><input type=\"submit\" value=\"New forum\" style='height: 18px' /></form>\n");
- }
- //stdfoot();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement