optimise and repair database from tracker

Started by rickandmary, July 20, 2012, 01:58:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rickandmary

#1
save as optimise.php or whatever you like and upload to root directory.

<?
//---------------------------------------------------------
//---- Optimize & Repair Database from Tracker by D3SI
//---------------------------------------------------------
require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
if (get_user_class() < UC_SYSOP)
stderr("Error", "Permission denied.");
$tables = "";
$tablesshow = mysql_query("SHOW TABLES FROM `".$mysql_db."`");
while (list($table) = mysql_fetch_row($tablesshow)){
$tables .= "`".mysql_real_escape_string($table)."`,";
}
$tables .= "...";
$tables = str_replace(",...", "", $tables);
mysql_query("OPTIMIZE TABLE ".$tables);
//mysql_query("REPAIR TABLE ".$tables);

stderr("Optimize & Repair Database", "Database OPTIMIZED & Repaired!");
//---------------------------------------------
//---- END
//---------------------------------------------
?>


Thanks to D3SI for this handy script