function review() { $id = (int) $_GET['user']; $q = mysql_query("select * from users where id='{$id}' "); $w = mysql_fetch_array($q); echo '<h2 class="ui header"> <i class="user icon"></i> <div class="content">'; echo $w['name'] . " " . $w['surname']; echo '</div></h2>'; echo '<h5 class="ui top attached header"> Etkinlikler </h5>'; $eventQuery = mysql_query("select * from events where uid='{$id}'"); while ($w = mysql_fetch_array($eventQuery)) { if ($w['event'] == 4 || $w['event'] == 6) { $icon = events($w['event'])[$w['state']]['icon']; $desc = events($w['event'])[$w['state']]['desc']; } else { $icon = events($w['event'])['icon']; $desc = events($w['event'])['desc']; } $pos = $w['videoPosition']; echo "<div class='ui attached segment'>\n\t\t\t<i class=' {$icon} icon'></i>\n\t\t\t{$desc} <b>[ {$pos} ]</b>\n\t\t\t<span style='float:right'>" . $w['clock'] . "</span>\n\t\t</div>"; echo "<div class='aciklama'>\n\t\t\t\n\t\t\t<table class='ui definition table'>\n\t\t\t <tbody>\n\t\t\t <tr>\n\t\t\t <td class='two wide column'>Size</td>\n\t\t\t <td>1 x 2</td>\n\t\t\t </tr>\n\t\t\t <tr>\n\t\t\t <td>Weight</td>\n\t\t\t <td>6 ounces</td>\n\t\t\t </tr>\n\t\t\t <tr>\n\t\t\t <td>Color</td>\n\t\t\t <td>Yellowish</td>\n\t\t\t </tr>\n\t\t\t <tr>\n\t\t\t <td>Odor</td>\n\t\t\t <td>Not Much Usually</td>\n\t\t\t </tr>\n\t\t\t </tbody>\n\t\t\t </table>\n\n\t\t</div>"; } echo '<div class="ui bottom attached warning message"> <i class="warning icon"></i> Başka bir işlem görünmüyor.. </div>'; }
function DirListsql($path) { $dir_handle = @opendir($path); if (!$dir_handle) { events("Unable to open \"{$path}\""); return array(); } $count = 0; while ($file = readdir($dir_handle)) { if ($file == '.') { continue; } if ($file == '..') { continue; } if (!is_file("{$path}/{$file}")) { continue; } if (!preg_match("#\\.sql\$#", $file)) { continue; } $array[$file] = $file; } if (!is_array($array)) { return array(); } @closedir($dir_handle); return $array; }
function start() { $events = events(1); $html = "\n\t<H1>{APP_PUREFTPD} {events}</H1>\n\t<div id='showevents' style='width:100%;height:250px;overflow:auto'>\n\t\t{$events}\n\t</div>\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
function popup() { $tpl = new templates(); $logs = events(); $html = "\n\t<H1>{APP_DHCP_EVENTS}</H1>\n\t" . RoundedLightWhite("\n\t<div style='width:100%;height:350px;overflow:auto' id='DHCPDL'>{$logs}</div>"); echo $tpl->_ENGINE_parse_body($html); }
function afficherPageAdminGE() { require './Modele/admins.php'; verifAdmin($db); require './Modele/evenements.php'; require_once './Modele/utilisateurs.php'; $events = events($db); include "./Vue/Admin/gestionEvent.php"; }
function Parseline($buffer) { $buffer = trim($buffer); if ($buffer == null) { return null; } if (strpos($buffer, "init urllist") > 0) { return; } if (strpos($buffer, "init expressionlist") > 0) { return; } if (strpos($buffer, "init domainlist") > 0) { return; } if (preg_match('#INFO: loading dbfile (.+)#', $buffer, $re)) { events("LOADING {$re['1']}"); $GLOBALS[__FILE__]["DBFILE"] = trim($re[1]); return null; } if (preg_match("#FATAL: Error db_open: Unknown error#", $buffer, $re)) { events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]} : {$buffer}"); if (basename($GLOBALS[__FILE__]["DBFILE"]) == "urls.db") { events("urls.db -> create " . dirname($GLOBALS[__FILE__]["DBFILE"]) . "/urls it and recompile it"); @file_put_contents(dirname($GLOBALS[__FILE__]["DBFILE"]) . "/urls", "www." . md5(time()) . ".bv"); } $file = "/etc/artica-postfix/croned.1/squidguard." . md5($GLOBALS[__FILE__]["DBFILE"]) . ".error"; if (IfFileTime($file)) { $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &"; events("{$cmd}"); shell_exec($cmd); WriteFileCache($file); } return null; } if (preg_match("#\\]\\s+(.+?):\\s+Cannot allocate memory#", $buffer, $re)) { events("ERROR ON {$re[1]} : Cannot allocate memory -> create it"); @file_put_contents($re[1], "www." . md5(time()) . ".bv"); shell_exec("squid -k reconfigure"); return null; } if (preg_match("#\\]\\s+(.+?):\\s+No such file or directory#", $buffer, $re)) { events("ERROR ON {$re[1]} : No such file or directory -> create it"); @file_put_contents($re[1], "www.nodomain.bv"); shell_exec("squid -k reconfigure"); return null; } if (strpos($buffer, "ERROR: Going into emergency mode") > 0) { events("ERROR: Going into emergency mode"); send_email_events("squidguard: squidguard turn to emergency mode", "SquidGuard claim\n{$buffer}\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled", "proxy"); return; } events("Not filtered: {$buffer}"); }
function Parseline($buffer) { $buffer = trim($buffer); if ($buffer == null) { return null; } $auth = new auth_tail(); if ($auth->ParseLog($buffer)) { return; } events("Not Filtered \"{$buffer}\""); }
function reservation() { checkPerm('view'); require_once _base_ . '/lib/lib.tab.php'; require_once _base_ . '/lib/lib.urlmanager.php'; require_once _base_ . '/lib/lib.form.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $mod_perm = checkPerm('mod', true); $lang =& DoceboLanguage::createInstance('reservation'); $um =& UrlManager::getInstance("reservation"); $out = $GLOBALS['page']; $out->setWorkingZone('content'); $man_res = new Man_Reservation(); $tab_man = new TabView('reservation', ''); $tab_events = new TabElemDefault('events', $lang->def('_RESERVATION_EVENTS')); $tab_my_events = new TabElemDefault('my_events', $lang->def('_RESERVATION_MY_EVENTS')); $tab_past_event = new TabElemDefault('past_events', $lang->def('_RESERVATION_PAST_EVENTS')); if ($mod_perm) { $tab_subscribed_user = new TabElemDefault('subscribed_user', $lang->def('_RESERVATION_SUBSCRIBED_USER')); } $tab_man->addTab($tab_events); $tab_man->addTab($tab_my_events); $tab_man->addTab($tab_past_event); if ($mod_perm) { $tab_man->addTab($tab_subscribed_user); } $tab_man->parseInput($_POST, $_SESSION); $active_tab = $tab_man->getActiveTab(); if ($active_tab != 'events' && $active_tab != 'my_events' && $active_tab != 'past_events' && $active_tab != 'subscribed_user') { $active_tab = importVar('active_tab', false, 'events'); $tab_man->setActiveTab($active_tab); } $out->add(getTitleArea(Lang::t('_RESERVATION', 'reservation')) . '<div class="std_block">', 'content'); $out->add(Form::openForm('tab_reservation', 'index.php?modname=reservation&op=reservation&confirm=1&ap=mod_profile&from=2') . $tab_man->printTabView_Begin('', false), 'content'); switch ($active_tab) { case 'events': events(); break; case 'my_events': myEvents(); break; case 'past_events': pastEvents(); break; case 'subscribed_user': subscribedUser(); break; } $out->add($tab_man->printTabView_End() . Form::closeForm(), 'content'); $out->add('</div>', 'content'); }
function ParseLogsDir() { $d = 0; $h = 0; $sock = new sockets(); $workingDir = $sock->GET_INFO("SquidOldLogsDefaultDir"); if (!($handle = opendir($workingDir))) { @mkdir($workingDir, 0755, true); return; } $squidtail = new squid_tail(); while (false !== ($filename = readdir($handle))) { if ($filename == ".") { continue; } if ($filename == "..") { continue; } $targetFile = "{$workingDir}/{$filename}"; if (!is_file($targetFile)) { continue; } $d++; $h++; $c = 0; if ($d > 300) { if (systemMaxOverloaded()) { $array_load = sys_getloadavg(); $internal_load = $array_load[0]; events("ParseSquidLogBrutProcess()::{$workingDir}:: Overloaded: {$internal_load} system, break loop...", __LINE__); break; } $d = 0; } $handle = @fopen($targetFile, "r"); if (!$handle) { events("Failed to open file", __LINE__); continue; } while (!feof($handle)) { $c++; $buffer = trim(fgets($handle, 4096)); if (!$squidtail->parse_tail($buffer, null)) { continue; } } } }
function Builsql($uri, $ip, $virus) { $virus = str_replace("+", " ", $virus); $virus = trim($virus); $md5 = md5(time() . "{$uri},{$ip},{$virus}"); $ip = GetComputerName($ip); $sql = "INSERT INTO `antivirus_events` (`zDate`, `TaskName`, `email`, `VirusName`, `InfectedPath`, `ComputerName`, `zmd5`) \n\tVALUES (NOW(), 'HTTP Scan', 0, '{$virus}', '{$uri}', '{$ip}', '{$md5}')"; $q = new mysql(); $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { events($q->mysql_error); events($sql); return; } events("Virus {$virus} found from {$uri} to {$ip}"); }
/** * Remove one or all listeners from event. * * @param $event * @param callable $listener * @return bool */ function off($event, callable $listener = null) { if (!isset(events()->{$event})) { return; } if ($listener === null) { unset(events()->{$event}); } else { foreach (events()->{$event} as $priority => $listeners) { if (false !== ($index = array_search($listener, $listeners, true))) { unset(events()->{$event}[$priority][$index]); } } } return true; }
function checkdates($workfile) { $handle = @fopen($workfile, "r"); if (!$handle) { events("Fopen failed on {$workfile}"); return false; } while (!feof($handle)) { $buffer = trim(fgets($handle)); $t = explode(",", $buffer); if (intval($t[1]) < 100) { continue; } $IPAddr = $t[0]; $date = date("Y-m-d H:i:s", $t[1]); echo "{$IPAddr} : {$date}\n"; } }
function xstart() { $Directory = "/home/artica-postfix/squid/StatsApplicance/BEREKLEY"; if (!is_dir($Directory)) { return; } if (!($handle = opendir($Directory))) { return; } while (false !== ($fileZ = readdir($handle))) { if ($fileZ == ".") { continue; } if ($fileZ == "..") { continue; } $path = "{$Directory}/{$fileZ}"; $lockfile = "{$Directory}/{$fileZ}.LCK"; events("parse_stats(): Scanning {$path}"); $t1 = microtime_float(); if (preg_match("#^(.+?)-UserAuthDB\\.db#", $fileZ, $re)) { if (is_file($lockfile)) { continue; } @file_put_contents($lockfile, time()); parse_userauthdb($path, $re[1], true); events("{$fileZ} " . microtime_ms($t1)); @unlink($path); @unlink($lockfile); continue; } if (preg_match("#^(.+?)-[0-9]+_QUOTASIZE\\.db#", $fileZ, $re)) { if (is_file($lockfile)) { continue; } @file_put_contents($lockfile, time()); ParseDB_FILE($path, $re[1], true); events("{$fileZ} " . microtime_ms($t1)); @unlink($lockfile); @unlink($path); continue; } } }
function Parseline($buffer) { $buffer = trim($buffer); if ($buffer == null) { return null; } if (!preg_match("#^[0-9]+,\\s+\\[(.+?)]#", $buffer, $re)) { events("Not filtered: {$buffer}"); return; } $date = date("Y-m-d H:i:00"); $category = trim(strtolower($re[1])); if (!isset($GLOBALS["MAIN"][$date][$category])) { $GLOBALS["MAIN"][$date][$category] = 1; } else { $GLOBALS["MAIN"][$date][$category] = $GLOBALS["MAIN"][$date][$category] + 1; } if (count($GLOBALS["MAIN"]) > 2) { dump_main(); } }
/** * The only tests done here are for existence and validation. */ public function test01_Conveniences() { /* * Test each function twice - first for value then after caching */ $this->assertTrue(forge() instanceof Forge); $this->assertTrue(forge('ioc') instanceof IlluminateContainer); $this->assertTrue(config() instanceof Config); $this->assertTrue(config() instanceof Config); $this->assertTrue(path() instanceof Paths); $this->assertTrue(path() instanceof Paths); $this->assertTrue(events() instanceof Events); $this->assertTrue(events() instanceof Events); //$this->assertTrue(router() instanceof Router); //$this->assertTrue(router() instanceof Router); //$this->assertTrue(routing() instanceof Routing); //$this->assertTrue(routing() instanceof Routing); $test = function () { return "test"; }; $this->assertEquals("test", value($test)); }
function Parseline($buffer){ $buffer=trim($buffer); if($buffer==null){return null;} if(strpos($buffer,"init urllist")>0){return ;} if(strpos($buffer,"init expressionlist")>0){return ;} if(strpos($buffer,"init domainlist")>0){return ;} if(preg_match('#INFO: loading dbfile (.+)#',$buffer,$re)){ events("LOADING $re[1]"); $GLOBALS[__FILE__]["DBFILE"]=trim($re[1]); return null; } if(preg_match("#FATAL: Error db_open: Unknown error#",$buffer,$re)){ events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]}"); $file="/etc/artica-postfix/croned.1/squidguard.". md5($GLOBALS[__FILE__]["DBFILE"]).".error"; if(IfFileTime($file)){ shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &"); WriteFileCache($file); } return null; } if(strpos($buffer,"ERROR: Going into emergency mode")>0){ events("ERROR: Going into emergency mode"); send_email_events("squidguard: squidguard turn to emergency mode","SquidGuard claim\n$buffer\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled","proxy"); return ; } events("Not filtered: $buffer"); }
function restore($id, $target_resource, $db) { $sql = "SELECT * FROM dar_index where filekey='{$id}'"; $q = new mysql(); $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup')); $ressource = $ligne["mount_md5"]; $sourcefile = $ligne["filepath"]; if ($_GET["RESTORE_DIR"]) { $sourcefile = dirname($sourcefile); } $ini = new Bs_IniHandler("/tmp/restore.{$id}.ini"); $ini->set('INFO', "backup_resource", $ressource); $ini->set('INFO', "target_resource", $target_resource); $ini->set('INFO', "database", $db); $ini->set('INFO', "source_path", $sourcefile); $ini->saveFile("/tmp/restore.{$id}.ini"); $ini = new Bs_IniHandler(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini"); $ini->set("STATUS", "progress", 15); $ini->set("STATUS", "text", "{Executing}..."); $ini->saveFile(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini"); $cmd = "/usr/share/artica-postfix/bin/artica-backup --dar-restore-path /tmp/restore.{$id}.ini"; events($cmd); system($cmd); }
function GeoIPavailable() { if (!function_exists("geoip_db_filename")) { events('geoip_db_filename not available...'); return; } $cst = array('GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION, 'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0, 'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0, 'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION, 'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION, 'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1, 'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1, 'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION, 'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION, 'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION, 'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION); foreach ($cst as $k => $v) { events($k . ': ' . geoip_db_filename($v) . ' ' . (geoip_db_avail($v) ? 'Available' : '')); } }
function mailarchives() { if (!$GLOBALS["POSTFIX_INSTALLED"]) { return; } $array[] = "exec.mailarchive.php"; $array[] = "exec.mailbackup.php"; $array[] = "exec.fetchmail.sql.php"; while (list($index, $file) = each($array)) { if (system_is_overloaded()) { events(__FUNCTION__ . ":: die, overloaded"); die; } $cmd = "{$GLOBALS["PHP5"]} /usr/share/artica-postfix/{$file}"; events("schedule {$cmd}", __FUNCTION__, __LINE__); $GLOBALS["CMDS"][] = $cmd; } if ($GLOBALS["VERBOSE"]) { events(__FUNCTION__ . ":: die..."); } }
function scanarp() { $GLOBALS["CLASS_USERS"] = new usersMenus(); $GLOBALS["CLASS_SOCKETS"] = new sockets(); if (!$GLOBALS["CLASS_USERS"]->ARPD_INSTALLED) { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . " ARPD_INSTALLED = FALSE\n"; } return; } $EnableArpDaemon = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableArpDaemon"); if (!is_numeric($EnableArpDaemon)) { $EnableArpDaemon = 1; } if ($EnableArpDaemon == 0) { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . " EnableArpDaemon = {$EnableArpDaemon}\n"; } return; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $unix = new unix(); $me = basename(__FILE__); $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, $me)) { if ($GLOBALS["VERBOSE"]) { echo " {$pid} --> Already executed.. aborting the process\n"; } $time = $unix->PROCCESS_TIME_MIN($pid); system_admin_events("Already executed pid {$pid} since {$time}Mn.. aborting the process", __FUNCTION__, __FILE__, __LINE__, "system"); die; } @file_put_contents($pidfile, getmypid()); if (!is_file("/var/lib/arpd/arpd.db")) { die; } $GLOBALS["CLASS_UNIX"] = $unix; $GLOBALS["nmblookup"] = $unix->find_program("nmblookup"); $GLOBALS["arpd"] = $unix->find_program("arpd"); $GLOBALS["arp"] = $unix->find_program("arp"); $GLOBALS["ARP_DB"] = "/var/lib/arpd/arpd.db"; $GLOBALS["CACHE_DB"] = "/etc/artica-postfix/arpd.cache"; $GLOBALS["EnableMacAddressFilter"] = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableMacAddressFilter")); if (!is_numeric($GLOBALS["EnableMacAddressFilter"])) { $GLOBALS["EnableMacAddressFilter"] = 1; } $squidbin = $unix->LOCATE_SQUID_BIN(); if (is_file($squidbin)) { if ($GLOBALS["EnableMacAddressFilter"] == 0) { return; } } $ArpdArray = unserialize(base64_decode(@file_get_contents($GLOBALS["CACHE_DB"]))); if ($GLOBALS["FLUSH"]) { $ArpdArray = array(); } if (!is_array($ArpdArray)) { $ArpdArray = array(); } if (!isset($ArpdArray["LAST"])) { $ArpdArray["LAST"] = 0; } $last_modified = filemtime($GLOBALS["ARP_DB"]); $TimeArpd = $ArpdArray["LAST"]; if ($TimeArpd == $last_modified) { events("{$TimeArpd} -> {$last_modified} No modification time", __FUNCTION__, __LINE__); return; } events("Scanning ARP table....", __FUNCTION__, __LINE__); $ArpdArray["LAST"] = $last_modified; exec("{$GLOBALS["arpd"]} -l 2>&1", $results); events("{$GLOBALS["arpd"]} -l return " . count($results) . " element(s)", __FUNCTION__, __LINE__); while (list($num, $ligne) = each($results)) { if (preg_match("#unexpected file type or format#", $ligne)) { @unlink($GLOBALS["ARP_DB"]); @unlink($GLOBALS["CACHE_DB"]); shell_exec("/etc/init.d/arpd restart"); die; } if (!preg_match("#^[0-9]+\\s+\\s+(.+?)\\s+(.+)#", $ligne, $re)) { if ($GLOBALS["VERBOSE"]) { echo "line: {$num}, unexpected line..\n"; } continue; } if (preg_match("#FAILED:#", $re[2])) { continue; } $mac = $re[2]; $ipaddr = $re[1]; if ($GLOBALS["VERBOSE"]) { echo "line: {$num}, MAC:{$mac} -> {$ipaddr}\n"; } if (isset($ArpdArray["MACS"][$mac])) { if ($GLOBALS["VERBOSE"]) { echo "MAC:{$mac} Already cached, aborting....\n"; } continue; } $ArpdArray["MACS"][$mac] = true; $cmp = new computers(); $uid = $cmp->ComputerIDFromMAC($mac); if ($GLOBALS["VERBOSE"]) { echo "line: {$num}, MAC:{$mac} -> {$uid}\n"; } if ($uid == null) { $res2 = array(); $computer_name = null; events("It is time to add {$mac}/{$ipaddr} in database", __FUNCTION__, __LINE__); exec("{$GLOBALS["arp"]} -a {$ipaddr} 2>&1", $res2); if (preg_match("#^(.+?)\\s+\\(#", trim(@implode("", $res2)), $rz)) { $computer_name = $rz[1]; } if (strlen($computer_name) < 3) { $computer_name = $ipaddr; } $cmp->uid = "{$computer_name}\$"; $cmp->ComputerIP = $ipaddr; $cmp->ComputerMacAddress = $mac; system_admin_events("adding/editing {$computer_name} with MAC:{$mac}", __FUNCTION__, __FILE__, __LINE__, "network"); $cmp->Add(); } else { if ($GLOBALS["FLUSH"]) { $res2 = array(); $cmp = new computers($uid); $computer_name = null; events("It is time to edit {$uid}/{$mac}/{$ipaddr} in database", __FUNCTION__, __LINE__); exec("{$GLOBALS["arp"]} -a {$ipaddr} 2>&1", $res2); if ($GLOBALS["VERBOSE"]) { echo "{$GLOBALS["arp"]} -a {$ipaddr} 2>&1 = >" . trim(@implode("", $res2)); } if (preg_match("#^(.+?)\\s+\\(#", trim(@implode("", $res2)), $rz)) { $computer_name = $rz[1]; } else { if ($GLOBALS["VERBOSE"]) { echo "Unable to find computer name\n"; } } if (strlen($computer_name) < 3) { $computer_name = $ipaddr; } if ($GLOBALS["VERBOSE"]) { echo "line: {$num}, UID:{$mac} -> {$uid}\n"; } if ($GLOBALS["VERBOSE"]) { echo "line: {$num}, NAME:{$computer_name} -> {$uid}\n"; } system_admin_events("adding/editing {$computer_name} with MAC:{$mac}", __FUNCTION__, __FILE__, __LINE__, "network"); $cmp->ComputerIP = $ipaddr; $cmp->ComputerMacAddress = $mac; $cmp->Add(); } } if (system_is_overloaded(basename(__FILE__))) { @file_put_contents($GLOBALS["CACHE_DB"], base64_encode(serialize($ArpdArray))); system_admin_events("Overloaded system, aborting the task...", __FUNCTION__, __FILE__, __LINE__, "network"); return; } @file_put_contents($GLOBALS["CACHE_DB"], base64_encode(serialize($ArpdArray))); $nice = EXEC_NICE(); $unix = new unix(); $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); shell_exec("{$nohup} {$nice} {$php5} " . __FILE__ . " --tomysql schedule-id={$GLOBALS["SCHEDULE_ID"]} >/dev/null 2>&1 &"); } }
function amavis_sa_update($buffer) { $unix = new unix(); $php = $unix->LOCATE_PHP5_BIN(); $nohup = $unix->find_program("nohup"); $cmd = "{$nohup} {$php} /usr/share/artica-postfix/exec.spamassassin.php --sa-update >/dev/null 2>&1 &"; $file = "/etc/artica-postfix/pids/" . __FUNCTION__ . ".error.time"; if (file_time_min($file) < 15) { events("-> detected {$buffer}, need to wait 15mn"); return null; } @unlink($file); @file_put_contents($file, "#"); shell_exec(trim($cmd)); events("{$cmd}"); return; }
if(isset($_GET["DelDarPersoFolder"])){user_defined_del();exit;} if(isset($_GET["external-storage"])){external_storage();exit;} if(isset($_GET["net_storage_server"])){external_storage_net_save();exit;} if(isset($_GET["external-storage-usb"])){external_storage_usb();exit;} if(isset($_GET["external-storage-usb-list"])){echo external_storage_usb_list();exit;} if(isset($_GET["ExternalUsbSelect"])){external_storage_usb_save();exit;} if(isset($_GET["external-storage-list"])){external_storage_list();exit;} if(isset($_GET["ExternalStorageDelete"])){external_storage_delete();exit;} if(isset($_GET["external-storage-network"])){external_storage_net();exit;} if(isset($_GET["refresh-dar-status"])){echo dar_status();exit;} if(isset($_GET["RebuildCollection"])){dar_rebuild();exit;} if(isset($_GET["events"])){events();exit;} if(isset($_GET["dar-view"])){dar_view_index();exit;} if(isset($_GET["mount-dar"])){js_dar_mount();exit;} if(isset($_GET["mount-dar-list"])){dar_mount_select();exit;} if(isset($_GET["mount-dar-2"])){dar_mount_2();exit;} if(isset($_GET["mount-dar-collection"])){dar_mount_collection();exit;} if(isset($_GET["dar-query"])){dar_query();exit;} if(isset($_GET["DarQuery"])){dar_query_results();exit;} if(isset($_GET["dar-list"])){dar_list();exit;} if(isset($_GET["dar-list-index"])){dar_list_type();exit;} if(isset($_GET["dar-list-query"])){dar_list_query();exit;}
function CheckAmavisLocalInterface() { $sock = new sockets(); $a = $sock->GET_INFO("EnableAmavisInMasterCF"); $EnableAmavisInMasterCF = intval(trim($a)); if ($EnableAmavisInMasterCF == 0) { events("CheckAmavisLocalInterface():: EnableAmavisInMasterCF not enabled = \"{$a}\""); return; } $datas = @file_get_contents("/usr/local/etc/amavisd.conf"); $tbl = explode("\n", $datas); events("CheckAmavisLocalInterface():: " . count($tbl) . " lines"); while (list($num, $ligne) = each($tbl)) { if (trim($ligne) == null) { continue; } if (preg_match("#inet_acl.+?qw#", $ligne)) { events("CheckAmavisLocalInterface():: inet_acl parameters ok"); return true; } } events("rebuild amavis"); $amavis = new amavis(); $amavis->Save(); $amavis->SaveToServer(); }
function GeoIP($site_IP) { if (!function_exists("geoip_record_by_name")) { if ($GLOBALS["VERBOSE"]) { echo "geoip_record_by_name no such function\n"; } return array(); } if ($site_IP == null) { events("GeoIP():: {$site_IP} is Null"); return array(); } if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+#", $site_IP)) { events("GeoIP():: {$site_IP} ->gethostbyname()"); $site_IP = gethostbyname($site_IP); events("GeoIP():: {$site_IP}"); } if (isset($GLOBALS["COUNTRIES"][$site_IP])) { events("GeoIP():: {$site_IP} {$GLOBALS["COUNTRIES"][$site_IP]}/{$GLOBALS["CITIES"][$site_IP]}"); if ($GLOBALS["VERBOSE"]) { echo "{$site_IP}:: MEM={$GLOBALS["COUNTRIES"][$site_IP]}\n"; } return array($GLOBALS["COUNTRIES"][$site_IP], $GLOBALS["CITIES"][$site_IP]); } $record = geoip_record_by_name($site_IP); if ($record) { $Country = $record["country_name"]; $city = $record["city"]; $GLOBALS["COUNTRIES"][$site_IP] = $Country; $GLOBALS["CITIES"][$site_IP] = $city; events("GeoIP():: {$site_IP} {$Country}/{$city}"); return array($GLOBALS["COUNTRIES"][$site_IP], $GLOBALS["CITIES"][$site_IP]); } else { events("GeoIP():: {$site_IP} No record"); if ($GLOBALS["VERBOSE"]) { echo "{$site_IP}:: No record\n"; } return array(); } return array(); }
function stop($aspid = false) { $unix = new unix(); $kill = $unix->find_program("kill"); if (!$aspid) { $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 "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, Already task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); } $pid = GETPID(); if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, already stopped\n"; } return; } if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, stopping pid: {$pid}\n"; } unix_system_kill_force($pid); for ($i = 0; $i < 6; $i++) { $pid = GETPID(); if (!$unix->process_exists($pid)) { break; } if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, waiting pid: {$pid} {$i}/5\n"; } unix_system_kill_force($pid); sleep(1); } $tail = $unix->find_program("tail"); $pid = $unix->PIDOF("/bin/nginx-tail"); if ($unix->process_exists($pid)) { for ($i = 0; $i < 20; $i++) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: killing old process pid {$pid}\n"; } unix_system_kill_force($pid); usleep(800); $pid = $unix->PIDOF("/bin/access-tail"); if (!$unix->process_exists($pid)) { break; } unix_system_kill_force($pid); } } $pid = GETPID(); if (!$unix->process_exists($pid)) { events("exec.init-tail-nginx.phpp success to stop daemon..."); if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, success\n"; } } else { events("exec.init-tail-nginx.php failed to stop daemon..."); if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: nginx-tail, failed\n"; } } }
<td colspan="4" class="hidden" align="right" width="25%">'; // multi page links $output .= generate_pagination('events.php?order_by=' . $order_by . '&dir=' . ($dir ? 0 : 1), $all_record, $itemperpage, $start); unset($start); $output .= ' </td> </tr> <tr> <td colspan="4" class="hidden" align="right">' . $lang_events['total'] . ' : ' . $all_record . '</td> </tr> </table> </center>'; } //############################################################################# // MAIN //############################################################################# // error variable reserved for future use //$err = (isset($_GET['error'])) ? $_GET['error'] : NULL; //unset($err); $lang_events = lang_events(); $output .= ' <div class="top"> <h1>' . $lang_events['events'] . '</h1> </div>'; // action variable reserved for future use //$action = (isset($_GET['action'])) ? $_GET['action'] : NULL; events(); //unset($action); unset($action_permission); unset($lang_events); require_once 'footer.php';
function Builsql($CLIENT, $name, $uri, $rule, $TYPE, $size = 0) { $CLIENT = trim($CLIENT); if ($CLIENT == '-') { $CLIENT = $name; } //events("CLIENT: $CLIENT:: name::$name rule::$rule TYPE::$TYPE"); if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $CLIENT)) { $user = $CLIENT; if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $name)) { $CLIENT = $name; } } if (preg_match("#^(?:[^/]+://)?([^/:]+)#", $uri, $re)) { $sitename = $re[1]; } else { events("unable to extract domain name from {$uri}"); return false; } if ($TYPE == null) { $TYPE = "PASS"; } if (preg_match("#\\*(.+?)\\*\\s+(.+?):#", $TYPE, $re)) { $TYPE = $re[1]; $REASON = $re[2]; } if (preg_match("#EXCEPTION.+?Exception site match#", $TYPE)) { $TYPE = "PASS"; $REASON = "Whitelisted"; } if (preg_match("#DENIED.+?Banned extension#", $TYPE)) { $TYPE = "DENIED"; $REASON = "Banned extension"; } if (preg_match("#SCANNED#", $TYPE)) { $TYPE = "PASS"; $REASON = "Scanned"; } if ($CLIENT != $name) { $CLIENT = $name; } $date = date('Y-m-d h:i:s'); if (trim($GLOBALS["IPs"][$sitename]) == null) { $site_IP = trim(gethostbyname($sitename)); $GLOBALS["IPs"][$sitename] = $site_IP; } else { $site_IP = $GLOBALS["IPs"][$sitename]; } if (count($_GET["IPs"]) > 5000) { unset($_GET["IPs"]); } if (count($_GET["COUNTRIES"]) > 5000) { unset($_GET["COUNTRIES"]); } if (trim($GLOBALS["COUNTRIES"][$site_IP]) == null) { if (function_exists("geoip_record_by_name")) { if ($site_IP == null) { $site_IP = $sitename; } $record = geoip_record_by_name($site_IP); if ($record) { $Country = $record["country_name"]; $GLOBALS["COUNTRIES"][$site_IP] = $Country; } } } else { $Country = $GLOBALS["COUNTRIES"][$site_IP]; } $date = date("Y-m-d H:i:s"); if ($size == null) { $size = 0; } if ($user == null) { $user = $CLIENT; } $zMD5 = md5("{$uri}{$date}{$CLIENT}{$TYPE}{$Country}{$site_IP}"); if (preg_match("#EXCEPTION#", $TYPE)) { $TYPE = "PASS"; $REASON = "Whitelisted"; } if ($CLIENT == $user) { if ($GLOBALS[$CLIENT] == null) { $user = gethostbyaddr($CLIENT); $GLOBALS[$CLIENT] = $user; } else { $user = $GLOBALS[$CLIENT]; } } if ($REASON == null) { $REASON = "Pass"; } events("{$date} {$REASON}:: {$CLIENT} ({$user}) -> {$sitename} ({$site_IP}) Country={$Country} REASON:\"{$REASON}\" TYPE::\"{$TYPE}\" size={$size}"); $uri = addslashes($uri); if (!is_dir("/var/log/artica-postfix/dansguardian-stats3")) { @mkdir("/var/log/artica-postfix/dansguardian-stats3", 600, true); } $filewebsite = "/var/log/artica-postfix/dansguardian-stats3/" . md5($sitename); $filewebsite_array = array("sitename" => $sitename, "country" => $Country, "ipaddr" => $site_IP); $filecontent = serialize($filewebsite_array); if (!is_file($filewebsite)) { @file_put_contents($filewebsite, $filecontent); } $table = "dansguardian_events_" . date('Ymd'); $sql = "INSERT IGNORE INTO {$table} (`sitename`,`uri`,`TYPE`,`REASON`,`CLIENT`,`zDate`,`zMD5`,`remote_ip`,`country`,`QuerySize`,`uid`) \n\tVALUES('{$sitename}','{$uri}','{$TYPE}','{$REASON}','{$CLIENT}','{$date}','{$zMD5}','{$site_IP}','{$Country}','{$size}','{$user}');"; @file_put_contents("/var/log/artica-postfix/dansguardian-stats/{$zMD5}.sql", $sql); }
function remove_mysql_sessions($aspid = false) { $unix = new unix(); $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; if ($GLOBALS["VERBOSE"]) { $GLOBALS["FORCE"] = true; echo "pidTime: {$pidTime}\n"; $GLOBALS["FORCE"] = true; } if (!$GLOBALS["FORCE"]) { if (!$aspid) { $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); events("Already executed pid {$pid} since {$timepid}Mn"); return; } @file_put_contents($pidfile, time()); } } if (!$GLOBALS["FORCE"]) { $time = $unix->file_time_min($pidTime); if ($time < 10) { return; } } @file_put_contents($pidTime, time()); $conntrack = $unix->find_program("conntrack"); $q = new mysql_squid_builder(); if ($q->COUNT_ROWS("hotspot_sessions") == 0) { remove_temp_sessions(); untrack(); $q->QUERY_SQL("DROP TABLE `hotspot_sessions`"); $sql = "CREATE TABLE `squidlogs`.`hotspot_sessions` (\n\t\t\t`md5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`logintime` BIGINT UNSIGNED ,\n\t\t\t`maxtime` INT UNSIGNED ,\n\t\t\t`finaltime` INT UNSIGNED ,\n\t\t\t`nextcheck` INT UNSIGNED ,\n\t\t\t`username` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`MAC` VARCHAR( 90 ) NOT NULL,\n\t\t\t`uid` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`hostname` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`ipaddr` VARCHAR( 128 ) ,\n\t\t\tPRIMARY KEY ( `md5` ) ,\n\t\t\tINDEX ( `logintime` , `maxtime` , `username` ,`finaltime`,`nextcheck`),\n\t\t\tKEY `MAC` (`MAC`),\n\t\t\tKEY `uid` (`uid`),\n\t\t\tKEY `hostname` (`hostname`),\n\t\t\tKEY `ipaddr` (`ipaddr`)\n\t\t\t) ENGINE = MEMORY;"; $q->QUERY_SQL($sql); return; } $iptables_save = $unix->find_program("iptables-save"); shell_exec("{$iptables_save} > {$GLOBALS["CACHE_FILE"]}"); $data = file_get_contents($GLOBALS["CACHE_FILE"]); $datas = explode("\n", $data); if ($GLOBALS["VERBOSE"]) { echo "DEBUG: {$GLOBALS["CACHE_FILE"]} -> " . count($datas) . " lines\n"; } while (list($num, $ligne) = each($datas)) { if (!preg_match("#-m mac --mac-source (.+?)\\s+.*?--comment HotSpotSession-#", $ligne, $re)) { if ($GLOBALS["VERBOSE"]) { echo "DEBUG: {$ligne} (no match )\n"; } continue; } $mac = trim(strtolower($re[1])); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `md5` FROM hotspot_sessions WHERE MAC='{$mac}'")); if ($ligne["md5"] == null) { if ($GLOBALS["OUTPUT"]) { echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} remove session \"{$mac}\"\n"; } hotspot_admin_mysql(2, "Session {$mac} is not in table", "Remove it from firewall"); remove_MAC_sessions($mac); } } $time = time(); $sql = "SELECT `md5`,MAC,ipaddr,username,maxtime,nextcheck FROM hotspot_sessions WHERE nextcheck>0 AND nextcheck < {$time}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n"; } $count = mysql_num_rows($results); if ($count == 0) { if ($GLOBALS["VERBOSE"]) { echo "Nothing to do...\n"; } return; } if ($GLOBALS["VERBOSE"]) { echo "{$count} rows\n"; } while ($ligne = mysql_fetch_assoc($results)) { $MAC = $ligne["MAC"]; $username = $ligne["username"]; $ipaddr = $ligne["ipaddr"]; $nextcheck = $ligne["nextcheck"]; if ($GLOBALS["VERBOSE"]) { echo "\n\n****\n\n DROP Session {$MAC} {$username} {$ipaddr} {$nextcheck} < {$time}\n****\n\n"; } remove_MAC_sessions($MAC); $NextCheckEdit = strtotime("+10 minutes", time()); $sql = "UPDATE hotspot_sessions SET nextcheck={$NextCheckEdit} WHERE `md5`='{$ligne["md5"]}'"; echo "{$sql}\n"; $q->QUERY_SQL($sql); hotspot_admin_mysql(2, "Drop session {$username} {$ipaddr}", "Hotspot session for {$username} reach time [{$nextcheck}] " . date("Y-m-d H:i:s", $nextcheck) . " current " . date("Y-m-d H:i:s", $nextcheck) . "\nNext check will be at:" . date("Y-m-d H:i:s", $NextCheckEdit), __FILE__, __LINE__); shell_exec("{$conntrack} -D -n {$ipaddr} 2>&1"); } $c = 0; $tab = array(); }
function nss_parser($buffer){ if(preg_match('#nss_wins.+?failed to bind to server\s+(.+?)\s+with\s+dn="(.+?)"\s+Error:\s+Invalid credentials#',$buffer,$re)){ $file="/etc/artica-postfix/croned.1/nss_parser.Invalidcredentials.error"; events("nss_wins:: Invalid credentials"); if(IfFileTime($file)){ email_events("System error NSS cannot bind to {$re[1]}: Invalid credentials","NSS Wins claim \"$buffer\"",'system'); } WriteFileCache($file); return; } events_not_filtered("nss_wins:: Not Filtered:\"$buffer\""); }
function postfix_status() { $user = new usersMenus(); if (!$user->POSTFIX_INSTALLED) { return null; } $user->LoadModulesEnabled(); $q = new mysql(); $fetchmail_count = 0; if ($user->fetchmail_installed) { BuildingExecRightStatus("Building fetchmail statistics...", 25); $sql = "SELECT COUNT(ID) as tcount FROM `fetchmail_events` WHERE DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT( NOW( ) ,'%Y-%m-%d' )"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_events')); $fetchmail_count = $ligne["tcount"]; $sql = "SELECT SUM(size) as tcount FROM `fetchmail_events` WHERE DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT( NOW( ) ,'%Y-%m-%d' )"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_events')); $fetchmail_size = FormatBytes($ligne["tcount"] / 1024); events("fetchmail_count={$fetchmail_count}, fetchmail_size={$fetchmail_size}"); } else { events('Fetchmail is not installed'); } BuildingExecRightStatus("Building storage statistics...", 30); $sql = "SELECT COUNT( MessageID ) as tcount FROM storage WHERE DATE_FORMAT( zDate, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) "; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup')); $backuped_mails = $ligne["tcount"]; BuildingExecRightStatus("Building quarantine statistics...", 35); $sql = "SELECT COUNT( MessageID ) as tcount FROM quarantine WHERE DATE_FORMAT( zDate, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' ) "; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup')); $quarantine_mails = $ligne["tcount"]; BuildingExecRightStatus("Building messages number statistics...", 40); $sql = "SELECT COUNT(ID) as tcount FROM `smtp_logs` WHERE DATE_FORMAT( time_sended, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' )"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_events')); $flow_mails = $ligne["tcount"]; if ($user->cyrus_imapd_installed) { BuildingExecRightStatus("Building imap/pop3 number statistics...", 45); $sql = "SELECT COUNT(ID) as tcount FROM `mbx_con` WHERE DATE_FORMAT( zDate, '%Y-%m-%d' ) = DATE_FORMAT( NOW( ) , '%Y-%m-%d' )"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_events')); $mbx_con = $ligne["tcount"]; $mbx_con = "<tr>\n\t\t\t<td class=legend nowrap>{mbx_con}:</td>\n\t\t\t<td style='font-size:12px;font-weight:bold'>{$mbx_con} {connections}</td>\n\t\t</tr>"; } if ($fetchmail_count > 0) { $fetchmail = "<tr>\n\t\t\t<td class=legend nowrap>{fetchmail_recup}:</td>\n\t\t\t<td style='font-size:12px;font-weight:bold'>{$fetchmail_count} {emails} ({$fetchmail_size})</td>\n\t\t</tr>"; } $html = "\n\t<H5>Postfix: {today}</h5>\n\t<table class=table_form>\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{received_mails}:</td>\n\t\t\t<td style='font-size:12px;font-weight:bold'>{$flow_mails}</td>\n\t\t</tr>\n\t\t{$mbx_con}\t\n\t\t{$fetchmail}\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{backuped_mails}:</td>\n\t\t\t<td style='font-size:12px;font-weight:bold'>{$backuped_mails}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{quarantine_mails}:</td>\n\t\t\t<td style='font-size:12px;font-weight:bold'>{$quarantine_mails}</td>\n\t\t</tr>\n\t</table>\n\t\t\t\t\t\t\n\t\n\t"; if ($user->AMAVIS_INSTALLED) { if ($user->EnableAmavisDaemon) { BuildingExecRightStatus("Building Amavis statistics...", 50); $ini = new Bs_IniHandler(); $sock = new sockets(); $ini->loadString($sock->getfile('amavisstatus')); $status_amavis = DAEMON_STATUS_ROUND("AMAVISD", $ini, null); $status_amavismilter = DAEMON_STATUS_ROUND("AMAVISD_MILTER", $ini, null); $status = "<br>{$status_amavis}<br>{$status_amavismilter}"; } } $html = RoundedLightGrey($html) . $status . "<br>"; file_put_contents('/usr/share/artica-postfix/ressources/logs/status.postfix.flow.html', $html); system('/bin/chmod 755 /usr/share/artica-postfix/ressources/logs/status.postfix.flow.html'); BuildingExecRightStatus("Building done...", 100); }