Просмотр файла include/admin.php

Размер файла: 7.63Kb
  1. <?php
  2. if($status != "admin")
  3. {
  4. header("Location: ".$forumdir);
  5. } else
  6. {
  7. switch($_GET['mode'])
  8. {
  9. default:
  10. $mforums = mysql_query("SELECT * FROM `mforums` ORDER BY `pos` ASC");
  11. $forums = mysql_query("SELECT * FROM `forums` ORDER BY `pos` ASC");
  12. if($version == "wml")
  13. {
  14. header("Content-type: text/vnd.wap.wml; charset=utf-8");
  15. header("Cache-Control: no-cache");
  16. echo(doctype("Админка").'
  17. Модераторы: <br />');
  18. $modersq = mysql_query("SELECT `status`, `id`, `username` FROM `users` WHERE `status`='moderator'");
  19. while($moders = mysql_fetch_array($modersq))
  20. {
  21. echo($moders['username'].'[<a href="./?p=27&amp;v=wml&amp;sid='.$sid.'&amp;mode=moder&amp;m=0&amp;id='.$moders['id'].'">Удалить</a>]<br />');
  22. }
  23.  
  24. echo('- - - - <br />
  25. Добавить подфорум:<br />
  26. - - - - <br />
  27. Имя: <br />
  28. <input type="text" name="name" /><br />
  29. Позиция: <br />
  30. <input type="text" name="pos" format="*N" /><br />
  31. <anchor>[Добавить]
  32. <go href="./?p=27&amp;v=wml&amp;mode=add&amp;sid='.$sid.'" method="post">
  33. <postfield name="name" value="$(name)" />
  34. <postfield name="pos" value="$(pos)" />
  35. </go></anchor><br />
  36. - - - - <br />
  37. Удалить подфорум: <br />
  38. <select name="id">');
  39. while($fnames = mysql_fetch_array($forums))
  40. {
  41. echo('<option value="'.$fnames['id'].'">'.$fnames['name'].'</option>');
  42. }
  43. echo('</select><br />
  44. <anchor>[Удалить]
  45. <go href="./?p=27&amp;v=wml&amp;sid='.$sid.'&amp;mode=del" method="post">
  46. <postfield name="id" value="$(id)" />
  47. </go></anchor><br />
  48. - - - - <br />
  49. Добавить модерский подфорум:<br />
  50. - - - - <br />
  51. Имя: <br />
  52. <input type="text" name="name" /><br />
  53. Позиция: <br />
  54. <input type="text" name="pos" format="*N" /><br />
  55. <anchor>[Добавить]
  56. <go href="./?p=27&amp;v=wml&amp;mode=addm&amp;sid='.$sid.'" method="post">
  57. <postfield name="name" value="$(name)" />
  58. <postfield name="pos" value="$(pos)" />
  59. </go></anchor><br />
  60. - - - - <br />
  61. Удалить модерский подфорум: <br />
  62. <select name="id">');
  63. while($fnamesm = mysql_fetch_array($mforums))
  64. {
  65. echo('<option value="'.$fnamesm['id'].'">'.$fnamesm['name'].'</option>');
  66. }
  67. echo('</select><br />
  68. <anchor>[Удалить]
  69. <go href="./?p=27&amp;v=wml&amp;sid='.$sid.'&amp;mode=delm" method="post">
  70. <postfield name="id" value="$(id)" />
  71. </go></anchor><br />
  72. - - - - <br />
  73. <a href="./?p=0&amp;v=wml&amp;sid='.$sid.'">В форум</a>
  74. </p></card></wml>');
  75. } elseif($version == "xhtml")
  76. {
  77. echo
  78. "<html>\r\n",
  79. "<head>\r\n",
  80. "<title>Админка</title>\r\n",
  81. "</head>\r\n",
  82. "<body bgcolor=\"".$style['background']."\" link=\"".$style['link']."\" vlink=\"".$style['link']."\" text=\"#000000\">\r\n",
  83. "<table align=\"center\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\" width=\"350\">\r\n",
  84. "<tr>\r\n",
  85. "<td align=\"center\" bgcolor=\"".$style['title']."\"><font color=\"#FFFFFF\"><b>Админка</b></font></td>\r\n",
  86. "</tr>\r\n",
  87. "<tr bgcolor=\"".$style['text']."\"><td>\r\n",
  88. "<b><u>Модераторы:</b></u>\r\n</td></tr>",
  89. "<tr>\r\n<td bgcolor=\"".$style['text']."\">\r\n";
  90. $modersq = mysql_query("SELECT `status`, `id`, `username` FROM `users` WHERE `status`='moderator'");
  91. while($moders = mysql_fetch_array($modersq))
  92. {
  93. echo($moders['username'].'[<a href="./?p=27&amp;v=xhtml&amp;sid='.$sid.'&amp;mode=moder&amp;m=0&amp;id='.$moders['id'].'">Удалить</a>]<br />');
  94. }
  95. echo
  96. "</td>\r\n",
  97. "</tr>\r\n",
  98. "<tr>\r\n",
  99. "<td bgcolor=\"".$style['text']."\">\r\n",
  100. "<b><u>Добавить подфорум:</b></u><br />\r\n",
  101. "<form action=\"./?p=27&amp;v=xhtml&amp;mode=add&amp;sid=".$sid."\" method=\"post\">\r\n",
  102. "Имя: <br />\r\n",
  103. "<input type=\"text\" name=\"name\" /><br />\r\n",
  104. "Позиция: <br /> \r\n",
  105. "<input type=\"text\" name=\"pos\" format=\"*N\" /><br />\r\n",
  106. "<input type=\"submit\" value=\"Добавить\" />\r\n",
  107. "</form>\r\n",
  108. "</td>\r\n</tr>\r\n",
  109. "<tr>\r\n",
  110. "<td bgcolor=\"".$style['text']."\">\r\n",
  111. "<b><u>Удалить подфорум:</b></u>\r\n",
  112. "</td>\r\n</tr>\r\n",
  113. "<tr>\r\n<td bgcolor=\"".$style['text']."\">\r\n",
  114. "<form action=\"./?p=27&amp;v=xhtml&amp;mode=del&amp;sid=".$sid."\" method=\"post\">\r\n",
  115. "<select name=\"id\">\r\n";
  116. while($fnames = mysql_fetch_array($forums))
  117. {
  118. echo("<option value=\"".$fnames['id']."\">".$fnames['name']."</option>\r\n");
  119. }
  120. echo
  121. "</select><br />\r\n",
  122. "<input type=\"submit\" value=\"Удалить\" />\r\n",
  123. "</form>\r\n",
  124. "</td>\r\n</tr>\r\n",
  125. "<td bgcolor=\"".$style['text']."\">\r\n",
  126. "<b><u>Добавить модерский подфорум:</b></u><br />\r\n",
  127. "<form action=\"./?p=27&amp;v=xhtml&amp;mode=addm&amp;sid=".$sid."\" method=\"post\">\r\n",
  128. "Имя: <br />\r\n",
  129. "<input type=\"text\" name=\"name\" /><br />\r\n",
  130. "Позиция: <br /> \r\n",
  131. "<input type=\"text\" name=\"pos\" format=\"*N\" /><br />\r\n",
  132. "<input type=\"submit\" value=\"Добавить\" />\r\n",
  133. "</form>\r\n",
  134. "</td>\r\n</tr>\r\n",
  135. "<tr>\r\n",
  136. "<td bgcolor=\"".$style['text']."\">\r\n",
  137. "<b><u>Удалить модерский подфорум:</b></u>\r\n",
  138. "</td>\r\n</tr>\r\n",
  139. "<tr>\r\n<td bgcolor=\"".$style['text']."\">\r\n",
  140. "<form action=\"./?p=27&amp;v=xhtml&amp;mode=delm&amp;sid=".$sid."\" method=\"post\">\r\n",
  141. "<select name=\"id\">\r\n";
  142. while($fnamesm = mysql_fetch_array($mforums))
  143. {
  144. echo("<option value=\"".$fnamesm['id']."\">".$fnamesm['name']."</option>\r\n");
  145. }
  146. echo
  147. "</select><br />\r\n",
  148. "<input type=\"submit\" value=\"Удалить\" />\r\n",
  149. "</form>\r\n",
  150. "</td>\r\n</tr>\r\n",
  151. "<tr><td bgcolor=\"".$style['bottom']."\">\r\n",
  152. "<a href=\"./?p=0&amp;v=xhtml&amp;sid=".$sid."\">Форумы</a> \r\n",
  153. "</td>\r\n</tr>\r\n</table>\r\n",
  154. "</body></html>";
  155. }
  156. break;
  157. case 'del':
  158. mysql_query("DELETE posts.*
  159. FROM posts
  160. LEFT JOIN themes
  161. ON posts.id_theme=themes.id
  162. WHERE id_forum=".intval($_POST['id']));
  163. mysql_query("DELETE FROM `themes` WHERE `id_forum`=".intval($_POST['id']));
  164. mysql_query("DELETE FROM `forums` WHERE `id`=".intval($_POST['id']));
  165. header("Location: ".str_replace("?", "", $forumdir).'/?p=27&v='.$version.'&sid='.$sid);
  166. break;
  167. case 'delm':
  168. mysql_query("DELETE mposts.*
  169. FROM mposts
  170. LEFT JOIN mthemes
  171. ON mposts.id_theme=mthemes.id
  172. WHERE id_forum=".intval($_POST['id']));
  173. mysql_query("DELETE FROM `mthemes` WHERE `id_forum`=".intval($_POST['id']));
  174. mysql_query("DELETE FROM `mforums` WHERE `id`=".intval($_POST['id']));
  175. header("Location: ".str_replace("?", "", $forumdir).'/?p=27&v='.$version.'&sid='.$sid);
  176. break;
  177. case 'add':
  178. mysql_query("INSERT INTO `forums` VALUES(0, '".htmlspecialchars(sql($_POST['name']))."', ".intval($_POST['pos']).")");
  179. header("Location: ".str_replace("?", "", $forumdir).'/?p=27&v='.$version.'&sid='.$sid);
  180. break;
  181. case 'addm':
  182. mysql_query("INSERT INTO `mforums` VALUES(0, '".htmlspecialchars(sql($_POST['name']))."', ".intval($_POST['pos']).")");
  183. header("Location: ".str_replace("?", "", $forumdir).'/?p=27&v='.$version.'&sid='.$sid);
  184. break;
  185. case 'moder':
  186. if($_GET['m'] == "0")
  187. {
  188. mysql_query("UPDATE `users` SET `status`='user' WHERE `id`=".intval($_GET['id']));
  189. } else
  190. {
  191. mysql_query("UPDATE `users` SET `status`='moderator' WHERE `id`=".intval($_GET['id']));
  192. }
  193. header("Location: ".str_replace("?", "", $forumdir).'/?p=27&v='.$version.'&sid='.$sid);
  194. break;
  195.  
  196.  
  197. }
  198. }
  199. ?>
  200.  
  201.