Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // Define Database Credentials
- $dbuser = "";
- $dbpass = "";
- $dbhost = "";
- $dbname = "";
- $shells = array();
- // Lets make a connection and get all the shells and add them into an array
- mysql_connect($dbhost, $dbuser, $dbpass);
- @mysql_select_db($dbname) or die( "Error loading shells!");
- $query="SELECT * FROM shells";
- $result=mysql_query($query);
- $num=mysql_numrows($result);
- mysql_close();
- $i=0;
- while ($i < $num) {
- $url=mysql_result($result,$i,"url");
- array_push($shells, $url)
- $i++;
- }
- echo "Added Shells To Array";
- // Ok we have all the shells now, time to dump the old DB
- $connection = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Unable to Truncate Table");
- mysql_select_db($dbname);
- $sql = "TRUNCATE TABLE shells";
- mysql_query($sql);
- echo "Shells Table Truncated/Emptied";
- mysql_close($connection);
- echo "Emptied Shells DB";
- // Finally, lets remove duplicates and add the shells back!
- $final = array_unique($shells);
- foreach ($final as &$value) {
- mysql_connect($dbhost,$dbuser,$dbpass);
- @mysql_select_db($dbname);
- mysql_query("INSERT shells (url) VALUES ('$value')");
- echo "Finished";
- // All duplicates are now removed.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement