function start_execution()
{
    $unix = new unix();
    BuildingExecRightStatus("Building postfix status...", 20);
    postfix_status();
    BuildingExecRightStatus("Building postfix status...", 55);
    events("postfix_status() OK");
    get_current_time();
    events("get_current_time() OK");
    BuildingExecRightStatus("Building postfix status...", 90);
    BuildingExecRightStatus("done...", 100);
}
Esempio n. 2
0
    exit;
}
if (isset($_GET["allstatus"])) {
    echo PAGE_REFRESH_All_Status();
    exit;
}
if (isset($_GET["StartPostfix"])) {
    echo StartPostfix();
    exit;
}
if (isset($_GET["PostfixHistoryMsgID"])) {
    echo PostfixHistoryMsgID();
    exit;
}
if (isset($_GET["postfix-status"])) {
    echo postfix_status();
    exit;
}
$users = new usersMenus();
writelogs("uid=" . $_SESSION["uid"], __FUNCTION__, __FILE__);
writelogs("AsOrgAdmin={$users->AsOrgAdmin}", __FUNCTION__, __FILE__);
writelogs("AsArticaAdministrator={$users->AsArticaAdministrator}", __FUNCTION__, __FILE__, __LINE__);
writelogs("AsOrgPostfixAdministrator={$users->AsOrgPostfixAdministrator}", __FUNCTION__, __FILE__, __LINE__);
writelogs("AsMessagingOrg={$users->AsMessagingOrg}", __FUNCTION__, __FILE__, __LINE__);
if ($_SESSION["uid"] == -100) {
    header('location:admin.index.php');
    exit;
}
if ($users->AsArticaAdministrator == true or $users->AsPostfixAdministrator or $user->AsSquidAdministrator) {
    header('location:admin.index.php');
    exit;
function proxy_status()
{
    $ntmlauthenticators_array = array();
    $COUNT_DE_CACHES_TEXT = null;
    $webfilters_paranoid_text = null;
    $users = new usersMenus();
    if ($users->STATS_APPLIANCE) {
        return influxdb_status();
    }
    if ($users->POSTFIX_INSTALLED) {
        return postfix_status();
    }
    $sock = new sockets();
    $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    $EnableArticaMetaServer = intval($sock->GET_INFO("EnableArticaMetaServer"));
    $EnableNginx = intval($sock->GET_INFO("EnableNginx"));
    $EnableHaProxy = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableHaProxy"));
    if ($SQUIDEnable == 0) {
        if ($EnableArticaMetaServer == 1) {
            return meta_server_status();
        }
        if ($EnableNginx == 1) {
            return nginx_server_status();
        }
        if ($EnableHaProxy == 1) {
            return haproxy_server_status();
        }
    }
    $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel");
    $HTTrackInSquid = intval($sock->GET_INFO("HTTrackInSquid"));
    if (!is_numeric($SquidCacheLevel)) {
        $SquidCacheLevel = 4;
    }
    unset($_GET["_"]);
    $sock = new sockets();
    if (!isset($_GET["ForceCache"])) {
        $md5CacheF = md5("proxy_status{$_SESSION["uid"]}{$tpl->language}" . serialize($_GET));
        $cachefile = "/usr/share/artica-postfix/ressources/interface-cache/{$md5CacheF}";
        if (file_time_sec_Web($cachefile) < 5) {
            return @file_get_contents($cachefile);
        }
    }
    if (isset($_GET["ForceCache"])) {
        $sock->getFrameWork("cmd.php?Global-Applications-Status=yes");
    }
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $page = CurrentPageName();
    $ini = new Bs_IniHandler();
    $users = new usersMenus();
    $perc_cache = null;
    $active_resquests = null;
    $important_events = null;
    $CountDeServices = null;
    $icon = "disks-128-ok.png";
    $rqs = null;
    $NOT_CATEGORIZED_ROW = null;
    $mgr_client_list = $q->COUNT_ROWS("mgr_client_list");
    $SNMP_WALK = proxy_snmp();
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    $SquidUrgency = intval($sock->GET_INFO("SquidUrgency"));
    $MacToUidUrgency = intval($sock->GET_INFO("MacToUidUrgency"));
    $SquidSSLUrgency = intval($sock->GET_INFO("SquidSSLUrgency"));
    $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
    $LogsWarninStop = intval($sock->GET_INFO("LogsWarninStop"));
    $SquidUFDBUrgency = intval($sock->GET_INFO("SquidUFDBUrgency"));
    $IsPortsConverted = intval($sock->GET_INFO("IsPortsConverted"));
    $SquidCacheFullHideWarn = intval($sock->GET_INFO("SquidCacheFullHideWarn"));
    $ActiveDirectoryEmergency = intval($sock->GET_INFO("ActiveDirectoryEmergency"));
    $BasicAuthenticatorEmergency = intval($sock->GET_INFO("BasicAuthenticatorEmergency"));
    $eCAPClamavEmergency = intval($sock->GET_INFO("eCAPClamavEmergency"));
    $ParanoidBlockerEmergency = intval($sock->GET_INFO("ParanoidBlockerEmergency"));
    $EnableeCapClamav = intval($sock->GET_INFO("EnableeCapClamav"));
    $curs = "OnMouseOver=\"this.style.cursor='pointer';\"\n\tOnMouseOut=\"this.style.cursor='auto'\"";
    $WebFiltering_blocked = null;
    $CACHES_AVG = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHES_AVG"), 1);
    $COUNT_DE_BLOCKED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_BLOCKED"));
    $SquidDebugAcls = intval($sock->GET_INFO("SquidDebugAcls"));
    $AsTransparent = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_TRANSPARENT"));
    $WATCHDOG_COUNT_EVENTS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/WATCHDOG_COUNT_EVENTS"));
    $COUNT_DE_CACHES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_CACHES"));
    $SUM_FAMILYSITES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/SUM_FAMILYSITES"));
    $WindowsUpdateCaching = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCaching"));
    $TOP_WEBSITE = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOP_WEBSITE"));
    $NOT_CATEGORIZED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/NOT_CATEGORIZED"));
    $CACHES_RATES = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOTAL_CACHED_ARRAY"));
    $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]);
    $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]);
    if ($users->AsProxyMonitor) {
        if ($EnableKerbAuth == 1) {
            $ntmlauthenticators = _ntmlauthenticators();
            while (list($cpu, $purc) = each($ntmlauthenticators)) {
                $color = "black";
                if ($purc > 95) {
                    $color = "#d32d2d";
                }
                $ntmlauthenticators_array[] = "\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"javscript:Loadjs('squid.ntmlauthenticators.php?cpu={$cpu}')\"\n\t\t\t\t\tstyle='text-decoration:underline;color:{$color}'>{ntlm_processes}: CPU#{$cpu} {$purc}%</a></td>\n\t\t\t\t\t</tr>";
            }
        }
    }
    $SERVICES_STATUS = SERVICES_STATUS();
    if (!is_array($SERVICES_STATUS)) {
        $CountDeServices = $SERVICES_STATUS;
    } else {
        $icon = "disks-128-warn.png";
        $err = $SERVICES_STATUS;
    }
    $scriptEnd = "LoadAjaxTiny('active-directory-dash-infos','{$page}?active-directory-dash-infos=yes');";
    $EnableUfdbGuard = $sock->EnableUfdbGuard();
    $realsquidversion = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidRealVersion");
    $sql = "SELECT COUNT(*) as tcount FROM proxy_ports WHERE enabled=1";
    $results = $q->QUERY_SQL($sql);
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (!$q->ok) {
        $err[] = proxy_status_warning("MySQL error", $q->mysql_error_html(), "blur()");
    }
    $COUNTDePorts = $ligne["tcount"];
    $js_icon_stats = null;
    $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'><img src='img/statistics-24-grey.png'></div>";
    $GotoNotCategorized = "GotoNotCategorized()";
    $ActiveRequests_js = "Loadjs('squid.active.requests.php')";
    $GotoNotCategorized_underline = "underline";
    $ActiveRequests_underline = "underline";
    $GotoMysQLAllWebsites_underline = "underline";
    $GoToCachedStatistics = "GoToCachedStatistics()";
    $GotoMysQLAllWebsites = "GotoMysQLAllWebsites()";
    $LoadProxyUpdate = "LoadProxyUpdate();";
    $LOadUfdbUpdate = "GoToWebfilteringDBstatus();";
    if (!$users->AllowViewStatistics) {
        $GotoNotCategorized = "blur();";
        $ActiveRequests_js = "blur()";
        $GotoNotCategorized_underline = "none";
        $ActiveRequests_underline = "none";
        $GoToCachedStatistics = "blur()";
        $GotoMysQLAllWebsites = "blur()";
        $GotoMysQLAllWebsites_underline = "none";
    }
    if (!$users->AsSquidAdministrator) {
        $LoadProxyUpdate = "blur()";
        $LOadUfdbUpdate = "blur()";
    }
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    if ($SquidPerformance < 2) {
        $prec = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHED_AVG"), 1);
        $PROXY_REQUESTS_NUMBER = @file_get_contents("{$GLOBALS["BASEDIR"]}/PROXY_REQUESTS_NUMBER");
        $PROXY_REQUESTS_NUMBER = FormatNumber($PROXY_REQUESTS_NUMBER);
        if ($COUNT_DE_CACHES > 0) {
            $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024;
            $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB);
        }
        $js_icon_stats = "OnMouseOver=\"this.style.cursor='pointer';\"\n\t\tOnMouseOut=\"this.style.cursor='auto'\"\n\t\tOnClick=\"javascript:{$GoToCachedStatistics};\"";
        if (is_file("{$GLOBALS["BASEDIR"]}/CACHED_ROW_DAY")) {
            $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'>\n\t\t\t\t\t<img src='img/statistics-24.png'></div>";
        }
        if ($SUM_FAMILYSITES > 0) {
            $SUM_FAMILYSITES = FormatNumber($SUM_FAMILYSITES);
            $SUM_FAMILYSITES_TEXT = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>{websites}:\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$GotoMysQLAllWebsites};\"\n\t\t\tstyle='text-decoration:{$GotoMysQLAllWebsites_underline}'>{$SUM_FAMILYSITES}</a></td>\n\t\t\t</tr>";
        }
    }
    $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 ($NOT_CATEGORIZED > 0) {
        $NOT_CATEGORIZED = FormatNumber($NOT_CATEGORIZED);
        $NOT_CATEGORIZED_ROW = "<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$GotoNotCategorized}\"\n\t\tstyle='text-decoration:{$GotoNotCategorized_underline}'>{websites}: {$NOT_CATEGORIZED} {not_categorized}</a></td>\n\t\t</tr>";
    }
    $TITLE_REQUESTS = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$ActiveRequests_js}\"\n\t\tstyle='text-decoration:{$ActiveRequests_underline}'>{$ActiveRequestsNumber} {active_requests}</a></td>\n\t\t</tr>";
    if ($COUNTDePorts == 0) {
        $err[] = proxy_status_warning("{no_listening_port_defined}", "{no_listening_port_proxydefined_explain}", "GotoSquidPorts()");
    }
    if ($SquidDebugAcls == 1) {
        $err[] = proxy_status_warning("{debug_acls}", "{debug_acls_explain}", "Loadjs('squid.acls.options.php')");
    }
    if ($SNMP_WALK["ERROR"]) {
        $err[] = proxy_status_warning("SNMP:{need_to_restart_webconsole}", "{click_to_install}", "Loadjs('php-snmp.progress.php'");
    }
    preg_match("#^([0-9]+)\\.([0-9]+)#", $realsquidversion, $re);
    $MAJOR = intval($re[1]);
    $MINOR = intval($re[2]);
    $INCOMPATIBLE = true;
    $REV = 0;
    $BUILD = 0;
    if ($MAJOR > 2) {
        if ($MINOR > 4) {
            $INCOMPATIBLE = false;
        }
    }
    if ($MAJOR == 0) {
        $INCOMPATIBLE = false;
    }
    if ($MAJOR == 4) {
        $INCOMPATIBLE = false;
    }
    if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $realsquidversion, $re)) {
        $REV = intval($re[3]);
    }
    if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $realsquidversion, $re)) {
        $BUILD = intval($re[4] . $re[5]);
    }
    if ($SQUIDEnable == 1) {
        if ($INCOMPATIBLE) {
            $incompatible_proxy_version = $tpl->_ENGINE_parse_body("{incompatible_proxy_version}");
            $incompatible_proxy_version = str_replace("%s", $realsquidversion, $incompatible_proxy_version);
            $err[] = proxy_status_warning($incompatible_proxy_version, $incompatible_proxy_version, $LoadProxyUpdate);
        }
        $ArticaTechNetSquidRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetSquidRepo")));
        $NEWVER = null;
        while (list($key, $array) = each($ArticaTechNetSquidRepo)) {
            $AVVERSION = $array["VERSION"];
            $XREV = 0;
            $XBUILD = 0;
            preg_match("#^([0-9]+)\\.([0-9]+)#", $AVVERSION, $re);
            $XMAJOR = intval($re[1]);
            $XMINOR = intval($re[2]);
            if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $AVVERSION, $re)) {
                $XREV = intval($re[3]);
            }
            if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $AVVERSION, $re)) {
                $XBUILD = intval($re[4] . $re[5]);
            }
            $KEY = intval("{$XMAJOR}{$XMINOR}{$XREV}{$XBUILD}");
            if ($MAJOR > $XMAJOR) {
                continue;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "<strong> squidver check {$XMAJOR}/{$XMINOR}/{$XREV}/{$XBUILD} - {$MAJOR}/{$MINOR}/{$REV}/{$BUILD}</strong>\n<br>";
            }
            if ($XMAJOR > $MAJOR) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "<strong> squidver check {$XMAJOR}>{$MAJOR}</strong>\n<br>";
                }
                $NEWVER = $AVVERSION;
                break;
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR > $MINOR) {
                    $NEWVER = $AVVERSION;
                    break;
                }
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR == $MINOR) {
                    if ($XREV > $REV) {
                        $NEWVER = $AVVERSION;
                        break;
                    }
                }
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR == $MINOR) {
                    if ($XREV == $REV) {
                        if ($XBUILD > $BUILD) {
                            $NEWVER = $AVVERSION;
                            break;
                        }
                    }
                }
            }
        }
        if ($users->AsSquidAdministrator) {
            if ($NEWVER != null) {
                $INFOS[] = status_info_event("{SQUID_NEWVERSION} {$NEWVER}", "{SQUID_NEWVERSION_TEXT}", $LoadProxyUpdate);
            }
        }
    }
    if ($SquidUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes')";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $err[] = proxy_status_warning("{proxy_in_emergency_mode}", "{proxy_in_emergency_mode_explain}", $jsOn);
        $icon = "disks-128-red.png";
        //proxy_in_emergency_mode
        //proxy_in_emergency_mode_explain
    }
    if ($SquidSSLUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?ssl=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-red.png";
        $err[] = proxy_status_warning("{proxy_in_ssl_emergency_mode}", "{proxy_in_ssl_emergency_mode_explain}", $jsOn);
    }
    if ($MacToUidUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-red.png";
        $err[] = proxy_status_warning("{proxy_in_MacToUid_emergency_mode}", "{proxy_in_MacToUid_emergency_mode_explain}", $jsOn);
    }
    if ($SQUIDEnable == 1) {
        if ($SquidUFDBUrgency == 1) {
            $jsOn = "Loadjs('squid.urgency.php?ufdb=yes');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-red.png";
            $err[] = proxy_status_warning("{proxy_in_webfiltering_emergency_mode}", "{proxy_in_webfiltering_emergency_mode_explain}", $jsOn);
        }
        if ($EnableUfdbGuard == 1) {
            if ($users->CORP_LICENSE) {
                $ufdbguard_artica_cloud_version = ufdbguard_artica_cloud_version();
                if ($ufdbguard_artica_cloud_version == 0) {
                    $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                    if (!$users->AsSquidAdministrator) {
                        $jsOn = "blur()";
                    }
                    $important_events[] = status_important_event("{update_webfiltering_artica_databases}", "{update_webfiltering_artica_databases_not_updated}", $jsOn);
                }
                if ($ufdbguard_artica_cloud_version > 1) {
                    $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                    if (!$users->AsSquidAdministrator) {
                        $jsOn = "blur()";
                    }
                    $important_events[] = status_important_event("{webfiltering_artica_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn);
                }
            }
            $ufdbguard_toulouse_cloud_version = ufdbguard_toulouse_cloud_version();
            if ($ufdbguard_toulouse_cloud_version == 0) {
                $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $important_events[] = status_important_event("{update_webfiltering_toulouse_databases}", "{update_webfiltering_toulouse_databases_not_updated}", $jsOn);
            }
            if ($ufdbguard_toulouse_cloud_version > 1) {
                $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $important_events[] = status_important_event("{webfiltering_toulouse_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn);
            }
        }
    }
    if ($SQUIDEnable == 1) {
        if ($LogsWarninStop == 1) {
            $jsOn = "Loadjs('system.log.emergency.php');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $help = help_icon("{squid_logs_urgency}");
            $text = texttooltip("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn);
            $icon = "disks-128-red.png";
            $err[] = proxy_status_warning("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn);
        }
    }
    if ($SQUIDEnable == 1) {
        if ($IsPortsConverted == 0) {
            $jsOn = "Loadjs('squid.compile.progress.php');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-warn.png";
            $err[] = proxy_status_warning("{IsPortsConverted_requested}", "{squid_IsPortsConverted_explain}", $jsOn);
        } else {
            if ($AsTransparent > 0) {
                $FireHolConfigured = intval($sock->GET_INFO("FireHolConfigured"));
                if ($FireHolConfigured == 0) {
                    $icon = "disks-128-warn.png";
                    $err[] = proxy_status_warning("{transparent_mode_issue}", "{squid_transparent_no_firewall}", $jsOn);
                }
            }
        }
    }
    $GoToCategoriesServiceA = "GoToCategoriesServiceA()";
    $GotoAdConnection = "GotoAdConnection()";
    $LoadMainDashProxy = "LoadMainDashProxy()";
    $GoToServices = "GoToServices()";
    $GoToUfdb = "GoToUfdb()";
    $GoToCaches = "GoToCaches()";
    $GoToCaches_underline = "underline";
    if (!$users->AsDansGuardianAdministrator) {
        $GoToCategoriesServiceA = "blur()";
        $GoToUfdb = "blur()";
    }
    if (!$users->AsSquidAdministrator) {
        $GotoAdConnection = "blur()";
        $LoadMainDashProxy = "blur()";
        $GoToServices = "blur()";
        $GoToCaches = "blur()";
        $GoToCaches_underline = "none";
    }
    if ($SQUIDEnable == 1) {
        $catz = new mysql_catz();
        if ($catz->UfdbCatEnabled == 1) {
            $categories = $catz->ufdbcat("google.com");
            if (!$catz->ok) {
                $icon = "disks-128-warn.png";
                $err[] = proxy_status_warning("{APP_UFDBCAT}: {connection_error}", $catz->mysql_error, $GoToCategoriesServiceA);
            }
        }
    }
    if ($SQUIDEnable == 1) {
        if ($sock->SQUID_IS_EXTERNAL_LDAP()) {
            $tests = CHECK_SQUID_EXTERNAL_LDAP();
            if ($tests != null) {
                $err[] = proxy_status_warning("{$tests}", "{$tests}", "GotoOpenldap()");
            }
        }
    }
    if ($BasicAuthenticatorEmergency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-warn.png";
        $err[] = proxy_status_warning("{authentication_emergency_mode}", "{authentication_emergency_mode_explain}", $jsOn);
    }
    if ($SQUIDEnable == 1) {
        if ($EnableKerbAuth == 1) {
            if ($ActiveDirectoryEmergency == 1) {
                $jsOn = "Loadjs('squid.urgency.php?activedirectory=yes');";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $icon = "disks-128-warn.png";
                $err[] = proxy_status_warning("{activedirectory_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn);
            }
            if (!$users->CORP_LICENSE) {
                $Days = 86400 * 30;
                $DayToLeft = 30;
                if (is_file("/usr/share/artica-postfix/ressources/class.pinglic.inc")) {
                    include_once "/usr/share/artica-postfix/ressources/class.pinglic.inc";
                    $EndTime = $GLOBALS['ADLINK_TIME'] + $Days;
                    $seconds_diff = $EndTime - time();
                    $DayToLeft = floor($seconds_diff / 3600 / 24);
                }
                $MAIN_ERROR = $tpl->_ENGINE_parse_body("{warn_no_license_activedirectory_30days}");
                $MAIN_ERROR = str_replace("%s", $DayToLeft, $MAIN_ERROR);
                $important_events[] = status_important_event($MAIN_ERROR, $MAIN_ERROR, $jsOn);
            }
            if ($ActiveDirectoryEmergency == 0) {
                $IsConnected = IsKerconnected();
                if ($IsConnected != "TRUE") {
                    $err[] = proxy_status_warning("{proxy_is_not_configured_ad}", null, $GotoAdConnection);
                }
            }
            $TestLDAPAD = TestLDAPAD();
            if ($TestLDAPAD != null) {
                $err[] = $TestLDAPAD;
            }
            $AdminAsSeenNTLMPerfs = intval($sock->GET_INFO("AdminAsSeenNTLMPerfs"));
            if ($AdminAsSeenNTLMPerfs == 0) {
                $err[] = proxy_status_warning("{NTLM_PERFORMANCES_NOT_DEFINED}", null, $GotoAdConnection);
            }
        }
    }
    if ($EnableeCapClamav == 1) {
        if ($eCAPClamavEmergency == 1) {
            $jsOn = "Loadjs('squid.urgency.php?eCAPClamavEmergency=yes');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-warn.png";
            $err[] = proxy_status_warning("{eCAPClamav_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn);
        }
    }
    if ($ParanoidBlockerEmergency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?ParanoidBlockerEmergency=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-warn.png";
        $err[] = proxy_status_warning("{paranoid_emergency_mode}", "{paranoid_emergency_mode_explain}", $jsOn);
    }
    if ($SquidCacheFullHideWarn == 0) {
        if ($COUNT_DE_CACHES > 0) {
            if ($CACHES_AVG > 85) {
                $err[] = proxy_status_warning("{caches_are_full}", "{caches_are_full_explain}", $GoToCaches);
            }
        }
    }
    if ($COUNT_DE_CACHES > 0) {
        $COUNT_DE_MEMBERS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/MEMBERS_COUNT"));
        if ($COUNT_DE_MEMBERS > 15) {
            if ($COUNT_DE_CACHES < 20000) {
                $undersized_proxy_caches_explain = $tpl->_ENGINE_parse_body("{undersized_proxy_caches_explain}");
                $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024;
                $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB);
                $undersized_proxy_caches_explain = str_replace("%S", $COUNT_DE_CACHES_TEXT, $undersized_proxy_caches_explain);
                $undersized_proxy_caches_explain = str_replace("%U", $COUNT_DE_MEMBERS, $undersized_proxy_caches_explain);
                if ($SquidCacheLevel > 0) {
                    $err[] = proxy_status_warning("{undersized_proxy_caches}", $undersized_proxy_caches_explain, $GoToCaches);
                }
            }
        }
    }
    if (!$users->AsSquidAdministrator) {
        $err = array();
    }
    if (count($err) > 0) {
        $errT[] = "<tr><td style='font-size:32px;color:#d32d2d;vertical-align:middle'>" . count($err) . " {issues}</td></tr>\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\t\n\t\t\t\t";
    }
    $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"]);
    $GotoParanoidMode = "GotoParanoidMode()";
    $GotoParanoidMode_underline = "underline";
    $GoToUfdb_underline = "underline";
    if (!$users->AsDansGuardianAdministrator) {
        $GotoParanoidMode = "blur()";
        $GoToUfdb = "blur()";
        $GotoParanoidMode_underline = "none";
        $GoToUfdb_underline = "none";
    }
    $UfdbEnableParanoidMode = intval($sock->GET_INFO("UfdbEnableParanoidMode"));
    if ($UfdbEnableParanoidMode == 1) {
        $q = new mysql_squid_builder();
        $webfilters_paranoid = $q->COUNT_ROWS("webfilters_paranoid");
        if ($webfilters_paranoid > 0) {
            $webfilters_paranoid_text = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GotoParanoidMode}\"\n\t\tstyle='text-decoration:{$GotoParanoidMode_underline}'>{paranoid_mode}: " . FormatNumber($webfilters_paranoid) . " {rules}</a></td>\n\t\t</tr>";
        }
    }
    if ($EnableUfdbGuard == 1) {
        if ($COUNT_DE_BLOCKED > 0) {
            $WebFiltering_blocked = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GoToUfdb}\"\n\t\tstyle='text-decoration:{$GoToUfdb_underline}'>{blocked_events}: " . FormatNumber($COUNT_DE_BLOCKED) . "</a></td>\n\t\t</tr>";
        }
    }
    if (intval($ini->_params["SQUID"]["service_disabled"]) == 1) {
        if ($ini->_params["SQUID"]["running"] == 0) {
            $icon = "disks-128-red.png";
        }
    }
    $mgr_client_list_TR = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoMgrClientList()\"\n\t\t\tstyle='text-decoration:underline'>{active_clients}: " . FormatNumber($SNMP_WALK["CLIENTS_NUMBER"]) . "</a></td>\n\t\t</tr>";
    $active_resquests_js = "Loadjs('squid.active.requests.php')";
    $active_resquests_underline = "underline";
    if (!$users->AsSquidAdministrator) {
        $active_resquests_js = "blur()";
        $active_resquests_underline = "none";
    }
    if ($ActiveRequestsNumber > 1) {
        $active_resquests = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$active_resquests_js}\"\n\t\t\tstyle='text-decoration:underline'>{active_requests}: {$ActiveRequestsNumber}</a></td>\n\t\t</tr>";
    }
    if (intval($WATCHDOG_COUNT_EVENTS) > 0) {
        $important_events[] = status_important_event("{$WATCHDOG_COUNT_EVENTS} {important_events_48h}", null, "GotoWatchdog()");
    }
    $CACHES_AVG_COLOR = "black";
    if ($CACHES_AVG > 85) {
        if ($SquidCacheFullHideWarn == 0) {
            $CACHES_AVG_COLOR = "#d32d2d";
        }
    }
    if (count($important_events) > 0) {
        $important_events_text = "<tr><td colspan=2>&nbsp;</td></tr>" . @implode("\n", $important_events);
    }
    if ($SQUIDEnable == 0) {
        $icon = "disks-128-ok-grey.png";
    }
    if (count($INFOS) > 0) {
        $INFOS[] = "<tr><td><br></td></tr>";
    }
    if ($SquidCacheLevel == 0) {
        $SNMP_WALK["PERC_CACHE"] = 0;
        $SNMP_WALK["STORED_OBJECTS"] = 0;
    }
    $prec = intval($SNMP_WALK["PERC_CACHE"]);
    if ($prec > 0) {
        $perc_cache = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>{$prec}% {cache} ({currently})</td>\n\t\t</tr>";
    }
    $REQUESTS = intval($SNMP_WALK["REQUESTS"]);
    if ($REQUESTS > 0) {
        $current_req = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($REQUESTS) . " {requests}</td>\n\t\t</tr>";
    }
    if ($SNMP_WALK["CPU"] > 0) {
        $current_cpu_use = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>{$SNMP_WALK["CPU"]}% {cpu_use}</td>\n\t\t</tr>";
    }
    $windowsUpdate = null;
    if ($WindowsUpdateCaching == 1) {
        $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/WindowsUpdate.state";
        $ARRAY = unserialize(@file_get_contents($cacheFile));
        if (intval($ARRAY["SIZEKB"]) > 4) {
            $windowsUpdate = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'> \n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWindowsUpdate()\"\n\t\t\tstyle='text-decoration:underline'>Windows Update:</a> " . FormatBytes($ARRAY["SIZEKB"]) . "</td>\n\t\t\t</tr>";
        }
    }
    $HTTrack = null;
    if ($HTTrackInSquid == 1) {
        $HTTRackSize = $sock->GET_INFO("HTTRackSize");
        if ($HTTRackSize > 0) {
            $HTTrack = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWebCopy()\"\n\t\t\tstyle='text-decoration:underline'>WebCopy:</a> " . FormatBytes($HTTRackSize / 1024) . "</td>\n\t\t\t</tr>";
        }
    }
    if ($SNMP_WALK["STORED_OBJECTS"] > 0) {
        $current_stored_objects = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($SNMP_WALK["STORED_OBJECTS"]) . " {stored_objects}</td>\n\t\t</tr>";
    }
    if ($SquidCacheLevel > 0) {
        if ($COUNT_DE_CACHES_TEXT != null) {
            $INFO_STORAGE_CACHE = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:{$CACHES_AVG_COLOR}'>\n\t\t\t\t\t\t{storage}: {$CACHES_AVG}%&nbsp;/&nbsp;{$COUNT_DE_CACHES_TEXT}</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
        }
    }
    $CACHED_DETAILS_TOTAL = null;
    $NOT_CACHED_DETAILS_TOTAL = null;
    if ($TOTALS_CACHED > 0) {
        $CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{cached}: " . FormatBytes($TOTALS_CACHED / 1024) . "</a>\n\t\t\t</td>\n\t\t</tr>\n\t";
    }
    if ($TOTALS_NOT_CACHED > 0) {
        $NOT_CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{not_cached}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t";
    }
    if (!$users->AsSquidAdministrator) {
        $important_events_text = null;
        $errT = array();
        $windowsUpdate = null;
        $mgr_client_list_TR = null;
    }
    $icon = imgtootltip($icon, "position:right:{configure_your_proxy}", "{$LoadMainDashProxy}");
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' style='width:128px' >\n\t\t\t{$icon}\n\t\t\t<div id='active-directory-dash-infos'>" . active_directory_infos() . "</div>\t\n\t\t</td>\n\t\t<td>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:30px'>\n\t\t\t\t" . texttooltip("{your_proxy}", "{configure_your_proxy}", "{$LoadMainDashProxy}") . "\n\t\t\t\t&nbsp;<span style='font-size:22px'>[&nbsp;<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.infos.php');\"\n\t\t\t\tstyle='text-decoration:underline'>Infos.</a>&nbsp;]</span>\t\t\n\t\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<!-- perc_cache -->\n\t\t\t{$perc_cache}\n\t\t\t<!-- TOTALS_CACHED:{$TOTALS_CACHED} -->\n\t\t\t{$CACHED_DETAILS_TOTAL}\n\t\t\t<!-- TOTALS NOT CACHED:{$TOTALS_NOT_CACHED} -->\n\t\t\t{$NOT_CACHED_DETAILS_TOTAL}\n\t\t\t<!-- windowsUpdate -->\n\t\t\t{$windowsUpdate}\n\t\t\t<!-- HTTrack -->\n\t\t\t{$HTTrack}\n\t\t\t<!-- current_req -->\n\t\t\t{$current_req}\n\t\t\t<!-- SUM_FAMILYSITES_TEXT -->\n\t\t\t{$SUM_FAMILYSITES_TEXT}\n\t\t\n\t\t\t{$active_resquests}\n\t\t\t{$mgr_client_list_TR}\n\t\t\t{$rqs}\n\t\t\t\t" . @implode("", $ntmlauthenticators_array) . "\n\t\t\t\n\t\t\t\n\t\t<!-- WebFiltering_blocked -->\n\t\t{$WebFiltering_blocked}\n\t\t<!-- webfilters_paranoid -->\n\t\t{$webfilters_paranoid_text}\t\n\t\t<!-- INFO_STORAGE_CACHE -->\n\t\t{$INFO_STORAGE_CACHE}\n\t\t\n\t\t\n\t\t\n\t<!-- current_stored_objects -->\n\t\t\t{$current_stored_objects}\n\t<!-- TITLE_REQUESTS -->\n\t\t\t{$TITLE_REQUESTS}\n\t<!-- TOP_GRAPHS -->\n\t\t\t" . TOP_GRAPHS() . "\n\t\t\t{$CountDeServices}\n\t\t\t" . @implode("", $INFOS) . "\n\t\t\t" . @implode("", $errT) . "\n\t\t\t" . @implode("", $err) . "\n\t\t\t{$important_events_text}\n\t\t\t\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjaxSilent('proxy_dashboard_counters','{$page}?proxy_dashboard_counters=yes');\n\t</script>\n\t";
    $html = $tpl->_ENGINE_parse_body($html);
    if (!is_dir("/usr/share/artica-postfix/ressources/interface-cache")) {
        @mkdir("/usr/share/artica-postfix/ressources/interface-cache");
    }
    @file_put_contents($cachefile, $html);
    return $html;
}