if ($mntLog) {
            error_log("{$currentTime} - Can't make connection to database server.\r\n", 3, $mntLogFile);
        }
        exit;
    }
}
/*
 * Open the database needed
 */
$dbselresult = @mysql_select_db($database);
if (!$dbselresult) {
    echo "Script failed. - cannot open database required. " . mysql_error();
    if ($mntLog) {
        error_log("{$currentTime} - Can't open database required.\r\n", 3, $mntLogFile);
    }
    exit;
}
/*
 * Remove the bans that are no longer needed.
 */
$recordset = @mysql_query("DELETE FROM ipbans WHERE banautoexpires=\"Y\" AND CURDATE() > banexpiry");
if ($mntLog) {
    error_log("{$currentTime} - " . mysql_affected_rows() . " outdated bans have been removed.\r\n", 3, $mntLogFile);
}
/*
 * Run a consistency check
 */
consistencyCheck(false, true);
if ($mntLog) {
    error_log("{$currentTime} - Ran consistency check.\r\n", 3, $mntLogFile);
}
                    // always KiB - default speed
                    echo "9:speedunit3:KiB";
                    //KiB
                }
                echo "e";
            }
            /*
             * Request the client not request another interval before a set value
             */
            echo "e5:flagsd20:min_request_intervali" . $GLOBALS["scrape_min_interval"] . "eee";
            /*
             * If bad data was found, and auto-consistency checking is on,
             * run the consistency check
             */
            if (!$scrapeConsistent && $GLOBALS["auto_db_check_scrape"]) {
                consistencyCheck();
            }
            exit;
        } else {
            /*
             * Send error message to client
             */
            showError("The scrape interface is disabled.");
        }
    }
}
///////////////////////////////////////////////////////////////////
// Handling of parameters from the URL and other setup
// Error: no web browsers allowed
if (!isset($_GET["info_hash"]) || !isset($_GET["peer_id"])) {
    header("HTTP/1.0 400 Bad Request");
<TR>
	<TD CLASS="data">This checks the database and:<BR><BR>1. Removes stale clients,<BR>
	2. Makes sure the seeder/leecher count is accurate, and <BR>3. Resets the Average % Done, if needed.<BR>
	4. Checks to make sure the downloaded amount is not negative.<BR>
   5. Resets the speed on the torrent to zero if there are no leechers present.<BR><BR>
	You may want to have this automatically run every <i>x</i> hours.<BR><BR>
	</TD>
</TR>
<TR>
	<TD CLASS="data">
<?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 die("Tracker error: can't open database {$database} - " . mysql_error());
/*
 * Do the check, outputting HTML
 */
consistencyCheck(true);
?>
	</TD>
</TR>
</TABLE>
</BODY>
</HTML>