本文整理汇总了PHP中ufdbguard_admin_events函数的典型用法代码示例。如果您正苦于以下问题:PHP ufdbguard_admin_events函数的具体用法?PHP ufdbguard_admin_events怎么用?PHP ufdbguard_admin_events使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ufdbguard_admin_events函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: purge_bysquid
function purge_bysquid()
{
$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__, "purge");
if ($GLOBALS["VERBOSE"]) {
echo "Already executed pid {$pid}\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
$sock = new sockets();
$users = new usersMenus();
$rm = $unix->find_program("rm");
$df = $unix->find_program("df");
$DF_RESULTS[] = "Scanning Artica directories in /var/log\ncurrent status:";
exec("{$df} -i /var/log 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h /var/log 2>&1", $DF_RESULTS);
$dirs = $unix->DirFiles("/var/log/artica-postfix");
while (list($directory, $b) = each($dirs)) {
$DF_RESULTS[] = "";
$DF_RESULTS[] = "";
$DF_RESULTS[] = date("Y-m-d H:i:s") . " Removing content of {$directory}";
$DF_RESULTS[] = date("Y-m-d H:i:s") . " {$directory} Before:";
$DF_RESULTS[] = "";
exec("{$df} -i {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h {$directory} 2>&1", $DF_RESULTS);
shell_exec("{$rm} -rf {$directory}/* 2>&1");
$DF_RESULTS[] = date("Y-m-d H:i:s") . " {$directory} After removing content:";
exec("{$df} -i {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
exec("{$df} -h {$directory} 2>&1", $DF_RESULTS);
$DF_RESULTS[] = "";
}
squid_admin_mysql(0, "Log partition cleaning report", @implode("\n", $DF_RESULTS) . __FILE__, __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:44,代码来源:exec.varlog-urgency.php
示例2: ping
function ping($hostid)
{
$mefile = basename(__FILE__);
$GLOBALS["CLASS_UNIX"] = new unix();
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: blackboxes({$hostid})", "/var/log/stats-appliance.log");
$black = new blackboxes($hostid);
$ssluri = $black->ssluri . "/nodes.listener.php";
$nossluri = $black->sslnouri . "/nodes.listener.php";
if ($GLOBALS["VERBOSE"]) {
echo "Try {$ssluri}\n";
}
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
$curl = new ccurl($ssluri);
$curl->parms["PING-ORDERS"] = true;
if ($GLOBALS["VERBOSE"]) {
$curl->parms["VERBOSE"] = true;
}
$curl->noproxyload = true;
if ($GLOBALS["VERBOSE"]) {
echo "Sending PING-ORDERS\n";
}
if (!$curl->get()) {
$ssluri = $nossluri;
$GLOBALS["CLASS_UNIX"]->events("{$mefile}:: {$ssluri}", "/var/log/stats-appliance.log");
if ($GLOBALS["VERBOSE"]) {
echo "error `{$ssluri}` {$curl->error}, trying http\n";
}
$curl = new ccurl($nossluri);
$curl->noproxyload = true;
$curl->parms["PING-ORDERS"] = true;
if (!$curl->get()) {
ufdbguard_admin_events("{$mefile}:: Failed to send ping to {$black->hostname} with Error:`{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "communicate");
return;
}
}
if ($GLOBALS["VERBOSE"]) {
echo $curl->data;
}
if (preg_match("#SUCCESS<#s", $curl->data)) {
$GLOBALS["CLASS_UNIX"]->events("Success to send ping to {$black->hostname}", "/var/log/stats-appliance.log");
ufdbguard_admin_events("{$mefile}:: Success to send ping to {$black->hostname}", __FUNCTION__, __FILE__, __LINE__, "communicate");
}
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:43,代码来源:exec.blackbox.php
示例3: month_visited
function month_visited()
{
$unix = new unix();
LoadParams();
$DaysbackupOlder = $GLOBALS["DaysbackupOlder"];
$workdir = $GLOBALS["WORKDIR"];
$q = new mysql_squid_builder();
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT MONTH( NOW( ) ) AS tmonth, YEAR( NOW( ) ) AS tyear", "artica_events"));
if (strlen($ligne["tmonth"]) == 1) {
$ligne["tmonth"] = "0" . $ligne["tmonth"];
}
$current_table = "{$ligne["tyear"]}{$ligne["tmonth"]}_day";
$sql = "SELECT MONTH( zDate ) AS tmonth, YEAR( zDate ) AS tyear FROM tables_day \n\tWHERE zDate < DATE_SUB( NOW( ) , INTERVAL 200 DAY ) GROUP BY tmonth, tyear";
$GLOBALS["BACKUPED_SIZE"] = 0;
$GLOBALS["TABLECOUNT"] = 0;
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
ufdbguard_admin_events("Fatal, {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "backup");
return;
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$alt_table0 = null;
$alt_table1 = null;
if (strlen($ligne["tmonth"]) == 1) {
$ligne["tmonth"] = "0" . $ligne["tmonth"];
}
$tablename = "{$ligne["tyear"]}{$ligne["tmonth"]}_day";
if ($tablename == $current_table) {
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename}\n";
}
$filename = "{$workdir}/{$tablename}.gz";
if (is_file($filename)) {
@unlink($filename);
}
if (backupTable($tablename, $filename)) {
if (is_file($filename)) {
$filesize = $unix->file_size($filename);
$GLOBALS["BACKUPED_SIZE"] = $GLOBALS["BACKUPED_SIZE"] + $filesize;
$GLOBALS["TABLECOUNT"]++;
}
}
$tablename = "{$ligne["tyear"]}{$ligne["tmonth"]}_members";
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename}\n";
}
$filename = "{$workdir}/{$tablename}.gz";
if (is_file($filename)) {
@unlink($filename);
}
if (backupTable($tablename, $filename)) {
if (is_file($filename)) {
$filesize = $unix->file_size($filename);
$GLOBALS["BACKUPED_SIZE"] = $GLOBALS["BACKUPED_SIZE"] + $filesize;
$GLOBALS["TABLECOUNT"]++;
}
}
$tablename = "{$ligne["tyear"]}{$ligne["tmonth"]}_blocked_days";
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename}\n";
}
$filename = "{$workdir}/{$tablename}.gz";
if (is_file($filename)) {
@unlink($filename);
}
if (backupTable($tablename, $filename)) {
if (is_file($filename)) {
$filesize = $unix->file_size($filename);
$GLOBALS["BACKUPED_SIZE"] = $GLOBALS["BACKUPED_SIZE"] + $filesize;
$GLOBALS["TABLECOUNT"]++;
}
}
if (system_is_overloaded(basename(__FILE__))) {
sleep(15);
if (system_is_overloaded(__FILE__)) {
sleep(10);
if (system_is_overloaded(__FILE__)) {
sleep(5);
}
}
}
if (system_is_overloaded(basename(__FILE__))) {
ufdbguard_admin_events("Fatal, Overloaded system, aborting task and restart in newt cycle...", __FUNCTION__, __FILE__, __LINE__, "backup");
return;
}
}
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:89,代码来源:exec.squid.dbback.php
示例4: clean_squid_stats_no_items
function clean_squid_stats_no_items()
{
$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 ($CleanArticaSquidDatabases == 1) {
return;
}
$q = new mysql_squid_builder();
$tables = $q->LIST_TABLES_DAYS();
$rows = 0;
$count_tables = 0;
if (!$q->ok) {
return;
}
while (list($num, $table) = each($tables)) {
if (!$q->ok) {
return;
}
$rows = $q->COUNT_ROWS($table);
if ($rows == 0) {
if ($GLOBALS["VERBOSE"]) {
echo " Delete table {$table} {$rows} rows \n";
}
$count_tables++;
ufdbguard_admin_events("{$table} was deleted (contains no row)", __FUNCTION__, __FILE__, __LINE__, "clean-stats");
$q->DELETE_TABLE($table);
}
}
$tables = $q->LIST_TABLES_DAYS_BLOCKED();
if (!$q->ok) {
return;
}
while (list($num, $table) = each($tables)) {
$rows = $q->COUNT_ROWS($table);
if (!$q->ok) {
return;
}
if ($rows == 0) {
if ($GLOBALS["VERBOSE"]) {
echo " Delete table {$table} {$rows} rows \n";
}
$count_tables++;
ufdbguard_admin_events("{$table} was deleted (contains no row)", __FUNCTION__, __FILE__, __LINE__, "clean-stats");
$q->DELETE_TABLE($table);
}
}
$tables = $q->LIST_TABLES_MEMBERS();
if (!$q->ok) {
return;
}
while (list($num, $table) = each($tables)) {
$rows = $q->COUNT_ROWS($table);
if (!$q->ok) {
return;
}
if ($rows == 0) {
if ($GLOBALS["VERBOSE"]) {
echo " Delete table {$table} {$rows} rows \n";
}
$count_tables++;
ufdbguard_admin_events("{$table} was deleted (contains no row)", __FUNCTION__, __FILE__, __LINE__, "clean-stats");
$q->DELETE_TABLE($table);
}
}
$tables = $q->LIST_TABLES_MONTH();
if (!$q->ok) {
return;
}
while (list($num, $table) = each($tables)) {
$rows = $q->COUNT_ROWS($table);
if (!$q->ok) {
return;
}
if ($rows == 0) {
if ($GLOBALS["VERBOSE"]) {
echo " Delete table {$table} {$rows} rows \n";
}
$count_tables++;
ufdbguard_admin_events("{$table} was deleted (contains no row)", __FUNCTION__, __FILE__, __LINE__, "clean-stats");
$q->DELETE_TABLE($table);
}
}
$tables = $q->LIST_TABLES_WEEKS();
if (!$q->ok) {
return;
}
while (list($num, $table) = each($tables)) {
$rows = $q->COUNT_ROWS($table);
if (!$q->ok) {
return;
}
if ($rows == 0) {
if ($GLOBALS["VERBOSE"]) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.mysql.clean.php
示例5: writelogs_squid
function writelogs_squid($text, $function = null, $file = null, $line = 0, $category = null, $nosql = false)
{
if (!isset($GLOBALS["CLASS_UNIX"])) {
$GLOBALS["CLASS_UNIX"] = new unix();
}
if (!isset($GLOBALS["MYPID"])) {
$GLOBALS["MYPID"] = @getmypid();
}
if (!isset($GLOBALS["AS_ROOT"])) {
if (posix_getuid() == 0) {
$GLOBALS["AS_ROOT"] = true;
} else {
$GLOBALS["AS_ROOT"] = false;
}
}
$array_load = sys_getloadavg();
$internal_load = $array_load[0];
if ($file != null) {
$me = basename($file);
} else {
$me = basename(__FILE__);
}
$date = @date("H:i:s");
if (function_exists("debug_backtrace")) {
$trace = debug_backtrace();
if (isset($trace[1])) {
$sourcefile = basename($trace[1]["file"]);
$sourcefunction = $trace[1]["function"];
$sourceline = $trace[1]["line"];
}
}
if ($function == __FUNCTION__) {
$function = null;
}
if ($function == null) {
$function = $sourcefunction;
}
if ($line == 0) {
$line = $sourceline;
}
if ($file == null) {
$line = $sourcefile;
}
if (function_exists("stats_admin_events")) {
stats_admin_events(2, $text, "{$date} {$me}" . "[" . $GLOBALS["MYPID"] . "/{$internal_load}]:{$category}::{$function}", $sourcefile, $sourceline);
}
if ($GLOBALS["AS_ROOT"]) {
$logFile = "/var/log/artica-squid-stats.log";
if (is_file($logFile)) {
$size = filesize($logFile);
if ($size > 5000000) {
unlink($logFile);
}
}
$f = fopen($logFile, 'a');
fwrite($f, "{$date} {$me}" . "[" . $GLOBALS["MYPID"] . "/{$internal_load}]:{$category}::{$function}::{$line}: {$text}\n");
fclose($f);
}
if ($nosql) {
return;
}
if (function_exists("ufdbguard_admin_events")) {
ufdbguard_admin_events($text, $function, $file, $line, $category);
}
}
开发者ID:articatech,项目名称:artica,代码行数:65,代码来源:class.mysql.squid.builder.php
示例6: inject_stored_items
function inject_stored_items($nopid = false)
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if (system_is_overloaded(basename(__FILE__))) {
$php = $unix->LOCATE_PHP5_BIN();
ufdbguard_admin_events("Overloaded system... ask to run this task later...", __FUNCTION__, __FILE__, __LINE__, "proxy");
$unix->THREAD_COMMAND_SET("{$php} " . __FILE__ . " --inject");
}
if (!$nopid) {
$pid = @file_get_contents($pidfile);
$myfile = basename(__FILE__);
if ($unix->process_exists($pid, $myfile)) {
ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "proxy");
return;
}
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$t1 = time();
$file = "/var/cache/purge.calculated.db";
if (!is_file($file)) {
echo "{$file} no such file\n";
return;
}
$q = new mysql_blackbox();
if (!$q->TABLE_EXISTS("cacheitems_localhost")) {
$q->build_cached_items_table("localhost");
}
$BIGARRAY = inject_stored_array();
$prefix = "INSERT IGNORE INTO cacheitems_localhost(sitename,familysite,size,items) VALUES ";
$q->QUERY_SQL("TRUNCATE TABLE cacheitems_localhost");
$f = array();
$c = 0;
while (list($sitename, $array) = each($BIGARRAY)) {
$c++;
$f[] = "('{$sitename}','{$array["FAMILY"]}','{$array["SIZE"]}','{$array["ITEMS"]}')";
if (count($f) > 500) {
$q->QUERY_SQL($prefix . @implode(",", $f));
if (!$q->ok) {
squid_admin_mysql(0, "MySQL error!", $q->mysql_error, __FILE__, __LINE__);
return;
}
}
}
if (count($f) > 0) {
$q->QUERY_SQL($prefix . @implode(",", $f));
if (!$q->ok) {
squid_admin_mysql(0, "MySQL error!", $q->mysql_error, __FILE__, __LINE__);
return;
}
}
$took = $unix->distanceOfTimeInWords($t1, time());
if ($c > 0) {
squid_admin_mysql(2, "Sucess adding {$c} cached websites took:{$took}", null, __FILE__, __LINE__);
}
@unlink($file);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:58,代码来源:exec.squid.purge.php
示例7: download_mydb
function download_mydb()
{
$sock = new sockets();
$unix = new unix();
$chmod = $unix->find_program("chmod");
$squidbin = $unix->find_program("squid3");
if (!is_file($squidbin)) {
$squidbin = $unix->find_program("squid");
}
if (!is_file($squidbin)) {
return;
}
$RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
$RemoteStatisticsApplianceSettings["SSL"] = 1;
}
if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
$RemoteStatisticsApplianceSettings["PORT"] = 9000;
}
$GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
$GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
$GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
if ($GLOBALS["REMOTE_SSL"] == 1) {
$refix = "https";
} else {
$refix = "http";
}
$baseUri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases";
$uri = "{$baseUri}/usersMacs.db";
$curl = new ccurl($uri, true);
if ($curl->GetFile("/etc/squid3/usersMacs.db")) {
shell_exec("{$chmod} 755 /etc/squid3/usersMacs.db");
ufdbguard_admin_events("download usersMacs.db success", __FUNCTION__, __FILE__, __LINE__, "global-compile");
} else {
ufdbguard_admin_events("Failed to download ufdbGuard.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
return;
}
$cmd = "/etc/init.d/squid reload --script=" . basename(__FILE__);
shell_exec("{$cmd} >/dev/null 2>&1");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:40,代码来源:exec.usrmactranslation.php
示例8: searchwords_hour
function searchwords_hour($aspid = false)
{
if (isset($GLOBALS["searchwords_hour_executed"])) {
return true;
}
$GLOBALS["searchwords_hour_executed"] = true;
$unix = new unix();
$GLOBALS["Q"] = new mysql_squid_builder();
$pidtime = "/etc/artica-postfix/pids/exec.squid-searchwords.php.searchwords_hour.time";
if ($GLOBALS["VERBOSE"]) {
echo "PidTime: {$pidtime}\n";
}
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
$myfile = basename(__FILE__);
if ($unix->process_exists($pid, $myfile)) {
ufdbguard_admin_events("{$pid} already running, aborting", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
$timeP = $unix->file_time_min($pidtime);
if ($timeP < 30) {
events("Main::Line: " . __LINE__ . " 30Mn minimal current: {$timeP}mn-> DIE - {$pidtime}");
die;
}
@unlink($pidtime);
@file_put_contents($pidtime, time());
@file_put_contents($pidfile, getmypid());
$currenttable = "searchwords_" . date("YmdH");
if (!isset($GLOBALS["Q"])) {
$GLOBALS["Q"] = new mysql_squid_builder();
}
$LIST_TABLES_SEARCHWORDS_HOURS = $GLOBALS["Q"]->LIST_TABLES_SEARCHWORDS_HOURS();
while (list($num, $tablename) = each($LIST_TABLES_SEARCHWORDS_HOURS)) {
if ($tablename == $currenttable) {
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename} -> {$currenttable} >skip\n";
}
continue;
}
if ($GLOBALS["VERBOSE"]) {
echo "{$tablename} -> {$currenttable}\n";
}
if (searchwords_hour_to_day($tablename)) {
$GLOBALS["Q"]->QUERY_SQL("DROP TABLE {$tablename}");
}
}
hour_SearchWordTEMP();
$mysqladmin = $unix->find_program("mysqladmin");
shell_exec("{$mysqladmin} -u root -S /var/run/mysqld/squid-db.sock flush-tables >/dev/null 2>&1 &");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:50,代码来源:exec.squid-searchwords.php
示例9: basename
$rm = $unix->find_program("rm");
$cp = $unix->find_program("cp");
//http://ftp.samba.org/pub/samba/stable/
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid)) {
die;
}
$dirsrc = "samba-0.0.0";
$Architecture = Architecture();
if (!$GLOBALS["NO_COMPILE"]) {
$v = "samba-4.1.6.tar.gz";
if (preg_match("#samba-(.+?)#", $v, $re)) {
$dirsrc = $re[1];
}
ufdbguard_admin_events("Downloading lastest file {$v}, working directory {$dirsrc} ...", __FUNCTION__, __FILE__, __LINE__);
}
if (!$GLOBALS["FORCE"]) {
if (is_file("/root/{$v}")) {
if ($GLOBALS["REPOS"]) {
echo "No updates...\n";
die;
}
}
}
if (is_dir("/root/samba-builder")) {
shell_exec("{$rm} -rf /root/samba-builder");
}
chdir("/root");
if (!$GLOBALS["NO_COMPILE"]) {
if (is_dir("/root/{$dirsrc}")) {
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:compile-samba4.php
示例10: websites_uid_not_categorised
function websites_uid_not_categorised($uid = null, $tablename = null, $aspid = false)
{
if (isset($GLOBALS["websites_uid_not_categorised_{$uid}"])) {
return;
}
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$uid}.pid";
if ($aspid) {
$pid = @file_get_contents($pidfile);
$myfile = basename(__FILE__);
if ($unix->process_exists($pid, $myfile)) {
ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
$q = new mysql_squid_builder();
if ($uid != null) {
$uidtable = $q->uid_to_tablename($uid);
$tablename = "www_{$uidtable}";
}
if (!$q->FIELD_EXISTS($tablename, "category")) {
$q->QUERY_SQL("ALTER TABLE `{$tablename}` ADD `category` varchar(255), ADD INDEX (`category`)");
}
$sql = "SELECT familysite,`category` FROM `{$tablename}` GROUP BY familysite,`category` HAVING `category` IS NULL ";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
if ($GLOBALS["VERBOSE"]) {
echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
}
return false;
}
$c = 0;
$mysql_num_rows = mysql_num_rows($results);
if ($mysql_num_rows == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "{$sql} (No rows)\n";
}
return true;
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$sitename = $ligne["familysite"];
$IpClass = new IP();
if ($IpClass->isValid($sitename)) {
if (isset($GLOBALS["IPCACHE"][$sitename])) {
$t = time();
$sitename = gethostbyaddr($sitename);
events("{$tablename}: {$ligne["familysite"]} -> {$sitename} " . $unix->distanceOfTimeInWords($t, time()) . " gethostbyaddr() LINE:" . __LINE__);
$GLOBALS["IPCACHE"][$sitename] = $sitename;
}
}
$category = $q->GET_CATEGORIES($sitename);
if ($IpClass->isValid($sitename)) {
if ($category == null) {
$category = "ipaddr";
}
$q->categorize($sitename, $category);
}
events("{$tablename}: {$ligne["familysite"]} -> {$sitename} [{$category}] LINE:" . __LINE__);
if (strlen($category) > 0) {
$category = mysql_escape_string2($category);
$ligne["familysite"] = mysql_escape_string2($ligne["familysite"]);
$sql = "UPDATE `{$tablename}` SET `category`='{$category}' WHERE familysite='{$ligne["familysite"]}'";
$q->QUERY_SQL($sql);
if (!$q->ok) {
ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
}
}
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:72,代码来源:exec.squid.retranslations.updates.php
示例11: backup_all
function backup_all()
{
$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;
}
$mysqldump = $unix->find_program("mysqldump");
$bzip2 = $unix->find_program("bzip2");
$directory = GetMountPoint();
$time = time();
$target_file = "{$directory}/squidlogs-{$time}.tar.bz2";
if (!is_dir(dirname($target_file))) {
@mkdir(dirname($target_file), 0755, true);
}
$bzip2_cmd = "| {$bzip2} ";
$Socket = " -S /var/run/mysqld/squid-db.sock -u root";
$cmd = "{$mysqldump}{$Socket} --single-transaction --skip-add-locks --skip-lock-tables squidlogs {$bzip2_cmd}> {$target_file} 2>&1";
shell_exec($cmd);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.squidlogs.purge.php
示例12: UseStatsAppliance
function UseStatsAppliance()
{
include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
$sock = new sockets();
$unix = new unix();
$tempdir = $unix->TEMP_DIR();
$RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
$RemoteStatisticsApplianceSettings["SSL"] = 1;
}
if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
$RemoteStatisticsApplianceSettings["PORT"] = 9000;
}
$GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
$GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
$GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
$unix = new unix();
$hostname = $unix->hostname_g();
if ($GLOBALS["REMOTE_SSL"] == 1) {
$refix = "https";
} else {
$refix = "http";
}
$uri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases/dnsmasq.conf";
$curl = new ccurl($uri, true);
if (!$curl->GetFile("{$tempdir}/dnsmasq.conf")) {
ufdbguard_admin_events("Failed to download dnsmasq.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "dns-compile");
return;
}
$mv = $unix->find_program("mv");
$cp = unix - find_program("cp");
$chmod = $unix->find_program("chmod");
shell_exec("{$mv} {$tempdir}/dnsmasq.conf /etc/dnsmasq.conf");
shell_exec("cp /etc/dnsmasq.conf /etc/artica-postfix/settings/Daemons/DnsMasqConfigurationFile");
$dnsmasqbin = $unix->find_program("dnsmasq");
if (is_file($dnsmasqbin)) {
$pid = $unix->PIDOF($dnsmasqbin);
if (is_numeric($pid)) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} reloading PID:`{$pid}`\n";
$kill = $unix->find_program("kill");
unix_system_HUP($pid);
}
}
}
开发者ID:articatech,项目名称:artica,代码行数:44,代码来源:exec.dnsmasq.php
示例13: run_schedules
function run_schedules($ID)
{
$GLOBALS["SCHEDULE_ID"] = $ID;
writelogs("Task {$ID}", __FUNCTION__, __FILE__, __LINE__);
$q = new mysql_squid_builder();
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT TaskType FROM webfilters_schedules WHERE ID={$ID}"));
$TaskType = $ligne["TaskType"];
if ($TaskType == 0) {
continue;
}
if (!isset($q->tasks_processes[$TaskType])) {
ufdbguard_admin_events("Unable to understand task type `{$TaskType}` For this task", __FUNCTION__, __FILE__, __LINE__, "tasks");
return;
}
$script = $q->tasks_processes[$TaskType];
$unix = new unix();
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$WorkingDirectory = dirname(__FILE__);
$cmd = "{$nohup} {$php5} {$WorkingDirectory}/{$script} --schedule-id={$ID} >/dev/null 2>&1 &";
writelogs("Task {$GLOBALS["SCHEDULE_ID"]} is executed with `{$cmd}` ", __FUNCTION__, __FILE__, __LINE__);
ufdbguard_admin_events("Task is executed with `{$cmd}`", __FUNCTION__, __FILE__, __LINE__, "tasks");
shell_exec($cmd);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:24,代码来源:exec.squid.php
示例14: familysites
function familysites($nopid = false)
{
$q = new mysql_squid_builder();
$q->QUERY_SQL("DROP TABLE visited_sites_tot");
$sql = "CREATE TABLE IF NOT EXISTS `visited_sites_tot` (\n\t\t\t `familysite` varchar(255) NOT NULL,\n\t\t\t `size` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t `hits` BIGINT(255) UNSIGNED NOT NULL,\n\t\t\t KEY `size` (`size`),\n\t\t\t KEY `hits` (`hits`),\n\t\t\t PRIMARY KEY `familysite` (`familysite`)\n\t\t\t) ENGINE = MYISAM;";
$q->QUERY_SQL($sql);
$sql = "SELECT familysite,SUM(size) as size,SUM(hits) as hits FROM visited_sites_days GROUP BY familysite HAVING hits>2";
$prefix = "INSERT IGNORE INTO `visited_sites_tot` (familysite,`size` ,`hits`) VALUES ";
$results = $q->QUERY_SQL($sql);
if (!$q->ok) {
ufdbguard_admin_events("Fatal {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$ligne["familysite"] = mysql_escape_string2($ligne["familysite"]);
$f[] = "('{$ligne["familysite"]}','{$ligne["size"]}','{$ligne["hits"]}')";
}
if (count($f) > 0) {
if ($GLOBALS["VERBOSE"]) {
echo count($f) . " rows...\n";
}
$q->QUERY_SQL($prefix . @implode(",", $f));
if (!$q->ok) {
if ($GLOBALS["VERBOSE"]) {
echo count($f) . " Fatal {$q->mysql_error}\n";
}
ufdbguard_admin_events("Fatal {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
return;
}
}
return true;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:32,代码来源:exec.squid.stats.days.websites.php
示例15: Clean_table
function Clean_table($category_table)
{
$noclean["categoryuris_phishing"] = true;
$noclean["categoryuris_malware"] = true;
echo "Cleaning {$category_table}\n";
$q = new mysql_squid_builder();
$sql = "DELETE FROM {$category_table} WHERE LENGTH(pattern)<5";
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo "{$sql}\n{$q->mysql_error}\n";
sendEmail("Error {$category_table} in line " . __LINE__ . " {$q->mysql_error}", "Function:" . __FUNCTION__);
ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "cloud");
return;
}
if (isset($noclean[$category_table])) {
return;
}
$q->QUERY_SQL("DELETE FROM {$category_table} WHERE pattern LIKE '%?%'");
if (!$q->ok) {
sendEmail("Error {$category_table} in line " . __LINE__ . " {$q->mysql_error}", "Function:" . __FUNCTION__);
ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "cloud");
return;
}
$q->QUERY_SQL("DELETE FROM {$category_table} WHERE pattern LIKE '%/%'");
if (!$q->ok) {
sendEmail("Error {$category_table} in line " . __LINE__ . " {$q->mysql_error}", "Function:" . __FUNCTION__);
ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "cloud");
return;
}
$sql = "DELETE FROM {$category_table} WHERE enabled=0";
$q->QUERY_SQL($sql);
if (!$q->ok) {
sendEmail("Error {$category_table} in line " . __LINE__ . " {$q->mysql_error}", "Function:" . __FUNCTION__);
ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "cloud");
return;
}
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:37,代码来源:exec.compile-official-ufdb.php
示例16: _week_uris_blocked_perform
function _week_uris_blocked_perform($tablesource, $week_table, $DAYOFWEEK)
{
$f = array();
$t1 = 0;
$GLOBALS["Q"]->RepairTableBLock($tablesource);
if (!$GLOBALS["Q"]->TABLE_EXISTS($tablesource)) {
ufdbguard_admin_events("{$tablesource} does not exists, skiping", __FUNCTION__, __FILE__, __LINE__, "stats");
return true;
}
$sql = "SELECT COUNT( ID ) as hits,`website`,`category`,`client`,`hostname`,`rulename`,`event`,`why`,`explain`,`blocktype`,`account`\n\tFROM `{$tablesource}`\n\tGROUP BY website,`category`, `client`, `hostname`, `rulename`,`event`,`why`,`explain`,`blocktype`,`account`";
$results = $GLOBALS["Q"]->QUERY_SQL($sql);
if (!$GLOBALS["Q"]->ok) {
echo "\n\n{$sql}\n";
ufdbguard_admin_events("Fatal: {$GLOBALS["Q"]->mysql_error} on `{$tablesource}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return false;
}
$prefix = "INSERT IGNORE INTO {$week_table} (`zMD5`,`hits`,`website`,`category`, `client`, `hostname`, `rulename`,`event`,`why`,`explain`,`blocktype`,`day`,`account`) VALUES ";
if (!$GLOBALS["Q"]->FIELD_EXISTS($week_table, "account")) {
ufdbguard_admin_events("Alter table {$week_table} (create new `account` field)", __FUNCTION__, __FILE__, __LINE__, "stats");
$GLOBALS["Q"]->QUERY_SQL("ALTER TABLE `{$week_table}` ADD `account` BIGINT UNSIGNED NOT NULL ,ADD INDEX ( `account` )");
}
if (!$GLOBALS["Q"]->FIELD_EXISTS($week_table, "MAC")) {
ufdbguard_admin_events("Alter table {$week_table} (create new `MAC` field)", __FUNCTION__, __FILE__, __LINE__, "stats");
$GLOBALS["Q"]->QUERY_SQL("ALTER TABLE `{$week_table}` ADD `MAC` VARCHAR(20) NOT NULL ,ADD INDEX ( `MAC` )");
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$zmd = array();
while (list($key, $value) = each($ligne)) {
$ligne[$key] = addslashes($value);
$zmd[] = $value;
}
$zMD5 = md5(@implode("", $zmd));
$f[] = "('{$zMD5}','{$ligne["hits"]}','{$ligne["website"]}','{$ligne["category"]}','{$ligne["client"]}','{$ligne["hostname"]}','{$ligne["rulename"]}','{$ligne["event"]}',\n\t\t'{$ligne["why"]}','{$ligne["explain"]}','{$ligne["blocktype"]}',{$DAYOFWEEK},'{$ligne["account"]}')";
if (count($f) > 500) {
$t1 = $t1 + count($f);
$GLOBALS["week_uris_blocked"] = $GLOBALS["week_uris_blocked"] + count($f);
if ($GLOBALS["VERBOSE"]) {
echo "{$week_table}: Adding " . count($f) . " events\n";
}
$GLOBALS["Q"]->QUERY_SQL($prefix . @implode(",", $f));
$f = array();
if (!$GLOBALS["Q"]->ok) {
ufdbguard_admin_events("Fatal: {$GLOBALS["Q"]->mysql_error} on `{$week_table}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return false;
}
}
}
if (count($f) > 0) {
$t1 = $t1 + count($f);
$GLOBALS["week_uris_blocked"] = $GLOBALS["week_uris_blocked"] + count($f);
if ($GLOBALS["VERBOSE"]) {
echo "{$week_table}: Adding " . count($f) . " events\n";
}
$GLOBALS["Q"]->QUERY_SQL($prefix . @implode(",", $f));
if (!$GLOBALS["Q"]->ok) {
ufdbguard_admin_events("Fatal: {$GLOBALS["Q"]->mysql_error} on `{$week_table}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return false;
}
}
$sql = "SELECT uid,MAC FROM webfilters_nodes";
$results = $GLOBALS["Q"]->QUERY_SQL($sql);
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
if (strlen($ligne["uid"]) > 1) {
$GLOBALS["Q"]->QUERY_SQL("UPDATE {$week_table} SET uid='{$ligne["uid"]}' WHERE MAC='{$ligne["MAC"]}' AND LENGTH(uid)<2");
}
}
ufdbguard_admin_events("Success: added {$t1} rows on `{$week_table}`", __FUNCTION__, __FILE__, __LINE__, "stats");
return true;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:69,代码来源:exec.squid.stats.blocked.week.php
示例17: Execute
function Execute()
{
$unix = new unix();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$myFile = basename(__FILE__);
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid, $myFile)) {
WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
die;
}
$cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$q = new mysql_squid_builder();
if ($q->COUNT_ROWS("framework_orders") == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "Table framework_orders as no row\n";
}
die;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$nice = EXEC_NICE();
$q = new mysql_squid_builder();
$results = $q->QUERY_SQL("SELECT * FROM framework_orders");
if (!$q->ok) {
if (strpos($q->mysql_error, "doesn't exist") > 0) {
$q->CheckTables();
$results = $q->QUERY_SQL("SELECT * FROM framework_orders");
}
}
if (!$q->ok) {
ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "framework");
die;
}
$reconfigure_plugins = false;
while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
if ($GLOBALS["VERBOSE"]) {
echo "ORDER: {$ligne["ORDER"]} -> {$ligne["zmd5"]}\n";
}
if (preg_match("#COMPILEDB:(.+)#", $ligne["ORDER"], $re)) {
if (preg_match("#english-(.+)#", $re[1])) {
$q->QUERY_SQL("DELETE FROM framework_orders WH
|
请发表评论