function page() { $html = ParseLogs(); $JS["JS"][] = 'js/dnsmasq.js'; $tpl = new template_users('Dnsmasq {events}', $html, 0, 0, 0, 10, $JS); echo $tpl->web_page; }
function ScanFile($toScan) { if (!$GLOBALS["SAMBA_INSTALLED"]) { return true; } $localdatabase = "/usr/share/artica-postfix/LocalDatabases"; $file = @file_get_contents($toScan); $ext = Get_extension($file); $nice = EXEC_NICE(); $database = "{$localdatabase}/samba.db"; if (!is_file($GLOBALS["omindex"])) { return true; } $directory = dirname($file); if ($GLOBALS["DIRS"]["{$directory}"]) { return true; } $basename = basename($file); $cmd = "{$nice}{$GLOBALS["omindex"]} -l 1 --follow -D {$database} -U \"{$directory}\" \"{$directory}\""; $GLOBALS["DIRS"]["{$directory}"] = true; exec($cmd, $results); ParseLogs($results); return true; }
function homes() { $GLOBALS["INDEXED"] = 0; $GLOBALS["SKIPPED"] = 0; $GLOBALS["DIRS"] = array(); $FOLDERS = array(); $RFOLDERS = array(); $unix = new unix(); $GLOBALS["omindex"] = $unix->find_program("omindex"); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid)) { system_admin_events("Already instance executed pid:{$olpid}", __FUNCTION__, __FILE__, __LINE__, "xapian"); die; } @file_put_contents($pidfile, getmypid()); $nice = EXEC_NICE(); $t1 = time(); if (!is_file($GLOBALS["omindex"])) { system_admin_events("omindex no such binary, aborting", __FUNCTION__, __FILE__, __LINE__, "xapian"); return; } $ldap = new clladp(); $attr = array("homeDirectory", "uid", "dn"); $pattern = "(&(objectclass=sambaSamAccount)(uid=*))"; $sock = new sockets(); $sock = new sockets(); $sr = @ldap_search($ldap->ldap_connection, "dc=organizations," . $ldap->suffix, $pattern, $attr); $hash = ldap_get_entries($ldap->ldap_connection, $sr); $sock = new sockets(); for ($i = 0; $i < $hash["count"]; $i++) { $uid = $hash[$i]["uid"][0]; $homeDirectory = $hash[$i][strtolower("homeDirectory")][0]; if ($uid == null) { writelogs("uid is null, SKIP ", __FUNCTION__, __FILE__, __LINE__); continue; } if ($uid == "nobody") { writelogs("uid is nobody, SKIP ", __FUNCTION__, __FILE__, __LINE__); continue; } if ($uid == "root") { writelogs("uid is root, SKIP ", __FUNCTION__, __FILE__, __LINE__); continue; } if (substr($uid, strlen($uid) - 1, 1) == '$') { writelogs("{$uid}:This is a computer, SKIP ", __FUNCTION__, __FILE__, __LINE__); continue; } if ($homeDirectory == null) { $homeDirectory = "/home/{$uid}"; } if (!is_dir($homeDirectory)) { continue; } $FOLDERS[$uid] = $homeDirectory; $RFOLDERS[$homeDirectory] = true; } $SambaXapianAuth = unserialize(base64_decode($sock->GET_INFO("SambaXapianAuth"))); $username = $SambaXapianAuth["username"]; $password = $SambaXapianAuth["password"]; $domain = $SambaXapianAuth["domain"]; $comp = $SambaXapianAuth["ip"]; if (!isset($SambaXapianAuth["lang"])) { $SambaXapianAuth["lang"] == "none"; } $lang = $SambaXapianAuth["lang"]; if ($lang == null) { $lang = "none"; } $t1 = time(); $dirs = $unix->dirdir("/home"); $samba = new samba(); $localdatabase = "/usr/share/artica-postfix/LocalDatabases"; while (list($dir, $ligne) = each($dirs)) { if ($dir == "/home/export") { continue; } if ($dir == "/home/netlogon") { continue; } if ($dir == "/home/artica") { continue; } if ($dir == "/home/logs-backup") { continue; } if (isset($RFOLDERS[$dir])) { continue; } if (isset($samba->main_shared_folders[$dir])) { continue; } $FOLDERS[basename($dir)] = $dir; } $count = 0; while (list($uid, $directory) = each($FOLDERS)) { $BaseUrl = $directory; $database = "{$localdatabase}/xapian-{$uid}"; @mkdir($database, 0755, true); if (!is_dir($directory)) { system_admin_events("{$directory}, no such directory", __FUNCTION__, __FILE__, __LINE__, "xapian"); continue; } $t = time(); $cmd = "{$nice}{$GLOBALS["omindex"]} -l 0 -s {$lang} -E 512 -m 60M --follow -D \"{$database}\" -U \"{$BaseUrl}\" \"{$directory}\" -v 2>&1"; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } $results_scan = array(); exec($cmd, $results_scan); $dirRes = ParseLogs($results_scan); $took = $unix->distanceOfTimeInWords($t, time(), true); $count++; system_admin_events("scanned {$directory} took {$took} indexed:{$dirRes[0]} skipped:{$dirRes[1]}", __FUNCTION__, __FILE__, __LINE__, "xapian"); } $took = $unix->distanceOfTimeInWords($t1, time(), true); system_admin_events("scanned {$count} directorie(s) took {$took}", __FUNCTION__, __FILE__, __LINE__, "xapian"); }
function deleteAllYesterday() { $sock = new sockets(); $error = $error . $sock->getfile('deleteallmailfrommailtoyesterday:' . $_GET["mail"]); SinglePage(ParseLogs($error)); }
include_once 'ressources/class.dnsmasq.inc'; include_once 'ressources/class.main_cf.inc'; if (posix_getuid() != 0) { $user = new usersMenus(); if ($user->AsDnsAdministrator == false) { $tpl = new templates(); echo $tpl->_ENGINE_parse_body("alert('{ERROR_NO_PRIVS}');"); die; exit; } } if (isset($_GET["show"])) { ParseLogs2(); exit; } ParseLogs(); function ParseLogs() { $page = CurrentPageName(); $html = "<div id='RefreshDNSMSQLogs-ev'></div>\n\t\n\t<script>\n\t\tfunction RefreshDNSMSQLogs(){\n\t\t\tLoadAjax('RefreshDNSMSQLogs-ev','{$page}?show=yes');\n\t\t}\n\t\tRefreshDNSMSQLogs();\n\t</script>"; echo $html; } function ParseLogs2() { $sock = new sockets(); $tbl = unserialize(base64_decode($sock->getFrameWork("cmd.php?syslog-query={$pattern}&prefix=dnsmasq*"))); if (is_array($tbl)) { $tbl = array_reverse($tbl); } $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th>" . imgtootltip("refresh-24.png", "{refresh}", "RefreshDNSMSQLogs()") . "</th>\n\t\t<th> </th>\n\t</tr>\n</thead>\n<tbody class='tbody'>"; while (list($index, $line) = each($tbl)) {