<TR>
	<TD CLASS="data" COLSPAN=15>&nbsp;</TD>
</TR>
<TR>
	<TD ALIGN="center" COLSPAN=15>Add a new torrent group<SUP>1</SUP>: <INPUT TYPE=TEXT NAME="addgrp" SIZE=40>&nbsp;&nbsp;<INPUT TYPE="submit" NAME="addnewgrp" VALUE="Add..." CLASS="button"><BR><BR><A HREF="bta_main.php">Return to main administration panel</A></TD>
</TR>
<?php 
/*
 * Connect to the database
 */
if ($GLOBALS["persist"]) {
    $db = @mysql_pconnect($dbhost, $dbuser, $dbpass) or die("<HTML><BODY><FONT COLOR=\"red\">Couldn't connect to database. Incorrect username/password?</FONT></BODY></HTML>");
} else {
    $db = @mysql_connect($dbhost, $dbuser, $dbpass) or die("<HTML><BODY><FONT COLOR=\"red\">Couldn't connect to database. Incorrect username/password?</FONT></BODY></HTML>");
}
mysql_select_db($database) or sqlErr(mysql_error());
echo "<TR>\r\n\t<TD COLSPAN=15>\r\n\t\t<TABLE CLASS=\"tblAdminOuter\">\r\n";
echo "\t\t<TR>\r\n\t\t\t<TD ALIGN=RIGHT COLSPAN=2>\r\n\t\t\t<TABLE CLASS=\"tblAdminInner\" cellpadding=\"5\" cellspacing=\"1\">\r\n";
echo "\t\t\t<TR>\r\n";
echo "\t\t\t\t<TD CLASS=\"advSortHeading\" ALIGN=\"left\" VALIGN=\"bottom\">Torrent</TD>\r\n";
echo "\t\t\t\t<TD CLASS=\"advSortHeading\" ALIGN=\"center\" VALIGN=\"bottom\">Group</TD>\r\n";
echo "\t\t\t</TR>\r\n";
/*
 * Grab the information out of the database
 */
$query = "SELECT summary.info_hash, \r\n\t\t\tnamemap.filename, \r\n\t\t\tsummary.external_torrent,\r\n\t\t\tsubgrouping.group_id,\r\n\t\t\tsubgrouping.heading FROM summary \r\n\t\t\t\tLEFT JOIN namemap ON summary.info_hash = namemap.info_hash \r\n\t\t\t\tLEFT OUTER JOIN subgrouping ON subgrouping.group_id = namemap.grouping {$where} ORDER BY subgrouping.groupsort, namemap.sorting";
$recordset = mysql_query($query) or die("Can't do SQL query - " . mysql_error());
/*
 * Classes used to alternate background colour in rows
 */
$clrRowBG[0] = 'CLASS="advSortOdd"';
 echo "\t\t\t\t\t<TD CLASS=\"heading\" ALIGN=\"center\" VALIGN=\"bottom\">Revive?</TD>\r\n";
 echo "\t\t\t\t\t<TD CLASS=\"heading\" ALIGN=\"center\" VALIGN=\"bottom\">Delete?</TD>\r\n";
 echo "\r\n\t\t\t\t</TR>";
 /*
  * These are the alternating Cascadying Style Sheet classes used for the data.
  */
 $classRowBGClr[0] = 'CLASS="odd"';
 $classRowBGClr[1] = 'CLASS="even"';
 /*
  * Build a query string of information we need to get from the database
  */
 $query = "SELECT info_hash, \r\n\t\t\tfilename, \r\n\t\t\tsize, \r\n\t\t\tcrc32, \r\n\t\t\tcategory,\r\n\t\t\tcompleted, \r\n\t\t\ttransferred, \r\n\t\t\tdateadded, \r\n\t\t\tdateretired FROM retired {$where} {$order}";
 /*
  * Get a recordset of the torrents...
  */
 $recordset = mysql_query($query) or sqlErr(mysql_error());
 /*
  * Let's keep track of totals stats, for the summary line, so we need to initialize a few variables
  */
 $totaltorrents = 0;
 $totalsize = 0;
 $totalcomplete = 0;
 $totalxferred = 0;
 /*
  * let's set anchors for the various categories
  * to do this we need to know 1. what the last category was and
  * 2. if we are sorting by category, otherwise it's useless
  */
 $lastCategory = "";
 /*
  * Let's parse through the recordset, and show the information.
     * Get the hash value from the session...
     */
    $hash = $_SESSION["info_hash"];
    /*
     * Connect to the database
     */
    if ($GLOBALS["persist"]) {
        $db = @mysql_pconnect($dbhost, $dbuser, $dbpass) or die("<HTML><BODY><FONT COLOR=\"red\">Couldn't connect to database. Incorrect username/password?</FONT></BODY></HTML>");
    } else {
        $db = @mysql_connect($dbhost, $dbuser, $dbpass) or die("<HTML><BODY><FONT COLOR=\"red\">Couldn't connect to database. Incorrect username/password?</FONT></BODY></HTML>");
    }
    mysql_select_db($database) or die("Can't open the database.");
    /*
     * Grab info needed
     */
    $recordset = mysql_query("SELECT namemap.info_hash, \r\n\t\t\t\t\tnamemap.filename,\r\n\t\t\t\t\tnamemap.size,\r\n\t\t\t\t\tnamemap.url, \r\n\t\t\t\t\tnamemap.mirrorurl, \r\n\t\t\t\t\tnamemap.sfvlink,\r\n\t\t\t\t\tnamemap.md5link,\r\n\t\t\t\t\tnamemap.infolink,\r\n\t\t\t\t\tnamemap.info, \r\n\t\t\t\t\tnamemap.category, \r\n\t\t\t\t\tnamemap.crc32, \r\n\t\t\t\t\tnamemap.DateAdded, \r\n\t\t\t\t\tnamemap.DateToRemoveURL,\r\n\t\t\t\t\tnamemap.DateToHideTorrent,\r\n\t\t\t\t\tsummary.hide_torrent,\r\n\t\t\t\t\tsummary.external_torrent,\r\n\t\t\t\t\tnamemap.comment,\r\n\t\t\t\t\tnamemap.show_comment FROM summary LEFT JOIN namemap ON summary.info_hash = namemap.info_hash WHERE summary.info_hash=\"{$hash}\"") or sqlErr("Database error. Cannot complete request.");
    /*
     * Make sure there was a record returned. If no record, hash must be invalid.
     */
    if (mysql_num_rows($recordset) == 0) {
        admShowMsg("Invalid info hash specified.", "Invalid hash specified (internal error).", "Error", true, "bta_main.php", 5);
        exit;
    } else {
        /*
         * There is data; retrieve it, and get the current day.
         */
        $row = mysql_fetch_row($recordset);
        $today = date("Y-m-d");
    }
}
/*