function databases_list_fill() { $unix = new unix(); if (system_is_overloaded(basename(__FILE__))) { writelogs("Overloaded system, aborting task", __FUNCTION__, __FILE__, __LINE__); return; } if (!$GLOBALS["FORCE"]) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidfileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { writelogs("Already process {$pid} exists", __FUNCTION__, __FILE__, __LINE__); return; } $time = $unix->file_time_min($pidfileTime); if ($time < 20) { if ($GLOBALS["VERBOSE"]) { echo "Minimal time = 20Mn (current is {$time}Mn)\n"; } return; } @unlink($pidfileTime); @file_put_contents($pidfileTime, time()); @file_put_contents($pidfile, getmypid()); } if ($GLOBALS["VERBOSE"]) { echo "databases_list_fill() executed\n"; } $prefix = "INSERT IGNORE INTO mysqldbs (databasename,TableCount,dbsize) VALUES "; $q = new mysql(); if (!$q->TABLE_EXISTS('mysqldbs', 'artica_backup')) { if ($GLOBALS["VERBOSE"]) { echo "check_storage_table()\n"; } $q->check_storage_table(true); } eventsDB("DATABASE_LIST_SIMPLE()", __LINE__); $databases = $q->DATABASE_LIST_SIMPLE(); eventsDB("DATABASE_LIST_SIMPLE() fone", __LINE__); eventsDB("Found " . count($databases) . " databases -> dROP mysqldbtables", __LINE__); $q->QUERY_SQL("DROP TABLE mysqldbtables", "artica_backup"); eventsDB("BuildTables()...", __LINE__); if (!class_exists("mysql_builder")) { include_once dirname(__FILE__) . "/ressources/class.mysql.builder.inc"; } $t = new mysql_builder(); $t->check_mysql_dbtables(); while (list($database, $ligne) = each($databases)) { eventsDB("-> databases_list_tables({$database})...", __LINE__); $rr = databases_list_tables($database); $TableCount = $rr[0]; $Size = $rr[1]; eventsDB("Found database `{$database}` {$TableCount} tables ({$Size})", __LINE__); $f[] = "('{$database}','{$TableCount}','{$Size}')"; } if (count($f) > 0) { eventsDB("Inbjecting " . count($f) . " elements...", __LINE__); $q->QUERY_SQL("TRUNCATE TABLE mysqldbs", "artica_backup"); $q->QUERY_SQL($prefix . @implode(",", $f), "artica_backup"); } eventsDB("multi_databases_parse()", __LINE__); multi_databases_parse(); eventsDB("multi_databases_parse() done...", __LINE__); @file_put_contents($pidfileTime, time()); }