Location: PHPKode > projects > Stuffed Tracker - Web Traffic Monitoring & Analysis > stuffed-tracker-web-traffic-monitoring-analysis/actions/pub.table_check.php
<?
if (!defined("NS_TRACKER_INDEX")) exit;
$Checked=0;
$Fixed=0;
$Query = "SHOW TABLES";
$Sql = new Query($Query,"ROW");
$TableArr=array();
while ($Row=$Sql->Row()) $TableArr[]=$Row[0];
foreach ($TableArr as $Table) {
    if (strpos($Table,PFX."_tracker")===false) continue;
    $Checked++;
    echo "$Table: ";
    $NeedsRepair=false;
    $Query = "CHECK TABLE $Table";
    $Sql = new Query($Query);
    while ($Row=$Sql->Row()) {
        if (strtolower($Row->Msg_text)=='ok' || strtolower($Row->Msg_text)=='table is already up to date') {
            $NeedsRepair=false; 
            break;
         }
        $NeedsRepair=true; 
    }
    
    if ($NeedsRepair) {
        $Query = "REPAIR TABLE $Table";
        $Db->Query($Query);
        echo "fixed.\n";
        $Fixed++;  
    }
    else echo "ok.\n";
}

echo "\nTotal tables checked: $Checked. Repaired: $Fixed.\n";
?>
Return current item: Stuffed Tracker - Web Traffic Monitoring & Analysis