本文整理汇总了PHP中ToSyslog函数的典型用法代码示例。如果您正苦于以下问题:PHP ToSyslog函数的具体用法?PHP ToSyslog怎么用?PHP ToSyslog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ToSyslog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SEND_MYSQL
function SEND_MYSQL($sql)
{
$bd = @mysql_connect(":/var/run/mysqld/mysqld.sock", "root", null);
if (!$bd) {
$des = @mysql_error();
$errnum = @mysql_errno();
ToSyslog("MySQL error: {$errnum} {$des}");
return;
}
$ok = @mysql_select_db("postfixlog", $bd);
if (!$ok) {
$des = @mysql_error();
$errnum = @mysql_errno();
ToSyslog("MySQL error: {$errnum} {$des}");
@mysql_close($bd);
return;
}
$results = @mysql_query($sql, $bd);
if (!$results) {
$des = @mysql_error();
$errnum = @mysql_errno();
ToSyslog("MySQL error: {$errnum} {$des}");
}
@mysql_close($bd);
}
示例2: parse_realtime_events
function parse_realtime_events($nopid = false)
{
events("parse_realtime_events():: nopid => {$nopid}");
$unix = new unix();
$TimePID = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$TimeExec = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
if (!$nopid) {
$pid = @file_get_contents($TimePID);
if ($unix->process_exists($pid)) {
$timePid = $unix->PROCCESS_TIME_MIN($pid);
events("parse_realtime_events():: Already process exists {$pid} since {$timePid}Mn");
if ($timePid > 10) {
$kill = $unix->find_program("kill");
events("parse_realtime_events():: Killing {$pid} running since {$timePid}Mn");
unix_system_kill_force($pid);
} else {
if ($GLOBALS["VERBOSE"]) {
echo "Already running PID {$pid} since {$timePid}mn";
}
die;
}
}
@file_put_contents($TimePID, getmypid());
}
events("parse_realtime_events():: Time File: {$TimeExec}");
@unlink($TimeExec);
@file_put_contents($TimeExec, time());
events("Wakup...");
Wakeup();
events("parse_realtime_events():: -> parse_realtime_hash()");
$GLOBALS["PARSE_SECOND_TIME"] = false;
parse_realtime_hash();
if (!$GLOBALS["PARSE_SECOND_TIME"]) {
return;
}
@mkdir("/var/log/squid/mysql-queue", 0755, true);
if (!($handle = opendir("/var/log/squid/mysql-queue"))) {
return;
}
$q = new mysql_squid_builder();
$q->check_youtube_hour(date("YmdH"));
$countDeFiles = 0;
while (false !== ($filename = readdir($handle))) {
if ($filename == ".") {
continue;
}
if ($filename == "..") {
continue;
}
$filepath = "/var/log/squid/mysql-queue/{$filename}";
if (preg_match("#^UserAutDB#", $filename)) {
$content = unserialize(@file_get_contents($filepath));
$contentSize = filesize($filepath) / 1024;
$ArraySize = count($content);
$sql = "INSERT IGNORE INTO UserAutDB (zmd5,MAC,ipaddr,uid,hostname,UserAgent) VALUES " . @implode(",", $content);
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo $q->mysql_error . "\n";
} else {
if ($GLOBALS["VERBOSE"]) {
echo $filepath . " ({$contentSize} KB) done with {$ArraySize} elements...\n";
}
@unlink($filepath);
}
continue;
}
if (preg_match("#^macscan#", $filename)) {
$content = unserialize(@file_get_contents($filepath));
$contentSize = filesize($filepath) / 1024;
$ArraySize = count($content);
$sql = "INSERT IGNORE INTO `macscan` (`MAC`,`ipaddr`) VALUES " . @implode(",", $content);
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo $q->mysql_error . "\n";
} else {
if ($GLOBALS["VERBOSE"]) {
echo $filepath . " ({$contentSize} KB) done with {$ArraySize} elements...\n";
}
@unlink($filepath);
}
continue;
}
if (preg_match("#^YoutubeRTT#", $filename)) {
$sql = trim(@file_get_contents($filepath));
$contentSize = strlen($sql) / 1024;
if (preg_match("#INSERT IGNORE INTO `(.+?)`#", $sql, $re)) {
$tablename = $re[1];
if (!preg_match("#youtubehours_([0-9]+)#", $tablename)) {
echo "***** replace {$tablename} to youtubehours_date(YmdH) ****\n";
$sql = str_replace($tablename, "youtubehours_" . date("YmdH"), $sql);
}
}
$q->QUERY_SQL($sql);
if (!$q->ok) {
ToSyslog("{$q->mysql_error} in line [" . __LINE__ . "]");
if (preg_match("#Table\\s+'.+?\\.youtubehours_(.+?)'\\s+doesn't exist#", $q->mysql_error, $re)) {
ToSyslog("Building youtubehours_{$re[1]} table");
$q->check_youtube_hour($re[1]);
$q->QUERY_SQL($sql);
}
//.........这里部分代码省略.........
示例3: events
if (!isset($GLOBALS["UfdbguardSMTPNotifs"]["BLOCK_NOTIFS"])) {
$GLOBALS["UfdbguardSMTPNotifs"]["BLOCK_NOTIFS"] = 0;
}
if ($GLOBALS["UfdbguardSMTPNotifs"]["ENABLED"] == 0) {
$GLOBALS["UfdbguardSMTPNotifs"]["BLOCK_NOTIFS"] = 0;
}
events("SMTP Notification: {$GLOBALS["UfdbguardSMTPNotifs"]["ENABLED"]}");
events("Threats Notifications: {$GLOBALS["UfdbguardSMTPNotifs"]["BLOCK_NOTIFS"]}");
events("SQUID_PERFORMANCE: {$GLOBALS["SQUID_PERFORMANCE"]}");
$GLOBALS["RELOADCMD"] = "{$GLOBALS["nohup"]} {$GLOBALS["PHP5_BIN"]} " . dirname(__FILE__) . "/exec.squidguard.php --reload-ufdb";
if ($argv[1] == '--date') {
echo date("Y-m-d H:i:s") . "\n";
}
@mkdir("{$GLOBALS["ARTICALOGDIR"]}/squid-stats", 0666, true);
@mkdir("{$GLOBALS["ARTICALOGDIR"]}/pagepeeker", 600, true);
ToSyslog("Watchdog started pid {$pid}");
events("ufdbGenTable = {$GLOBALS["ufdbGenTable"]}");
if (!is_dir("/home/ufdb/relatime-events")) {
@mkdir("/home/ufdb/relatime-events", 0755, true);
}
shell_exec("{$GLOBALS["chown"]} -R squid:squid /home/ufdb/relatime-events");
$pipe = fopen("php://stdin", "r");
while (!feof($pipe)) {
$buffer .= fgets($pipe, 4096);
try {
Parseline($buffer);
} catch (Exception $e) {
ufdbguard_admin_events("Fatal error on {$buffer}: " . $e->getMessage(), "MAIN", __FILE__, __LINE__, "ufdbguard-service");
}
$buffer = null;
}
示例4: SwapWatchdog
function SwapWatchdog()
{
$sock = new sockets();
$unix = new unix();
$MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig")));
$MonitConfig = watchdog_config_default($MonitConfig);
$ps = $unix->find_program("ps");
if ($GLOBALS["VERBOSE"]) {
echo "\n******** SWAP *******\n";
}
if ($MonitConfig["SWAP_MONITOR"] == 0) {
return;
}
include_once dirname(__FILE__) . "/ressources/class.main_cf.inc";
$sys = new systeminfos();
$pourc = round($sys->swap_used / $sys->swap_total * 100);
$freeMemory = $unix->TOTAL_MEMORY_MB_FREE();
$SwapMemoryused = $sys->swap_used;
ToSyslog("SwapWatchdog(): {$sys->swap_used}MB used Current {$pourc}% Free Memory: {$freeMemory}MB, min:{$MonitConfig["SWAP_MIN"]}% MAX:{$MonitConfig["SWAP_MAX"]}%");
if ($pourc < $MonitConfig["SWAP_MIN"]) {
return;
}
if (!isset($MonitConfig["SWAP_MIN"])) {
$MonitConfig["SWAP_MIN"] = 5;
}
if (!isset($MonitConfig["SWAP_MAX"])) {
$MonitConfig["SWAP_MAX"] = 55;
}
$ps_text[] = "There is not enough memory to clean the swap";
$ps_text[] = "Current configuration was: Free Swap memory over than {$MonitConfig["SWAP_MAX"]}%";
$ps_text[] = "Your current Swap file using: {$SwapMemoryused}M - {$pourc}% - {$sys->swap_used}/{$sys->swap_total}";
$ps_text[] = "Memory free on your system:{$freeMemory}M";
$ps_text[] = "You will find here a snapshot of current tasks";
$ps_text[] = ps_mem_report();
$ps_mail = @implode("\n", $ps_text);
if ($pourc > $MonitConfig["SWAP_MAX"]) {
if ($SwapMemoryused < $freeMemory) {
squid_admin_mysql(0, "[ALERT] REBOOT server!!! Swap exceed rule {$pourc}% max: {$MonitConfig["SWAP_MAX"]}%", $ps_mail, __FILE__, __LINE__);
FailOverDown("Swap exceed rule - reboot - {$pourc}% max:{$MonitConfig["SWAP_MAX"]}%\n{$ps_mail}");
shell_exec($unix->find_program("shutdown") . " -rF now");
die;
}
squid_admin_mysql(1, "Cleaning SWAP current: {$pourc}% max:{$MonitConfig["SWAP_MAX"]}%", "clean the swap ({$SwapMemoryused}M/{$freeMemory}M)\n{$ps_mail}", __FILE__, __LINE__);
SwapWatchdog_FreeSync();
die;
}
squid_admin_mysql(1, "Cleaning SWAP current:{$pourc}% min:{$MonitConfig["SWAP_MIN"]}%", "clean the swap ({$SwapMemoryused}M/{$freeMemory}M)\n{$ps_mail}", __FILE__, __LINE__);
SwapWatchdog_FreeSync();
}
示例5: gencaches_start
function gencaches_start()
{
$unix = new unix();
$min = 10;
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "Time File: {$timefile}\n";
}
$pid = @file_get_contents($pidfile);
if ($GLOBALS["FORCE"]) {
ToSyslog("gencaches_start(): Executed in --force mode");
}
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";
}
ToSyslog("gencaches_start(): already executed pid {$pid}");
return;
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < $min) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
@unlink($timefile);
@file_put_contents($timefile, time());
gencaches();
gencache_day();
gencache_hier();
gencache_TOP();
}
示例6: restart_routes
function restart_routes()
{
$unix = new unix();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
ToSyslog("kernel: [ Artica-Net] Start Network [artica-ifup] (" . basename(__FILE__) . "/" . __LINE__ . ")");
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/exec.virtuals-ip.php.html", "\n");
@chmod("/usr/share/artica-postfix/ressources/logs/web/exec.virtuals-ip.php.html", 0777);
shell_exec("{$nohup} /etc/init.d/artica-ifup routes >> /usr/share/artica-postfix/ressources/logs/web/exec.virtuals-ip.php.html 2>&1 &");
}
示例7: wifidog_register_perform
function wifidog_register_perform()
{
session_start();
$page = CurrentPageName();
$autocreate_confirmed = 0;
if ($GLOBALS["HOTSPOT_DEBUG"]) {
ToSyslog("Starting wifidog_register_perform()");
}
$sock = new sockets();
$ArticaHotSpotSMTP = SMTP_SETTINGS();
$email = trim(strtolower($_POST["email"]));
$q = new mysql_squid_builder();
$password2 = trim($_POST["password2"]);
$password = trim($_POST["password"]);
if ($password2 != $password) {
return wifidog_register("{password_mismatch}");
}
if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 1) {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
return wifidog_register("{error_email_invalid}");
}
$tr = explode("@", $email);
$domain = $tr[1];
if (!checkdnsrr($domain, 'MX')) {
return wifidog_register("«{$domain}»<br>{error_domain_email_invalid}");
}
}
$ligne = mysql_fetch_array($q->QUERY_SQL("SELECT uid FROM hotspot_members WHERE `uid`='{$email}'"));
$wifidog_build_uri = wifidog_build_uri();
$uriext = $wifidog_build_uri[0];
$HiddenFields = $wifidog_build_uri[1];
if ($ligne["uid"] != null) {
if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 1) {
$link = "<center><a href=\"{$page}?wifidog-recover=yes&{$uriext}\">{lost_password}</a></center>";
}
return wifidog_register("{this_account_already_exists}<hr>{$link}");
}
$MAC = $_REQUEST["mac"];
$REGISTER_MAX_TIME = $ArticaHotSpotSMTP["REGISTER_MAX_TIME"];
$ArticaSplashHotSpotEndTime = $ArticaHotSpotSMTP["ArticaSplashHotSpotEndTime"];
$password = md5($password);
$creationtime = time();
$autocreate_maxttl = $ArticaHotSpotSMTP["REGISTER_MAX_TIME"];
$sessionkey = md5($password . $creationtime . $email);
$gateway_addr = $_REQUEST["gw_address"];
$gw_port = $_REQUEST["gw_port"];
$gw_id = $_REQUEST["gw_id"];
$ARP = $_REQUEST["mac"];
$url = $_REQUEST["url"];
$token = $_REQUEST["token"];
if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 0) {
$autocreate_confirmed = 1;
}
if ($GLOBALS["HOTSPOT_DEBUG"]) {
ToSyslog("Create new member {$email},{$password},TTL:{$ArticaSplashHotSpotEndTime} in line:" . __LINE__);
}
$sql = "INSERT IGNORE INTO hotspot_members \n\t(uid,ttl,sessiontime,password,enabled,creationtime,autocreate,autocreate_confirmed,autocreate_maxttl,sessionkey,MAC) VALUES\n\t('{$email}','{$ArticaSplashHotSpotEndTime}','','{$password}',1,'{$creationtime}',1,'{$autocreate_confirmed}',{$autocreate_maxttl},'{$sessionkey}','{$MAC}')";
$q->QUERY_SQL($sql);
if (!$q->ok) {
if (strpos(" {$q->mysql_error}", "Unknown column") > 0) {
if ($GLOBALS["HOTSPOT_DEBUG"]) {
ToSyslog("check_hotspot_tables in line:" . __LINE__);
}
$q->check_hotspot_tables();
if (!$q->ok) {
if ($GLOBALS["HOTSPOT_DEBUG"]) {
ToSyslog("{$q->mysql_error} in line:" . __LINE__);
}
}
$q->QUERY_SQL($sql);
}
}
if (!$q->ok) {
ToSyslog("{$q->mysql_error}");
return wifidog_register($q->mysql_error);
}
if ($ArticaHotSpotSMTP["ENABLED_SMTP"] == 0) {
$array["SERVER_NAME"] = $_SERVER["SERVER_NAME"];
$array["redirecturi"] = $url;
$array["LOGIN"] = $email;
$array["redirecturi"] = $_REQUEST["url"];
$array["REMOTE_ADDR"] = $_REQUEST["ip"];
$array["token"] = $token;
$array["HOST"] = $_REQUEST["ip"];
UnLock($array);
ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: SESSION(HOTSPOT_REDIRECT_URL) = {$url}");
$_SESSION["HOTSPOT_AUTO_REGISTER"] = true;
$_SESSION["HOTSPOT_REDIRECT_URL"] = $url;
$redirecturi = "http://{$gateway_addr}:{$gw_port}/wifidog/auth?token={$token}";
ToSyslog("wifidog_auth/" . __FUNCTION__ . ":: Redirect Token: {$token} to {$redirecturi}");
header("Location: {$redirecturi}");
return;
}
$proto = "http";
$myHostname = $_SERVER["HTTP_HOST"];
$page = CurrentPageName();
if (isset($_SERVER["HTTPS"])) {
$proto = "https";
}
$URL_REDIRECT = "{$proto}://{$myHostname}/{$page}?wifidog-confirm={$sessionkey}";
//.........这里部分代码省略.........
示例8: start
function start()
{
$unix = new unix();
$pid = getmypid();
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "pidTime: {$pidTime}\n";
}
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid)) {
if ($pid != $pid) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($time > 120) {
ToSyslog("killing {$pid} (line: Line: " . __LINE__ . ")");
unix_system_kill_force($pid);
} else {
die;
}
}
}
@file_put_contents($pidfile, getmypid());
$pidTimeEx = $unix->file_time_min($pidTime);
if (!$GLOBALS["FORCE"]) {
if ($pidTimeEx < 240) {
ToSyslog("Waiting 240mn minimal - current ({$pidTimeEx}Mn)");
return;
}
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$ARRAY = array();
$curlftps = $unix->find_program("curlftpfs");
$pgrep = $unix->find_program("pgrep");
exec("{$pgrep} -l -f \"{$curlftps}\" 2>&1", $results);
while (list($index, $line) = each($results)) {
$line = trim($line);
if ($line == null) {
continue;
}
$MOUNTED = null;
$pidtime = 0;
$pid = 0;
if (preg_match("#pgrep#", $line)) {
continue;
}
if (preg_match("#^([0-9]+)\\s+(.+)#", $line, $re)) {
$pid = $re[1];
$pidtime = $unix->PROCESS_TTL($pid);
$cmdline = trim($re[2]);
$cmdline = str_replace($curlftps, "", $cmdline);
$cmdline = trim($re[2]);
if ($GLOBALS["VERBOSE"]) {
echo "Found {$pid} {$pidtime}Mn [{$cmdline}]\n";
}
$ARRAY[$pid]["TIME"] = $pidtime;
if ($GLOBALS["VERBOSE"]) {
echo "Explode {$cmdline}\n";
}
$TR = explode(" ", $cmdline);
while (list($index2, $bg) = each($TR)) {
if ($GLOBALS["VERBOSE"]) {
echo "Checks {$bg}\n";
}
if (substr($bg, 0, 1) == "/") {
$MOUNTED = $bg;
if ($GLOBALS["VERBOSE"]) {
echo "Found {$pid} {$pidtime}Mn mounted on {$bg}\n";
}
$ARRAY[$pid]["MOUNTED"] = $MOUNTED;
break;
}
}
}
}
if (count($ARRAY) == 0) {
return;
}
$umount = $unix->find_program("umount");
while (list($pid, $ar) = each($ARRAY)) {
$TIME = $ar["TIME"];
$MOUNTED = $ar["MOUNTED"];
if ($TIME < 960) {
continue;
}
ToSyslog("Umounting curlftps process id {$pid} mounted on {$MOUNTED} and running since {$TIME}mn, and exceed 960mn");
shell_exec("{$umount} -l {$MOUNTED}");
if ($unix->process_exists($pid)) {
ToSyslog("Killing curlftps process id {$pid}");
$unix->KILL_PROCESS($pid, 9);
}
}
}
示例9: caches_infos
function caches_infos($aspid = false)
{
$cacheFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$cachePID = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
if ($GLOBALS["FORCE"]) {
ToSyslog("caches_infos(): Executed in force mode");
}
$unix = new unix();
$sock = new sockets();
if (!$GLOBALS["VERBOSE"]) {
if (system_is_overloaded(basename(__FILE__))) {
EventsWatchdog("Overloaded system, aborting task...");
ToSyslog("caches_infos(): Overloaded system, aborting task");
writelogs("Overloaded system, aborting task...", __FUNCTION__, __FILE__, __LINE__);
return;
}
if ($aspid) {
$pid = @file_get_contents($cachePID);
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($timepid < 15) {
ToSyslog("caches_infos(): Already task PID: {$pid} running since {$timepid}Mn");
}
$kill = $unix->find_program("{$kill}");
unix_system_kill_force($pid);
}
}
}
if ($GLOBALS["VERBOSE"]) {
echo "init...\n";
}
$q = new mysql_squid_builder();
if (!$GLOBALS["FORCE"]) {
$CacheTime = $unix->file_time_min($cacheFile);
if ($CacheTime < 15) {
EventsWatchdog("Max 15Mn, current={$CacheTime} ({$cacheFile})...");
if ($GLOBALS["VERBOSE"]) {
echo "Max 15Mn, current={$CacheTime}\n";
}
return;
}
}
$squid_pid = SQUID_PID();
if (!$unix->process_exists($squid_pid)) {
$nohup = $unix->find_program("nohup");
squid_admin_mysql(0, "Squid-Cache is not running..., start it", null, __FILE__, __LINE__);
ToSyslog("caches_infos(): Squid-Cache is not running..., start it");
shell_exec("{$nohup} /etc/init.d/squid start >/dev/null 2>&1 &");
return;
}
@unlink($cacheFile);
@file_put_contents($cacheFile, time());
$ttl = $unix->PROCCESS_TIME_MIN($squid_pid);
if ($unix->PROCCESS_TIME_MIN($squid_pid) < 5) {
ToSyslog("caches_infos(): squid-cache running only since {$ttl}mn, aborting");
return;
}
ToSyslog("caches_infos(): Starting get Squid-cache informations.");
$array = $unix->squid_get_cache_infos();
for ($i = 0; $i < 10; $i++) {
$check = true;
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() O items !!\n";
}
$check = false;
sleep(1);
$array = $unix->squid_get_cache_infos();
continue;
}
if ($check) {
break;
}
}
if (!is_array($array)) {
if ($GLOBALS["VERBOSE"]) {
echo "unix->squid_get_cache_infos() Not an array...\n";
}
return;
}
if (count($array) == 0) {
if ($GLOBALS["VERBOSE"]) {
echo basename(__FILE__) . "[" . __LINE__ . "] unix->squid_get_cache_infos() O items !!...\n";
}
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
return;
}
@unlink("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db");
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", serialize($array));
@chmod("/usr/share/artica-postfix/ressources/logs/web/squid_get_cache_infos.db", 0755);
//.........这里部分代码省略.........
示例10: PushToRepo
function PushToRepo($filepath)
{
$curl = "/usr/bin/curl";
$unix = new unix();
$ftpass5 = trim(@file_get_contents("/root/ftp-password5"));
$uri = "ftp://mirror.articatech.net/www.artica.fr/WebfilterDBS";
$size = round(filesize($filepath) / 1024);
$ftpass5 = $unix->shellEscapeChars($ftpass5);
ToSyslog("Push {$filepath} ( {$size} KB ) to {$uri}\n{$curl} -T {$filepath} {$uri}/ --user {$ftpass5}");
shell_exec("{$curl} -T {$filepath} {$uri}/ --user {$ftpass5}");
}
示例11: load_stats
//.........这里部分代码省略.........
@file_put_contents("/var/log/artica-postfix/sys_loadavg/{$time}", $internal_load);
@file_put_contents("/var/log/artica-postfix/sys_mem/{$time}", $ram_used);
$NtpdateAD = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NtpdateAD"));
$NTPDClientEnabled = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NTPDClientEnabled"));
if ($NtpdateAD == 1) {
$NTPDClientEnabled = 1;
}
if (system_is_overloaded(basename(__FILE__))) {
$date = time();
if (!is_file("/var/log/artica-postfix/sys_alerts/{$date}")) {
$ps = $unix->find_program("ps");
$load = $GLOBALS["SYSTEM_INTERNAL_LOAD"];
if (!$unix->process_exists($GLOBALS["CLASS_UNIX"]->PIDOF_PATTERN("{$ps}"))) {
$cmd = trim($GLOBALS["nohup"] . " {$GLOBALS["NICE"]} {$ps} auxww >/var/log/artica-postfix/sys_alerts/{$date}-{$load} 2>&1");
shell_exec($cmd);
}
}
} else {
if (is_file("/etc/artica-postfix/WEBSTATS_APPLIANCE")) {
shell_exec_time("exec.squid.php --ping-clients-proxy", 5);
}
}
// NTP CLIENT *****************************************************************************
if ($NTPDClientEnabled == 1) {
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.ntp.time");
$NTPDClientPool = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NTPDClientPool"));
if ($NTPDClientPool == 0) {
$NTPDClientPool = 120;
}
if ($time_file > $NTPDClientPool) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.ntpdate.php >/dev/null 2>&1 &");
}
}
// ****************************************************************************************
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.syslog-engine.php.load_stats.time");
if ($time_file > 5) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.syslog-engine.php --load-stats >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.mpstat.php.time");
if ($time_file > 1) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.mpstat.php >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.philesight.php.scan_directories.time");
if ($time_file > 60) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.philesight.php --directories >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.seeker.php.xtart.time");
events("seeker: {$time_file}mn/30mn");
$GLOBALS["CLASS_UNIX"]->events("seeker: {$time_file}mn/30mn (/etc/artica-postfix/pids/exec.seeker.php.xtart.time)", "/var/log/seeker.log", false, __FUNCTION__, __LINE__, basename(__FILE__));
if ($time_file > 5) {
events("************ Executing seeker... ************");
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.seeker.php >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/croned.1/cron.notifs.php.time");
if ($time_file > 5) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/cron.notifs.php >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.cleanfiles.php.time");
if ($time_file > 120) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.cleanfiles.php >/dev/null 2>&1 &");
}
$timefile = $time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.clean.logs.php.CleanLogs.time");
if ($time_file > 240) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.clean.logs.php --clean-tmp >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.squid.watchdog.php.CHECK_DNS_SYSTEMS.time");
events("CHECK_DNS_SYSTEMS: {$time_file}mn", __FUNCTION__, __LINE__);
if ($time_file > 4) {
$cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --dns >/dev/null 2>&1 &";
events($cmd, __FUNCTION__, __LINE__);
shell_exec2("{$cmd}");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.clean.logs.php.clean_space.time");
events("clean_space: {$time_file}mn", __FUNCTION__, __LINE__);
if ($time_file > 240) {
$cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.clean.logs.php --clean-space >/dev/null 2>&1 &";
events($cmd, __FUNCTION__, __LINE__);
shell_exec2("{$cmd}");
}
$kill = $GLOBALS["CLASS_UNIX"]->find_program("kill");
$pgrep = $GLOBALS["CLASS_UNIX"]->find_program("pgrep");
exec("pgrep -l -f \"exec.schedules.php --run\" 2>&1", $results);
while (list($index, $line) = each($results)) {
if (preg_match("#pgrep#", $line)) {
continue;
}
if (!preg_match("#^([0-9]+)\\s+#", $line, $re)) {
continue;
}
$pid = $re[1];
$TTL = $GLOBALS["CLASS_UNIX"]->PROCCESS_TIME_MIN($pid);
events("{$line} -> {$TTL}Mn");
if ($TTL < 420) {
continue;
}
ToSyslog("Killing exec.schedules.php PID {$pid}");
unix_system_kill_force($pid);
}
events("************************ SCHEDULE ****************************", __FUNCTION__, __LINE__);
}
示例12: CheckCallable
function CheckCallable()
{
include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc";
include_once dirname(__FILE__) . "/ressources/class.influx.inc";
include_once dirname(__FILE__) . "/ressources/class.status.openldap.inc";
include_once dirname(__FILE__) . "/framework/class.status.hardware.inc";
include_once dirname(__FILE__) . "/ressources/class.status.ftp-proxy.inc";
if (!isset($GLOBALS["CLASS_UNIX"])) {
$GLOBALS["CLASS_UNIX"] = new unix();
}
if (!isset($GLOBALS["CLASS_USERS"])) {
$GLOBALS["CLASS_USERS"] = new settings_inc();
}
if (!isset($GLOBALS["CLASS_SOCKETS"])) {
$GLOBALS["CLASS_SOCKETS"] = new sockets();
}
$methodVariable = array($GLOBALS["CLASS_UNIX"], 'GetVersionOf');
if (!is_callable($methodVariable, true, $callable_name)) {
ToSyslog("Loading unix class");
$GLOBALS["CLASS_UNIX"] = new unix();
}
$methodVariable = array($GLOBALS["CLASS_UNIX"], 'find_program');
if (!is_callable($methodVariable, true, $callable_name)) {
events("Loading unix class");
$GLOBALS["CLASS_UNIX"] = new unix();
}
$methodVariable = array($GLOBALS["CLASS_SOCKETS"], 'GET_INFO');
if (!is_callable($methodVariable, true, $callable_name)) {
ToSyslog("Loading socket class");
$GLOBALS["CLASS_SOCKETS"] = new sockets();
}
$methodVariable = array($GLOBALS["CLASS_USERS"], 'BuildLeftMenus');
if (!is_callable($methodVariable, true, $callable_name)) {
ToSyslog("Loading usersMenus class");
$GLOBALS["CLASS_USERS"] = new settings_inc();
}
$GLOBALS["OS_SYSTEM"] = new os_system();
$GLOBALS["MEMORY_INSTALLED"] = $GLOBALS["OS_SYSTEM"]->memory();
if (is_file("/etc/artica-postfix/amavis.watchdog.cache")) {
$GLOBALS["AMAVIS_WATCHDOG"] = unserialize(@file_get_contents("/etc/artica-postfix/amavis.watchdog.cache"));
}
$GLOBALS["TIME_CLASS"] = time();
$GLOBALS["ArticaWatchDogList"] = unserialize(base64_decode($GLOBALS["CLASS_SOCKETS"]->GET_INFO("ArticaWatchDogList")));
}
示例13: ufdbguard_blocks_errors
function ufdbguard_blocks_errors($nopid = false)
{
$unix = new unix();
if ($nopid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = @file_get_contents($pidfile);
if ($unix->process_exists($pid)) {
writelogs("Already running pid {$pid}", __FUNCTION__, __FILE__, __LINE__);
return;
}
$t = 0;
}
if (!is_dir("/var/log/artica-postfix/ufdbguard-blocks-errors")) {
return;
}
if (!($handle = opendir("/var/log/artica-postfix/ufdbguard-blocks-errors"))) {
events_tail("ufdbguard_blocks_errors:: -> glob failed in Line: /var/log/artica-postfix/ufdbguard-blocks-errors " . __LINE__);
return;
}
$q = new mysql_squid_builder();
while (false !== ($filename = readdir($handle))) {
if ($filename == ".") {
continue;
}
if ($filename == "..") {
continue;
}
$targetFile = "/var/log/artica-postfix/ufdbguard-blocks-errors/{$filename}";
$queries = unserialize(@file_get_contents($targetFile));
if (!is_array($queries)) {
events_tail("PaseUdfdbGuard:: {$targetFile}, not an array....");
@unlink($targetFile);
continue;
}
if (!preg_match("#(.+?)\\.([0-9]+)#", $filename, $re)) {
events_tail("PaseUdfdbGuard:: {$targetFile}, No compatible file");
@unlink($targetFile);
continue;
}
$tablename = $re[1];
$q->CheckTablesBlocked_day(0, $tablename);
$prefix = "INSERT IGNORE INTO `{$tablename}` (`zmd5`,`client`,`website`,`category`,`rulename`,`public_ip`,`why`,`blocktype`,`hostname`,`uid`,`MAC`,`uri`,`zDate`) VALUES ";
if (!$q->QUERY_SQL($prefix . @implode(",", $queries))) {
ToSyslog("Fatal line " . __LINE__ . " " . $q->mysql_error);
$time = $unix->file_time_min($targetFile);
if ($time > 5760) {
@unlink($targetFile);
}
continue;
}
@unlink($targetFile);
}
}
示例14: clean_empty_tables
function clean_empty_tables()
{
$unix = new unix();
///etc/artica-postfix/pids/exec.squid.stats.hours.php.clean_empty_tables.time
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
if ($GLOBALS["VERBOSE"]) {
echo "Time File: {$timefile}\n";
}
$pid = @file_get_contents($pidfile);
if ($GLOBALS["FORCE"]) {
ToSyslog("macscan(): Executed in --force mode");
}
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";
}
ToSyslog("clean_empty_tables(): already executed pid {$pid}");
return;
}
$timeexec = $unix->file_time_min($timefile);
if ($timeexec < 30) {
return;
}
$mypid = getmypid();
@file_put_contents($pidfile, $mypid);
}
@unlink($timefile);
@file_put_contents($timefile, time());
$q = new mysql_squid_builder();
$TABLES = $q->LIST_TABLES_HOURS_TEMP();
$current = "squidhour_" . date("YmdH");
while (list($tablename, $none) = each($TABLES)) {
if ($tablename == $current) {
continue;
}
if ($q->COUNT_ROWS($tablename) > 0) {
continue;
}
$q->QUERY_SQL("DROP TABLE `{$tablename}`");
}
$TABLES = $q->LIST_TABLES_SIZEHOURS();
$current = "sizehour_" . date("YmdH");
while (list($tablename, $none) = each($TABLES)) {
if ($tablename == $current) {
continue;
}
if ($q->COUNT_ROWS($tablename) > 0) {
continue;
}
$q->QUERY_SQL("DROP TABLE `{$tablename}`");
}
$TABLES = $q->LIST_TABLES_dansguardian_events();
$current = " dansguardian_events_" . date("Ymd");
while (list($tablename, $none) = each($TABLES)) {
if ($tablename == $current) {
continue;
}
if ($q->COUNT_ROWS($tablename) > 0) {
continue;
}
$q->QUERY_SQL("DROP TABLE `{$tablename}`");
}
}
示例15: load_stats
function load_stats()
{
events("************************ SCHEDULE ****************************", __FUNCTION__, __LINE__);
if (!isset($GLOBALS["CLASS_SOCKETS"])) {
$GLOBALS["CLASS_SOCKETS"] = new sockets();
}
if (!isset($GLOBALS["CLASS_UNIX"])) {
$unix = new unix();
} else {
$unix = $GLOBALS["CLASS_UNIX"];
}
$time = time();
$BASEDIR = "/usr/share/artica-postfix";
$hash_mem = array();
@mkdir("/var/log/artica-postfix/sys_alerts", 0755, true);
$NtpdateAD = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NtpdateAD"));
$NTPDClientEnabled = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NTPDClientEnabled"));
$SquidPerformance = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("SquidPerformance"));
if ($NtpdateAD == 1) {
$NTPDClientEnabled = 1;
}
// NTP CLIENT *****************************************************************************
if ($NTPDClientEnabled == 1) {
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.ntp.time");
$NTPDClientPool = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("NTPDClientPool"));
if ($NTPDClientPool == 0) {
$NTPDClientPool = 120;
}
if ($time_file > $NTPDClientPool) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.ntpdate.php >/dev/null 2>&1 &");
}
}
// ****************************************************************************************
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.syslog-engine.php.load_stats.time");
events("exec.syslog-engine.php --load-stats = {$time_file}/5mn");
if ($time_file > 5) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.syslog-engine.php --load-stats >/dev/null 2>&1 &");
}
// ****************************************************************************************
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.philesight.php.scan_directories.time");
if ($time_file > 60) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.philesight.php --directories >/dev/null 2>&1 &");
}
// ****************************************************************************************
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.seeker.php.xtart.time");
events("seeker: {$time_file}mn/30mn");
$GLOBALS["CLASS_UNIX"]->events("seeker: {$time_file}mn/30mn (/etc/artica-postfix/pids/exec.seeker.php.xtart.time)", "/var/log/seeker.log", false, __FUNCTION__, __LINE__, basename(__FILE__));
if ($time_file > 5) {
events("************ Executing seeker... ************");
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.seeker.php >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/croned.1/cron.notifs.php.time");
if ($time_file > 5) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/cron.notifs.php >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.cleanfiles.php.time");
if ($time_file > 120) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.cleanfiles.php >/dev/null 2>&1 &");
}
$timefile = $time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.clean.logs.php.CleanLogs.time");
if ($time_file > 240) {
shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.clean.logs.php --clean-tmp >/dev/null 2>&1 &");
}
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.squid.watchdog.php.CHECK_DNS_SYSTEMS.time");
events("CHECK_DNS_SYSTEMS: {$time_file}mn", __FUNCTION__, __LINE__);
$time_file = $GLOBALS["CLASS_UNIX"]->file_time_min("/etc/artica-postfix/pids/exec.clean.logs.php.clean_space.time");
events("clean_space: {$time_file}mn", __FUNCTION__, __LINE__);
if ($time_file > 240) {
$cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.clean.logs.php --clean-space >/dev/null 2>&1 &";
events($cmd, __FUNCTION__, __LINE__);
shell_exec2("{$cmd}");
}
$kill = $GLOBALS["CLASS_UNIX"]->find_program("kill");
$pgrep = $GLOBALS["CLASS_UNIX"]->find_program("pgrep");
exec("pgrep -l -f \"exec.schedules.php --run\" 2>&1", $results);
while (list($index, $line) = each($results)) {
if (preg_match("#pgrep#", $line)) {
continue;
}
if (!preg_match("#^([0-9]+)\\s+#", $line, $re)) {
continue;
}
$pid = $re[1];
$TTL = $GLOBALS["CLASS_UNIX"]->PROCCESS_TIME_MIN($pid);
events("{$line} -> {$TTL}Mn");
if ($TTL < 420) {
continue;
}
ToSyslog("Killing exec.schedules.php PID {$pid}");
unix_system_kill_force($pid);
}
events("************************ SCHEDULE ****************************", __FUNCTION__, __LINE__);
}