PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/Suggest/modules/Sections.php

https://code.google.com/p/nuked-klan/
PHP | 160 lines | 126 code | 26 blank | 8 comment | 20 complexity | a46f9064ccf55ff416b66a8183fb0430 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 - Portal PHP //
  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. exit('You can\'t run this file alone.');
  13. }
  14. function form($content, $sug_id)
  15. {
  16. global $nuked, $user, $language, $captcha;
  17. translate("modules/Sections/lang/" . $language . ".lang.php");
  18. if ($content != "")
  19. {
  20. $titre = "<big><b>" . _VALIDART . "</b></big>";
  21. $action = "index.php?file=Suggest&amp;page=admin&amp;op=valid_suggest&amp;module=Sections";
  22. $autor = $content[3];
  23. $autor_id = $content[4];
  24. echo "<script type=\"text/javascript\">\n"
  25. . "<!--\n"
  26. . "\n"
  27. . "function del_sug(id)\n"
  28. . "{\n"
  29. . "if (confirm('" . _DELETESUG . " '+id+' ! " . _CONFIRM . "'))\n"
  30. . "{document.location.href = 'index.php?file=Suggest&page=admin&op=raison&sug_id='+id;}\n"
  31. . "}\n"
  32. . "\n"
  33. . "// -->\n"
  34. . "</script>\n";
  35. $refuse = "&nbsp;<input type=\"button\" value=\"" . _REMOVE . "\" onclick=\"javascript:del_sug('" . $sug_id . "');\" /></div>\n"
  36. . "<div style=\"text-align: center;\"><br />[ <a href=\"index.php?file=Suggest&amp;page=admin\"><b>" . _BACK . "</b></a> ]</div></form><br />\n";
  37. }
  38. else
  39. {
  40. $titre = "<big><b> " . _SECTIONS . " </b></big></div>\n"
  41. . "<div style=\"text-align: center;\"><br />\n"
  42. . "[ <a href=\"index.php?file=Sections\" style=\"text-decoration: underline\">" . _INDEXSECTIONS . "</a> | "
  43. . "<a href=\"index.php?file=Sections&amp;op=classe&amp;orderby=news\" style=\"text-decoration: underline\">" . _NEWSART . "</a> | "
  44. . "<a href=\"index.php?file=Sections&amp;op=classe&amp;orderby=count\" style=\"text-decoration: underline\">" . _TOPART . "</a> | "
  45. . _SUGGESTART . " ]";
  46. $action = "index.php?file=Suggest&amp;op=add_sug&amp;module=Sections";
  47. $autor = $user[2];
  48. $autor_id = $user[0];
  49. $refuse = "</div></form><br />\n";
  50. }
  51. echo "<br /><div style=\"text-align: center;\">" . $titre . "</div><br />\n"
  52. . "<form method=\"post\" action=\"$action\">\n"
  53. . "<table style=\"margin: auto; width: 98%; text-align: left;\" cellspacing=\"0\" cellpadding=\"2\"border=\"0\">\n"
  54. . "<tr><td><b>" . _TITLE . "</b> : <input type=\"text\" name=\"title\" size=\"45\" value=\"" . $content[0] . "\" /></td></tr>\n"
  55. . "<tr><td><b>" . _CAT . " :</b> <select name=\"secid\"><option value=\"0\">* " . _NONE . "</option>\n";
  56. $sql = mysql_query("SELECT secid, secname FROM " . SECTIONS_CAT_TABLE . " WHERE parentid = 0 ORDER BY position, secname");
  57. while (list($secid, $titre) = mysql_fetch_array($sql))
  58. {
  59. $titre = printSecuTags($titre);
  60. if ($content)
  61. {
  62. if ($secid == $content[1]) $selected = "selected=\"selected\"";
  63. else $selected = "";
  64. }
  65. echo "<option value=\"" . $secid . "\" " . $selected . ">* " . $titre . "</option>\n";
  66. $sql2 = mysql_query("SELECT secid, secname FROM " . SECTIONS_CAT_TABLE . " WHERE parentid = '" . $secid . "' ORDER BY position, secname");
  67. while (list($s_cid, $s_titre) = mysql_fetch_array($sql2))
  68. {
  69. $s_titre = printSecuTags($s_titre);
  70. if ($content)
  71. {
  72. if ($s_cid == $content[1]) $selected1 = "selected=\"selected\"";
  73. else $selected = "";
  74. }
  75. echo "<option value=\"" . $s_cid . "\" " . $selected1 . ">&nbsp;&nbsp;&nbsp;" . $s_titre . "</option>\n";
  76. }
  77. }
  78. echo "</select></td></tr>\n";
  79. echo "<tr><td><b>" . _TEXT . "</b></td></tr>\n"
  80. . "<tr><td><textarea ";
  81. echo $_REQUEST['page'] == 'admin' ? 'class="editor" ' : 'id="e_advanced" ';
  82. echo "name=\"texte\" cols=\"65\" rows=\"12\">" . $content[2] . "</textarea></td></tr>\n";
  83. if ($captcha == 1) create_captcha(1);
  84. echo "<tr><td>&nbsp;<input type=\"hidden\" name=\"sug_id\" value=\"" . $sug_id . "\" />\n"
  85. . "<input type=\"hidden\" name=\"auteur\" value=\"" . $autor . "\" />\n"
  86. . "<input type=\"hidden\" name=\"auteur_id\" value=\"" . $autor_id . "\" /></td></tr></table>\n"
  87. . "<div style=\"text-align: center;\"><small>" . _PAGEBREACK . "</small></div>\n"
  88. . "<div style=\"text-align: center;\"><br /><input type=\"submit\" value=\"" . _SEND . "\" />" . $refuse;
  89. }
  90. function make_array($data)
  91. {
  92. $data['title'] = printSecuTags($data['title']);
  93. $data['secid'] = htmlentities($data['secid']);
  94. $data['auteur'] = htmlentities($data['auteur']);
  95. $data['auteur_id'] = htmlentities($data['auteur_id']);
  96. $data['title'] = str_replace("|", "&#124;", $data['title']);
  97. $data['texte'] = str_replace("|", "&#124;", $data['texte']);
  98. $content = $data['title'] . "|" . $data['secid'] . "|" . $data['texte'] . "|" . $data['auteur'] . "|" . $data['auteur_id'];
  99. return $content;
  100. }
  101. function send($data)
  102. {
  103. global $nuked;
  104. if ($data['auteur'] != "")
  105. {
  106. $autor = $data['auteur'];
  107. }
  108. else
  109. {
  110. $autor = $user[2];
  111. }
  112. if ($data['auteur_id'] != "")
  113. {
  114. $autor_id = $data['auteur_id'];
  115. }
  116. else
  117. {
  118. $autor_id = $user[0];
  119. }
  120. $data['title'] = mysql_real_escape_string(stripslashes($data['title']));
  121. $data['texte'] = html_entity_decode($data['texte']);
  122. $data['texte'] = mysql_real_escape_string(stripslashes($data['texte']));
  123. $date = time();
  124. $upd = mysql_query("INSERT INTO " . SECTIONS_TABLE . " ( `artid` , `secid` , `title` , `content` , `autor` , `autor_id`, `counter` , `date` ) VALUES ( '' , '" . $data['secid'] . "' , '" . $data['title'] . "' , '" . $data['texte'] . "' , '" . $autor . "' , '" . $autor_id . "' , '' , '" . $date. "' )");
  125. $sql2 = mysql_query("SELECT artid FROM " . SECTIONS_TABLE . " WHERE title = '" . $data['title'] . "' AND date='".$date."'");
  126. list($artid) = mysql_fetch_array($sql2);
  127. echo "<script>\n"
  128. ."setTimeout('screen()','3000');\n"
  129. ."function screen() { \n"
  130. ."screenon('index.php?file=Sections&op=article&artid=".$artid."', 'index.php?file=Suggest&page=admin');\n"
  131. ."}\n"
  132. ."</script>\n";
  133. }
  134. ?>