home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / admin / modules / comments.php < prev    next >
PHP Script  |  2004-08-23  |  10KB  |  277 lines

  1. <?PHP
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
  16. global $prefix, $db;
  17. $aid = substr(trim($aid), 0,25);
  18. $row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
  19. if ($row['radminsuper'] == 1) {
  20.  
  21. //vlozi copyrightove informace
  22. function un_comments_copyright() {
  23. echo "<table border=\"0\" align=\"right\" valign=\"top\"><tr><td align=\"right\">Copyright (c) 2004 <a href=\"mailto:united-nuke@openland.cz\">Jiri Stavinoha</a></td></tr></table>";
  24. }
  25.  
  26. //zakladnφ menu 
  27. function un_comments_remover_main() {
  28. include("header.php");
  29. GraphicAdmin();
  30. title(""._COMMENTS_TITLE."");
  31. OpenTable();
  32. echo "<form action=\"admin.php\" method=\"post\"\n";
  33. echo "<table border=\"0\" align=\"center\" cellspacing=\"5\">\n";
  34. echo "<tr><td align=\"right\">"._COMMENTS_INSERTIP."</td><td align=\"left\">\n";
  35. echo "<input type=\"text\" name=\"poster_ip\" size=\"16\">\n";
  36. echo "<input type=\"hidden\" name=\"op\" value=\"CommentsRemoverViewList\">\n";
  37. echo "<input type=\"submit\" value=\""._COMMENTS_DISPLAYCOMMENTS."\">\n";
  38. echo "</td></tr>\n";
  39. echo "</form>\n";
  40. echo "</table>\n";
  41. CloseTable();
  42. un_comments_copyright();
  43. include("footer.php");
  44. }
  45.  
  46. //zobrazeni prispevku
  47. function un_comments_remover_view_list($poster_ip) {
  48. global $db, $prefix, $anonymous;
  49. include("header.php");
  50. GraphicAdmin();
  51. title(""._COMMENTS_TITLE."");
  52.  
  53. $result = $db->sql_query("SELECT subject, comment, tid, sid, name, date FROM ".$prefix."_comments WHERE host_name='$poster_ip' ORDER BY date DESC");
  54.  
  55. if ($db->sql_numrows($result) == 0) {
  56. OpenTable();
  57. echo "<center>"._COMMENTS_NOCOMMENTS."</center>";
  58. CloseTable();
  59. } else {
  60. OpenTable();
  61. echo "<center>"._COMMENTS_COMMENTSWITHIP." $poster_ip "._COMMENTS_BYTIMEINSERT."</center>";
  62. CloseTable();
  63. echo "<br>";
  64. OpenTable();
  65. while ($row = $db->sql_fetchrow($result)) {
  66.   $subject = $row['subject'];
  67.   $comment = $row['comment'];
  68.   $tid = intval($row['tid']);
  69.   $sid = intval($row['sid']);
  70.   $name = $row['name'];
  71.   $date = $row['date'];
  72.  
  73. if ($name == $anonymous OR $name == "") {
  74. $from_poster = $anonymous;
  75. } else {
  76. $from_poster = "<a href=\"modules.php?name=Your_Account&op=userinfo&username=$name\" target=\"_blank\">$name</a>";
  77. }
  78.     
  79. echo "<table bgcolor=\"$bgcolor1\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\" width=\"100%\">\n";
  80. echo "<tbody><tr>\n";
  81. echo "  <td>\n";
  82. echo "  <table border=\"0\" width=\"99%\">\n";
  83. echo "  <tbody><tr bgcolor=\"$bgcolor1\">\n";
  84. echo "    <td width=\"500\">\n";
  85. echo "    <b>$subject</b> <font class=\"content\"><br>"._BY." $from_poster "._ON." ".formatTimestamp($date)."</font>\n";
  86. echo "  </td>\n";
  87. echo "  </tr><tr>\n";
  88. echo "  <td>$comment</td>\n";
  89. echo "    </tr></tbody>\n";
  90. echo "    </table>\n";
  91. echo "<font class=\"content\">[ <a href=\"admin.php?op=RemoveComment&tid=$tid&sid=$sid\" target=\"_blank\">"._DELETE."</a> ]</font>\n";
  92. echo "  </td>\n";
  93. echo "</tr></tbody>\n";
  94. echo "</table>";    
  95. }
  96.  
  97. CloseTable();
  98. echo "<br>";
  99. OpenTable();
  100.  
  101. echo "<form action=\"admin.php\" method=\"post\"\n";
  102. echo "<table border=\"0\" align=\"center\" cellspacing=\"5\">\n";
  103. echo "<tr><td align=\"center\">\n";
  104. echo "<input type=\"hidden\" name=\"ok\" value=\"0\">\n";
  105. echo "<input type=\"hidden\" name=\"poster_ip\" value=\"$poster_ip\">\n";
  106. echo "<input type=\"hidden\" name=\"op\" value=\"CommentsRemoverremoveAll\">\n";
  107. echo "<input type=\"submit\" value=\""._COMMENTS_DELETEALLSELECTEDCOMMENTS."\">\n";
  108. echo "</td></tr>\n";
  109. echo "</form>\n";
  110. echo "</table>\n";
  111.  
  112. CloseTable();
  113.  
  114. }
  115.  
  116. un_comments_copyright();
  117. include("footer.php");
  118. }
  119.  
  120.  
  121. function un_comments_removerremove_all($poster_ip, $ok) {
  122. global $db, $prefix;
  123. include("header.php");
  124. GraphicAdmin();
  125. title(""._COMMENTS_TITLE."");
  126.  
  127. if ($ok) {
  128. $result = $db->sql_query("SELECT tid, sid FROM ".$prefix."_comments WHERE host_name='$poster_ip'");
  129.   if ($db->sql_numrows($result) == 0) {
  130.   OpenTable();
  131.   echo "<center>"._COMMENTS_NOCOMMENTSWITHIP." $poster_ip "._COMMENTS_COMMENTSNOTFOUND."</center>";
  132.   CloseTable();
  133.   } else {
  134.   while ($row = $db->sql_fetchrow($result)) {
  135.  
  136.   $tid = intval($row['tid']);
  137.   $sid = intval($row['sid']);
  138.  
  139.   removeComment ($tid, $sid, 1, 1); 
  140.   }
  141. Header("Location: admin.php?op=CommentsRemoverMain");
  142. }
  143.  
  144. } else {
  145. OpenTable();
  146. echo "<center>"._COMMENTS_AREYOUSUREDELETEALLSELECTED."<br><br>[ <a href=\"javascript:history.go(-1)\">"._NO."</a> | <a href=\"admin.php?op=CommentsRemoverremoveAll&poster_ip=$poster_ip&ok=1\">"._YES."</a> ]</center>\n";
  147. CloseTable();
  148. }
  149.  
  150. un_comments_copyright();
  151. include("footer.php");
  152. }
  153.  
  154. /*********************************************************/
  155. /* Comments Delete Function                              */
  156. /*********************************************************/
  157.  
  158. /* Thanks to Oleg [Dark Pastor] Martos from http://www.rolemancer.ru */
  159. /* to code the comments childs deletion function!                    */
  160.  
  161. function removeSubComments($tid) {
  162.     global $prefix, $db;
  163.     $tid = intval($tid);
  164.     $result = $db->sql_query("SELECT tid from ".$prefix."_comments where pid='$tid'");
  165.     $numrows = $db->sql_numrows($result);
  166.     if($numrows>0) {
  167.     while ($row = $db->sql_fetchrow($result)) {
  168.     $stid = intval($row['tid']);
  169.             removeSubComments($stid);
  170.             $stid = intval($stid);
  171.             $db->sql_query("delete from ".$prefix."_comments where tid='$stid'");
  172.         }
  173.     }
  174.     $db->sql_query("delete from ".$prefix."_comments where tid='$tid'");
  175. }
  176.  
  177. function removeComment ($tid, $sid, $ok=0, $un_all = 0) {
  178.     global $ultramode, $prefix, $db;
  179.     if($ok) {
  180.         $tid = intval($tid);
  181.         $result = $db->sql_query("SELECT date from ".$prefix."_comments where pid='$tid'");
  182.         $numresults = $db->sql_numrows($result);
  183.         $row = $db->sql_fetchrow($result);
  184.         $sid = intval($sid);
  185.         $db->sql_query("update ".$prefix."_stories set comments=comments-1-'$numresults' where sid='$sid'");
  186.     /* Call recursive delete function to delete the comment and all its childs */
  187.         removeSubComments($tid);
  188.         if ($ultramode) {
  189.             ultramode();
  190.         }
  191.         if ($un_all == 0) {
  192.         Header("Location: modules.php?name=News&file=article&sid=$sid");
  193.     }
  194.     } else {
  195.     include("header.php");
  196.         GraphicAdmin();
  197.     OpenTable();
  198.     echo "<center><font class=\"title\"><b>"._REMOVECOMMENTS."</b></font></center>";
  199.     CloseTable();
  200.     echo "<br>";
  201.     OpenTable();
  202.         echo "<center>"._SURETODELCOMMENTS."";
  203.         echo "<br><br>[ <a href=\"javascript:history.go(-1)\">"._NO."</a> | <a href=\"admin.php?op=RemoveComment&tid=$tid&sid=$sid&ok=1\">"._YES."</a> ]</center>";
  204.     CloseTable();
  205.         include("footer.php");
  206.     }
  207. }
  208.  
  209. function removePollSubComments($tid) {
  210.     global $prefix, $db;
  211.     $tid = intval($tid);
  212.     $result = $db->sql_query("SELECT tid from ".$prefix."_pollcomments where pid='$tid'");
  213.     $numrows = $db->sql_numrows($result);
  214.     if($numrows>0) {
  215.     while ($row = $db->sql_fetchrow($result)) {
  216.     $stid = intval($row['tid']);
  217.             removePollSubComments($stid);
  218.             $db->sql_query("delete from ".$prefix."_pollcomments where tid='$stid'");
  219.         }
  220.     }
  221.     $db->sql_query("delete from ".$prefix."_pollcomments where tid='$tid'");
  222. }
  223.  
  224. function RemovePollComment ($tid, $pollID, $ok=0) {
  225.     if($ok) {
  226.         removePollSubComments($tid);
  227.         Header("Location: modules.php?name=Surveys&op=results&pollID=$pollID");
  228.     } else {
  229.     include("header.php");
  230.         GraphicAdmin();
  231.     OpenTable();
  232.     echo "<center><font class=\"title\"><b>"._REMOVECOMMENTS."</b></font></center>";
  233.     CloseTable();
  234.     echo "<br>";
  235.     OpenTable();
  236.         echo "<center>"._SURETODELCOMMENTS."";
  237.         echo "<br><br>[ <a href=\"javascript:history.go(-1)\">"._NO."</a> | <a href=\"admin.php?op=RemovePollComment&tid=$tid&pollID=$pollID&ok=1\">"._YES."</a> ]</center>";
  238.     CloseTable();
  239.         include("footer.php");
  240.     }
  241. }
  242.  
  243. switch ($op) {
  244.  
  245.     case "RemoveComment":
  246.     removeComment ($tid, $sid, $ok);
  247.     break;
  248.  
  249.     case "removeSubComments":
  250.     removeSubComments($tid);
  251.     break;
  252.  
  253.     case "removePollSubComments":
  254.     removePollSubComments($tid);
  255.     break;
  256.  
  257.     case "RemovePollComment":
  258.     RemovePollComment($tid, $pollID, $ok);
  259.     break;
  260.     
  261.     case "CommentsRemoverMain":
  262.     un_comments_remover_main();
  263.     break;
  264.  
  265.     case "CommentsRemoverViewList":
  266.     un_comments_remover_view_list($poster_ip);
  267.     break;
  268.     
  269.     case "CommentsRemoverremoveAll":
  270.     un_comments_removerremove_all($poster_ip, $ok);
  271.     break;
  272. }
  273.  
  274. } else {
  275.     echo "Access Denied";
  276. }
  277. ?>