function repair_table_days() { $q = new mysql_squid_builder(); echo "Delete table tables_day\n"; $q->DELETE_TABLE("tables_day"); echo "Check databases...\n"; $q->CheckTables(); $array = $q->LIST_TABLES_dansguardian_events(); while (list($tablename, $none) = each($array)) { echo $tablename . "\n"; $time = $q->TIME_FROM_DANSGUARDIAN_EVENTS_TABLE($tablename); $date = date("Y-m-d", $time); $q->QUERY_SQL("INSERT IGNORE INTO tables_day (tablename,zDate) VALUES ('{$tablename}','{$date}')"); } }
function clean_squid_stats_dbs() { $sock = new sockets(); $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics"); $CleanArticaSquidDatabases = $sock->GET_INFO("CleanArticaSquidDatabases"); if (!is_numeric($DisableArticaProxyStatistics)) { $DisableArticaProxyStatistics = 0; } if (!is_numeric($CleanArticaSquidDatabases)) { $CleanArticaSquidDatabases = 0; } if (!$GLOBALS["FORCE"]) { if ($CleanArticaSquidDatabases == 0) { echo "Option is not activated...\n"; return; } } $q = new mysql_squid_builder(); $tables = $q->LIST_TABLES_DAYS(); $rows = 0; $count_tables = 0; while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_DAYS_BLOCKED(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_MEMBERS(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_MONTH(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_WEEKS(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $q = new mysql_catz(); $tables = $q->LIST_TABLES_CATEGORIES(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $q = new mysql(); if ($q->DATABASE_EXISTS("catz")) { $q->DELETE_DATABASE("catz"); } if ($count_tables > 0) { mysql_admin_mysql(1, "Restarting MySQL service...", null, __FILE__, __LINE__); shell_exec("/etc/init.d/mysql restart"); } $sock->TOP_NOTIFY("{$count_tables} statistics tables as been deleted with {$rows} rows", "info"); //print_r($tables); }
function purge() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } if ($unix->process_exists($pid, basename(__FILE__))) { $timepid = $unix->PROCCESS_TIME_MIN($pid); ufdbguard_admin_events("Already executed pid {$pid} since {$timepid}", __FUNCTION__, __FILE__, __LINE__, "reports"); if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } @file_put_contents($pidfile, getmypid()); $sock = new sockets(); $users = new usersMenus(); $LICENSE = 0; $mysqldump = $unix->find_program("mysqldump"); $tar = $unix->find_program("tar"); $EnableSquidRemoteMySQL = $sock->GET_INFO("EnableSquidRemoteMySQL"); if (!is_numeric($EnableSquidRemoteMySQL)) { $EnableSquidRemoteMySQL = 0; } if ($EnableSquidRemoteMySQL == 1) { return; } if (!is_file($mysqldump)) { echo "mysqldump, no such binary\n"; squid_admin_purge(0, "mysqldump, no such binary", "Backup process cannot be performed"); ufdbguard_admin_events("mysqldump, no such binary", __FUNCTION__, __FILE__, __LINE__, "backup"); return; } if (!is_file($tar)) { echo "tar, no such binary\n"; squid_admin_purge(0, "tar, no such binary", "Backup process cannot be performed"); ufdbguard_admin_events("tar, no such binary", __FUNCTION__, __FILE__, __LINE__, "backup"); return; } $flic = @file_get_contents(base64_decode("L3Vzci9sb2NhbC9zaGFyZS9hcnRpY2EvLmxpYw==")); if (preg_match("#TRUE#is", $flic)) { $LICENSE = 1; } $ArticaProxyStatisticsBackupDays = $sock->GET_INFO("ArticaProxyStatisticsBackupDays"); $ArticaProxyStatisticsBackupFolder = GetMountPoint(); $BackupSquidStatsUseNas = intval($sock->GET_INFO("BackupSquidStatsUseNas")); if ($BackupSquidStatsUseNas == 0) { $BackupSquidLogsUseNas = intval($sock->GET_INFO("BackupSquidLogsUseNas")); if ($BackupSquidLogsUseNas == 1) { $BackupSquidStatsUseNas = 1; } } if ($BackupSquidStatsUseNas == 0) { $ArticaProxyStatisticsBackupFolder = $sock->GET_INFO("ArticaProxyStatisticsBackupFolder"); if ($ArticaProxyStatisticsBackupFolder == null) { $ArticaProxyStatisticsBackupFolder = "/home/artica/squid/backup-statistics"; } $percent = $unix->DIRECTORY_USEPERCENT($ArticaProxyStatisticsBackupFolder); if ($percent > 90) { squid_admin_purge(0, "Fatal backup partition is over 90% {$percent}%, aborting backup", "Directory is :{$ArticaProxyStatisticsBackupFolder}", __FILE__, __LINE__, "backup", null, __FILE__, __LINE__); squid_admin_mysql(0, "Fatal backup partition is over 90% {$percent}%, aborting backup", "Directory is :{$ArticaProxyStatisticsBackupFolder}", __FILE__, __LINE__); die; } } $ArticaProxyStatisticsBackupFolderORG = $ArticaProxyStatisticsBackupFolder; if (!is_numeric($ArticaProxyStatisticsBackupDays)) { $ArticaProxyStatisticsBackupDays = 90; } if ($GLOBALS["MAXDAYS"] > 0) { $ArticaProxyStatisticsBackupDays = $GLOBALS["MAXDAYS"]; } if ($LICENSE == 0) { $ArticaProxyStatisticsBackupDays = 5; } if (!ScanDays()) { if ($GLOBALS["VERBOSE"]) { squid_admin_purge(2, "ScanDay() report failed", __FILE__, __LINE__); echo "Failed...\n"; } KillMountPoint(); return; } if ($GLOBALS["VERBOSE"]) { "Max Day: {$ArticaProxyStatisticsBackupDays}; folder:{$ArticaProxyStatisticsBackupFolder}\n"; } $q = new mysql_squid_builder(true); $sql = "SELECT tablename,zDate FROM tables_day WHERE zDate<DATE_SUB(NOW(),INTERVAL {$ArticaProxyStatisticsBackupDays} DAY)"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { squid_admin_purge(0, "Fatal Error: {$q->mysql_error}", __FILE__, __LINE__, "backup"); return; } ufdbguard_admin_events("Items: " . mysql_num_rows($results), __FUNCTION__, __FILE__, __LINE__, "backup"); if ($GLOBALS["VERBOSE"]) { echo $sql . " => " . mysql_num_rows($results) . "\n"; } squid_admin_purge(2, "Day retentions are: {$ArticaProxyStatisticsBackupDays} Days - " . mysql_num_rows($results) . " tables to purge", __FILE__, __LINE__); @mkdir("{$ArticaProxyStatisticsBackupFolder}", 0755, true); if (!is_dir($ArticaProxyStatisticsBackupFolder)) { squid_admin_purge(0, "Fatal {$ArticaProxyStatisticsBackupFolder} permission denied", "Backup process cannot be performed", __FILE__, __LINE__); if ($GLOBALS["VERBOSE"]) { echo "{$ArticaProxyStatisticsBackupFolder} permission denied\n"; } ufdbguard_admin_events("Fatal Error: {$ArticaProxyStatisticsBackupFolder} permission denied", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } $t = time(); if (!@file_put_contents("{$ArticaProxyStatisticsBackupFolder}/{$t}", time())) { squid_admin_purge(0, "Fatal {$ArticaProxyStatisticsBackupFolder} write error", "Backup process cannot be performed", __FILE__, __LINE__); if ($GLOBALS["VERBOSE"]) { echo "{$ArticaProxyStatisticsBackupFolder} write error\n"; } ufdbguard_admin_events("Fatal Error: {$ArticaProxyStatisticsBackupFolder} write error..", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } if (!is_file("{$ArticaProxyStatisticsBackupFolder}/{$t}")) { squid_admin_purge(0, "Fatal {$ArticaProxyStatisticsBackupFolder} permission denied", "Backup process cannot be performed", __FILE__, __LINE__); if ($GLOBALS["VERBOSE"]) { echo "{$ArticaProxyStatisticsBackupFolder} permission denied\n"; } ufdbguard_admin_events("Fatal Error: {$ArticaProxyStatisticsBackupFolder} permission denied", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } @unlink("{$ArticaProxyStatisticsBackupFolder}/{$t}"); $DeleteTables = 0; $TotalSize = 0; $mysqldump_prefix = "{$mysqldump} {$q->MYSQL_CMDLINES} --skip-add-locks --insert-ignore --quote-names --skip-add-drop-table --verbose --force {$q->database} "; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $tablename = $ligne["tablename"]; $TableKey = $tablename; $day = $ligne["zDate"]; $DayTime = strtotime("{$day} 00:00:00"); echo "To backup {$tablename} ({$day})\n"; $container = "{$ArticaProxyStatisticsBackupFolder}/squidlogs.{$day}." . time() . ".sql"; if (is_file($container)) { sleep(1); } $container = "{$ArticaProxyStatisticsBackupFolder}/squidlogs.{$day}." . time() . ".sql"; if (!@file_put_contents($container, time())) { if ($GLOBALS["VERBOSE"]) { echo "{$container} permission denied\n"; } squid_admin_purge(0, "Fatal Error: {$container} permission denied", "Backup process cannot be performed", __FILE__, __LINE__); ufdbguard_admin_events("Fatal Error: {$container} permission denied", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } @unlink($container); $tablesB = array(); if ($q->TABLE_EXISTS($tablename)) { $tablesB[$tablename] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tablename} no such table, continue\n"; } } $tableTMP = date("Ymd", $DayTime) . "_hour"; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = date("Ymd", $DayTime) . "_members"; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = date("Ymd", $DayTime) . "_visited"; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = date("Ymd", $DayTime) . "_blocked"; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = "searchwordsD_" . date("Ymd", $DayTime) . ""; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = "UserSizeD_" . date("Ymd", $DayTime) . ""; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = "youtubeday_" . date("Ymd", $DayTime) . ""; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = "quotaday_" . date("Ymd", $DayTime) . ""; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $tableTMP = date("Ymd", $DayTime) . "_catfam"; if ($q->TABLE_EXISTS($tableTMP)) { $tablesB[$tableTMP] = true; } else { if ($GLOBALS["VERBOSE"]) { echo "{$tableTMP} no such table, continue\n"; } } $c = array(); while (list($a, $b) = each($tablesB)) { $c[] = $a; } reset($tablesB); echo "Backup tables: " . @implode(", ", $c) . "\n"; if (count($tablesB) > 0) { $cmdline = "{$mysqldump_prefix}" . @implode(" ", $c) . " >{$container}"; if ($GLOBALS["VERBOSE"]) { echo "\n*******\n{$cmdline}\n*******\n"; } $resultsZ = array(); exec($cmdline, $resultsZ); if (!TestDump($resultsZ, $container)) { ufdbguard_admin_events("Fatal Error: day: Dump failed {$day}", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } $size = @filesize($container); chdir($ArticaProxyStatisticsBackupFolder); $cmdline = "{$tar} cfz {$container}.tar.gz {$container} 2>&1"; $resultsZ = array(); exec($cmdline, $resultsZ); while (list($a, $b) = each($resultsZ)) { echo "Compress: `{$b}`\n"; } if (!$unix->TARGZ_TEST_CONTAINER("{$container}.tar.gz")) { squid_admin_purge(0, "Error {$container} failed", __FILE__, __LINE__); ufdbguard_admin_events("Fatal Error: tar {$container} failed", __FUNCTION__, __FILE__, __LINE__, "backup"); @unlink($container); @unlink("{$container}.tar.gz"); KillMountPoint(); return; } $TotalSize = $TotalSize + $size; @unlink($container); reset($tablesB); while (list($tablename, $line) = each($tablesB)) { if ($GLOBALS["VERBOSE"]) { echo "Delete table `{$tablename}`\n"; } if (!$q->DELETE_TABLE($tablename)) { if ($GLOBALS["VERBOSE"]) { echo "Delete {$tablename} failed {$q->mysql_error} ...\n"; } ufdbguard_admin_events("Fatal Error: Delete {$tablename} failed {$q->mysql_error} ", __FUNCTION__, __FILE__, __LINE__, "backup"); KillMountPoint(); return; } $DeleteTables++; } } if ($GLOBALS["VERBOSE"]) { echo "Delete table `{$TableKey}` from tables_day\n"; } $q->QUERY_SQL("DELETE FROM tables_day WHERE tablename='{$TableKey}'"); } $container = "{$ArticaProxyStatisticsBackupFolder}/squidlogs.FULL.sql"; $resultsZ = array(); $cmd = "{$mysqldump_prefix} >{$container}"; exec($cmd, $resultsZ); chdir($ArticaProxyStatisticsBackupFolder); $cmdline = "{$tar} cfz {$container}.tar.gz {$container} 2>&1"; exec($cmdline); if (!$unix->TARGZ_TEST_CONTAINER("{$container}.tar.gz")) { squid_admin_purge(0, "Error {$container}.tar.gz, not a valid compressed file", __FILE__, __LINE__); ufdbguard_admin_events("Error {$container}.tar.gz, not a valid compressed file", __FUNCTION__, __FILE__, __LINE__, "backup"); @unlink("{$container}.tar.gz"); } else { $size = @filesize($container); $TotalSize = $TotalSize + $size; @unlink("{$container}"); } if ($DeleteTables > 0) { $TotalSize = FormatBytes($TotalSize / 1024); $took = $unix->distanceOfTimeInWords($t, time(), true); squid_admin_purge(2, "Success backup and purge {$DeleteTables} table(s) ({$TotalSize})", "took:{$took}", __FILE__, __LINE__); ufdbguard_admin_events("Success backup and purge {$DeleteTables} table(s) ({$TotalSize}) took:{$took}", __FUNCTION__, __FILE__, __LINE__, "backup"); } CleanQuotas(); KillMountPoint(); }
function backupTable($tablename, $filename) { if (isset($GLOBALS["ALREADYDONETABLE"][$tablename])) { return true; } $GLOBALS["ALREADYDONETABLE"][$tablename] = true; $unix = new unix(); $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS($tablename)) { return true; } $q->BD_CONNECT(); $dump = new phpMyDumper("squidlogs", $q->mysql_connection, $filename, true, $tablename); if (!$dump->doDump()) { ufdbguard_admin_events("Fatal, unable to dump database {$ligne["tablename"]}", __FUNCTION__, __FILE__, __LINE__, "backup"); return false; } $filesize = $unix->file_size($filename); if ($filesize < 200) { ufdbguard_admin_events("Fatal, {$filesize} bytes it seems there is an issue on {$tablename} table", __FUNCTION__, __FILE__, __LINE__, "backup"); return false; } $q->QUERY_SQL("INSERT INTO webstats_backup (`tablename`,`filepath`,`filesize`) \n\tVALUES('{$tablename}','{$filename}','{$filesize}')"); if (!$q->ok) { ufdbguard_admin_events("Fatal, MySQL error {$q->mysql_error} on webstats_backup", __FUNCTION__, __FILE__, __LINE__, "backup"); return false; } $q->DELETE_TABLE($tablename); return true; }
function build_report($ID, $nopid = false) { if (!is_numeric($ID)) { ufdbguard_admin_events("Not a numeric ID", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } $t = time(); $unix = new unix(); $tablename = "WebTrackMem{$ID}"; $tableBlock = "WebTrackMeB{$ID}"; if (!$nopid) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } if ($unix->process_exists($pid, basename(__FILE__))) { ufdbguard_admin_events("Already executed pid {$pid}", __FUNCTION__, __FILE__, __LINE__, "reports"); if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } } if ($GLOBALS["VERBOSE"]) { echo "Building report {$ID}\n"; } $q = new mysql_squid_builder(); if ($q->TABLE_EXISTS($tablename)) { $q->DELETE_TABLE($tablename); } if ($q->TABLE_EXISTS($tableBlock)) { $q->DELETE_TABLE($tableBlock); } if (!$q->CreateMemberReportTable($tablename)) { ufdbguard_admin_events("could not create table {$tablename}", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } if (!$q->CreateMemberReportBlockTable($tableBlock)) { ufdbguard_admin_events("could not create table {$tablename}", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } $rp = new squid_report($ID); $LIST_TABLES_dansguardian_events = $q->LIST_TABLES_dansguardian_events(); progress(10, $ID); $counttables = count($LIST_TABLES_dansguardian_events); $prefix = "INSERT IGNORE INTO {$tablename} (`zMD5`,`sitename`,`familysite`,`{$rp->userfield}`,`zDate`,`size`,`hits`,`category`) VALUES "; while (list($sourcetable, $ligne) = each($LIST_TABLES_dansguardian_events)) { $c++; $sql = $rp->BuildQuery($sourcetable); $results = $q->QUERY_SQL($sql); if (!$q->ok) { ufdbguard_admin_events("{$q->mysql_error}\n{$sql}", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } if ($GLOBALS["VERBOSE"]) { echo "Parsing {$sourcetable} \n{$sql}\n-> `" . mysql_num_rows($results) . "` rows\n"; } if (mysql_num_rows($results) == 0) { continue; } $purc = round($c / $counttables, 2) * 100; progress($purc, $ID); $f = array(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $md5 = md5(serialize($ligne)); $sitename = $ligne["sitename"]; $familysite = $q->GetFamilySites($sitename); if (!isset($GLOBALS["CATEGORY"][$sitename])) { $GLOBALS["CATEGORY"][$sitename] = $q->GET_CATEGORIES($sitename); } $category = $GLOBALS["CATEGORY"][$sitename]; $source = addslashes($ligne["source"]); $zDate = $ligne["zDate"]; $size = $ligne["size"]; $hits = $ligne["hits"]; $category = addslashes($category); $f[] = "('{$md5}','{$sitename}','{$familysite}','{$source}','{$zDate}','{$size}','{$hits}','{$category}')"; } if (count($f) == 0) { continue; } $q->QUERY_SQL($prefix . @implode(",", $f)); if (!$q->ok) { ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } if (system_is_overloaded(__FILE__)) { sleep(5); } } if ($rp->csv == 1) { SaveCSV($ID); } $LIST_TABLES_BLOCKED = $q->LIST_TABLES_BLOCKED(); $prefix = "INSERT IGNORE INTO {$tableBlock} (`zMD5`,`zDate`,`hits`,`website`,`category`,`rulename`,`event`,`why`,`explain`,`blocktype`,`{$rp->userfield}`) VALUES "; while (list($sourcetable, $ligne) = each($LIST_TABLES_BLOCKED)) { $c++; if ($GLOBALS["VERBOSE"]) { echo "Parsing {$sourcetable}\n"; } $sql = $rp->BuildQueryBlock($sourcetable); if (!$q->FIELD_EXISTS("{$sourcetable}", "uid")) { $q->QUERY_SQL("ALTER TABLE `{$sourcetable}` ADD `uid` VARCHAR( 128 ) NOT NULL ,ADD INDEX ( `uid` )"); } $results = $q->QUERY_SQL($sql); if (!$q->ok) { ufdbguard_admin_events("{$q->mysql_error}\n{$sql}", __FUNCTION__, __FILE__, __LINE__, "reports"); return; } if (mysql_num_rows($results) == 0) { continue; } $purc = round($c / $counttables, 2) * 100; progress($purc, $ID); $f = array(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $zMD5 = md5(serialize($ligne)); $sitename = $ligne["sitename"]; $category = $ligne["category"]; if ($category == null) { if (!isset($GLOBALS["CATEGORY"][$sitename])) { $GLOBALS["CATEGORY"][$sitename] = $q->GET_CATEGORIES($sitename); } $category = $GLOBALS["CATEGORY"][$sitename]; } $source = addslashes($ligne["source"]); $zDate = $ligne["zDate"]; $hits = $ligne["hits"]; $rulename = $ligne["rulename"]; $event = $ligne["event"]; $why = $ligne["why"]; $explain = $ligne["explain"]; $blocktype = $ligne["blocktype"]; $category = addslashes($category); $f[] = "('{$zMD5}','{$zDate}','{$hits}','{$sitename}','{$category}','{$rulename}','{$event}','{$why}','{$explain}','{$blocktype}','{$source}')"; } if (system_is_overloaded(__FILE__)) { sleep(5); } } $myisamchk = $unix->find_program("myisamchk"); $myisampack = $unix->find_program("myisampack"); $mysql_data = $unix->MYSQL_DATA_DIR(); echo "OPTIMIZE TABLE {$tableBlock}\n"; $q->QUERY_SQL("OPTIMIZE TABLE {$tableBlock}"); echo "OPTIMIZE TABLE {$tablename}\n"; $q->QUERY_SQL("OPTIMIZE TABLE {$tablename}"); echo "LOCK TABLE {$tablename}\n"; $q->QUERY_SQL("LOCK TABLE {$tablename} WRITE"); echo "LOCK TABLE {$tableBlock}\n"; $q->QUERY_SQL("LOCK TABLE {$tableBlock} WRITE"); $q->QUERY_SQL("FLUSH TABLE {$tableBlock}"); $q->QUERY_SQL("FLUSH TABLE {$tablename}"); echo "myisamchk {$tablename}\n"; shell_exec("{$myisamchk} -cFU {$mysql_data}/squidlogs/{$tablename}.MYI"); echo "myisamchk {$tableBlock}\n"; shell_exec("{$myisamchk} -cFU {$mysql_data}/squidlogs/{$tableBlock}.MYI"); echo "myisampack {$tablename}\n"; shell_exec("{$myisampack} -f {$mysql_data}/squidlogs/{$tablename}.MYI"); echo "myisampack {$tableBlock}\n"; shell_exec("{$myisampack} -f {$mysql_data}/squidlogs/{$tableBlock}.MYI"); $q->QUERY_SQL("FLUSH TABLE {$tablename}"); $q->QUERY_SQL("FLUSH TABLE {$tableBlock}"); $rp->set_duration($unix->distanceOfTimeInWords($t, time(), true)); progress(100, $ID); }