function ParseMainDir() { $unix = new unix(); $mypid = getmypid(); $kill = $unix->find_program("kill"); $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); @mkdir("/etc/artica-postfix/pids", 0755, true); $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $pidtime_hour = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".hours.time"; $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($time > 60) { unix_system_kill_force($pid); } else { events("Already executed pid {$pid} since {$time}mn-> DIE"); if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid} since {$time}mn\n"; } die; } } $timeP = $unix->file_time_min($pidtime); if ($timeP < 3) { events("Main::Line: " . __LINE__ . " 3Mn minimal current: {$timeP}mn-> DIE"); die; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, $mypid); $dirs = $unix->dirdir("/var/log/artica-postfix/squid/queues"); while (list($directory, $array) = each($dirs)) { $dirs2 = $unix->dirdir($directory); if (count($dirs2) == 0) { events("{$dirs2} 0 elements, remove...", __LINE__); @rmdir($directory); continue; } if (is_dir("{$directory}/SearchWords")) { events("Scanning {$directory}/SearchWords", __LINE__); ParseSubDir("{$directory}/SearchWords"); } } $timeP = $unix->file_time_min($pidtime_hour); if ($timeP > 30) { @unlink($pidtime_hour); @file_put_contents($pidtime_hour, time()); shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.squid-searchwords.php --hour >/dev/null 2>&1"); } }
function status() { $cache_file = "/usr/share/artica-postfix/ressources/logs/web/monit.status.all"; $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n"; } return; } $time = $unix->file_time_min($cache_file); if ($time < 2) { return; } $monit = new monit_unix(); $array = $monit->all_status(); if (count($array) < 2) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} array returned less than 2 items\n"; } return; } @unlink($cache_file); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Saving {$cache_file}\n"; } @file_put_contents($cache_file, serialize($array)); @chmod($cache_file, 0755); }
function check() { $EnablePhileSight = GET_INFO_DAEMON("EnablePhileSight"); if ($EnablePhileSight == null) { $EnablePhileSight = 0; } if ($EnablePhileSight == 0) { writelogs("feature disabled, aborting...", __FUNCTION__, __FILE__, __LINE__); die; } if (system_is_overloaded()) { writelogs("System overloaded, aborting this feature for the moment", __FUNCTION__, __FILE__, __LINE__); die; } @mkdir("/opt/artica/philesight"); $unix = new unix(); $min = $unix->file_time_min("/opt/artica/philesight/database.db"); $sock = new sockets(); $rr = $sock->GET_INFO("PhileSizeRefreshEach"); if ($rr == null) { $rr = 120; } if ($rr == "disable") { die; } writelogs("/opt/artica/philesight/database.db = {$min} minutes, {$rr} minutes to run", __FUNCTION__, __FILE__, __LINE__); if ($min >= $rr) { run(); } }
function xstart() { $unix = new unix(); $sock = new sockets(); $GLOBALS["CLASS_SOCKETS"] = $sock; $FORCED_TEXT = null; $NOTIFY = false; $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db"; $pid = $unix->get_pid_from_file($pidfile); $GLOBALS["CLASS_UNIX"] = $unix; if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); echo "Already executed\n"; return; } if (!$GLOBALS["FORCE"]) { if ($unix->file_time_min($pidTime) < 30) { return; } } $GLOBALS["MAIN_ARRAY"] = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS.db")); ArticaWebFilter(); ArticaUfdb(); @mkdir("/usr/share/artica-postfix/ressources/logs", 0755, true); @unlink($pidTime); @file_put_contents($pidTime, serialize($GLOBALS["MAIN_ARRAY"])); if ($GLOBALS["VERBOSE"]) { echo "Saving {$pidTime}\n"; } @chmod($pidTime, 0755); }
function parse() { $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.time"; $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.pid"; $GLOBALS["LogFileDeamonLogDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/LogFileDeamonLogDir"); if ($GLOBALS["LogFileDeamonLogDir"] == null) { $GLOBALS["LogFileDeamonLogDir"] = "/home/artica/squid/realtime-events"; } $unix = new unix(); $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "{$pid} already executed since {$timepid}Mn\n"; } if ($timepid < 14) { return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } @file_put_contents($pidfile, getmypid()); $TimeExec = $unix->file_time_min($TimeFile); if (!$GLOBALS["FORCE"]) { if ($TimeExec < 20) { return; } } @unlink($TimeFile); @file_put_contents($TimeFile, time()); parsedb("/var/log/squid"); parsedb($GLOBALS["LogFileDeamonLogDir"]); }
function detect_kernels() { $unix = new unix(); if (!$GLOBALS["VERBOSE"]) { if (is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")) { if ($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst") < 360) { die; } } } $users = new usersMenus(); if ($users->LinuxDistriCode != "DEBIAN" && $users->LinuxDistriCode != "UBUNTU") { die; } $unix = new unix(); $apt_cache = $unix->find_program("apt-cache"); if ($apt_cache == null) { echo "Could not find apt-cache\n"; die; } if (system_is_overloaded(basename(__FILE__))) { $unix->send_email_events("apt-cache aborted, system is overloaded..", "will restart analyzis in next cycle", "system"); die; } echo "{$apt_cache} search linux-image\n"; exec("{$apt_cache} search linux-image", $results); while (list($num, $val) = each($results)) { if (preg_match("#linux-image-([0-9\\.]+)-([0-9]+)-(.+?)\\s+-\\s+(.+?)\$#", $val, $re)) { $array["DPKG"][] = array("VERSION" => $re[1], "BUILD" => $re[2], "ARCH" => $re[3], "INFOS" => $re[4], "PACKAGE" => "linux-image-{$re[1]}-{$re[2]}-{$re[3]}", "FULL_VERSION" => "{$re[1]}-{$re[2]}-{$re[3]}"); } } $array["INFOS"] = CpuFamilyInfos(); @file_put_contents("/usr/share/artica-postfix/ressources/logs/kernel.lst", base64_encode(serialize($array))); }
function xstart() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { return; } $TimeExec = $unix->file_time_min($pidtime); if ($TimeExec < 360) { return; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); $php5 = $unix->LOCATE_PHP5_BIN(); $q = new mysql_squid_builder(); $q->CreateCategoryUrisTable("malware"); $COUNT1 = $q->COUNT_ROWS("categoryuris_malware"); vxvault(); malwareurls_joxeankoret(); clean_mx_de(); $COUNT2 = $q->COUNT_ROWS("categoryuris_malware"); $URLS_ADDED = $COUNT2 - $COUNT1; if ($URLS_ADDED > 0) { system("{$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category malware"); squid_admin_mysql(2, "{$URLS_ADDED} malware URLs added", null, __FILE__, __LINE__); } }
function xstart() { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $pid = @file_get_contents($pidfile); if ($GLOBALS["VERBOSE"]) { echo "{$pidtime}\n"; } $unix = new unix(); $squid = $unix->LOCATE_SQUID_BIN(); if (!$GLOBALS["FORCE"]) { if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid} since {$time}mn\n"; } die; } } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); $timefile = $unix->file_time_min($pidtime); if ($GLOBALS["VERBOSE"]) { echo "Timelock:{$pidtime} {$timefile} Mn\n"; } if (!$GLOBALS["FORCE"]) { if ($timefile < 5) { if ($GLOBALS["VERBOSE"]) { echo "{$timefile}mn require 5mn\n"; } return; } } @unlink($pidtime); @file_put_contents($pidtime, time()); if (!is_file("/home/ufdb/smtp-events/ACCESS_LOG")) { if ($GLOBALS["VERBOSE"]) { echo "/home/ufdb/smtp-events/ACCESS_LOG no such file\n"; } } $array = explode("\n", @file_get_contents("/home/ufdb/smtp-events/ACCESS_LOG")); @unlink("/home/ufdb/smtp-events/ACCESS_LOG"); $body = array(); $mmstp = new ufdb_msmtp(); $Subject = count($array) . " Web filtering blocked event(s)"; $body[] = "Return-Path: <{$mmstp->smtp_sender}>"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$mmstp->smtp_sender}"; $body[] = "Subject: {$Subject}"; $body[] = "To: {$mmstp->recipient}"; $body[] = ""; $body[] = ""; $body[] = @implode("\r\n", $array); $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$mmstp->Send($finalbody)) { squid_admin_mysql(0, "Unable to send notification {$Subject} to {$mmstp->recipient}", "{$Subject} to {$mmstp->recipient}\n------------------\n" . @implode("\n", $array) . "\n\t\tThe following error encountered\n" . $mmstp->logs . "\n", __FILE__, __LINE__); } }
function ParseAllcontacts() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid)) { return; } @file_put_contents($pidfile, getmypid()); if ($unix->file_time_min($pidtime) < 120) { return; } @file_put_contents($pidtime, time()); $ldap = new clladp(); $suffix = $ldap->suffix; $arr = array("uid"); $sr = @ldap_search($ldap->ldap_connection, "dc=organizations,{$suffix}", '(objectclass=userAccount)', $arr); if ($sr) { $hash = ldap_get_entries($ldap->ldap_connection, $sr); for ($i = 0; $i < $hash["count"]; $i++) { ParseContacts($hash[$i]["uid"][0]); if (system_is_overloaded(dirname(__FILE__))) { $unix->send_email_events(basename(__FILE__) . " Overloaded aborting task", "Zarafa contacts importation has been canceled due to overloaded system", "mailbox"); return; } sleep(1); } } }
function visited_sites_by_cron() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/squid.visited_sites_by_cron.pid"; $TimeFile = "/etc/artica-postfix/settings/Daemons/exec.squid.visited.sites.php.time"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } $t = time(); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid} since {$time}mn\n"; } die; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); $TimeExec = $unix->file_time_min($TimeFile); if ($TimeExec < 240) { return; } visited_sites(true, true); }
function start_parse() { if ($GLOBALS["VERBOSE"]) { "echo Loading...\n"; } $unix = new unix(); if ($GLOBALS["VERBOSE"]) { "echo Loading done...\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".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; } $timeexec = $unix->file_time_min($timefile); if ($timeexec < 10) { return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } @unlink($timefile); @file_put_contents($timefile, time()); $ldap = new clladp(); if (!$ldap->IsKerbAuth()) { return; } $q = new mysql_squid_builder(); $sql = "SELECT ID,GroupName FROM webfilters_sqgroups WHERE `enabled`=1 AND `GroupType`='proxy_auth_statad'"; $results = $q->QUERY_SQL($sql); $REFRESH = false; $Count = mysql_num_rows($results); $UPDATED = array(); while ($ligne = mysql_fetch_assoc($results)) { if (parse_object($ligne["ID"], $ligne["GroupName"])) { $UPDATED[] = $ligne["GroupName"]; $REFRESH = true; } } if ($REFRESH) { squid_admin_mysql(1, "Reloading proxy service after updating " . count($UPDATED) . " Active Directory group(s)", @implode("\n", $UPDATED), __FILE__, __LINE__); $squid = $unix->LOCATE_SQUID_BIN(); system("/etc/init.d/squid reload --force --script=exec.squid.static.ad.groups.php/" . __LINE__); $sock = new sockets(); $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27")); if ($EnableTransparent27 == 1) { system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__)); } } }
function importActivedirectoryusers() { $sock = new sockets(); $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth"); if (!is_numeric($EnableKerbAuth)) { $EnableKerbAuth = 0; } if ($EnableKerbAuth == 0) { return; } $unix = new unix(); $user = new settings_inc(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { WriteMyLogs("Process {$pid} already exists", __FUNCTION__, __FILE__, __LINE__); return; } if (system_is_overloaded(basename(__FILE__))) { WriteMyLogs("Overloaded system, aborting", __FUNCTION__, __FILE__, __LINE__); return; } @file_put_contents($pidfile, getmypid()); $TImeStamp = $unix->file_time_min($pidTime); if (!$GLOBALS["FORCE"]) { if ($TImeStamp < 20) { WriteMyLogs("Need 20mn, current={$TImeStamp}Mn executed by:{$GLOBALS["EXECUTOR"]} Params:{$GLOBALS["PARAMS"]}", __FUNCTION__, __FILE__, __LINE__); return; } } @unlink($pidTime); @file_put_contents($pidTime, time()); $netbin = $unix->LOCATE_NET_BIN_PATH(); $usermod = $unix->find_program("usermod"); $chmod = $unix->find_program("chmod"); if (!is_file($netbin)) { WriteMyLogs("net no such binary, aborting", __FUNCTION__, __FILE__, __LINE__); return; } if (is_dir("/var/run/samba/winbindd_privileged")) { shell_exec("{$usermod} -G winbindd_priv squid >/dev/null 2>&1"); shell_exec("{$chmod} 0750 /var/run/samba/winbindd_privileged/ >/dev/null 2>&1"); } $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos"))); $domainUp = strtoupper($array["WINDOWS_DNS_SUFFIX"]); $domain_lower = strtolower($array["WINDOWS_DNS_SUFFIX"]); $adminpassword = $array["WINDOWS_SERVER_PASS"]; $adminpassword = $unix->shellEscapeChars($adminpassword); $adminname = $array["WINDOWS_SERVER_ADMIN"]; $ad_server = $array["WINDOWS_SERVER_NETBIOSNAME"]; $GLOBALS["AUTHCMD"] = " -U {$adminname}%{$adminpassword}"; getNetInfos(); if (!isset($GLOBALS["LDAP_HOST"])) { WriteMyLogs("Unable to get ldap infos, aborting", __FUNCTION__, __FILE__, __LINE__); return; } GetUsersArray(); }
function start() { $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $unix = new unix(); $pid = $unix->get_pid_from_file($pidFile); if ($unix->process_exists($pid)) { return; } @file_put_contents($pidFile, getmypid()); $time = $unix->file_time_min($pidtime); if ($time < 5) { return; } @file_put_contents($pidtime, time()); $free = $unix->find_program("free"); $echo = $unix->find_program("echo"); $sync = $unix->find_program("sync"); $swapoff = $unix->find_program("swapoff"); $swapon = $unix->find_program("swapon"); exec("{$free} 2>&1", $results); $used = 0; $total = 0; while (list($num, $ligne) = each($results)) { if (preg_match("#Swap:\\s+([0-9]+)\\s+([0-9]+)\\s+([0-9]+)#", $ligne, $re)) { $total = $re[1]; $used = $re[2]; } } if (!is_numeric($total)) { return; } if ($total == 0) { return; } if ($used == 0) { return; } if ($total == $used) { return; } $tot1 = $used / $total; $tot1 = $tot1 * 100; if ($GLOBALS["VERBOSE"]) { echo "Swap:{$used}/{$total} - {$tot1}\n"; } $perc = round($tot1); if ($GLOBALS["VERBOSE"]) { echo "Swap:{$used}/{$total} {$perc}%\n"; } $t = time(); $GLOBALS["ALL_SCORES"]++; shell_exec("{$swapoff} -a && {$swapon} -a"); $usedTXT = FormatBytes($used); $report = $unix->ps_mem_report(); $distance = $unix->distanceOfTimeInWords($t, time(), true); squid_admin_mysql(0, "System swap exceed rule: {$perc}%", "Used {$usedTXT}\nSystem cache was flushed took {$distance}\nThis means you did have enough memory for this computer.\n{$report}", __FILE__, __LINE__); }
function BuildDHCP($nopid = false) { $LOGBIN = "DHCP Server"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $unix = new unix(); if (!$nopid) { if (!$GLOBALS["FORCE"]) { if ($unix->file_time_min($timefile) < 2) { if ($GLOBALS["VERBOSE"]) { echo "{$timefile} -> is less than 2mn\n"; } return; } } } build_progress("{starting_service}", 65); $ldap = new clladp(); if ($ldap->ldapFailed) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} ldap connection failed,aborting\n"; return; } if (!$ldap->ExistsDN("dc=organizations,{$ldap->suffix}")) { echo "Starting......: " . date("H:i:s") . " DHCP SERVER dc=organizations,{$ldap->suffix} no such branch, aborting\n"; return; } echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} ldap connection success\n"; $dhcpd = new dhcpd(); $conf = $dhcpd->BuildConf(); $confpath = dhcp3Config(); $unix = new unix(); @mkdir(dirname($confpath), null, true); @file_put_contents($confpath, $conf); echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n"; if (!$unix->UnixUserExists("dhcpd")) { $unix->CreateUnixUser("dhcpd", "dhcpd"); } if (!is_dir("/var/lib/dhcp3")) { @mkdir("/var/lib/dhcp3", 0755, true); } $unix->chown_func("dhcpd", "dhcpd", "/var/lib/dhcp3/*"); $unix->chmod_func(0755, "/var/lib/dhcp3"); $complain = $unix->find_program("aa-complain"); if (is_file($complain)) { $dhcpd3 = $unix->DHCPD_BIN_PATH(); if (is_file($dhcpd3)) { shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1"); } } @unlink($timefile); @file_put_contents($timefile, time()); build_progress("{starting_service}", 70); $sock = new sockets(); $sock->getFrameWork("dnsmasq.php?restart=yes"); $sock->getFrameWork("services.php?restart-monit=yes"); $sock->getFrameWork("cmd.php?restart-artica-status=yes"); }
function scan_stored_items($nopid = true) { $sock = new sockets(); $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); if ($SquidPerformance < 3) { die; } $unix = new unix(); 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__ . " --scan"); } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; 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; } } $TimePid = $unix->file_time_min($pidTime); if ($TimePid < 1440) { ufdbguard_admin_events("Task cannot be used less than 14h currently ({$TimePid}Mn)", __FUNCTION__, __FILE__, __LINE__, "proxy"); return; } if (ScanPurgeexc()) { ufdbguard_admin_events("Already Executed...", __FUNCTION__, __FILE__, __LINE__, "proxy"); return; } @unlink($pidTime); @file_put_contents($pidTime, time()); $mypid = getmypid(); @file_put_contents($pidfile, $mypid); $purge = $unix->find_program("purge"); if (strlen($purge) < 5) { ufdbguard_admin_events("purge no such file, aborting task", __FUNCTION__, __FILE__, __LINE__, "proxy"); return; } $nice = EXEC_NICE(); $cmd = "{$nice}{$purge} -c /etc/squid3/squid.conf -e \".\" -P 0 -n >/var/cache/purge.calculated.db 2>&1"; if ($GLOBALS["VERBOSE"]) { echo $cmd . "\n"; } $t1 = time(); system(trim($cmd)); $took = $unix->distanceOfTimeInWords($t1, time()); if ($GLOBALS["VERBOSE"]) { echo "done {$took}\n"; } squid_admin_mysql(2, "Stored items: Extracting items information from cache done took:{$took}", null, __FILE__, __LINE__, "proxy"); inject_stored_items(true); }
function ScanFoldders() { $sock = new sockets(); $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = file_get_contents("{$pidfile}"); if ($GLOBALS["VERBOSE"]) { echo "{$timefile}\n"; } if (system_is_overloaded(basename(__FILE__))) { die; } if ($unix->process_exists($pid, basename(__FILE__))) { $timeMin = $unix->PROCCESS_TIME_MIN($pid); if ($timeMin > 240) { system_admin_events("Too many TTL, {$pid} will be killed", __FUNCTION__, __FILE__, __LINE__, "logrotate"); $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } else { die; } } if (!$GLOBALS["FORCE"]) { $TimeExec = $unix->file_time_min($timefile); if ($TimeExec < 240) { return; } } @unlink($timefile); @file_put_contents($timefile, time()); $LogRotatePath = $sock->GET_INFO("LogRotatePath"); $SystemLogsPath = $sock->GET_INFO("SystemLogsPath"); $BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir"); $maillogStoragePath = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/maillogStoragePath")); if ($GLOBALS["VERBOSE"]) { echo "Starting Main\n"; } $q = new mysql(); $q->QUERY_SQL("DROP TABLE `sysstorestatus`", "artica_events"); $sql = "CREATE TABLE IF NOT EXISTS `sysstorestatus` (\n\t\t\t `filepath` VARCHAR(255) NOT NULL,\n\t\t\t `filesize` BIGINT UNSIGNED NOT NULL,\n\t\t\t `zDate` DATETIME,\n\t\t\t PRIMARY KEY (`filepath`),\n\t\t\t KEY `zDate` (`zDate`),\n\t\t\t KEY `filesize` (`filesize`)\n\t\t\n\t\t\t)"; $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { echo $q->mysql_error; return; } ScanThis("/home/postfix/maillog"); ScanThis("/home/logrotate"); ScanThis("/home/logrotate_backup"); ScanThis("/home/logs-backup"); ScanThis("/home/backup/postfix"); ScanThis($LogRotatePath); ScanThis($SystemLogsPath); ScanThis($maillogStoragePath); }
function sigtool() { $unix = new unix(); $sigtool = $unix->find_program("sigtool"); if (strlen($sigtool) < 5) { die; } if (is_file("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases")) { $ttim = $unix->file_time_min("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases"); if ($ttim < 30) { return; } } $baseDir = "/var/lib/clamav"; $patnz = $unix->DirFiles($baseDir, "\\.(cvd|cld|hdb|ign2|ndb)\$"); while (list($path, $none) = each($patnz)) { $patterns[basename($path)] = true; } while (list($pattern, $none) = each($patterns)) { if (!is_file("{$baseDir}/{$pattern}")) { continue; } $results = array(); exec("{$sigtool} --info={$baseDir}/{$pattern} 2>&1", $results); while (list($index, $line) = each($results)) { if (preg_match("#Build time:\\s+(.+)#", $line, $re)) { $time = strtotime($re[1]); $MAIN[$pattern]["zDate"] = date("Y-m-d H:i:s"); continue; } if (preg_match("#Version:\\s+([0-9]+)#", $line, $re)) { $MAIN[$pattern]["version"] = $re[1]; continue; } if (preg_match("#Signatures:\\s+([0-9]+)#", $line, $re)) { $MAIN[$pattern]["signatures"] = $re[1]; continue; } } if (!isset($MAIN[$pattern]["zDate"])) { $time = filemtime("{$baseDir}/{$pattern}"); $MAIN[$pattern]["zDate"] = date("Y-m-d H:i:s", $time); if (!isset($MAIN[$pattern]["version"])) { $MAIN[$pattern]["version"] = date("YmdHi", $time); } } if (!isset($MAIN[$pattern]["signatures"])) { $MAIN[$pattern]["signatures"] = $unix->COUNT_LINES_OF_FILE("{$baseDir}/{$pattern}"); } } if (count($MAIN) == 0) { return; } @file_put_contents("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases", serialize($MAIN)); }
function update() { if (system_is_overloaded()) { return; } $unix = new unix(); $sock = new sockets(); $pidfile = "/etc/artica-postfix/pids/exec.ipblock.php.update.pid"; $pidtime = "/etc/artica-postfix/pids/exec.ipblock.php.update.time"; $pid = @file_get_contents($pidfile); if (!$GLOBALS["FORCE"]) { if ($unix->process_exists($pid)) { echo "Already running pid {$pid}\n"; return; } } include_once dirname(__FILE__) . '/ressources/class.ccurl.inc'; if (!is_file($pidtime)) { @file_put_contents($pidtime, time()); } if (!$GLOBALS["FORCE"]) { if ($unix->file_time_min($pidtime) > 720) { @unlink($pidtime); @file_put_contents($pidtime, time()); return; } } @file_put_contents($pidfile, getmypid()); $EnableIpBlocks = intval($sock->GET_INFO("EnableIpBlocks")); if ($EnableIpBlocks == 0) { return; } $DIR_TEMP = $unix->TEMP_DIR(); $curl = new ccurl("http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz"); if (!$curl->GetFile("{$DIR_TEMP}/all-zones.tar.gz")) { system_admin_events(0, "Fatal, Unable to download all-zones.tar.gz from ipdeny.com", __FILE__, __LINE__); return; } $OldMd5 = $sock->GET_INFO("IpBlocksMD5"); $md5File = md5_file("{$DIR_TEMP}/all-zones.tar.gz"); if ($md5File == $OldMd5) { ipblocks(); return; } $tar = $unix->find_program("tar"); @mkdir("/home/artica/ipblocks", 0755, true); shell_exec("{$tar} xf {$DIR_TEMP}/all-zones.tar.gz -C /home/artica/ipblocks/"); if (ipblocks()) { $sock->SET_INFO("IpBlocksMD5", "{$md5File}"); system_admin_events(0, "Restarting Firewall in order to refresh countries blocking"); } }
function scan() { if (system_is_overloaded(basename(__FILE__))) { apache_admin_mysql(0, "Overloaded system, retry next time....", null, __FILE__, __LINE__); return; } $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $unix = new unix(); $pid = $unix->get_pid_from_file($pidFile); if ($unix->process_exists($pid)) { events("A process, {$pid} Already exists..."); return; } $GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g(); @file_put_contents($pidFile, getmypid()); $time = $unix->file_time_min($pidtime); if (!$GLOBALS["VERBOSE"]) { if ($time < 5) { events("{$time}mn, require minimal 5mn"); return; } } $q = new mysql_squid_builder(); $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_apache_sizes` ( `TIME` DATETIME,\n\t\t\t`zmd5` VARCHAR(90) NOT NULL PRIMARY KEY,\n\t\t\t`SITENAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED, `RQS` BIGINT UNSIGNED,\n\t\t\tKEY `TIME` (`TIME`),\n\t\t\tKEY `SIZE` (`SIZE`),\n\t\t\tKEY `RQS` (`RQS`)\n\t\t\t) ENGINE=MYISAM;"); if (!$q->ok) { apache_admin_mysql(0, "Fatal MySQL error", $q->mysql_error, __FILE__, __LINE__); return; } if (!is_file("/home/apache/artica-stats/requests.log")) { echo "/home/apache/artica-stats/requests.log no such file...\n"; return; } @mkdir("/home/apache/artica-stats/works", 0755, true); if (is_file("/home/apache/artica-stats/works/apache.log")) { echo "Parse /home/apache/artica-stats/works/apache.log\n"; Parse("/home/apache/artica-stats/works/apache.log"); return; } if (!@copy("/home/apache/artica-stats/requests.log", "/home/apache/artica-stats/works/apache.log")) { echo "Copy failed\n"; return; } if (!is_file("/home/apache/artica-stats/works/apache.log")) { echo "/home/apache/artica-stats/works/apache.log no such file...\n"; return; } @unlink("/home/apache/artica-stats/requests.log"); echo "Parse /home/apache/artica-stats/works/apache.log\n"; Parse("/home/apache/artica-stats/works/apache.log"); CLEAN_MYSQL(); }
function parse() { $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.time"; $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.quota-week.parser.php.pid"; $unix = new unix(); $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "{$pid} already executed since {$timepid}Mn\n"; } if ($timepid < 14) { return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } @file_put_contents($pidfile, getmypid()); $sock = new sockets(); $SquidPerformance = intval($sock->GET_INFO("SquidPerformance")); $time = $unix->file_time_min($TimeFile); if (!$GLOBALS["FORCE"]) { if ($time < 1440) { return; } } @unlink($TimeFile); @file_put_contents($TimeFile, time()); $f = $unix->DirFiles("/var/log/squid", "[0-9]+_QUOTASIZE\\.db"); $export_path = "/home/artica/squid/dbExport"; @mkdir($export_path, 0755, true); while (list($filename, $none) = each($f)) { preg_match("#([0-9]+)_#", $filename, $re); $xdate = $re[1]; echo "{$filename} ( {$xdate} )\n"; if ($SquidPerformance > 1) { if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) { continue; } @unlink("/var/log/squid/{$filename}"); continue; } if (!parse_file("/var/log/squid/{$filename}", $xdate)) { continue; } if (!@copy("/var/log/squid/{$filename}", "{$export_path}/{$filename}")) { continue; } @unlink("/var/log/squid/{$filename}"); } }
function hourly() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "time: {$timefile}\n"; } $pid = @file_get_contents($pidfile); if (!$GLOBALS["VERBOSE"]) { if (!$GLOBALS["FORCE"]) { if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } if ($pid < 100) { $pid = null; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } } $timex = $unix->file_time_min($timefile); if ($timex < 60) { return; } @unlink($timefile); @file_put_contents($timefile, time()); $q = new mysql(); $LIST_TABLES_CURL_HOUR = $q->LIST_TABLES_CURL_HOUR(); $HourTable = date("YmdH"); $currenttable = "{$HourTable}_curl"; while (list($tablenameH, $timex) = each($LIST_TABLES_CURL_HOUR)) { if ($tablenameH == $currenttable) { continue; } CompressTableDay($tablenameH, $timex); } $DayTable = date("Ymd"); $currenttable = "{$DayTable}_curl"; $LIST_TABLES_CURL_DAY = $q->LIST_TABLES_CURL_DAY(); while (list($tablenameH, $timex) = each($LIST_TABLES_CURL_HOUR)) { if ($tablenameH == $currenttable) { continue; } CompressTableMonth($tablenameH, $timex); } }
function postfix_hours() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid)) { $timepid = $unix->PROCCESS_TIME_MIN($pid); system_admin_events("Already PID {$pid} running since {$timepid}mn", __FUNCTION__, __FILE__, __LINE__, "postfix-stats"); return; } if (!$GLOBALS["VERBOSE"]) { $timeexec = $unix->file_time_min($timefile); if ($timeexec < 60) { return; } } @unlink($timefile); @file_put_contents($timefile, time()); $GLOBALS["Q"] = new mysql_postfix_builder(); $LIST_HOUR_TABLES = $GLOBALS["Q"]->LIST_HOUR_TABLES(); if (count($LIST_HOUR_TABLES) == 0) { return; } $currentHourTable = date("YmdH") . "_hour"; $MyTime = time(); while (list($tablesource, $time) = each($LIST_HOUR_TABLES)) { if ($currentHourTable == $tablesource) { continue; } $xtime = strtotime($time); if ($xtime > $MyTime) { $GLOBALS["Q"]->QUERY_SQL("DROP TABLE `{$tablesource}`"); continue; } if ($GLOBALS["VERBOSE"]) { echo "{$tablesource}\t{$time}\n"; } if (_parse_hour_table($tablesource, $xtime)) { $GLOBALS["Q"]->DUMP_TABLE($tablesource); $GLOBALS["Q"]->QUERY_SQL("DROP TABLE `{$tablesource}`"); } else { if ($GLOBALS["VERBOSE"]) { echo "{$tablesource}\t{$time} FAILED\n"; } } } }
function install() { if (extension_loaded('snmp')) { return; } $unix = new unix(); $FileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; if ($unix->file_time_min($FileTime) < 15) { return; } @unlink($FileTime); @file_put_contents($FileTime, time()); $unix->DEBIAN_INSTALL_PACKAGE("php5-snmp"); system("/etc/init.d/artica-webconsole restart"); system("/etc/init.d/artica-status restart"); }
function xfiledesc() { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $unix = new unix(); $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { squid_admin_mysql(0, "Cannot change file descriptors (PID {$pid} already executed)", null, __FILE__, __LINE__); die; } @file_put_contents($pidfile, getmypid()); $TimePid = $unix->file_time_min($pidTime); if ($TimePid < 5) { squid_admin_mysql(0, "Cannot change file descriptors ( require 5mn, current {$TimePid}mn)", null, __FILE__, __LINE__); die; } @unlink($pidTime); @file_put_contents($pidTime, time()); $squid = new squidbee(); $sock = new sockets(); $sysctl = $unix->find_program("sysctl"); $t = time(); if (!is_numeric($squid->max_filedesc)) { $squid->max_filedesc = 8192; } exec("{$sysctl} -n fs.file-max", $results); $file_max = intval(trim(@implode("", $results))); $file_max_org = $file_max; $max_filedesc = intval($squid->max_filedesc); if ($max_filedesc == 0) { $max_filedesc = 8192; } $new_max_filedesc = $max_filedesc + 1000; echo "Current System: {$file_max}, Proxy {$max_filedesc}\n"; if ($new_max_filedesc > $file_max - 100) { $file_max = $file_max + 1000; shell_exec("{$sysctl} -w fs.file-max={$file_max}"); $unix->sysctl("fs.file-max", $file_max); } $squid->max_filedesc = $new_max_filedesc; $squid->SaveToLdap(true); $php = $unix->LOCATE_PHP5_BIN(); shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force"); squid_admin_mysql(0, "Restarting Proxy service to increase file descriptors from {$max_filedesc}/{$file_max_org} to {$new_max_filedesc}/{$file_max}", null, __FILE__, __LINE__); shell_exec("/etc/init.d/squid restart --force"); }
function start_parse() { if ($GLOBALS["VERBOSE"]) { "echo Loading...\n"; } $unix = new unix(); if ($GLOBALS["VERBOSE"]) { "echo Loading done...\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/exec.stats-appliance-clean.php.start_parse.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; } $timeexec = $unix->file_time_min($timefile); if ($timeexec < 60) { return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } @unlink($timefile); @file_put_contents($timefile, time()); $q = new mysql_squid_builder(); $time = date("YmdH"); $currentTable = "{$time}_statsuapp"; $LIST_TABLES_STATS_UAPP = $q->LIST_TABLES_STATS_UAPP(); while (list($tablename, $arrayF) = each($LIST_TABLES_STATS_UAPP)) { if ($currentTable == $tablename) { continue; } if (parseToMonth($tablename)) { $q->QUERY_SQL("DROP TABLE `{$tablename}`"); } } }
function pgsql() { if (extension_loaded('pgsql')) { return; } $unix = new unix(); $FileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; if ($unix->file_time_min($FileTime) < 15) { return; } @unlink($FileTime); @file_put_contents($FileTime, time()); squid_admin_mysql(1, "Installing missing package php5-pgsql", null, __FILE__, __LINE__); $unix->DEBIAN_INSTALL_PACKAGE("php5-pgsql"); system("/usr/share/artica-postfix/exec.php.ini.php"); system("/etc/init.d/artica-webconsole restart"); system("/etc/init.d/artica-status restart"); }
function parse_days() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if (!$GLOBALS["VERBOSE"]) { if ($unix->file_time_min($pidTime) < 1440) { return; } } $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); return; } @file_put_contents($pidfile, getmypid()); @unlink($pidTime); @file_put_contents($pidTime, time()); $sock = new sockets(); $EnableNginxStats = $sock->GET_INFO("EnableNginxStats"); if (!is_numeric($EnableNginxStats)) { $EnableNginxStats = 0; } if ($EnableNginxStats == 0) { return; } if (system_is_overloaded(basename(__FILE__))) { events("Overloaded system: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} aborting", __FUNCTION__, __LINE__); return; } $FALSES["information_schema"] = true; $FALSES["mysql"] = true; $q = new nginx_stats(); $DATABASE_LIST_SIMPLE = $q->DATABASE_LIST_SIMPLE(); while (list($db, $b) = each($DATABASE_LIST_SIMPLE)) { if (isset($FALSES[$db])) { continue; } if ($GLOBALS["VERBOSE"]) { echo "Parsing database {$db}\n"; } parse_database($db); } }
function detect_kernels(){ $unix=new unix(); if(!$GLOBALS["VERBOSE"]){ if(is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")){ if($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst")<360){die();} }} $users=new usersMenus(); if(($users->LinuxDistriCode<>"DEBIAN") && ($users->LinuxDistriCode<>"UBUNTU")){die();} $unix=new unix(); $apt_cache=$unix->find_program("apt-cache"); if($apt_cache==null){ echo "Could not find apt-cache\n"; die(); } echo "$apt_cache search linux-image\n"; exec("$apt_cache search linux-image",$results); while (list ($num, $val) = each ($results) ){ if(preg_match("#linux-image-([0-9\.]+)-([0-9]+)-(.+?)\s+-\s+(.+?)$#",$val,$re)){ $array["DPKG"][]=array("VERSION"=>$re[1],"BUILD"=>$re[2],"ARCH"=>$re[3],"INFOS"=>$re[4], "PACKAGE"=>"linux-image-{$re[1]}-{$re[2]}-{$re[3]}", "FULL_VERSION"=>"{$re[1]}-{$re[2]}-{$re[3]}" ); } } $array["INFOS"]=CpuFamilyInfos(); @file_put_contents("/usr/share/artica-postfix/ressources/logs/kernel.lst",base64_encode(serialize($array))); }
function start() { // /etc/artica-postfix/pids/exec.loadavg.php.start.time $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pidfileTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { echo "{$pidfileTime}\n"; } if (!$GLOBALS["VERBOSE"]) { if ($unix->file_time_min($pidfileTime) < 59) { return; } } $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } if ($unix->process_exists($pid, basename(__FILE__))) { $timepid = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "{$pid} already executed since {$timepid}Mn\n"; } if ($timepid < 15) { return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } @file_put_contents($pidfile, getmypid()); if (system_is_overloaded()) { if ($GLOBALS["VERBOSE"]) { echo "Overloaded\n"; } die; } @unlink($pidfileTime); @file_put_contents($pidfileTime, time()); if ($GLOBALS["VERBOSE"]) { echo "cpustats\n"; } cpustats(); }
function install() { $unix = new unix(); $timefile = "/etc/artica-postfix/pids/" . __FILE__ . ".time"; if ($unix->file_time_min($timefile) < 240) { return; } @unlink($timefile); @file_put_contents($timefile, time()); $bin = $unix->find_program("fail2ban-server"); if (!is_file($bin)) { $unix->DEBIAN_INSTALL_PACKAGE("fail2ban"); } $bin = $unix->find_program("fail2ban-server"); $fail2ban = new fail2ban(); if (is_file($bin)) { $fail2ban->buildinit(); build(); } }