}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$q = new mysql_squid_builder();
$sql = "SELECT * FROM categorize_changes";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
    writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
    die;
}
if (mysql_num_rows($results) == 0) {
    echo "No changes\n";
    die;
}
$table_hours = $q->LIST_TABLES_HOURS();
$table_days = $q->LIST_TABLES_DAYS();
$table_week = $q->LIST_TABLES_WEEKS();
$ALREADY = array();
$MAX = mysql_num_rows($results);
$D = 0;
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
    if (isset($ALREADY[$ligne["sitename"]])) {
        $q->QUERY_SQL("DELETE FROM categorize_changes WHERE `zmd5`='{$ligne["zmd5"]}'");
        continue;
    }
    $website = $ligne["sitename"];
    $categories = $q->GET_CATEGORIES($website, true);
    $ALREADY[$ligne["sitename"]] = true;
    reset($table_hours);
    reset($table_days);
    reset($table_week);
Beispiel #2
0
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 remove_numeric_members()
{
    $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;
    }
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("DELETE FROM members_uid WHERE uid REGEXP '^[0-9]+\$'");
    $q->QUERY_SQL("DELETE FROM UserAuthDaysGrouped WHERE uid REGEXP '^[0-9]+\$'");
    $q->QUERY_SQL("DELETE FROM UserAutDB WHERE uid REGEXP '^[0-9]+\$'");
    $tables = $q->LIST_TABLES_WWWUID();
    while (list($tablename, $ligne) = each($tables)) {
        if (!preg_match("#^www_[0-9]+\$#", $ligne)) {
            continue;
        }
        $q->QUERY_SQL("DROP TABLE {$tablename}");
    }
    $tables = $q->LIST_TABLES_DAYS();
    while (list($tablename, $ligne) = each($tables)) {
        $q->QUERY_SQL("DELETE FROM {$tablename} WHERE uid REGEXP '^[0-9]+\$'");
    }
    $tables = $q->LIST_TABLES_WEEKS();
    while (list($tablename, $ligne) = each($tables)) {
        $q->QUERY_SQL("DELETE FROM {$tablename} WHERE uid REGEXP '^[0-9]+\$'");
    }
    $tables = $q->LIST_TABLES_MONTH();
    while (list($tablename, $ligne) = each($tables)) {
        $q->QUERY_SQL("DELETE FROM {$tablename} WHERE uid REGEXP '^[0-9]+\$'");
    }
    $tables = $q->LIST_TABLES_MEMBERS();
    while (list($tablename, $ligne) = each($tables)) {
        $q->QUERY_SQL("DELETE FROM {$tablename} WHERE uid REGEXP '^[0-9]+\$'");
    }
}