if (isset($_SESSION["deletelist"])) {
     /*
      * Go through each value and remove the data and tables
      */
     foreach ($_SESSION["deletelist"] as $key => $value) {
         @mysql_query("DELETE FROM summary WHERE info_hash=\"" . $_SESSION["deletelist"][$key]["hash"] . "\"");
         @mysql_query("DELETE FROM namemap WHERE info_hash=\"" . $_SESSION["deletelist"][$key]["hash"] . "\"");
         @mysql_query("DELETE FROM timestamps WHERE info_hash=\"" . $_SESSION["deletelist"][$key]["hash"] . "\"");
         @mysql_query("DELETE FROM trk_ext WHERE info_hash=\"" . $_SESSION["deletelist"][$key]["hash"] . "\"");
         @mysql_query("DROP TABLE x" . $_SESSION["deletelist"][$key]["hash"]);
         @mysql_query("DROP TABLE y" . $_SESSION["deletelist"][$key]["hash"]);
         /*
          * Time to reorder the remaining torrents, ignoring the return error (seeing as there isn't much we can do
          * if it decides to not work...
          */
         advSortDelete($_SESSION["deletelist"][$key]["category"], $_SESSION["deletelist"][$key]["grouping"], $_SESSION["deletelist"][$key]["sorting"]);
         /*
          * Delete the torrent from the database if enabled.
          */
         if ($GLOBALS["move_to_db"]) {
             @mysql_query("DELETE FROM torrents WHERE info_hash=\"" . $_SESSION["deletelist"][$key]["hash"] . "\"");
         }
     }
     /*
      * Destroy the variable
      */
     unset($_SESSION["deletelist"]);
 }
 /*
  * Process retired torrent revive list, if some were selected
  */
              * REALLY disorganized!
              */
             $rstNewSorting = @mysql_query("SELECT `sorting` FROM `namemap` WHERE `info_hash`=\"" . $_SESSION["grouplist"][$key]["hash"] . "\"");
             if ($rstNewSorting === false) {
                 $newSort = $_SESSION["grouplist"][$key]["sorting"];
             } else {
                 $newSort = mysql_result($rstNewSorting, 0, 0);
             }
             /*
              * First, group it in the requested group adding it to the end of the torrents
              */
             @mysql_query("UPDATE `namemap` SET `grouping` = " . $_POST["groupname"] . ", `sorting` = {$advsort} WHERE `info_hash`=\"" . $_SESSION["grouplist"][$key]["hash"] . "\"");
             /*
              * Then reorder the old group it was in
              */
             advSortDelete($_SESSION["grouplist"][$key]["category"], 0, $newSort);
             /*
              * Increment the advanced sort counter, to keep everything in order!
              */
             $advsort++;
         }
     }
     admShowMsg("Update complete", "Redirecting to advanced sorting page.", "Redirecting", true, "bta_advsort.php", 3);
     exit;
 }
 /*
  * If processbuttonstep1 is set, this means it is the first step from the main sorting page...
  */
 if (isset($_POST["processbuttonstep1"])) {
     /*
      * Commit the changes to the headings