daily pastebin goal
26%
SHARE
TWEET

Ryan

a guest May 26th, 2009 349 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if($_POST['action'] == "nuke"){
  2.                 $username="xxxxxx";
  3.                 $password="xxxxxx";
  4.                 $database="xxxxxx";
  5.                 $server="xxxxxxx";
  6.                
  7.                 //Connect to DB
  8.                 mysql_connect($server,$username,$password) or die("Unable to Conenct");
  9.                 @mysql_select_db($database) or die( "Unable to select database");
  10.                
  11.                 //Get user id and ip
  12.                 $query= "SELECT * FROM phpbb_users WHERE username_clean = '".strtolower($_POST['username'])."';";
  13.                 $result=mysql_query($query) or die("Query Failed: ".$query);
  14.                 $row = mysql_fetch_array($result);
  15.                
  16.                 $userID = $row['user_id'];
  17.                 $userIP = $row['user_ip'];
  18.                
  19.                 //Delete User
  20.                 $query= "DELETE FROM phpbb_users WHERE user_id = ".$userID.";";
  21.                 mysql_query($query) or header("location: nuke.php?error=usernotfound"); //die("Post Deletion Failed.  Query: ".$query);
  22.  
  23.                 //Delete posts
  24.                 $query= "DELETE FROM phpbb_posts WHERE poster_id = ".$userID.";";
  25.                 mysql_query($query) or die("Post Deletion Failed.  Query: ".$query);
  26.                
  27.                 //Delete topics
  28.                 $query= "DELETE FROM phpbb_topics WHERE topic_poster = ".$userID.";";
  29.                 mysql_query($query) or die("Post Deletion Failed.  Query: ".$query);
  30.          
  31.                 //Ban user ID
  32.                 $query = "INSERT INTO phpbb_banlist (ban_userid) VALUES (".$userID.");";
  33.                 mysql_query($query) or die("Banlist Update User ID Failed.  Query: ".$query);
  34.                
  35.                 //Ban user IP address
  36.                 if(!empty($userIP)){
  37.                         $query = "INSERT INTO `vdp_forum_new`.`phpbb_banlist` (`ban_id`, `ban_userid`, `ban_ip`, `ban_email`, `ban_start`, `ban_end`, `ban_exclude`, `ban_reason`, `ban_give_reason`) VALUES (NULL, '0', '".$userIP."', '', '0', '0', '0', '', 'nuked');";
  38.                         mysql_query($query) or die("Banlist Update User IP Failed.  Query: ".$query);
  39.                 }
  40.                
  41.                 //Fix 'last post by' and 'last post time' on forums that were affected by deleted posts
  42.                 $query = "SELECT * FROM phpbb_forums WHERE forum_last_poster_id = ".$userID.";";
  43.                 $result = mysql_query($query) or die("Query Failed: ".$query);
  44.                 while($row = mysql_fetch_assoc($result)){
  45.                         $query = "SELECT * FROM phpbb_posts WHERE forum_id = ".$row['forum_id']." ORDER BY post_time DESC LIMIT 1;";
  46.                         $result2 = mysql_query($query) or die("Query Failed: ".$query);
  47.                                
  48.                         //get last poster and time
  49.                         $row2 = mysql_fetch_array($result2);
  50.                         $realLastPosterID = $row2['poster_id'];
  51.                         $realLastPostTime = $row2['post_time'];
  52.  
  53.                         //Set last post time
  54.                         $query = "UPDATE phpbb_forums SET forum_last_post_time = '".$realLastPostTime."' WHERE forum_id = ".$row['forum_id'].";";
  55.                         mysql_query($query) or die("Fix failed: ". $query);
  56.                        
  57.                         //Set last poster id
  58.                         $query = "UPDATE phpbb_forums SET forum_last_poster_id = ".$realLastPosterID." WHERE forum_id = ".$row['forum_id'].";";
  59.                         mysql_query($query) or die("Fix failed: ". $query);
  60.                        
  61.                         //Set last poster name
  62.                         $name = getName($realLastPosterID);
  63.                         $query = "UPDATE phpbb_forums SET forum_last_poster_name = '".$name."' WHERE forum_id = ".$row['forum_id'].";";
  64.                         mysql_query($query) or die("Fix failed: ". $query);
  65.                 }
  66.                
  67.                 header("Location: nuke.php?success=1");
  68.         }
  69.        
  70.         //Get username based on ID
  71.         function getName($id){
  72.                 $query = "SELECT * FROM phpbb_users WHERE user_id = ".$id.";";
  73.                 $result = mysql_query($query) or die("Fix failed: ". $query);
  74.                 $row = mysql_fetch_array($result);
  75.                 return $row['username'];
  76.         }
  77. ?>
  78. <center><br />
  79.         This form is <b>very</b> dangerous...be careful.<br /><br />
  80.         <form method="post">
  81.                 Username: <input type="text" name="username" /> &nbsp; <input type="submit" value="Nuke" />
  82.                 <input type="hidden" name="action" value="nuke" />
  83.         </form>
  84.         <? if($_GET['success'] == 1){ ?>
  85.         <br />
  86.         Deleted user...<span style="color:green;">Success!</span><br />
  87.         Deleted posts...<span style="color:green;">Success!</span><br />
  88.         Banned Username...<span style="color:green;">Success!</span><br />
  89.         Banned IP...<span style="color:green;">Success!</span><br />
  90.         Fixed post info...<span style="color:green;">Success!</span><br />
  91.         <? } ?>
  92.        
  93.         <? if($_GET['error'] == 'usernotfound'){ ?>
  94.         <br />
  95.         <span style="color:red;">Username not found.</span>
  96.         <? } ?>
  97.        
  98. </center>
RAW Paste Data
Top