PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/TBDev/installer_v4_1/forummanage.php

https://github.com/cybernet/CyBerFuN-CoDeX
PHP | 343 lines | 272 code | 43 blank | 28 comment | 44 complexity | d0c1b44a64cffe55f4ae2929b8cdd48f MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require ("include/bittorrent.php");
  3. require ("include/user_functions.php");
  4. require ("include/bbcode_functions.php");
  5. dbconn();
  6. maxcoder();
  7. if (!logged_in()) {
  8. header("HTTP/1.0 404 Not Found");
  9. // moddifed logginorreturn by retro//Remember to change the following line to match your server
  10. print("<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 ".$SITENAME." Server at " . $_SERVER['SERVER_NAME'] . " Port 80</address></body></html>\n");
  11. die();
  12. }
  13. if (get_user_class() < UC_SYSOP)
  14. hacker_dork("Forum Manage - Nosey Cunt !");
  15. $id = (int) + $_GET['id'];
  16. // DELETE FORUM ACTION
  17. if ($_GET['action'] == "del") {
  18. if (!$id) {
  19. header("Location: $BASEURL/forummanage.php");
  20. die();
  21. }
  22. $result = sql_query ("SELECT * FROM topics where forumid = '" . unsafeChar($_GET['id']) . "'");
  23. if ($row = mysql_fetch_array($result)) {
  24. do {
  25. sql_query ("DELETE FROM posts where topicid = '" . unsafeChar($row["id"]) . "'") or sqlerr(__FILE__, __LINE__);
  26. } while ($row = mysql_fetch_array($result));
  27. }
  28. sql_query ("DELETE FROM topics where forumid = '" . unsafeChar($_GET['id']) . "'") or sqlerr(__FILE__, __LINE__);
  29. sql_query ("DELETE FROM forums where id = '" . unsafeChar($_GET['id']) . "'") or sqlerr(__FILE__, __LINE__);
  30. header("Location: $BASEURL/forummanage.php");
  31. die();
  32. }
  33. // EDIT FORUM ACTION
  34. if ($_POST['action'] == "editforum") {
  35. $name = ($_POST['name']);
  36. $desc = ($_POST['desc']);
  37. if (!$name && !$desc && !$id) {
  38. header("Location: $BASEURL/forummanage.php");
  39. die();
  40. }
  41. sql_query("UPDATE forums SET sort = '" . $_POST['sort'] . "', name = " . sqlesc($_POST['name']) . ", description = " . sqlesc($_POST['desc']) . ", forid = " . sqlesc(($_POST['overforums'])) . ", minclassread = '" . $_POST['readclass'] . "', minclasswrite = '" . $_POST['writeclass'] . "', minclasscreate = '" . $_POST['createclass'] . "' where id = '" . $_POST['id'] . "'") or sqlerr(__FILE__, __LINE__);
  42. header("Location: $BASEURL/forummanage.php");
  43. die();
  44. }
  45. // ADD FORUM ACTION
  46. if ($_POST['action'] == "addforum") {
  47. $name = ($_POST['name']);
  48. $desc = ($_POST['desc']);
  49. if (!$name && !$desc) {
  50. header("Location: $BASEURL/forummanage.php");
  51. die();
  52. }
  53. sql_query("INSERT INTO forums (sort, name, description, minclassread, minclasswrite, minclasscreate, forid) VALUES(" . $_POST['sort'] . ", " . sqlesc($_POST['name']) . ", " . sqlesc($_POST['desc']) . ", " . $_POST['readclass'] . ", " . $_POST['writeclass'] . ", " . $_POST['createclass'] . ", " . sqlesc(($_POST['overforums'])) . ")") or sqlerr(__FILE__, __LINE__);
  54. header("Location: $BASEURL/forummanage.php");
  55. die();
  56. }
  57. // SHOW FORUMS WITH FORUM MANAGMENT TOOLS
  58. stdhead("Forum Management Tools");
  59. begin_main_frame();
  60. begin_frame("Forums");
  61. ?>
  62. <script language="JavaScript">
  63. <!--
  64. function confirm_delete(id)
  65. {
  66. if(confirm('Are you sure you want to delete this forum?'))
  67. {
  68. self.location.href='<?php $_SERVER["PHP_SELF"];
  69. ?>?action=del&id='+id;
  70. }
  71. }
  72. //-->
  73. </script>
  74. <?php
  75. echo '<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">';
  76. echo "<tr><td class=colhead align=left>Name</td><td class=colhead>OverForum</td><td class=colhead>Read</td><td class=colhead>Write</td><td class=colhead>Create topic</td><td class=colhead>Modify</td></tr>";
  77. $result = sql_query ("SELECT * FROM forums ORDER BY sort ASC");
  78. if ($row = mysql_fetch_array($result)) {
  79. do {
  80. $forid = $row['forid'];
  81. $res2 = sql_query("SELECT name FROM overforums WHERE id=" . unsafeChar($forid) . "");
  82. $arr2 = mysql_fetch_array($res2);
  83. $name = $arr2['name'];
  84. echo "<tr><td><a href=forums.php?action=viewforum&forumid=" . safeChar($row["id"]) . "><b>" . safeChar($row["name"]) . "</b></a><br>" . safeChar($row["description"]) . "</td>";
  85. echo "<td>" . safeChar($name) . "</td><td>" . get_user_class_name($row["minclassread"]) . "</td><td>" . get_user_class_name($row["minclasswrite"]) . "</td><td>" . get_user_class_name($row["minclasscreate"]) . "</td><td align=center nowrap><b><a href=\"" . $PHP_SELF . "?action=editforum&id=" . safeChar($row["id"]) . "\">Edit</a>&nbsp;|&nbsp;<a href=\"javascript:confirm_delete('" . $row["id"] . "');\"><font color=red>Delete</font></a></b></td></tr>";
  86. } while ($row = mysql_fetch_array($result));
  87. } else {
  88. print "<tr><td>Sorry, no records were found!</td></tr>";
  89. }
  90. echo "</table>";
  91. ?>
  92. <br><br>
  93. <form method=post action="<?=$_SERVER["PHP_SELF"];
  94. ?>">
  95. <table width="100%" border="0" cellspacing="0" cellpadding="3" align="center">
  96. <tr align="center">
  97. <td colspan="2" class=colhead>Make new forum</td>
  98. </tr>
  99. <tr>
  100. <td><b>Forum name</td>
  101. <td><input name="name" type="text" size="20" maxlength="60"></td>
  102. </tr>
  103. <tr>
  104. <td><b>Forum description </td>
  105. <td><input name="desc" type="text" size="30" maxlength="200"></td>
  106. </tr>
  107. <tr>
  108. <td><b>OverForum </td>
  109. <td>
  110. <select name=overforums>\n
  111. <?php
  112. /* $res = mysql_query("SELECT * FROM overforums");
  113. $maxrow = mysql_num_rows($res);
  114. for ($i = 1; $i <= $maxrow; ++$i) {
  115. $arr = mysql_fetch_array($res);
  116. $name = $arr["name"];
  117. $forid = $arr["id"];
  118. print("<option value=$i" . ($forid == $i ? " selected" : "") . ">$prefix" . $name . "\n");
  119. }*/
  120. $forid = $row["forid"];
  121. $res = sql_query("SELECT * FROM overforums");
  122. while ($arr = mysql_fetch_array($res)) {
  123. $name = $arr["name"];
  124. $i = $arr["id"];
  125. print("<option value=$i" . ($forid == $i ? " selected" : "") . ">$prefix" . $name . "\n");
  126. }
  127. ?>
  128. </select>
  129. </td>
  130. </tr>
  131. <tr>
  132. <td><b>Minimun read permission </td>
  133. <td>
  134. <select name=readclass>\n
  135. <?php
  136. $maxclass = get_user_class();
  137. for ($i = 0; $i <= $maxclass; ++$i)
  138. print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  139. ?>
  140. </select>
  141. </td>
  142. </tr>
  143. <tr>
  144. <td><b>Minimun write permission </td>
  145. <td><select name=writeclass>\n
  146. <?php
  147. $maxclass = get_user_class();
  148. for ($i = 0; $i <= $maxclass; ++$i)
  149. print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  150. ?>
  151. </select></td>
  152. </tr>
  153. <tr>
  154. <td><b>Minimun create topic permission </td>
  155. <td><select name=createclass>\n
  156. <?php
  157. $maxclass = get_user_class();
  158. for ($i = 0; $i <= $maxclass; ++$i)
  159. print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  160. ?>
  161. </select></td>
  162. </tr>
  163. <tr>
  164. <td><b>Forum rank </td>
  165. <td>
  166. <select name=sort>\n
  167. <?php
  168. $res = sql_query ("SELECT sort FROM forums");
  169. $nr = mysql_num_rows($res);
  170. $maxclass = $nr + 1;
  171. for ($i = 0; $i <= $maxclass; ++$i)
  172. print("<option value=$i>$i \n");
  173. ?>
  174. </select>
  175. </td>
  176. </tr>
  177. <tr align="center">
  178. <td colspan="2"><input type="hidden" name="action" value="addforum"><input type="submit" name="Submit" value="Make forum" class=btn></td>
  179. </tr>
  180. </table>
  181. <?php
  182. print("<tr><td align=center colspan=1><form method=\"get\" action=\"moforums.php#add\"></form><form method=\"get\" action=\"moforums.php#add\"><input type=\"submit\" value=\"SubForum Manager\" class=\"btn\" /></form></td></tr>\n");
  183. end_frame();
  184. ?>
  185. <?php if ($_GET['action'] == "editforum") {
  186. // EDIT PAGE FOR THE FORUMS
  187. $id = (int) + ($_GET["id"]);
  188. begin_frame("Edit Forum");
  189. $result = sql_query ("SELECT * FROM forums where id = " . sqlesc($id));
  190. if ($row = mysql_fetch_array($result)) {
  191. // Get OverForum Name - To Be Written
  192. do {
  193. ?>
  194. <form method=post action="<?=$_SERVER["PHP_SELF"];
  195. ?>">
  196. <table width="100%" border="0" cellspacing="0" cellpadding="3" align="center">
  197. <tr align="center">
  198. <td colspan="2" class=colhead>edit forum: <?=$row["name"];
  199. ?></td>
  200. </tr>
  201. <td><b>Forum name</td>
  202. <td><input name="name" type="text" size="20" maxlength="60" value="<?=$row["name"];
  203. ?>"></td>
  204. </tr>
  205. <tr>
  206. <td><b>Forum description </td>
  207. <td><input name="desc" type="text" size="30" maxlength="200" value="<?=$row["description"];
  208. ?>"></td>
  209. </tr>
  210. <tr>
  211. <td><b>OverForum </td>
  212. <td>
  213. <select name=overforums>\n
  214. <?php
  215. // $maxclass = get_user_class();
  216. // for ($i = 0; $i <= $maxclass; ++$i)
  217. // print("<option value=$i" . ($row["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  218. /*$forid = $row["forid"];
  219. $res = sql_query("SELECT * FROM overforums");
  220. $maxrow = mysql_num_rows($res);
  221. for ($i = 1; $i <= $maxrow; ++$i) {
  222. $arr = mysql_fetch_array($res);
  223. $name = $arr["name"];
  224. print("<option value=$i" . ($forid == $i ? " selected" : "") . ">$prefix" . $name . "\n");
  225. }*/
  226. $forid = $row["forid"];
  227. $res = sql_query("SELECT * FROM overforums");
  228. while ($arr = mysql_fetch_array($res)) {
  229. $name = $arr["name"];
  230. $i = $arr["id"];
  231. print("<option value=$i" . ($forid == $i ? " selected" : "") . ">$prefix" . $name . "\n");
  232. }
  233. ?>
  234. </select>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td><b>Minimun read permission </td>
  239. <td>
  240. <select name=readclass>\n
  241. <?php
  242. $maxclass = get_user_class();
  243. for ($i = 0; $i <= $maxclass; ++$i)
  244. print("<option value=$i" . ($row["minclassread"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  245. ?>
  246. </select>
  247. </td>
  248. </tr>
  249. <tr>
  250. <td><b>Minimun write permission </td>
  251. <td><select name=writeclass>\n
  252. <?php
  253. $maxclass = get_user_class();
  254. for ($i = 0; $i <= $maxclass; ++$i)
  255. print("<option value=$i" . ($row["minclasswrite"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  256. ?>
  257. </select></td>
  258. </tr>
  259. <tr>
  260. <td><b>Minimun create topic permission </td>
  261. <td><select name=createclass>\n
  262. <?php
  263. $maxclass = get_user_class();
  264. for ($i = 0; $i <= $maxclass; ++$i)
  265. print("<option value=$i" . ($row["minclasscreate"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  266. ?>
  267. </select></td>
  268. </tr>
  269. <tr>
  270. <td><b>Forum rank </td>
  271. <td>
  272. <select name=sort>\n
  273. <?php
  274. $res = sql_query ("SELECT sort FROM forums");
  275. $nr = mysql_num_rows($res);
  276. $maxclass = $nr + 1;
  277. for ($i = 0; $i <= $maxclass; ++$i)
  278. print("<option value=$i" . ($row["sort"] == $i ? " selected" : "") . ">$i \n");
  279. ?>
  280. </select>
  281. </td>
  282. </tr>
  283. <tr align="center">
  284. <td colspan="2"><input type="hidden" name="action" value="editforum"><input type="hidden" name="id" value="<?=$id;
  285. ?>"><input type="submit" name="Submit" value="Edit forum" class="btn"></td>
  286. </tr>
  287. </table>
  288. <?php
  289. } while ($row = mysql_fetch_array($result));
  290. } else {
  291. print "Sorry, no records were found!";
  292. }
  293. print("<tr><td align=center colspan=1><form method=\"get\" action=\"forummanage.php#add\"><input type=\"submit\" value=\"Return\" class=\"btn\" /></form></td></tr>\n");
  294. end_frame();
  295. end_main_frame();
  296. }
  297. print("</table>");
  298. stdfoot();
  299. ?>