home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / admin / modules / comments.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  4.5 KB  |  123 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", $PHP_SELF)) { die ("Access Denied"); }
  16. $result = sql_query("select radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  17. list($radminsuper) = sql_fetch_row($result, $dbi);
  18. if ($radminsuper==1) {
  19.  
  20. /*********************************************************/
  21. /* Comments Delete Function                              */
  22. /*********************************************************/
  23.  
  24. /* Thanks to Oleg [Dark Pastor] Martos from http://www.rolemancer.ru */
  25. /* to code the comments childs deletion function!                    */
  26.  
  27. function removeSubComments($tid) {
  28.     global $prefix, $dbi;
  29.     $result = sql_query("select tid from ".$prefix."_comments where pid='$tid'", $dbi);
  30.     $numrows = sql_num_rows($result, $dbi);
  31.     if($numrows>0) {
  32.     while(list($stid) = sql_fetch_row($result, $dbi)) {
  33.             removeSubComments($stid);
  34.             sql_query("delete from ".$prefix."_comments where tid='$stid'", $dbi);
  35.         }
  36.     }
  37.     sql_query("delete from ".$prefix."_comments where tid='$tid'", $dbi);
  38. }
  39.  
  40. function removeComment ($tid, $sid, $ok=0) {
  41.     global $ultramode, $prefix, $dbi;
  42.     if($ok) {
  43.     $result = sql_query("select date from ".$prefix."_comments where pid='$tid'", $dbi);
  44.     $numresults = sql_num_rows($result, $dbi);
  45.         sql_query("update ".$prefix."_stories set comments=comments-1-'$numresults' where sid='$sid'", $dbi);
  46.     /* Call recursive delete function to delete the comment and all its childs */
  47.         removeSubComments($tid);
  48.         if ($ultramode) {
  49.             ultramode();
  50.         }
  51.         Header("Location: modules.php?name=News&file=article&sid=$sid");
  52.     } else {
  53.     include("header.php");
  54.         GraphicAdmin();
  55.     OpenTable();
  56.     echo "<center><font class=\"title\"><b>"._REMOVECOMMENTS."</b></font></center>";
  57.     CloseTable();
  58.     echo "<br>";
  59.     OpenTable();
  60.         echo "<center>"._SURETODELCOMMENTS."";
  61.         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>";
  62.     CloseTable();
  63.         include("footer.php");
  64.     }
  65. }
  66.  
  67. function removePollSubComments($tid) {
  68.     global $prefix, $dbi;
  69.     $result = sql_query("select tid from ".$prefix."_pollcomments where pid='$tid'", $dbi);
  70.     $numrows = sql_num_rows($result, $dbi);
  71.     if($numrows>0) {
  72.     while(list($stid) = sql_fetch_row($result, $dbi)) {
  73.             removePollSubComments($stid);
  74.             sql_query("delete from ".$prefix."_pollcomments where tid='$stid'", $dbi);
  75.         }
  76.     }
  77.     sql_query("delete from ".$prefix."_pollcomments where tid='$tid'", $dbi);
  78. }
  79.  
  80. function RemovePollComment ($tid, $pollID, $ok=0) {
  81.     if($ok) {
  82.         removePollSubComments($tid);
  83.         Header("Location: modules.php?name=Surveys&op=results&pollID=$pollID");
  84.     } else {
  85.     include("header.php");
  86.         GraphicAdmin();
  87.     OpenTable();
  88.     echo "<center><font class=\"title\"><b>"._REMOVECOMMENTS."</b></font></center>";
  89.     CloseTable();
  90.     echo "<br>";
  91.     OpenTable();
  92.         echo "<center>"._SURETODELCOMMENTS."";
  93.         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>";
  94.     CloseTable();
  95.         include("footer.php");
  96.     }
  97. }
  98.  
  99. switch ($op) {
  100.  
  101.     case "RemoveComment":
  102.     removeComment ($tid, $sid, $ok);
  103.     break;
  104.  
  105.     case "removeSubComments":
  106.     removeSubComments($tid);
  107.     break;
  108.  
  109.     case "removePollSubComments":
  110.     removePollSubComments($tid);
  111.     break;
  112.  
  113.     case "RemovePollComment":
  114.     RemovePollComment($tid, $pollID, $ok);
  115.     break;
  116.  
  117. }
  118.  
  119. } else {
  120.     echo "Access Denied";
  121. }
  122. ?>
  123.