0.8.1a
[gfh.git] / messagelist.php
blob4c73b0884b663a190fe2184cc64becc71db144bf
1 <?php session_start();
3 include ("config.php");
4 if (!$_GET['board'])
6 echo "Invalid boardID.";
7 exit;
9 if (!$_GET['topic'])
11 Echo "Invalid topicID.";
12 exit;
14 function clancheck($bdnum, $username)
16 $sql = "SELECT * FROM users WHERE username='$username'";
17 $result = mysql_query($sql);
18 $myrow = mysql_fetch_array($result);
19 $clan2 = $myrow["faction"];
20 $sql = "SELECT * FROM boards WHERE boardid='$bdnum'";
21 $result = mysql_query($sql);
22 $myrow = mysql_fetch_array($result);
23 if ($clan2 == $myrow["clan"])
25 return 1;
26 } else
28 return 0;
31 function checkl($topicid)
33 $sql = "SELECT * FROM topics WHERE topicid='$topicid'";
34 $result = mysql_query($sql);
35 $myrow = mysql_fetch_array($result);
36 if ($myrow["active"] == 0)
37 return 0;
38 if ($myrow["active"] == 1)
39 return 1;
41 function check2($board)
43 $sql = "SELECT * FROM boards WHERE boardid='$board'";
44 $result = mysql_query($sql);
45 $myrow = mysql_fetch_array($result);
46 return $myrow["boardlevel"];
48 function check3($board, $topic)
50 $sql = "SELECT * FROM messages WHERE topic='$topic' AND mesboard='$board'";
51 $result = mysql_query($sql);
52 if (!mysql_num_rows($result))
54 return 0;
55 } else
57 return 1;
60 function howsugs()
62 $sql = "SELECT * FROM suggest WHERE active=1";
63 $result = mysql_query($sql);
64 $suggests = mysql_num_rows($result);
65 return $suggests;
67 function howmarks()
69 $sql = "SELECT * FROM marked WHERE active=1";
70 $result = mysql_query($sql);
71 $marks = mysql_num_rows($result);
72 return $marks;
74 function getlevel($username)
76 $sql = "SELECT * FROM users WHERE username='$username'";
77 $result = mysql_query($sql);
78 $myrow = mysql_fetch_array($result);
79 return $myrow["level"];
81 function useid($usename)
83 $sql = "SELECT * FROM users WHERE username='$usename'";
84 $result = mysql_query($sql);
85 $myrow = mysql_fetch_array($result);
86 return $myrow["userid"];
88 function useid2($usename)
90 $sql = "SELECT * FROM users WHERE username='$usename'";
91 $result = mysql_query($sql);
92 $myrow = mysql_fetch_array($result);
93 return $myrow["username"];
95 $username = auth();
96 $sql = "SELECT * FROM users WHERE username='$uname'";
97 $result = mysql_query($sql);
98 $myrow = mysql_fetch_array($result);
99 $userlevel = $myrow["level"];
100 $sql = "SELECT * FROM boards WHERE boardid='{$_GET['board']}'";
101 $result = mysql_query($sql);
102 $myrow = mysql_fetch_array($result);
103 $boardname = $myrow["boardname"];
104 $clanvalue = $myrow["clan"];
105 if (!$username)
107 echo "<font color=black>You cannot view this board.</font>";
108 exit;
110 if ($username)
112 $clan = clancheck($_GET['board'], $uname);
113 if ($clanvalue != 0 AND $userlevel != 60)
115 if ($clan == 0)
117 echo "<font color=black>You cannot view this board.</font>";
118 exit;
121 $sql = "SELECT * FROM topics WHERE topicid='{$_GET['topic']}'";
122 $result = mysql_query($sql);
123 $myrow = mysql_fetch_array($result);
124 $topicname = $myrow["topicname"];
125 $topicname = stripslashes($topicname);
126 $sql = "SELECT * FROM users WHERE username='$uname'";
127 $result = mysql_query($sql);
128 $myrow = mysql_fetch_array($result);
129 echo "<font size=6 face=arial color=black><b><center>".stripslashes($boardname)."</b><br></font><font size=3 face=arial color=black>".$topicname."</center></font>\n";
130 echo "<table width=100%><tr align=center bgcolor=".$titlecolor."><td><font face=arial size=3><b><a href=user.php?board=".$_GET['board']."&topic=".$_GET['topic'].">".$myrow["username"]." (".$myrow["level"].")</a>: <a href=index.php>Board List</a> | <a href=topiclist.php?board=".$_GET['board'].">Topic List</a> | <a href=postmes.php?board=".$_GET['board']."&topic=".$_GET['topic'].">Post a new message</a> | <a href=logout.php>Log Out</a></b> | <b><a href=faq.php>FAQ</a></b></td>\n</tr></font>\n";
131 if ($userlevel >= 50)
133 $marks = howmarks();
134 $sugs = howsugs();
135 echo "<tr><td bgcolor=".$titlecolor."><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></td></tr></font>\n";
137 echo "</table>";
138 $talive = checkl($_GET['topic']);
139 if ($talive == 0)
141 echo "<font color=black>This topic has been deleted.</font>";
142 exit;
144 echo "<table width=100% cellpadding=0 cellspacing=2 border=0>";
145 if (empty($_GET['page']))
147 $page = 0;
148 } else
150 $page = $_GET['page'] -1;
152 $pages = $page * 50;
153 $sql = "SELECT * FROM messages WHERE topic='{$_GET['topic']}' ORDER BY theorder ASC LIMIT ".$pages.",50";
154 $result = mysql_query($sql);
155 $boardlevel = check2($_GET['board']);
156 $uselevel = getlevel($uname);
157 if ($boardlevel > $uselevel)
159 echo "<font color=black>You cannot view this.</font>";
160 exit;
162 while ($myrow = mysql_fetch_array($result))
164 $alive = check3($_GET['board'], $_GET['topic']);
165 if ($alive == 0)
167 echo "<font color=black>Invalid link.</font>";
168 exit;
170 $mes = stripslashes($myrow["messbody"]);
171 $userid = useid($myrow["messby"]);
172 echo "<tr><td bgcolor=".$secondcolor."><font face=arial><b>From: </b><a href=whois.php?user=".$userid."&board=".$_GET['board']."&topic=".$_GET['topic'].">".$myrow["messby"]."</a> | <b>Posted:</b> ".$myrow["postdate"]." | ";
173 $useename = useid2($uname);
174 if ($myrow["messby"] == $useename)
176 echo "<a href=delmessage.php?board=".$_GET['board']."&topic=".$_GET['topic']."&message=".$myrow["messageid"].">Delete</a> this message.";
177 } else
179 echo "<a href=modnotice.php?board=".$_GET['board']."&topic=".$_GET['topic']."&message=".$myrow["messageid"].">Mark</a> for moderation</font>";
181 echo " <font face=arial>| <font face=arial><a href=suggestcook.php?board=".$_GET['board']."&topic=".$_GET['topic']."&message=".$myrow["messageid"].">Suggest</a> this person for aura.";
182 if ($myrow["auraed"] == 1)
184 echo "<img src=take.gif>";
186 if ($myrow["auraed"] == 2)
188 echo "<img src=add.gif>";
190 echo "</td></tr><tr><td bgcolor=".$firstcolor."><font face=arial>".$mes."</font></td></tr>\n";
192 echo "\n</table>";
193 $sql = "SELECT * FROM messages WHERE topic='{$_GET['topic']}'";
194 $result = mysql_query($sql);
195 if (mysql_num_rows($result) > 50)
197 $previouspage = $page +2;
198 $nextpage = $page;
199 $numberoftopics = mysql_num_rows($result);
200 $numberoftopics = $numberoftopics / 50;
201 $count = 0;
202 echo "<table width=100% cellpadding=0 cellspacing=2 border=0>\n<tr align=center>\n<td bgcolor=".$titlecolor."><b>Pages: ";
203 while ($count < $numberoftopics)
205 $count = $count +1;
206 echo "<a href=messagelist.php?board=".$_GET['board']."&topic=".$_GET['topic']."&page=".$count.">".$count."</a> ";
208 echo "</td></tr><tr><td bgcolor=".$titlecolor.">";
209 if ($page <> 0)
210 echo "\n<center><a href=messagelist.php?board=".$_GET['board']."&topic=".$_GET['topic']."&page=".$nextpage.">Previous Page</a> | ";
211 echo "<center><a href=messagelist.php?board=".$_GET['board']."&topic=".$_GET['topic']."&page=".$previouspage.">Next Page</a>\n</td>\n</tr>\n</table>";
213 echo "\n<center><font size=1 color=black>The fine print: I Neo (Chuck Sakoda) cannot be held responsible for any content the user's post";
214 } else
216 echo "You cannot view this board.";