function CleanAll() { $q = new mysql_squid_builder(); $LIST_TABLES_MONTH = $q->LIST_TABLES_MONTH(); while (list($tablename, $none) = each($LIST_TABLES_MONTH)) { echo "Empty {$tablename}\n"; $q->QUERY_SQL("DROP TABLE `{$tablename}`"); } $q->QUERY_SQL("UPDATE tables_day SET monthdone=0 WHERE monthdone=1"); }
function change_month_popup() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $t = $_GET["t"]; $members = $tpl->_ENGINE_parse_body("{members}"); $month = $tpl->_ENGINE_parse_body("{month}"); $array = array(); $tables = $q->LIST_TABLES_MONTH(); while (list($index, $tablez) = each($tables)) { $array[$tablez] = $q->MONTH_TITLE_FROM_TABLENAME($tablez); } $field = Field_array_Hash($array, "table-m-{$t}", $table, " DayMemberChangeMonthPanel{$t}()", null, 0, "font-size:14px"); $array = array(); $html = "\n\t<table style='width:99%' class=form>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:16px;'>{month}:</td>\n\t\t\t\t<td>{$field}</td>\n\t\t\t</tr>\n\t</table>\n\n\t<script>\n\t\tfunction DayMemberChangeMonthPanel{$t}(){\n\t\t\tvar xday=document.getElementById('table-m-{$t}').value;\n\t\t\t\$('.ftitle').html('{$members}»{$month}»table:'+xday);\n\t\t\t\$('#{$t}').flexOptions({url: '{$page}?search=yes&table='+xday,title:'{$members}'+xday}).flexReload();\n\t\t\n\t\t}\n\t\n\t</script>"; echo $tpl->_ENGINE_parse_body($html); }
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 updates_retranslation($MAC, $uid) { $GLOBALS["Q"] = new mysql_squid_builder(); if ($GLOBALS["VERBOSE"]) { "echo Loading...\n"; } $unix = new unix(); if ($GLOBALS["VERBOSE"]) { "echo Loading done...\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . md5($MAC . $uid) . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . md5($MAC . $uid) . ".time"; $pid = @file_get_contents($pidfile); if (!$GLOBALS["FORCE"]) { if ($pid < 100) { $pid = null; } $unix = new unix(); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } $q = new mysql_squid_builder(); $sql = "UPDATE youtube_all SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); $sql = "UPDATE UserAuthDaysGrouped SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); $sql = "UPDATE UserAuthDays SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); $TABLES = $q->LIST_TABLES_QUOTADAY(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_QUOTAMONTH(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_dansguardian_events(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_USERSIZED(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_YOUTUBE_HOURS(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_YOUTUBE_DAYS(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_YOUTUBE_WEEK(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_SEARCHWORDS_DAY(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_SEARCHWORDS_HOURS(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } $TABLES = $q->LIST_TABLES_MONTH(); while (list($tablename, $rows) = each($TABLES)) { $sql = "UPDATE `{$tablename}` SET uid='{$uid}' WHERE MAC='{$MAC}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } } }
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]+\$'"); } }
function not_categorized_months() { $current_month_table = date("Ym") . "_month"; $q = new mysql_squid_builder(); $q->QUERY_SQL("TRUNCATE TABLE `catztemp`"); if ($q->TABLE_EXISTS($current_month_table)) { _not_categorized_months($current_month_table); } $LIST_TABLES_MONTH = $q->LIST_TABLES_MONTH(); while (list($tablename, $infos) = each($LIST_TABLES_MONTH)) { if ($tablename == $current_month_table) { continue; } echo "Scanning {$tablename}\n"; _not_categorized_months($tablename); } }