Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <?PHP
  2. // Define Database Credentials
  3. $dbuser = "";
  4. $dbpass = "";
  5. $dbhost = "";
  6. $dbname = "";
  7. $shells = array();
  8. // Lets make a connection and get all the shells and add them into an array
  9. mysql_connect($dbhost, $dbuser, $dbpass);
  10. @mysql_select_db($dbname) or die( "Error loading shells!");
  11. $query="SELECT * FROM shells";
  12. $result=mysql_query($query);
  13. $num=mysql_numrows($result);
  14. mysql_close();
  15.  
  16. $i=0;
  17. while ($i < $num) {
  18. $url=mysql_result($result,$i,"url");
  19. array_push($shells, $url)
  20. $i++;
  21.  
  22. }
  23. echo "Added Shells To Array";
  24.  
  25. // Ok we have all the shells now, time to dump the old DB
  26. $connection = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Unable to Truncate Table");
  27. mysql_select_db($dbname);
  28. $sql = "TRUNCATE TABLE shells";
  29. mysql_query($sql);
  30. echo "Shells Table Truncated/Emptied";
  31. mysql_close($connection);
  32. echo "Emptied Shells DB";
  33.  
  34. // Finally, lets remove duplicates and add the shells back!
  35. $final = array_unique($shells);
  36. foreach ($final as &$value) {
  37. mysql_connect($dbhost,$dbuser,$dbpass);
  38. @mysql_select_db($dbname);
  39. mysql_query("INSERT shells (url) VALUES ('$value')");
  40. echo "Finished";
  41.  
  42. // All duplicates are now removed.
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement