Guest User

Untitled

a guest
Apr 28th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.09 KB | None | 0 0
  1. <?php
  2. class forums {
  3.     function index() {
  4.         global $client;
  5.  
  6. section_content("<table id='forum_table'>");
  7. $fetch1 = mysql_query("SELECT * FROM `forum_category`");
  8. while ($category = mysql_fetch_array($fetch1))
  9. {
  10. section_content ("<tr>
  11. <td id='mains'><b>$category[name]<b><br></td><td id='mains'>Último mensaje</td><td id='mains'><center>Temas</center></td>
  12. </tr>
  13. ");
  14. $fetch2 = mysql_query("SELECT * FROM `forum_topic` WHERE `cat_id` = '$category[id]'");
  15. while ($topic = mysql_fetch_array($fetch2))
  16. {
  17. section_content("<tr>
  18. <td id='fields'><a href='index.php?p=forums/forum&id=$topic[id]'><b>$topic[name]</b></a><br><i>$topic[description]</i></td>");
  19.  
  20.  
  21.  
  22. $fetchthreads = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '".$topic['id']."' ORDER BY `latestreply` DESC LIMIT 1");
  23. $threadinfo = mysql_fetch_array($fetchthreads);
  24. $getnumthreads = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '".$topic['id']."'");
  25. $numthreads = mysql_num_rows($getnumthreads);
  26. $getlatestposter = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$threadinfo['id']."' ORDER BY time desc");
  27. $latestposter = mysql_fetch_array($getlatestposter);
  28. $getnumposts = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$threadinfo['id']."'");
  29. $numposts = mysql_num_rows($getnumposts);
  30. if($numthreads > '0'){
  31. section_content("<td id='fields'><a href='index.php?p=forums/forumdisplay&id=".$threadinfo['id']."'>".$threadinfo['title']."</a><br>by ");
  32. if(mysql_num_rows($getlatestposter) == 0){
  33. section_content("".$threadinfo['poster']."");
  34. }else{
  35. section_content("".$latestposter['poster']."");
  36.  }
  37.  section_content("<font size=\"1\">(".time_elapsed_string($threadinfo['latestreply']).")</td>");
  38. }else{
  39. section_content("<td id='fields'>--</td>");
  40. }
  41.  
  42. section_content("<td id='fields'><center>".$numthreads."</center></td>");
  43.  
  44. section_content("</tr>
  45. ");
  46. }
  47. }
  48. section_content ("</table>");
  49. $rows = mysql_num_rows($fetch1);
  50. if ($rows == 0)
  51. {
  52. sys_notice("Forum is Empty");
  53. }
  54.  
  55.  
  56.        
  57.     }
  58.  
  59.     function forum() {
  60.     global $client;
  61.         section_content ("<table id='forum_table'>");
  62. $fetch1 = mysql_query("SELECT * FROM `forum_topic` WHERE `id` = '$_GET[id]'");
  63. $topic = mysql_fetch_array($fetch1);
  64. set_title(''.$topic['name'].'');
  65. section_content ("<tr><td id='mains'><b>$topic[name]</b> - <a href='index.php?p=forums/newthread&id=$_GET[id]'>Nuevo Tema</a></td><td id='mains'>Creado</td><td id='mains'>Última respuesta</td><td id='mains'>Vistas</td><td id='mains'>Respuestas</td></tr>");
  66.  
  67.  
  68.  
  69. $fetch2 = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$_GET[id]' AND `sticky` = 'Yes'");
  70.  
  71.  
  72.  
  73.  
  74.  
  75. while($thread = mysql_fetch_array($fetch2)){
  76. $fetchreplies = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread[id]'");
  77. $numreplies = mysql_num_rows($fetchreplies);
  78. $latestreply = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread[id]' order by time desc limit 1");
  79. $getreply = mysql_fetch_assoc($latestreply);
  80. $threadtitle = $thread['title'];
  81. $bbctt1 = forum_bb($threadtitle);
  82.  
  83. section_content ("<tr><td id='fields'><a href='index.php?p=forums/forumdisplay&id=$thread[id]'><b>Sticky: $bbctt1</b></a><br><i>by ".$thread['poster']."</i></td><td id='fields'><font size=\"1\">".date('D jS M Y', $thread['time'])."<br>".time_elapsed_string($thread['time'])."</font></td>");
  84. if($getreply){
  85. section_content("<td id='fields'><font size=\"1\">".time_elapsed_string($getreply['time'])."<br>by ".$getreply['poster']."</font></td><td id='fields'>".$thread['views']."</td><td id='fields'>$numreplies</td></tr>");
  86. }else{
  87. section_content("<td id='fields'>--</td><td id='fields'>".$thread['views']."</td><td id='fields'>$numreplies</td></tr>");
  88. }
  89. }
  90. $nonsticky = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$_GET[id]' AND `sticky` = 'No' ORDER BY `latestreply` DESC");
  91. while($thread2 = mysql_fetch_assoc($nonsticky)){
  92. $fetchreplies = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread2[id]'");
  93. $numreplies = mysql_num_rows($fetchreplies);
  94. $latestreply = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread2[id]' order by time desc limit 1");
  95. $getreply = mysql_fetch_array($latestreply);
  96. $threadtitle = $thread2['title'];
  97. $bbctt1 = forum_bb($threadtitle);
  98. section_content ("<tr><td id='fields'><a href='index.php?p=forums/forumdisplay&id=$thread2[id]'><b>$bbctt1</b></a><br><i>by ".$thread2['poster']."</i></td><td id='fields'><font size=\"1\">".date('D jS M Y', $thread2['time'])."<br>".time_elapsed_string($thread2['time'])."</font></td>");
  99.  
  100. if($getreply){
  101. section_content("<td id='fields'><font size=\"1\">".time_elapsed_string($getreply['time'])."<br>by ".$getreply['poster']."</font></td><td id='fields'>".$thread2['views']."</td><td id='fields'>$numreplies</td></tr>");
  102. }else{
  103. section_content("<td id='fields'>--</td><td id='fields'>".$thread2['views']."</td><td id='fields'>$numreplies</td></tr>");
  104. }
  105. }
  106.  
  107.  
  108. section_content ("</table>");
  109.        
  110.     }
  111.  
  112.     function forumdisplay() {
  113.     global $client;
  114.     section_content("<script src=\"modules/forums/ioquatix-jquery-syntax-36a1d65/examples/jquery-1.4.4.min.js\" type=\"text/javascript\"></script>
  115.              <script src=\"modules/forums/ioquatix-jquery-syntax-36a1d65/public/jquery.syntax.min.js\" type=\"text/javascript\"></script>
  116.                          
  117. <script type=\"text/javascript\">
  118.    // This function is executed when the page has finished loading.
  119.    jQuery(function($) {
  120.        // This function highlights (by default) pre and code tags which are annotated correctly.
  121.        $.syntax();
  122.         replace: true
  123.    });
  124.    
  125. </script>
  126. ");
  127.         section_content ("<table id='forum_table'>");
  128. $fetch1 = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$_GET[id]'");
  129. $thread = mysql_fetch_array($fetch1);
  130. $updateviews = mysql_query("UPDATE `forum_thread` SET `views` = views+1 WHERE `id` = '$_GET[id]'");
  131. $fetch3 = mysql_query("SELECT * FROM `".tb()."accounts` WHERE `username` = '$thread[poster]'");
  132. $threadavatar = mysql_fetch_array($fetch3);
  133. set_title(''.$thread['title'].'');
  134. $threadtitle = "$thread[title]";
  135. $bbctt2 = forum_bb($threadtitle);
  136.  
  137. $threadmessage = "$thread[message]";
  138. $bbctm = forum_bb(nl2br(htmlentities($threadmessage)));
  139.  
  140. section_content ("<tr>
  141. ");
  142. if($thread['sticky'] == Yes)
  143. {
  144. section_content ("<td id='mains' colspan=\"2\"><b>Sticky:</b> $bbctt2 <font size=\"1\" style=\"float:right;\">".date('D jS M Y', $thread['time'])." (".time_elapsed_string($thread['time']).")</font></td></tr>");
  145. }
  146. else
  147. {
  148. section_content ("<td id='mains' colspan=\"2\"><b>$bbctt2</b> <font size=\"1\" style=\"float:right;\">".date('D jS M Y', $thread['time'])." (".time_elapsed_string($thread['time']).")</font></td></tr>");
  149. }
  150. section_content ("<tr>
  151. <td id='fields' align='center' width='120' valign='top'>".$thread['poster']."<br>
  152. ".avatar($threadavatar,50)."
  153. ");
  154. if (allow_access(3))
  155. {
  156. if($thread['locked'] == Yes){
  157. section_content("<br><a href='index.php?p=forums/unlock&id=$thread[id]'>Unlock</a>");
  158. }else{
  159. section_content("<br><a href='index.php?p=forums/lock&id=$thread[id]'>Lock</a>");
  160. }
  161. section_content (" - <a href='index.php?p=forums/editthread&id=$thread[id]'>Edit</a> - <a href='index.php?p=forums/sticky&id=$thread[id]'>Sticky</a>");
  162. }
  163. if ($thread['poster'] == $client['username'])
  164. {
  165. section_content ("<br><a href='index.php?p=forums/editthread&id=$thread[id]'>Edit Post</a>");
  166. }
  167. section_content ("
  168. </td><td id='fields' align='left' valign='top'>$bbctm</td></tr>");
  169.  
  170. $fetch2 = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$_GET['id']."'");
  171. while ($posts = mysql_fetch_array($fetch2))
  172. {
  173. $postsmessage = $posts['message'];
  174. $bbcpm = forum_bb(nl2br(htmlentities($postsmessage)));
  175.  
  176. $fetch4 = mysql_query("SELECT * FROM `".tb()."accounts` WHERE `username` = '".$posts['poster']."'");
  177. $postsavatar = mysql_fetch_array($fetch4);
  178.  
  179. section_content ("<tr><td id='replymains' colspan='2'><font size=\"1\" style=\"float:right;\">".date('D jS M Y', $posts['time'])." (".time_elapsed_string($posts['time']).")</font></td></tr>
  180. <tr>
  181. <td id='fields' align='center' valign='top'>$posts[poster]
  182. <br>
  183. ".avatar($postsavatar,50)."
  184. ");
  185. if (allow_access(3))
  186. {
  187. section_content ("<br><a href='index.php?p=forums/delete&id=$posts[id]'>Delete</a> - <a href='index.php?p=forums/editpost&id=$posts[id]'>Edit</a>");
  188. }
  189. if ($client['username'] == $posts['poster'])
  190. {
  191. section_content ("<br><a href='index.php?p=forums/editpost&id=$posts[id]'>Edit Post</a>");
  192. }
  193. section_content ("
  194. </td>
  195. <td id='fields' align='left' valign='top'>$bbcpm</td>
  196. </tr>");
  197. }
  198. if ($thread['locked'] == 'Yes')
  199. {
  200. section_content ("<tr><td id='fields'>&nbsp;</td><td id='fields' valign='top'><b>This Thread is locked.</b></td></tr>");
  201. }
  202. else
  203. {
  204. section_content ("
  205. <tr>
  206. <td id='fields'valign='top'><center><font size=\"2\">BBcode list</font></center>
  207. <font size=\"1\">
  208. <ul>
  209. <li>[code]</li>
  210. <li>[php]</li>
  211. <li>[js]</li>
  212. <li>[quote]</li>
  213. <li>[b]</li>
  214. <li>[i]</li>
  215. <li>[u]</li>
  216. <li>[url]</li>
  217. <li>[img]</li>
  218. </ul></font></td>
  219. <form method='POST' action='index.php?p=forums/addreply'>
  220. <td id='fields'>Quick Reply<br /><textarea id='forumtxtarea' name='message' rows='8' cols='30'></textarea><br>
  221. <input type='submit' name='submit' value='Post'>
  222. <input type='hidden' name='id' value='".$_GET['id']."'></td>
  223. </tr>
  224. </form>
  225. ");
  226. }
  227.        
  228.     }
  229.    
  230.     function addreply(){
  231.     global $client;
  232.     $id = mysql_real_escape_string($_POST['id']);
  233. $message = mysql_real_escape_string($_POST['message']);
  234. $insert = mysql_query("INSERT INTO `forum_posts` (`message`, `poster`, `thr_id`, `time`) VALUES ('$message', '$client[username]', '$id', '".time()."')");
  235. $update = mysql_query("UPDATE `forum_thread` SET `latestreply` = '".time()."' WHERE `id` = '$id'");
  236. sys_notice ("Thanks for your reply. You will be re-directed back to the thread. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  237.  
  238.     }
  239.    
  240.     function newthread(){
  241.     global $client;
  242.     section_content ("<form method='POST' action='index.php?p=forums/addthread'>
  243. <table width='100%'>
  244. <tr>
  245. <td>Titulo</td>
  246. <td><input type='text' name='title'></td>
  247. </tr>
  248. <tr>
  249. <td>Mensaje</td>
  250. <td><textarea id=\"forumtxtarea\" name='message' rows='10' cols='40'></textarea></td>
  251. </tr>
  252. <tr>
  253. <td></td>
  254. <td><input type='submit' name='submit' value='Post'>
  255. <input type='hidden' name='id' value='$_GET[id]'></td>
  256. </tr>
  257. </table>
  258. </form>
  259. ");
  260.     }
  261.    
  262.     function addthread(){
  263.     global $client;
  264.     $id = mysql_real_escape_string($_POST['id']);
  265. $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  266. $array = mysql_fetch_array($query);
  267. if ($array['locked'] == 'Yes')
  268. {
  269. sys_notice ("You can't post that in here.");
  270. }
  271. else
  272. {
  273. $title = mysql_real_escape_string($_POST['title']);
  274. $message = mysql_real_escape_string($_POST['message']);
  275. $insert = mysql_query("INSERT INTO `forum_thread` (`title`, `message`, `poster`, `thr_id`, `time`, `latestreply`)VALUES ('$title', '$message', '$client[username]', '$id', '".time()."', '".time()."')");
  276. $query2 = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$id' ORDER BY time DESC");
  277. $getinfo = mysql_fetch_array($query2);
  278. sys_notice ("Your thread has been added. You will be re-directed back to the forum! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forum&id=$id'>");
  279. stream_publish( t('posted a new thread in forum<br><br>{1}<br><font size="1">'.substr(mysql_real_escape_string($message),0,200).'...</font>',url('forums/forumdisplay&id='.$getinfo['id'].'',t('<b>'.$getinfo['title'].'</b>'))));
  280. }
  281.     }
  282.    
  283.     function editthread(){
  284.     global $client;
  285.     $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$_GET[id]'");
  286. $thread = mysql_fetch_array($fetch);
  287. if ($client['username'] == $thread['poster'] || allow_access(3))
  288. {
  289. section_content ("
  290. <form method='POST' action='index.php?p=forums/updatethread'>
  291. <table width='100%'>
  292. <tr>
  293. <td>Title</td>
  294. <td><input type='text' name='title' value='$thread[title]'></td>
  295. </tr>
  296. <tr>
  297. <td>Message</td>
  298. <td><textarea id='forumtxtarea' name='message' rows='10' cols='40'>$thread[message]</textarea></td>
  299. </tr>
  300. <tr>
  301. <td></td>
  302. <td><input type='submit' name='submit' value='Post'>
  303. <input type='hidden' name='id' value='$_GET[id]'></td>
  304. </tr>
  305. </table>
  306. </form>
  307. ");
  308. }
  309. else
  310. {
  311. sys_notice ("You can't edit this thread.");
  312. }
  313.     }
  314.    
  315.     function updatethread(){
  316.     global $client;
  317.     $id = mysql_real_escape_string($_POST['id']);
  318. $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  319. $array = mysql_fetch_array($query);
  320. if ($array['poster'] == $client['username'] || allow_access(3))
  321. {
  322. $title = mysql_real_escape_string($_POST['title']);
  323. $message = mysql_real_escape_string($_POST['message']);
  324. $query = mysql_query("UPDATE `forum_thread` SET `title` = '$title', `message` = '$message' WHERE `id` = '$id'");
  325. sys_notice ("Thread has been updated. Re-directing you back to thread! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  326. }
  327. else
  328. {
  329. sys_notice ("You can't edit this thread.");
  330. }
  331. }
  332.  
  333. function editpost(){
  334. global $client;
  335. $fetch = mysql_query("SELECT * FROM `forum_posts` WHERE `id` = '$_GET[id]'");
  336. $post = mysql_fetch_array($fetch);
  337. if ($client['username'] == $post['poster'] || allow_access(3))
  338. {
  339. section_content ("
  340. <form method='POST' action='index.php?p=forums/updatepost'>
  341. <table width='100%'>
  342. <tr>
  343. <td>Message</td>
  344. <td><textarea id='forumtxtarea' name='message' rows='10' cols='40'>$post[message]</textarea></td>
  345. </tr>
  346. <tr>
  347. <td></td>
  348. <td><input type='submit' name='submit' value='Post'>
  349. <input type='hidden' name='id' value='$_GET[id]'>
  350. <input type='hidden' name='thr_id' value='$post[thr_id]'>
  351.  
  352. </td>
  353. </tr>
  354. </table>
  355. </form>
  356. ");
  357. }
  358. else
  359. {
  360. sys_notice ("You can't edit this post.");
  361. }
  362.     }
  363.    
  364.     function updatepost(){
  365.     global $client;
  366.     $id = mysql_real_escape_string($_POST['id']);
  367.     $thrid = mysql_real_escape_string($_POST['thr_id']);
  368. $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  369. $array = mysql_fetch_array($query);
  370. if ($array['poster'] == $client['username'] || allow_access(3))
  371. {
  372. $message = mysql_real_escape_string($_POST['message']);
  373. $update = mysql_query("UPDATE `forum_posts` SET `message` = '$message' WHERE `id` = '$id'");
  374. sys_notice ("Thread updated. You will now be re-directed back to thread! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$thrid'>");
  375. }
  376. else
  377. {
  378. sys_notice ("You can't edit this thread.");
  379. }
  380.     }
  381.    
  382.     function sticky(){
  383.     global $client;
  384.     $id = (int) mysql_real_escape_string($_GET['id']);
  385. $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  386. $thread = mysql_fetch_array($fetch);
  387. if ($thread['sticky'] == 'Yes')
  388. {
  389. sys_notice ("This has already been sticked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  390. }
  391. else
  392. {
  393. $update = mysql_query("UPDATE `forum_thread` SET `sticky` = 'Yes' WHERE `id` = '$id'");
  394. sys_notice ("Thread has been stickied. Re-directing you now!<meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  395. }
  396.     }
  397.    
  398.     function lock(){
  399.     global $client;
  400.     $id = (int) mysql_real_escape_string($_GET['id']);
  401. $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  402. $thread = mysql_fetch_array($fetch);
  403. if ($thread['locked'] == 'Yes')
  404. {
  405. sys_notice ("This has already been locked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  406. }
  407. else
  408. {
  409. $update = mysql_query("UPDATE `forum_thread` SET `locked` = 'Yes' WHERE `id` = '$id'");
  410. sys_notice ("Thread has been locked. Re-directing you now! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  411. }
  412.     }
  413.    
  414.     function unlock(){
  415.     global $client;
  416.     $id = (int) mysql_real_escape_string($_GET['id']);
  417. $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
  418. $thread = mysql_fetch_array($fetch);
  419. if ($thread['locked'] == 'No')
  420. {
  421. sys_notice ("This has already been unlocked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  422. }
  423. else
  424. {
  425. $update = mysql_query("UPDATE `forum_thread` SET `locked` = 'No' WHERE `id` = '$id'");
  426. sys_notice ("Thread has been unlocked. Re-directing you now! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
  427. }
  428.     }
  429.    
  430.     function delete(){
  431.     global $client;
  432.     $id = (int) mysql_real_escape_string($_GET['id']);
  433. $fetch = mysql_query("DELETE FROM `forum_posts` WHERE `id` = '$id'");
  434. section_content ("Post has been deleted.<br><a href='javascript: history.go(-1)'>Go back.</a>");
  435.     }
  436.    
  437.     function admin(){
  438.     global $client;
  439.     section_content ("
  440. <a href='index.php?p=forums/addcategory'>Add Category</a>
  441. <br>
  442. <a href='index.php?p=forums/deletecategory'>Delete Category</a>
  443. <br>
  444. <a href='index.php?p=forums/addtopic'>Add Topic</a>
  445. <br>
  446. <a href='index.php?p=forums/deletetopic'>Delete Topic</a>
  447. ");
  448.     }
  449.    
  450.     function addcategory(){
  451.     global $client;
  452.     section_content ("
  453. <form method='POST' action='index.php?p=forums/insertcategory'>
  454. <table width='100%'>
  455. <tr>
  456. <td align='right' width='25%'>New Category Name</td>
  457. <td align='left'>
  458. <input size='25' name='category'></td>
  459. </tr>
  460. <tr>
  461. <td align='center'></td>
  462. <td align='left'>
  463. <input type='submit' name='submit' value='Update'></td>
  464. </tr>
  465. </table>
  466. </form>
  467. ");
  468.     }
  469.    
  470.     function insertcategory(){
  471.     global $client;
  472.     $category = strip_tags(mysql_real_escape_string($_POST['category']));
  473. $insert = mysql_query("INSERT INTO `forum_category` (`name`) VALUES ('$category')");
  474. section_content ("New Category Created. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
  475. }
  476.  
  477. function deletecategory(){
  478. global $client;
  479. section_content ("
  480. <form method='POST' action='index.php?p=forums/removecategory'>
  481. <table width='100%'>
  482. <tr>
  483. <td align='right' width='25%'>Delete Category</td>
  484. <td align='left'>
  485. <select name='category'>
  486. ");
  487. $fetch = mysql_query("SELECT * FROM `forum_category`"); //fetches all the forum categories from the database and displays them
  488. while ($category = mysql_fetch_array($fetch))
  489. {
  490. section_content ("<option value='$category[name]'>$category[name]</option>");
  491. }
  492. section_content ("
  493. </select>
  494. </td>
  495. </tr>
  496. <tr>
  497. <td align='center'></td>
  498. <td align='left'>
  499. <input type='submit' name='submit' value='Update'></td>
  500. </tr>
  501. </table>
  502. </form>
  503. ");
  504.     }
  505.    
  506.     function removecategory(){
  507.     global $client;
  508.     $category = strip_tags(mysql_real_escape_string($_POST['category']));
  509. $insert = mysql_query("DELETE FROM `forum_category` WHERE name = '$category'");
  510. section_content ("Category Deleted. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
  511. }
  512.  
  513. function addtopic(){
  514. global $client;
  515. section_content ("
  516. <form method='POST' action='index.php?p=forums/inserttopic'>
  517. <table width='100%'>
  518. <tr>
  519. <td align='right' width='25%'>New Topic Name</td>
  520. <td align='left'>
  521. <input size='25' name='topic'></td>
  522. </tr>
  523. <tr>
  524. <td align='right' width='25%'>Description</td>
  525. <td align='left'>
  526. <input size='25' name='description'></td>
  527. </tr>
  528. <tr>
  529. <td align='right' width='25%'>Under Category</td>
  530. <td align='left'>
  531. <select name='cid'>
  532. ");
  533. $fetch = mysql_query("SELECT * FROM `forum_category`");
  534. while ($category = mysql_fetch_array($fetch))
  535. {
  536. section_content ("<option value='$category[id]'>$category[name]</option>");
  537. }
  538. section_content ("
  539. </select>
  540. </td>
  541. </tr>
  542. <tr>
  543. <td align='center'></td>
  544. <td align='left'>
  545. <input type='submit' name='submit' value='Update'></td>
  546. </tr>
  547. </table>
  548. </form>
  549. ");
  550.     }
  551.    
  552.     function inserttopic(){
  553.     global $client;
  554.     $description = strip_tags(mysql_real_escape_string($_POST['description']));
  555. $topic = strip_tags(mysql_real_escape_string($_POST['topic']));
  556. $cid = (int) mysql_real_escape_string($_POST['cid']);
  557. $insert = mysql_query("INSERT INTO `forum_topic` (`name`, `cat_id`, `description`) VALUES ('$topic', '$cid', '$description')");
  558. section_content ("New Category Created. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
  559.  
  560.     }
  561.    
  562.     function deletetopic(){
  563.     global $client;
  564.     section_content ("
  565. <form method='POST' action='index.php?p=forums/removetopic'>
  566. <table width='100%'>
  567. <tr>
  568. <td align='right' width='25%'>Delete Topic</td>
  569. <td align='left'>
  570. <select name='topic'>
  571. ");
  572. $fetch = mysql_query("SELECT * FROM `forum_topic`");
  573. while ($topic = mysql_fetch_array($fetch))
  574. {
  575. section_content ("<option value='$topic[name]'>$topic[name]</option>");
  576. }
  577. section_content ("
  578. </select>
  579. </td>
  580. </tr>
  581. <tr>
  582. <td align='center'></td>
  583. <td align='left'>
  584. <input type='submit' name='submit' value='Update'></td>
  585. </tr>
  586. </table>
  587. </form>
  588. ");
  589.     }
  590.    
  591.     function removetopic(){
  592.     global $client;
  593.     $topic = mysql_real_escape_string(strip_tags($_POST['topic']));
  594. $insert = mysql_query("DELETE FROM `forum_topic` WHERE name = '$topic'");
  595. section_content("Category Deleted. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
  596.  
  597.     }
  598.    
  599.    
  600. }
  601. ?>
Advertisement
Add Comment
Please, Sign In to add comment