PageRenderTime 69ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/over_forums.php

https://github.com/Bigjoos/U-232-V1
PHP | 281 lines | 207 code | 49 blank | 25 comment | 19 complexity | e5c524dd6602745d09080aae33ee238e MD5 | raw file
  1. <?php
  2. /**
  3. * https://09source.kicks-ass.net:8443/svn/installer09/
  4. * Licence Info: GPL
  5. * Copyright (C) 2010 Installer09 v.1
  6. * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
  7. * Project Leaders: Mindless,putyn,kidvision.
  8. **/
  9. /**********************************************************
  10. New 2010 forums that don't suck for TB based sites....
  11. Beta Thurs Sept 9th 2010 v0.5
  12. //=== over forum manager by Retro, but updated \o/
  13. ***************************************************************/
  14. if ( ! defined( 'IN_TBDEV_ADMIN' ) )
  15. {
  16. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  18. <head>
  19. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  20. <title>ERROR</title>
  21. </head><body>
  22. <h1 style="text-align:center;">ERROR</h1>
  23. <p style="text-align:center;">How did you get here? silly rabbit Trix are for kids!.</p>
  24. </body></html>';
  25. exit();
  26. }
  27. require_once(INCL_DIR.'html_functions.php');
  28. $lang = array_merge( $lang );
  29. $HTMLOUT='';
  30. require_once(INCL_DIR.'class_check.php');
  31. class_check(UC_ADMINISTRATOR);
  32. $over_forums = '';
  33. $main_links = '<p><span style="font-weight: bold;">Over Forums</span> ::
  34. <a class="altlink" href="staffpanel.php?tool=forum_manage&amp;action=forum_manage">Forum Manager</a> ::
  35. <a class="altlink" href="staffpanel.php?tool=forum_config&amp;action=forum_config">Configure Forums</a><br /></p>';
  36. $id = (isset($_GET['id']) ? intval($_GET['id']) : (isset($_POST['id']) ? intval($_POST['id']) : 0));
  37. $maxclass = $CURUSER['class'];
  38. $name = strip_tags(isset($_POST['name']) ? $_POST['name'] : '');
  39. $desc = strip_tags(isset($_POST['desc']) ? $_POST['desc'] : '');
  40. $sort = (isset($_POST['sort']) ? intval($_POST['sort']) : 0);
  41. $min_class_view = (isset($_POST['min_class_view']) ? intval($_POST['min_class_view']) : 0);
  42. //=== post / get action posted so we know what to do :P
  43. $posted_action = (isset($_GET['action2']) ? $_GET['action2'] : (isset($_POST['action2']) ? $_POST['action2'] : ''));
  44. //=== add all possible actions here and check them to be sure they are ok
  45. $valid_actions = array('delete', 'edit_forum', 'add_forum', 'edit_forum_page');
  46. $action = (in_array($posted_action, $valid_actions) ? $posted_action : 'forum');
  47. //=== here we go with all the possibilities \\o\o/o//
  48. switch ($action)
  49. {
  50. //=== delete over forum
  51. case 'delete':
  52. if (!$id)
  53. {
  54. stderr('ERROR', 'Bad ID');
  55. }
  56. sql_query ('DELETE FROM over_forums where id = '.$id);
  57. header('Location: staffpanel.php?tool=over_forums');
  58. die();
  59. break;
  60. //=== edit forum
  61. case 'edit_forum':
  62. if (!$name && !$desc && !$id)
  63. {
  64. stderr('ERROR', 'Missing form data!');
  65. }
  66. $res = sql_query ('SELECT sort FROM over_forums WHERE sort = '.$sort);
  67. if (mysql_num_rows($res) > 0)
  68. {
  69. stderr('ERROR', 'Over forum Sort number in use. Please select another Over forum Sort number!');
  70. }
  71. sql_query('UPDATE over_forums SET sort = '.$sort.', name = '.sqlesc($name).', description = '.sqlesc($desc).', min_class_view = '.$min_class_view.' WHERE id = '.$id);
  72. header('Location: staffpanel.php?tool=over_forums');
  73. die();
  74. break;
  75. //=== add forum
  76. case 'add_forum':
  77. if (!$name && !$desc)
  78. {
  79. stderr('ERROR', 'Missing form data');
  80. }
  81. $res = sql_query ('SELECT sort FROM over_forums WHERE sort = '.$sort);
  82. if (mysql_num_rows($res) > 0)
  83. {
  84. stderr('ERROR', 'Over forum Sort number in use. Please select another Over forum Sort number!');
  85. }
  86. sql_query('INSERT INTO over_forums (sort, name, description, min_class_view) VALUES ('.$sort.', '.sqlesc($name).', '.sqlesc($desc).', '.$min_class_view.')');
  87. header('Location: staffpanel.php?tool=over_forums');
  88. die();
  89. break;
  90. //=== edit over forum stuff
  91. case 'edit_forum_page':
  92. //echo stdhead('Edit Overforum');
  93. $res = sql_query ('SELECT * FROM over_forums where id ='.$id);
  94. if (mysql_num_rows($res) > 0)
  95. {
  96. $row = mysql_fetch_array($res);
  97. $HTMLOUT .= $main_links.'<form method="post" action="staffpanel.php?tool=over_forums&amp;action=over_forums">
  98. <input type="hidden" name="action2" value="edit_forum" />
  99. <input type="hidden" name="id" value="'.$id.'" />
  100. <table width="600" border="0" cellspacing="0" cellpadding="3" align="center">
  101. <tr>
  102. <td colspan="2" class="forum_head_dark">edit overforum: '.htmlentities($row['name'], ENT_QUOTES).'</td>
  103. </tr>
  104. <tr>
  105. <td align="right" class="three"><span style="font-weight: bold;">Overforum name:</span></td>
  106. <td align="left" class="three"><input name="name" type="text" class="text_default" size="20" maxlength="60" value="'.htmlentities($row['name'], ENT_QUOTES).'" /></td>
  107. </tr>
  108. <tr>
  109. <td align="right" class="three"><span style="font-weight: bold;">Overforum description:</span> </td>
  110. <td align="left" class="three"><input name="desc" type="text" class="text_default" size="30" maxlength="200" value="'.htmlentities($row['description'], ENT_QUOTES).'" /></td>
  111. </tr>
  112. <tr>
  113. <td align="right" class="three"><span style="font-weight: bold;">Minimun view permission: </span></td>
  114. <td align="left" class="three">
  115. <select name="min_class_view">';
  116. for ($i = 0; $i <= $maxclass; ++$i)
  117. {
  118. $over_forums .= '<option class="body" value="'.$i.'"'.($row['min_class_view'] == $i ? ' selected="selected"' : '') .'>'.get_user_class_name($i).'</option>';
  119. }
  120. $HTMLOUT .= $over_forums.'</select></td></tr><tr>
  121. <td align="right" class="three"><span style="font-weight: bold;">Over forum Sort:</span></td>
  122. <td align="left" class="three">
  123. <select name="sort">';
  124. $sorted='';
  125. $res = mysql_query ('SELECT sort FROM over_forums');
  126. $nr = mysql_num_rows($res);
  127. $maxclass = $nr + 1;
  128. for ($i = 0; $i <= $maxclass; ++$i)
  129. {
  130. $sorted .= '<option class="body" value="'.$i.'"'.($row['sort'] == $i ? ' selected="selected"' : '').'>'.$i.'</option>';
  131. }
  132. $HTMLOUT .= $sorted.'</select></td></tr>
  133. <tr>
  134. <td colspan="2" class="three" align="center">
  135. <input type="submit" name="button" class="button" value="Edit overforum" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" />
  136. </td>
  137. </tr>
  138. </table></form>';
  139. }
  140. break;
  141. //=== over forum stuff
  142. case 'forum':
  143. //echo stdhead('Overforum');
  144. $HTMLOUT .= $main_links.'<table width="750" border="0" align="center" cellpadding="2" cellspacing="0">
  145. <tr><td class="forum_head_dark" align="center">Sort</td>
  146. <td class="forum_head_dark" align="left">Name</td>
  147. <td class="forum_head_dark" align="center">Minimun Class View</td>
  148. <td class="forum_head_dark" align="center">Modify</td>
  149. </tr>';
  150. $res = sql_query ('SELECT * FROM over_forums ORDER BY sort ASC');
  151. if (mysql_num_rows($res) > 0)
  152. {
  153. while($row = mysql_fetch_array($res))
  154. {
  155. //=== change colors
  156. $count='';
  157. $count= (++$count)%2;
  158. $class = ($count == 0 ? 'one' : 'two');
  159. $over_forums .= '<tr>
  160. <td class="'.$class.'" align="center">'.$row['sort'].'</td>
  161. <td class="'.$class.'">
  162. <a class="altlink" href="forums.php?action=forum_view&amp;fourm_id='.$row['id'].'">'.htmlentities($row['name'], ENT_QUOTES).'</a><br />
  163. '.htmlentities($row['description'], ENT_QUOTES).'</td>
  164. <td class="'.$class.'" align="center">'. get_user_class_name($row['min_class_view']).'</td>
  165. <td align="center" class="'.$class.'">
  166. <a class="altlink" href="staffpanel.php?tool=over_forums&amp;action=over_forums&amp;action2=edit_forum_page&amp;id='.$row['id'].'">Edit</a>&nbsp;|&nbsp;
  167. <a href="javascript:confirm_delete(\''.$row['id'].'\');"><span style="font-weight: bold;">Delete</span></a></td>
  168. </tr>';
  169. } //=== end while
  170. }//=== end if
  171. $HTMLOUT .= $over_forums. '</table><br /><br />
  172. <form method="post" action="staffpanel.php?tool=over_forums&amp;action=over_forums">
  173. <input type="hidden" name="action2" value="add_forum" />
  174. <table width="600" border="0" cellspacing="0" cellpadding="3" align="center">
  175. <tr align="center">
  176. <td colspan="2" class="forum_head_dark">Make new over forum</td>
  177. </tr>
  178. <tr>
  179. <td align="right" class="three"><span style="font-weight: bold;">Overforum name:</span></td>
  180. <td align="left" class="three"><input name="name" type="text" class="text_default" size="20" maxlength="60" /></td>
  181. </tr>
  182. <tr>
  183. <td align="right" class="three"><span style="font-weight: bold;">Overforum description:</span> </td>
  184. <td align="left" class="three"><input name="desc" type="text" class="text_default" size="30" maxlength="200" /></td>
  185. </tr>
  186. <tr>
  187. <td align="right" class="three"><span style="font-weight: bold;">Minimun view permission:</span> </td>
  188. <td align="left" class="three">
  189. <select name="min_class_view">';
  190. $min_class_viewer='';
  191. for ($i = 0; $i <= $maxclass; ++$i)
  192. {
  193. $min_class_viewer .= '<option class="body" value="'.$i.'">'.get_user_class_name($i).'</option>';
  194. }
  195. $HTMLOUT .= $min_class_viewer.'</select>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td align="right" class="three"><span style="font-weight: bold;">Overforum sort:</span> </td>
  200. <td align="left" class="three">
  201. <select name="sort">';
  202. $sorted='';
  203. $res = sql_query ('SELECT sort FROM over_forums');
  204. $nr = mysql_num_rows($res);
  205. $maxclass = $nr + 1;
  206. for ($i = 0; $i <= $maxclass; ++$i)
  207. {
  208. $sorted .= '<option class="body" value="'.$i.'">'.$i.'</option>';
  209. }
  210. $HTMLOUT .= $sorted.'</select></td></tr>
  211. <tr>
  212. <td colspan="2" class="three" align="center">
  213. <input type="submit" name="button" class="button" value="Make overforum" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" /></td>
  214. </tr>
  215. </table></form>';
  216. break;
  217. } //=== end switch
  218. $HTMLOUT .= '<script type="text/javascript">
  219. <!--
  220. function confirm_delete(id)
  221. {
  222. if(confirm(\'Are you sure you want to delete this overforum?\'))
  223. {
  224. self.location.href=\'staffpanel.php?tool=over_forums&action=over_forums&action2=delete&id=\'+id;
  225. }
  226. }
  227. //-->
  228. </script>';
  229. print stdhead('Forum Manage') . $HTMLOUT . stdfoot();
  230. ?>