function squid_frontend_status() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $TITLE_REQUESTS = null; $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); if (!is_numeric($SquidCacheLevel)) { $SquidCacheLevel = 4; } $LogsWarninStop = $sock->GET_INFO("LogsWarninStop"); if ($LogsWarninStop == 1) { echo FATAL_ERROR_SHOW_128("<div style='font-size:20px'>{squid_logs_urgency}</div>\n\t\t\t\t<div style='text-align:right;font-size:22px;text-align:right;text-decoration:underline;margin-top:20px'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('system.log.emergency.php')\">{squid_logs_urgency_section}</a>\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t"); } $squid5mn = unserialize(base64_decode($sock->getFrameWork("squid.php?5mncounter=yes"))); //$realMemory=unserialize(base64_decode($sock->getFrameWork("services.php?realMemory=yes"))); $CounterInfos = unserialize(base64_decode($sock->getFrameWork("squid.php?CounterInfos=yes"))); $StorageCapacity = unserialize(base64_decode($sock->getFrameWork("squid.php?StorageCapacity=yes"))); $SquidMonitorParms = unserialize(base64_decode($sock->GET_INFO("SquidMonitorParms"))); $t = time(); $server_all_kbytes_in = $SquidMonitorParms["server_all_kbytes_in"]; $server_all_kbytes_out = $SquidMonitorParms["server_all_kbytes_out"]; $HttpRequests = $SquidMonitorParms["HttpRequests"]; $ActiveRequests = $SquidMonitorParms["ActiveRequests"]; $TITLE_USERS = null; $TITLE_COMPUTERS = null; $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth")); if ($EnableKerbAuth == 1) { include_once dirname(__FILE__) . "/ressources/class.external.ad.inc"; $ldap = new external_ad_search(); $NET_RPC_INFOS = $ldap->NET_RPC_INFOS(); $NumBerOfUsers = intval($NET_RPC_INFOS["Num users"]); if ($NumBerOfUsers > 0) { $TITLE_USERS = " | <a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:AnimateDiv('BodyContent');LoadAjax('BodyContent','squid.adker.php?tabs=yes');\" \n\t\t\tstyle='text-decoration:underline'>{$NumBerOfUsers} {members}</a>"; } } $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(MAC) as tcount FROM (SELECT MAC FROM UserAutDB GROUP BY MAC) as t")); $Nodes = $ligne["tcount"]; if ($Nodes > 0) { $TITLE_COMPUTERS = " | <a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.computer-browse.php')\"\n\t\tstyle='text-decoration:underline'>{$Nodes} {computers}</a>"; } $CACHES_RATES = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/TOTAL_CACHED")); $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]); $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]); $TOTALS_DOWNLOAD = $TOTALS_NOT_CACHED + $TOTALS_CACHED; $TOTALS_NOT_CACHED = intval(@file_get_contents("/usr/share/artica-postfix/ressources/logs/stats/NOT_CACHED")); if ($TOTALS_NOT_CACHED > 0) { $TOTALS_NOT_CACHED_TEXT = " | <a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('admin.index.loadvg.squid.notcached-week.php');\"\n\t\tstyle='text-decoration:underline;font-weight:bold'>{not_cached_this_week}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>"; } $Status_cache = " | {downloaded} " . FormatBytes($TOTALS_DOWNLOAD / 1024) . " | {cached}:" . FormatBytes($TOTALS_CACHED / 1024) . $TOTALS_NOT_CACHED_TEXT; $RATE = $TOTALS_CACHED / $TOTALS_DOWNLOAD * 100; $RATE = round($RATE, 1); $TITLE_RATE = " | {cache_rate} <strong>{$RATE}%</strong>"; if (!is_numeric($server_all_kbytes_in)) { $server_all_kbytes_in = 1000; } if (!is_numeric($server_all_kbytes_out)) { $server_all_kbytes_out = 250; } if (!is_numeric($HttpRequests)) { $HttpRequests = 150; } if (!is_numeric($ActiveRequests)) { $ActiveRequests = 150; } if (!isset($squid5mn["cpu_usage"])) { $squid5mn["cpu_usage"] = 0; } $squid5mn["cpu_usage"] = round($squid5mn["cpu_usage"], 2); $squid5mn["client_http.requests"] = round($squid5mn["client_http.requests"], 2); $squid5mn["server.all.kbytes_in"] = round($squid5mn["server.all.kbytes_in"], 2); $squid5mn["server.all.kbytes_out"] = round($squid5mn["server.all.kbytes_out"], 2); $ActiveRequestsR = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/active_requests.inc")); $ActiveRequestsNumber = count($ActiveRequestsR["CON"]); $ActiveRequestsIpaddr = count($ActiveRequestsR["IPS"]); $ActiveRequestsMembers = count($ActiveRequestsR["USERS"]); if ($ActiveRequestsNumber > 0) { $TITLE_REQUESTS = " | <a href=\"javascript:blur();\"\n\t\tOnClick=\"Loadjs('squid.active.requests.php')\"\n\t\tstyle='text-decoration:underline'>{$ActiveRequestsNumber} {active_requests}</a>"; } if (!is_numeric($ActiveRequestsNumber)) { $ActiveRequestsNumber = 0; } if (!is_numeric($ActiveRequestsIpaddr)) { $ActiveRequestsIpaddr = 0; } if (!is_numeric($ActiveRequestsMembers)) { $ActiveRequestsMembers = 0; } $server_all_kbytes_in_text = $tpl->javascript_parse_text("{server_all_kbytes_in}"); $server_all_kbytes_out_text = $tpl->javascript_parse_text("{server_all_kbytes_out}"); $active_requests = $tpl->javascript_parse_text("{active_requests}"); $proxy_status = $tpl->javascript_parse_text("{proxy_status}"); $second = $tpl->javascript_parse_text("{second}"); $requests = $tpl->javascript_parse_text("{requests}"); $countStorages = count($StorageCapacity); for ($i = 0; $i < $countStorages; $i++) { $tS[] = "<div id='squid-s{$i}-{$t}' style='width:160px; height:100px'>"; $js[] = " var s{$i} = new JustGage({\n\t\tid: 'squid-s{$i}-{$t}',\n\t\tvalue: {$StorageCapacity[$i]},\n\t\tmin: 0,\n\t\tmax: 100,\n\t\ttitle: 'Storage Capacity Kid " . ($i + 1) . "',\n\t\tlabel: '%',\n\t\tlevelColorsGradient: true\n\t}); "; } $storages = CompileTr4($tS, true, null, true); $ini = new Bs_IniHandler(); $color = "black"; $ini->loadFile("/usr/share/artica-postfix/ressources/databases/ALL_SQUID_STATUS"); if ($ini->_params["SQUID"]["running"] == 0) { $color = "#d32d2d"; $status = "{stopped}"; } else { if ($ini->_params["SQUID"]["master_time"]) { $status2 = " {running} {since} " . distanceOfTimeInWords($ini->_params["SQUID"]["master_time"], time()); } } $version = @file_get_contents("/usr/share/artica-postfix/ressources/databases/SQUID.version"); if ($version != null) { $version = " v.{$version}"; } if ($SquidCacheLevel == 0) { $nocache = " <span style='color:#d32d2d'>{no_cached_sites_warn}</span>"; } $squi1_text = $tpl->javascript_parse_text("{monitor}"); $squi1_onmouse = "OnMouseOver=\"javascript:AffBulle('{$squi1_text}');this.style.cursor='pointer'\" OnMouseOut=\"javascript:HideBulle();this.style.cursor='default'\""; $squi1_onClick = "OnClick=\"javascript:Loadjs('squid.task.monitor.php')\""; echo $tpl->_ENGINE_parse_body("\n<table style='width:99%' >\n\t<tr>\n\t\t<td colspan=4 style='font-size:22px'>\n\t\t\t<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:LoadAjax('BodyContent','squid.caches.status.php?tabs=yes')\" \n\t\t\tstyle='text-decoration:underline;color:{$color}'>{$proxy_status} {$status} {$version}</a>\n\t\t\t{$TITLE_RATE}{$TITLE_USERS}{$TITLE_REQUESTS}{$TITLE_COMPUTERS}\n\t\t\t<br>\n\t\t\t<div style='font-size:11px'><i>{$status2}{$nocache}{$Status_cache}</i></div>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t\t<td valign='top' width=25%>\n\t\t\t\t<div id='squid-1-{$t}' style='width:160px; height:100px' {$squi1_onmouse} {$squi1_onClick}></div>\n\t\t\t\n\t\t\t</td>\n\t\t\t<td valign='top' width=25%><div id='squid-2-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-3-{$t}' style='width:170px; height:100px'></div></td>\n\t\t\t<td valign='top' width=25%><div id='squid-4-{$t}' style='width:170px; height:100px'></div></td>\n\t</tr>\n\t\n</table>{$storages}\n\t\t\t\n" . "<div style='text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjaxTiny('squid-front-end-status','{$page}?squid-front-end-status=yes');") . "</div>\n<script>\nvar g = new JustGage({\n\tid: 'squid-1-{$t}',\n\tvalue: {$squid5mn["cpu_usage"]},\n\tmin: 0.1,\n\tmax: 100,\n\ttitle: 'Proxy CPU Usage',\n\tlabel: '%',\n\tlevelColorsGradient: true\n});\n\t\nvar g2 = new JustGage({\n\tid: 'squid-2-{$t}',\n\tvalue: {$squid5mn["client_http.requests"]},\n\tmin: 0.1,\n\tmax: {$HttpRequests},\n\ttitle: 'HTTP {$requests}/{$second}',\n\tlabel: 'RQ/s',\n\tlevelColorsGradient: true\n});\n\nvar g3 = new JustGage({\n\tid: 'squid-3-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_in"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_in},\n\ttitle: '{$server_all_kbytes_in_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n\t});\nvar g4 = new JustGage({\n\tid: 'squid-4-{$t}',\n\tvalue: {$squid5mn["server.all.kbytes_out"]},\n\tmin: 0,\n\tmax: {$server_all_kbytes_out},\n\ttitle: '{$server_all_kbytes_out_text}',\n\tlabel: 'KB',\n\tlevelColorsGradient: true\n});\n" . @implode("\n", $js) . "\nif(document.getElementById('squid-rttrqs-status')){\n\tLoadAjaxSilent('squid-rttrqs-status','admin.index.loadavg.squidrtt.php');\n}\n\n\t</script>\n\t"); }
function register() { if ($GLOBALS["VERBOSE"]) { echo __FUNCTION__ . "() in line " . __LINE__ . "\n"; } $sock = new sockets(); $unix = new unix(); $URIBASE = $unix->MAIN_URI(); $URIBASE = str_replace("articatech.net", "artica.fr", $URIBASE); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid)) { WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__); die; } $sock = new sockets(); $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth"); if (!is_numeric("{$EnableKerbAuth}")) { $EnableKerbAuth = 0; } if ($GLOBALS["VERBOSE"]) { echo "Loading WizardSavedSettings " . __FUNCTION__ . "() in line " . __LINE__ . "\n"; } $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings"))); $WizardSavedSettingsSend = $sock->GET_INFO("WizardSavedSettingsSend"); if (count($WizardSavedSettings) < 2) { if ($GLOBALS["VERBOSE"]) { echo "WizardSavedSettings array is less than 2" . __FUNCTION__ . "() in line " . __LINE__ . "\n"; } return; } if (!isset($WizardSavedSettings["company_name"])) { $WizardSavedSettings["company_name"] = null; } if ($WizardSavedSettings["company_name"] == null) { return; } if (!is_numeric($WizardSavedSettingsSend)) { $WizardSavedSettingsSend = 0; } if ($WizardSavedSettingsSend == 1) { if (!$GLOBALS["FORCE"]) { if ($GLOBALS["VERBOSE"]) { echo "WizardSavedSettingsSend == 1, aborting.. (use --force)" . __FUNCTION__ . "() in line " . __LINE__ . "\n"; } return; } } $uuid = $unix->GetUniqueID(); if ($uuid == null) { if ($GLOBALS["VERBOSE"]) { echo "No system ID !\n"; } return; } $WizardSavedSettings["ACTIVE_DIRECTORY"] = $EnableKerbAuth; if ($EnableKerbAuth == 1) { include_once dirname(__FILE__) . "/ressources/class.external.ad.inc"; $ldap = new external_ad_search(); $NET_RPC_INFOS = $ldap->NET_RPC_INFOS(); while (list($a, $b) = each($NET_RPC_INFOS)) { $WizardSavedSettings[$a] = $b; } } $WizardSavedSettings["UUID"] = $uuid; $WizardSavedSettings["CPUS_NUMBER"] = $unix->CPU_NUMBER(); $WizardSavedSettings["MEMORY"] = $unix->SYSTEM_GET_MEMORY_MB() . "MB"; $WizardSavedSettings["LINUX_DISTRI"] = $unix->LINUX_DISTRIBUTION(); $WizardSavedSettings["ARTICAVERSION"] = @file_get_contents("/usr/share/artica-postfix/VERSION"); $WizardSavedSettings["STATS_APPLIANCE"] = 0; if (is_file("/etc/artica-postfix/STATS_APPLIANCE")) { $WizardSavedSettings["APPLIANCE"] = "Artica Stats Appliance"; $WizardSavedSettings["STATS_APPLIANCE"] = 1; } $zarafa_server = $unix->find_program("zarafa-server"); if (is_file($zarafa_server)) { $WizardSavedSettings["ZARAFA APPLIANCE"] = "YES"; } $squid = $unix->find_program("squid"); if (is_file($squid)) { $WizardSavedSettings["PROXY INSTALLED"] = "YES"; } if (is_file("/etc/artica-postfix/FROM_ISO")) { $WizardSavedSettings["FROM ISO"] = "YES"; } if (is_file("/etc/artica-postfix/SQUID_APPLIANCE")) { $WizardSavedSettings["APPLIANCE"] = "Artica Proxy"; $WizardSavedSettings["PROXY APPLIANCE"] = "YES"; } if (is_file("/etc/artica-postfix/SAMBA_APPLIANCE")) { $WizardSavedSettings["APPLIANCE"] = "Artica NAS"; $WizardSavedSettings["N.A.S APPLIANCE"] = "YES"; } if (is_file("/etc/artica-postfix/artica-iso-first-reboot")) { $zDate = filemtime("/etc/artica-postfix/artica-iso-first-reboot"); $WizardSavedSettings["INSTALL_DATE"] = date("Y-m-d H:i:s", $zDate); } else { $zDate = filemtime("/etc/artica-postfix/."); $WizardSavedSettings["INSTALL_DATE"] = date("Y-m-d H:i:s", $zDate); } if (is_file("/etc/artica-postfix/dmidecode.cache.url")) { $final_array = unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/dmidecode.cache.url"))); while (list($a, $b) = each($final_array)) { $WizardSavedSettings[$a] = $b; } } @file_put_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings", base64_encode(serialize($WizardSavedSettings))); if ($GLOBALS["VERBOSE"]) { echo "Send order to {$URIBASE}/shalla-orders.php " . __FUNCTION__ . "() in line " . __LINE__ . "\n"; } $curl = new ccurl("{$URIBASE}/shalla-orders.php", false, null); $curl->parms["REGISTER"] = base64_encode(serialize($WizardSavedSettings)); if ($GLOBALS["VERBOSE"]) { $curl->parms["VERBOSE"] = true; } $curl->NoLocalProxy(); $curl->get(); if ($GLOBALS["VERBOSE"]) { echo $curl->data; } if (preg_match("#GOOD#s", $curl->data)) { $sock->SET_INFO("WizardSavedSettingsSend", 1); } }