本文整理汇总了PHP中ufdbguard_admin_events函数的典型用法代码示例。如果您正苦于以下问题:PHP ufdbguard_admin_events函数的具体用法?PHP ufdbguard_admin_events怎么用?PHP ufdbguard_admin_events使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ufdbguard_admin_events函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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__);
}
示例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");
}
}
示例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;
}
}
}
示例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"]) {
//.........这里部分代码省略.........
示例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);
}
}
示例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);
}
示例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");
}
示例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 &");
}
示例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}")) {
示例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;
}
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
}