PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/Textbox/admin.php

https://code.google.com/p/nuked-klan/
PHP | 300 lines | 244 code | 40 blank | 16 comment | 16 complexity | cd5d8969ee1d6040f79c44bb2fabee8e MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, LGPL-2.1
  1. <?php
  2. // -------------------------------------------------------------------------//
  3. // Nuked-KlaN - PHP Portal //
  4. // http://www.nuked-klan.org //
  5. // -------------------------------------------------------------------------//
  6. // This program is free software. you can redistribute it and/or modify //
  7. // it under the terms of the GNU General Public License as published by //
  8. // the Free Software Foundation; either version 2 of the License. //
  9. // -------------------------------------------------------------------------//
  10. if (!defined("INDEX_CHECK"))
  11. {
  12. die ("<div style=\"text-align: center;\">You cannot open this page directly</div>");
  13. }
  14. global $user, $language;
  15. translate("modules/Textbox/lang/" . $language . ".lang.php");
  16. include("modules/Admin/design.php");
  17. admintop();
  18. if (!$user)
  19. {
  20. $visiteur = 0;
  21. }
  22. else
  23. {
  24. $visiteur = $user[1];
  25. }
  26. $ModName = basename(dirname(__FILE__));
  27. $level_admin = admin_mod($ModName);
  28. if ($visiteur >= $level_admin && $level_admin > -1)
  29. {
  30. function edit_shout($mid)
  31. {
  32. global $nuked, $language;
  33. $sql = mysql_query("SELECT auteur, texte, ip FROM " . TEXTBOX_TABLE . " WHERE id = '" . $mid . "'");
  34. list($pseudo, $texte, $ip) = mysql_fetch_array($sql);
  35. $texte = htmlspecialchars($texte);
  36. echo "<div class=\"content-box\">\n" //<!-- Start Content Box -->
  37. . "<div class=\"content-box-header\"><h3>" . _ADMINSHOUTBOX . "</h3>\n"
  38. . "<div style=\"text-align:right;\"><a href=\"help/" . $language . "/Textbox.php\" rel=\"modal\">\n"
  39. . "<img style=\"border: 0;\" src=\"help/help.gif\" alt=\"\" title=\"" . _HELP . "\" /></a>\n"
  40. . "</div></div>\n"
  41. . "<div class=\"tab-content\" id=\"tab2\"><form method=\"post\" action=\"index.php?file=Textbox&amp;page=admin&amp;op=modif_shout\">\n"
  42. . "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" width=\"60%\" border=\"0\">\n"
  43. . "<tr><td><b>" . _NICKNAME . " :</b> " . $pseudo . " ( " . $ip . " )</td></tr>\n"
  44. . "<tr><td>&nbsp;</td></tr><tr><td><b>" . _SHOUT . " :</b></td></tr>\n"
  45. . "<tr><td><textarea name=\"texte\" cols=\"65\" rows=\"10\">" . $texte . "</textarea></td></tr>\n"
  46. . "<tr><td align=\"center\"><input type=\"hidden\" name=\"mid\" value=\"" . $mid . "\" />&nbsp;</td></tr>\n"
  47. . "<tr><td align=\"center\"><input type=\"submit\" value=\"" . _MODIF . "\" /></td></tr></table>\n"
  48. . "<div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Textbox&amp;page=admin\"><b>" . _BACK . "</b></a> ]</div></form><br /></div></div>\n";
  49. }
  50. function modif_shout($mid, $texte)
  51. {
  52. global $nuked, $user;
  53. $texte = mysql_real_escape_string(stripslashes($texte));
  54. $sql = mysql_query("UPDATE " . TEXTBOX_TABLE . " SET texte = '" . $texte . "' WHERE id = '" . $mid . "'");
  55. // Action
  56. $texteaction = "". _ACTIONMODIFSHO .".";
  57. $acdate = time();
  58. $sqlaction = mysql_query("INSERT INTO ". $nuked['prefix'] ."_action (`date`, `pseudo`, `action`) VALUES ('".$acdate."', '".$user[0]."', '".$texteaction."')");
  59. //Fin action
  60. echo "<div class=\"notification success png_bg\">\n"
  61. . "<div>\n"
  62. . "" . _MESSEDIT . "\n"
  63. . "</div>\n"
  64. . "</div>\n";
  65. redirect("index.php?file=Textbox&page=admin", 2);
  66. }
  67. function del_shout($mid)
  68. {
  69. global $nuked, $user;
  70. $sql = mysql_query("DELETE FROM " . TEXTBOX_TABLE . " WHERE id = '" . $mid . "'");
  71. // Action
  72. $texteaction = "". _ACTIONDELSHO .".";
  73. $acdate = time();
  74. $sqlaction = mysql_query("INSERT INTO ". $nuked['prefix'] ."_action (`date`, `pseudo`, `action`) VALUES ('".$acdate."', '".$user[0]."', '".$texteaction."')");
  75. //Fin action
  76. echo "<div class=\"notification success png_bg\">\n"
  77. . "<div>\n"
  78. . "" . _MESSDEL . "\n"
  79. . "</div>\n"
  80. . "</div>\n";
  81. redirect("index.php?file=Textbox&page=admin", 2);
  82. }
  83. function del_all_shout()
  84. {
  85. global $nuked, $user;
  86. $sql = mysql_query("DELETE FROM " . TEXTBOX_TABLE);
  87. // Action
  88. $texteaction = "". _ACTIONALLDELSHO .".";
  89. $acdate = time();
  90. $sqlaction = mysql_query("INSERT INTO ". $nuked['prefix'] ."_action (`date`, `pseudo`, `action`) VALUES ('".$acdate."', '".$user[0]."', '".$texteaction."')");
  91. //Fin action
  92. echo "<div class=\"notification success png_bg\">\n"
  93. . "<div>\n"
  94. . "" . _ALLMESSDEL . "\n"
  95. . "</div>\n"
  96. . "</div>\n";
  97. redirect("index.php?file=Textbox&page=admin", 2);
  98. }
  99. function main()
  100. {
  101. global $nuked, $language;
  102. $nb_mess_guest = 30;
  103. $sql2 = mysql_query("SELECT id FROM " . TEXTBOX_TABLE);
  104. $count = mysql_num_rows($sql2);
  105. if (!$_REQUEST['p']) $_REQUEST['p'] = 1;
  106. $start = $_REQUEST['p'] * $nb_mess_guest - $nb_mess_guest;
  107. echo "<script type=\"text/javascript\">\n"
  108. . "<!--\n"
  109. . "\n"
  110. . "function del_shout(pseudo, id)\n"
  111. . "{\n"
  112. . "if (confirm('" . _DELETETEXT . " '+pseudo+' ! " . _CONFIRM . "'))\n"
  113. . "{document.location.href = 'index.php?file=Textbox&page=admin&op=del_shout&mid='+id;}\n"
  114. . "}\n"
  115. . "\n"
  116. . "function delall()\n"
  117. . "{\n"
  118. . "if (confirm('" . _DELETEALLTEXT . "'))\n"
  119. . "{document.location.href = 'index.php?file=Textbox&page=admin&op=del_all_shout';}\n"
  120. . "}\n"
  121. . "\n"
  122. . "// -->\n"
  123. . "</script>\n";
  124. echo "<div class=\"content-box\">\n" //<!-- Start Content Box -->
  125. . "<div class=\"content-box-header\"><h3>" . _ADMINSHOUTBOX . "</h3>\n"
  126. . "<div style=\"text-align:right;\"><a href=\"help/" . $language . "/Textbox.php\" rel=\"modal\">\n"
  127. . "<img style=\"border: 0;\" src=\"help/help.gif\" alt=\"\" title=\"" . _HELP . "\" /></a>\n"
  128. . "</div></div>\n"
  129. . "<div class=\"tab-content\" id=\"tab2\"><div style=\"text-align: center;\">" . _SHOUTBOX . "<b> | "
  130. . "<a href=\"index.php?file=Textbox&amp;page=admin&amp;op=main_pref\">" . _PREFS . "</a> | "
  131. . "<a href=\"javascript:delall();\">" . _DELALLMESS . "</a></b></div><br />\n";
  132. if ($count > $nb_mess_guest)
  133. {
  134. number($count, $nb_mess_guest, "index.php?file=Textbox&page=admin");
  135. }
  136. echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\">\n"
  137. . "<tr>\n"
  138. . "<td style=\"width: 20%;\" align=\"center\"><b>" . _DATE . "</b></td>\n"
  139. . "<td style=\"width: 25%;\" align=\"center\"><b>" . _NICKNAME . "</b></td>\n"
  140. . "<td style=\"width: 25%;\" align=\"center\"><b>" . _IP . "</b></td>\n"
  141. . "<td style=\"width: 15%;\" align=\"center\"><b>" . _EDIT . "</b></td>\n"
  142. . "<td style=\"width: 15%;\" align=\"center\"><b>" . _DEL . "</b></td></tr>\n";
  143. $sql = mysql_query("SELECT id, date, auteur, ip FROM " . TEXTBOX_TABLE . " ORDER BY id DESC LIMIT " . $start . ", " . $nb_mess_guest."");
  144. while (list($id, $date, $auteur, $ip) = mysql_fetch_array($sql))
  145. {
  146. $date = nkDate($date);
  147. echo "<tr>\n"
  148. . "<td style=\"width: 20%;\" align=\"center\">" . $date . "</td>\n"
  149. . "<td style=\"width: 25%;\" align=\"center\">" . $auteur . "</td>\n"
  150. . "<td style=\"width: 25%;\" align=\"center\">" . $ip . "</td>\n"
  151. . "<td style=\"width: 15%;\" align=\"center\"><a href=\"index.php?file=Textbox&amp;page=admin&amp;op=edit_shout&amp;mid=" . $id . "\"><img style=\"border: 0;\" src=\"images/edit.gif\" alt=\"\" title=\"" . _EDITTHISMESS . "\" /></a></td>\n"
  152. . "<td style=\"width: 15%;\" align=\"center\"><a href=\"javascript:del_shout('" . mysql_real_escape_string(stripslashes($auteur)) . "', '" . $id . "');\"><img style=\"border: 0;\" src=\"images/del.gif\" alt=\"\" title=\"" . _DELTHISMESS . "\" /></a></td></tr>\n";
  153. }
  154. if ($count == "0")
  155. {
  156. echo "<tr><td align=\"center\" colspan=\"5\">" . _NOMESS . "</td></tr>\n";
  157. }
  158. echo "</table>";
  159. if ($count > $nb_mess_guest)
  160. {
  161. number($count, $nb_mess_guest, "index.php?file=Textbox&amp;page=admin");
  162. }
  163. echo "<div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Admin\"><b>" . _BACK . "</b></a> ]</div><br /></div></div>\n";
  164. }
  165. function main_pref()
  166. {
  167. global $nuked, $language;
  168. echo "<script type=\"text/javascript\">\n"
  169. . "<!--\n"
  170. . "\n"
  171. . "function delall()\n"
  172. . "{\n"
  173. . "if (confirm('" . _DELETEALLTEXT . "'))\n"
  174. . "{document.location.href = 'index.php?file=Textbox&page=admin&op=del_all_shout';}\n"
  175. . "}\n"
  176. . "\n"
  177. . "// -->\n"
  178. . "</script>\n";
  179. echo "<div class=\"content-box\">\n" //<!-- Start Content Box -->
  180. . "<div class=\"content-box-header\"><h3>" . _ADMINSHOUTBOX . "</h3>\n"
  181. . "<div style=\"text-align:right;\"><a href=\"help/" . $language . "/Textbox.php\" rel=\"modal\">\n"
  182. . "<img style=\"border: 0;\" src=\"help/help.gif\" alt=\"\" title=\"" . _HELP . "\" /></a>\n"
  183. . "</div></div>\n"
  184. . "<div class=\"tab-content\" id=\"tab2\"><div style=\"text-align: center;\"><b><a href=\"index.php?file=Textbox&amp;page=admin\">" . _SHOUTBOX . "</a> | "
  185. . "</b>" . _PREFS . "<b> | "
  186. . "<a href=\"javascript:delall();\">" . _DELALLMESS . "</a></b></div><br />\n"
  187. . "<form method=\"post\" action=\"index.php?file=Textbox&amp;page=admin&amp;op=change_pref\">\n"
  188. . "<table style=\"margin-left: auto;margin-right: auto;text-align: left;\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n"
  189. . "<tr><td colspan=\"2\" align=\"center\"><big>" . _PREFS . "</big></td></tr>\n"
  190. . "<tr><td>" . _NUMBERSHOUT . " :</td><td> <input type=\"text\" name=\"max_shout\" size=\"2\" value=\"" . $nuked['max_shout'] . "\" /></td></tr>\n"
  191. . "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" name=\"Submit\" value=\"" . _SEND . "\" /></td></tr></table>\n"
  192. . "<div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Textbox&amp;page=admin\"><b>" . _BACK . "</b></a> ]</div></form><br /></div></div>\n";
  193. }
  194. function change_pref($max_shout)
  195. {
  196. global $nuked, $user;
  197. $upd = mysql_query("UPDATE " . CONFIG_TABLE . " SET value = '" . $max_shout . "' WHERE name = 'max_shout'");
  198. // Action
  199. $texteaction = "". _ACTIONCONFSHO .".";
  200. $acdate = time();
  201. $sqlaction = mysql_query("INSERT INTO ". $nuked['prefix'] ."_action (`date`, `pseudo`, `action`) VALUES ('".$acdate."', '".$user[0]."', '".$texteaction."')");
  202. //Fin action
  203. echo "<div class=\"notification success png_bg\">\n"
  204. . "<div>\n"
  205. . "" . _PREFUPDATED . "\n"
  206. . "</div>\n"
  207. . "</div>\n";
  208. redirect("index.php?file=Textbox&page=admin", 2);
  209. }
  210. switch ($_REQUEST['op'])
  211. {
  212. case "edit_shout":
  213. edit_shout($_REQUEST['mid']);
  214. break;
  215. case "modif_shout":
  216. modif_shout($_REQUEST['mid'], $_REQUEST['texte']);
  217. break;
  218. case "del_shout":
  219. del_shout($_REQUEST['mid']);
  220. break;
  221. case "del_all_shout":
  222. del_all_shout();
  223. break;
  224. case "main_pref":
  225. main_pref();
  226. break;
  227. case "change_pref":
  228. change_pref($_REQUEST['max_shout']);
  229. break;
  230. default:
  231. main();
  232. break;
  233. }
  234. }
  235. else if ($level_admin == -1)
  236. {
  237. echo "<div class=\"notification error png_bg\">\n"
  238. . "<div>\n"
  239. . "<br /><br /><div style=\"text-align: center;\">" . _MODULEOFF . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a></div><br /><br />"
  240. . "</div>\n"
  241. . "</div>\n";
  242. }
  243. else if ($visiteur > 1)
  244. {
  245. echo "<div class=\"notification error png_bg\">\n"
  246. . "<div>\n"
  247. . "<br /><br /><div style=\"text-align: center;\">" . _NOENTRANCE . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a></div><br /><br />"
  248. . "</div>\n"
  249. . "</div>\n";
  250. }
  251. else
  252. {
  253. echo "<div class=\"notification error png_bg\">\n"
  254. . "<div>\n"
  255. . "<br /><br /><div style=\"text-align: center;\">" . _ZONEADMIN . "<br /><br /><a href=\"javascript:history.back()\"><b>" . _BACK . "</b></a></div><br /><br />"
  256. . "</div>\n"
  257. . "</div>\n";
  258. }
  259. adminfoot();
  260. ?>