0.8.1a
[gfh.git] / topiclist.php
blobf725a531c42719b5964d013f41b600b81dca690c
1 <?php session_start();
2 $thissid = session_id();
3 include "config.php";
4 if (!isset($_GET['board']))
6 echo "Invalid boardID.";
7 exit;
9 if (empty($_GET['page']))
11 $page = 0;
12 } else
14 $page = $_GET['page'] -1;
16 $pages = $page * 50;
17 function getuserid($username)
19 $sql = "SELECT * FROM users WHERE username='$username'";
20 $result = mysql_query($sql);
21 $myrow = mysql_fetch_array($result);
22 return $myrow["userid"];
24 function clancheck($bdnum, $username)
26 $sql = "SELECT * FROM users WHERE username='$username'";
27 $result = mysql_query($sql);
28 $myrow = mysql_fetch_array($result);
29 $clan2 = $myrow["faction"];
30 $sql = "SELECT * FROM boards WHERE boardid='$bdnum'";
31 $result = mysql_query($sql);
32 $myrow = mysql_fetch_array($result);
33 if ($clan2 == $myrow["clan"])
35 return 1;
36 } else
38 return 0;
41 function notify($username)
43 $sql = "SELECT * FROM users WHERE username='$username'";
44 $result = mysql_query($sql);
45 $myrow = mysql_fetch_array($result);
46 if ($myrow["notify"] == 1)
48 return 1;
49 } else
51 return 0;
54 function howsugs()
56 $sql = "SELECT * FROM suggest WHERE active=1";
57 $result = mysql_query($sql);
58 return mysql_num_rows($result);
60 function howmarks()
62 $sql = "SELECT * FROM marked WHERE active=1";
63 $result = mysql_query($sql);
64 return mysql_num_rows($result);
67 function postcount($topicid)
69 $sql = "SELECT * FROM messages WHERE topic='$topicid'";
70 $result = mysql_query($sql);
71 return mysql_num_rows($result);
73 function boardex($board)
75 $sql = "SELECT * FROM boards WHERE boardid='$board'";
76 $result = mysql_query($sql);
77 if (!mysql_num_rows($result))
79 return 0;
80 } else
82 return 1;
85 $username = auth();
86 if (!$username)
88 echo "You cannot view this board.";
89 exit;
91 $setfav = 0;
92 if (!empty($_GET['favadd']))
94 $userid = getuserid($uname);
95 $sql = "SELECT * FROM favorites WHERE fboard='{$_GET['board']}' AND fuser='$userid'";
96 $result = mysql_query($sql);
97 if ((mysql_num_rows($result)) < 1)
99 $sql = "INSERT INTO favorites (fboard,fuser) VALUES ('{$_GET['board']}','$userid')";
100 $result = mysql_query($sql);
101 $setfav = 1;
104 $sql = "SELECT * FROM users WHERE username='$uname'";
105 $result = mysql_query($sql);
106 $myrow = mysql_fetch_array($result);
107 $userlevel = $myrow["level"];
108 $sql = "SELECT * FROM boards WHERE boardid='{$_GET['board']}'";
109 $result = mysql_query($sql);
110 $myrow = mysql_fetch_array($result);
111 $boardname = $myrow["boardname"];
112 $clanvalue = $myrow["clan"];
113 if ($username)
115 if ($myrow["boardlevel"] <= $userlevel)
117 $datedate = date("n/j/y H:i:s");
118 $timetime = time();
119 $sql = "UPDATE users SET lastactivity='$datedate' WHERE username='$uname'";
120 $result = mysql_query($sql);
121 $sql = "UPDATE users SET lastsec='$timetime' WHERE username='$uname'";
122 $result = mysql_query($sql);
123 $sql = "UPDATE users SET lastacip='{$_SERVER['REMOTE_ADDR']}' WHERE username='$uname'";
124 $result = mysql_query($sql);
125 echo "<font size=6 color=black face=arial><b><center>".stripslashes($boardname)."</b></center></font>\n";
126 $exist = boardex($_GET['board']);
127 $notify = notify($uname);
128 $clan = clancheck($_GET['board'], $uname);
129 if ($clanvalue != 0 AND $userlevel != 60)
131 if ($clan == 0)
133 echo "<font color=black>You cannot view this board.</font>";
134 exit;
137 if ($exist == 0)
139 echo "<font color=black>Invalid boardID.</font>";
140 exit;
142 $sql = "SELECT * FROM users WHERE username='$uname'";
143 $result = mysql_query($sql);
144 $myrow = mysql_fetch_array($result);
145 echo "<table width=100%>\n<tr align=center bgcolor=".$titlecolor.">\n<td>\n<font face=arial size=3><b><a href=user.php?board=".$_GET['board'].">".$myrow["username"]." (".$myrow["level"].")</a>: <a href=index.php>Board List</a> | <a href=post.php?board=".$_GET['board'].">Create a new topic</a> | <a href=topiclist.php?board=".$_GET['board']."&favadd=1>Add this to your Favorites</a> | <a href=logout.php>Log Out</a></b> | <b><a href=faq.php>FAQ</a></b>\n</td>\n</tr>";
146 if ($notify == 1)
148 echo "<tr bgcolor=".$systemnotcolor."><td align=center><font face=arial>You have recieve a system notification. Please read it at your earliest chance. Read it <a href=systemnot.php>here</a>.</td></tr>";
150 if ($setfav == 1)
152 echo "<tr bgcolor=".$systemnotcolor."><td align=center>You have added this board to your favorites.</td></tr>\n";
154 if ($userlevel >= 50)
156 $marks = howmarks();
157 $sugs = howsugs();
158 echo "<tr>\n<td bgcolor=".$titlecolor.">\n<b><font face=arial>Marks:</b> <a href=modme.php>".$marks."</a> | <b>Suggests:</b> <a href=helpme.php>".$sugs."</a> | <a href=modresources.php>Moderator Resources</a>\n</td>\n</tr></font>";
160 echo "</table>";
161 echo "<table width=100% cellpadding=0 cellspacing=2 border=0>\n<tr align=center>\n<td bgcolor=".$firstcolor.">\n<font face=arial><b>Topic Name</b></font>\n</td>\n<td bgcolor=".$firstcolor."><b><font face=arial>Created By</b></font>\n</td>\n<td bgcolor=".$firstcolor."><b><font face=arial>Messages</b></font>\n</td>\n<td bgcolor=".$firstcolor."><font face=arial><b>Last Post</b></font>\n</td>\n</tr>";
162 $sql = "SELECT * FROM topics WHERE boardnum='{$_GET['board']}' ORDER BY timesec DESC LIMIT ".$pages.",50";
163 $result = mysql_query($sql);
164 echo "<!-- ".time()." -->\n";
165 while ($myrow = mysql_fetch_array($result))
167 if ($myrow["active"] == 1)
169 $posts = postcount($myrow["topicid"]);
170 $topicname = stripslashes($myrow["topicname"]);
171 echo "<tr><td bgcolor=".$firstcolor."><font face=arial><a href=messagelist.php?board=".$_GET['board']."&topic=".$myrow["topicid"].">".$topicname."</a>";
172 if ($myrow["closed"] == 1)
173 echo "<img src=closed.gif>";
174 echo "</font></td><td bgcolor=".$firstcolor."><font face=arial>".$myrow["topicby"]."</font></td><td bgcolor=".$firstcolor."><font face=arial>".$posts."</font></td><td bgcolor=".$firstcolor."><font face=arial>".$myrow["postdate"]."</font></td></tr>\n";
177 echo "<!-- ".time()." -->\n";
178 echo "</table>";
179 $sql = "SELECT * FROM topics WHERE boardnum='{$_GET['board']}'";
180 $result = mysql_query($sql);
181 if (mysql_num_rows($result) > 50)
183 $previouspage = $page +2;
184 $nextpage = $page;
185 $sql = "SELECT * FROM topics WHERE boardnum='$board'";
186 $result = mysql_query($sql);
187 $numberoftopics = mysql_num_rows($result);
188 $numberoftopics = $numberoftopics / 50;
189 $count = 0;
190 echo "<table width=100% cellpadding=0 cellspacing=2 border=0>\n<tr align=center>\n<td bgcolor=".$titlecolor."><b>Pages: ";
191 while ($count < $numberoftopics)
193 $count = $count +1;
194 echo "<a href=topiclist.php?board=".$_GET['board']."&page=".$count.">".$count."</a> ";
196 echo "</td></tr><tr><td bgcolor=".$titlecolor.">";
197 if ($page <> 0)
198 echo "\n<center><a href=topiclist.php?board=".$_GET['board']."&page=".$nextpage.">Next Page</a> | ";
199 echo "<center><a href=topiclist.php?board=".$_GET['board']."&page=".$previouspage.">Previous Page</a>\n</td>\n</tr>\n</table>";
201 } else
203 echo "You cannot view this board.";