function parseTemplate_unlock_checkcred() { include_once dirname(__FILE__) . "/ressources/class.sockets.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; include_once dirname(__FILE__) . "/ressources/class.user.inc"; include_once dirname(__FILE__) . "/ressources/class.templates.inc"; include_once dirname(__FILE__) . "/ressources/class.users.menus.inc"; include_once dirname(__FILE__) . "/ressources/class.external.ad.inc"; include_once dirname(__FILE__) . "/ressources/class.ldap-extern.inc"; include "ressources/settings.inc"; $sock = new sockets(); $UfdbGuardHTTPAllowNoCreds = intval($sock->GET_INFO("UfdbGuardHTTPAllowNoCreds")); if ($UfdbGuardHTTPAllowNoCreds == 1) { return true; } if ($_POST["nocreds"] == 1) { return true; } $username = $_POST["username"]; $password = trim($_POST["password"]); if ($sock->SQUID_IS_EXTERNAL_LDAP()) { $ldap_extern = new ldap_extern(); if ($ldap_extern->checkcredentials($username, $password)) { return true; } } if (trim(strtolower($username)) == trim(strtolower($_GLOBAL["ldap_admin"]))) { if ($password == trim($_GLOBAL["ldap_password"])) { return true; } } $ldap = new clladp(); if ($ldap->IsKerbAuth()) { $external_ad_search = new external_ad_search(); if ($external_ad_search->CheckUserAuth($username, $password)) { return true; } } $q = new mysql(); $sql = "SELECT `username`,`value`,id FROM radcheck WHERE `username`='{$username}' AND `attribute`='Cleartext-Password' LIMIT 0,1"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!is_numeric($ligne["id"])) { $ligne["id"] = 0; } if (!$q->ok) { writelogs("{$username}:: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__); } if ($ligne["id"] > 0) { if ($ligne["value"] == $password) { return true; } } $u = new user($username); if (trim($u->uidNumber) != null) { if (trim($password) == trim($u->password)) { return true; } } return false; }
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> </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> </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}% / {$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 <span style='font-size:22px'>[ <a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.infos.php');\"\n\t\t\t\tstyle='text-decoration:underline'>Infos.</a> ]</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; }
function CHECK_SQUID_EXTERNAL_LDAP() { $sock = new sockets(); if (!$sock->SQUID_IS_EXTERNAL_LDAP()) { return; } $unix = new unix(); $filetime = "/etc/artica-postfix/pids/" . md5(__FILE__ . __FUNCTION__); $TimeExec = $unix->file_time_min($filetime); $EXTERNAL_LDAP_AUTH_PARAMS = unserialize(base64_decode($sock->GET_INFO("SquidExternalAuth"))); $ldap_server = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_server"]; $ldap_port = intval($EXTERNAL_LDAP_AUTH_PARAMS["ldap_port"]); if ($ldap_port == 0) { $ldap_port = 389; } $ldap_suffix = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_suffix"]; $CONNECTION = @ldap_connect($ldap_server, $ldap_port); if (!$CONNECTION) { if ($TimeExec > 30) { @unlink($filetime); squid_admin_mysql(0, "Connection to LDAP server failed {$ldap_server}:{$ldap_port}", null, __FILE__, __LINE__); @file_put_contents($filetime, time()); } return; } @ldap_set_option($CONNECTION, LDAP_OPT_PROTOCOL_VERSION, 3); @ldap_set_option($CONNECTION, LDAP_OPT_REFERRALS, 0); @ldap_set_option($CONNECTION, LDAP_OPT_PROTOCOL_VERSION, 3); // on passe le LDAP en version 3, necessaire pour travailler avec le AD @ldap_set_option($CONNECTION, LDAP_OPT_REFERRALS, 0); $userdn = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_user"]; $ldap_password = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_password"]; $BIND = @ldap_bind($CONNECTION, $userdn, $ldap_password); if (!$BIND) { $error = @ldap_err2str(@ldap_errno($CONNECTION)); if (@ldap_get_option($CONNECTION, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) { $error = $error . " {$extended_error}"; } @ldap_close($CONNECTION); if ($TimeExec > 30) { @unlink($filetime); squid_admin_mysql(0, "Authenticate to LDAP server {$ldap_server}:{$ldap_port} failed {$error}", $error, __FILE__, __LINE__); @file_put_contents($filetime, time()); } return; } @unlink($filetime); @ldap_close($CONNECTION); }
function rule_popup() { $dans = new dansguardian_rules(); $md5 = $_GET["rule-popup"]; $tpl = new templates(); $page = CurrentPageName(); $fields_size = 22; $q = new mysql_squid_builder(); $sock = new sockets(); $t = time(); $bt = "{add}"; if ($md5 != null) { $bt = "{apply}"; } $Timez[0] = "{default}"; $Timez[5] = "5 {minutes}"; $Timez[10] = "10 {minutes}"; $Timez[15] = "15 {minutes}"; $Timez[30] = "30 {minutes}"; $Timez[60] = "1 {hour}"; $Timez[120] = "2 {hours}"; $Timez[240] = "4 {hours}"; $Timez[720] = "12 {hours}"; $Timez[2880] = "2 {days}"; $cats = $dans->LoadBlackListes(); while (list($num, $ligne) = each($cats)) { $newcat[$num] = $num; } $newcat[null] = "{all_categories}"; $newcat["safebrowsing"] = "Google Safe Browsing"; $newcat["blacklist"] = "{blacklist}"; $newcat["generic"] = "{generic}"; if (!$q->FIELD_EXISTS("ufdb_page_rules", "ticket")) { $q->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `ticket` smallint(1) NOT NULL DEFAULT 0, ADD INDEX ( `ticket` )"); } if (!$q->FIELD_EXISTS("ufdb_page_rules", "ticket")) { $q->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `ticket` smallint(1) NOT NULL DEFAULT 0, ADD INDEX ( `ticket` )"); } if (!$q->FIELD_EXISTS("ufdb_page_rules", "webruleid")) { $q->QUERY_SQL("ALTER TABLE `ufdb_page_rules` ADD `webruleid` INT(10) NOT NULL NOT NULL DEFAULT 0, ADD INDEX ( `webruleid` )"); } $sql = "SELECT ID,groupname FROM webfilter_rules WHERE enabled=1"; $results = $q->QUERY_SQL($sql); $RULES["0"] = "{all_rules}"; $btname = "{add}"; $t = time(); while ($ligne = mysql_fetch_assoc($results)) { $RULES[$ligne["ID"]] = "{$ligne["groupname"]}"; } $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM ufdb_page_rules WHERE zmd5='{$md5}'")); $group_legend = "{active_directory_group}"; if ($sock->SQUID_IS_EXTERNAL_LDAP()) { $group_legend = "{ldap_group}"; } if (!$q->ok) { echo FATAL_ERROR_SHOW_128($q->mysql_error); return; } $html[] = "<div style='width:98%' class=form>"; $html[] = "<table style='width:100%'>"; $html[] = Field_list_table("webruleid-{$t}", "{rule}", $ligne["webruleid"], $fields_size, $RULES, null, 450); $html[] = Field_list_table("category-{$t}", "{category}", $ligne["category"], $fields_size, $newcat, null, 450); $html[] = Field_list_table("maxtime-{$t}", "{unlock_during}", $ligne["maxtime"], $fields_size, $Timez, null, 450); $html[] = Field_text_table("adgroup-{$t}", "{$group_legend}", $ligne["adgroup"], $fields_size, null, 450); if ($sock->SQUID_IS_EXTERNAL_LDAP()) { $html[] = Field_button_table_autonome("{browse}", "Loadjs('browse-extldap-groups.php?MainFunction=FdapGroup{$t}')"); } $html[] = Field_text_table("username-{$t}", "{username}", $ligne["username"], $fields_size, null, 450); $html[] = Field_checkbox_table("deny-{$t}", "{deny_unlock}", $ligne["deny"], $fields_size, null, "UnCheckAllow{$t}()"); $html[] = Field_checkbox_table("allow-{$t}", "{allow_unlock}", $ligne["allow"], $fields_size, null, "UnCheckDeny{$t}()"); $html[] = Field_checkbox_table("ticket-{$t}", "{submit_ticket}", $ligne["ticket"], $fields_size, null, "UnTicket{$t}()"); $html[] = Field_checkbox_table("noauth-{$t}", "{not_authenticate}", $ligne["noauth"], $fields_size); $html[] = Field_list_table("addTocat-{$t}", "{automatically_add_to}", $ligne["addTocat"], $fields_size, $newcat, null, 450); $html[] = Field_button_table_autonome($bt, "Submit{$t}", 30); $html[] = "</table>"; $html[] = "</div>\n\t<script>\n\tvar xSubmit{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);}\n\t\t\$('#UFDB_PAGE_RULE').flexReload();\n\t\n\t}\n\t\n\tfunction UnCheckAllow{$t}(){\n\t\tif(document.getElementById('deny-{$t}').checked){\n\t\t\tdocument.getElementById('allow-{$t}').checked=false;\n\t\t}else{\n\t\t\tdocument.getElementById('allow-{$t}').checked=true;\n\t\t\n\t\t}\n\t\n\t}\n\t\n\tfunction UnCheckDeny{$t}(){\n\t\tif(document.getElementById('allow-{$t}').checked){\n\t\t\tdocument.getElementById('deny-{$t}').checked=false;\n\t\t}else{\n\t\t\tdocument.getElementById('deny-{$t}').checked=true;\n\t\t}\n\t}\n\t\n\tfunction UnTicket{$t}(){\n\t\tif(document.getElementById('ticket-{$t}').checked){\n\t\t\tdocument.getElementById('deny-{$t}').checked=true;\n\t\t\tdocument.getElementById('allow-{$t}').checked=false;\n\t\t\tdocument.getElementById('noauth-{$t}').checked=true;\n\t\t\tdocument.getElementById('deny-{$t}').disabled=true;\n\t\t\tdocument.getElementById('allow-{$t}').disabled=true;\n\t\t\tdocument.getElementById('noauth-{$t}').disabled=true;\n\t\t\tdocument.getElementById('maxtime-{$t}').disabled=true;\n\t\t\tdocument.getElementById('addTocat-{$t}').disabled=true;\n\t\t}else{\n\t\t\tdocument.getElementById('deny-{$t}').disabled=false;\n\t\t\tdocument.getElementById('allow-{$t}').disabled=false;\n\t\t\tdocument.getElementById('noauth-{$t}').disabled=false;\n\t\t\tdocument.getElementById('maxtime-{$t}').disabled=false;\n\t\t\tdocument.getElementById('addTocat-{$t}').disabled=false;\n\t\t\t}\n\t\t\n\t}\n\t\n\tfunction FdapGroup{$t}(DN){\n\t\tdocument.getElementById('adgroup-{$t}').value='EXTLDAP:'+DN;\n\t}\n\t\n\t\n\tfunction Submit{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('rule','{$md5}');\n\t\tXHR.appendData('category',document.getElementById('category-{$t}').value);\n\t\tXHR.appendData('adgroup',document.getElementById('adgroup-{$t}').value);\n\t\tXHR.appendData('username',document.getElementById('username-{$t}').value);\n\t\tXHR.appendData('addTocat',document.getElementById('addTocat-{$t}').value);\n\t\tXHR.appendData('maxtime',document.getElementById('maxtime-{$t}').value);\n\t\tXHR.appendData('webruleid',document.getElementById('webruleid-{$t}').value);\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tif(document.getElementById('deny-{$t}').checked){\n\t\t\tXHR.appendData('deny','1');\t\n\t\t}else{\n\t\t\tXHR.appendData('deny','0');\t\n\t\t\n\t\t}\n\t\tif(document.getElementById('allow-{$t}').checked){\n\t\t\tXHR.appendData('allow','1');\t\n\t\t}else{\n\t\t\tXHR.appendData('allow','0');\t\n\t\t\n\t\t}\t\n\n\t\tif(document.getElementById('noauth-{$t}').checked){\n\t\t\tXHR.appendData('noauth','1');\t\n\t\t}else{\n\t\t\tXHR.appendData('noauth','0');\t\n\t\t\n\t\t}\n\n\t\tif(document.getElementById('ticket-{$t}').checked){\n\t\t\tXHR.appendData('ticket','1');\t\n\t\t}else{\n\t\t\tXHR.appendData('ticket','0');\t\n\t\t\n\t\t}\t\t\t\n\t\t\n\t\t\n\n\t\tXHR.sendAndLoad('{$page}', 'POST',xSubmit{$t});\n\t}\n\t\n\tUnCheckAllow{$t}();\n\tUnTicket{$t}();\n\t</script>\n\t\t\n\t"; echo $tpl->_ENGINE_parse_body(@implode("\n", $html)); }
function build() { if (!is_dir("/usr/share/phpldapadmin/config")) { echo "slapd: [INFO] phpldapadmin not detected\n"; } writelogs("Starting building phpldapadmin", __FUNCTION__, __FILE__, __LINE__); $ldap = new clladp(); $sock = new sockets(); $EnableSambaActiveDirectory = $sock->GET_INFO("EnableSambaActiveDirectory"); $EnableParamsInPhpldapAdmin = $sock->GET_INFO("EnableParamsInPhpldapAdmin"); if (!is_numeric($EnableParamsInPhpldapAdmin)) { $EnableParamsInPhpldapAdmin = 0; } $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth"); if (!is_numeric("{$EnableKerbAuth}")) { $EnableKerbAuth = 0; } $suffix = trim(@file_get_contents("/etc/artica-postfix/ldap_settings/suffix")); $EnableOpenLdapProxy = $sock->GET_INFO("EnableOpenLdapProxy"); $OpenLdapProxySuffix = $sock->GET_INFO("OpenLdapProxySuffix"); if ($OpenLdapProxySuffix == null) { $OpenLdapProxySuffix = "dc=meta"; } if (!is_numeric($EnableOpenLdapProxy)) { $EnableOpenLdapProxy = 0; } $f[] = "<?php"; $f[] = "\$session[\"blowfish\"]=\"5ebe2294ecd0e0f08eab7690d2a6ee69\";"; $f[] = "\$config->custom->appearance[\"tree\"] = \"AJAXTree\";"; $f[] = "\$config->custom->appearance[\"friendly_attrs\"] = array("; $f[] = "\t\"facsimileTelephoneNumber\" => \"Fax\","; $f[] = "\t\"gid\" => \"Group\","; $f[] = "\t\"mail\" => \"Email\","; $f[] = "\t\"telephoneNumber\" => \"Telephone\","; $f[] = "\t\"uid\" => \"User Name\","; $f[] = "\t\"userPassword\" => \"Password\""; $f[] = ");"; $f[] = ""; $f[] = ""; $f[] = "\$servers = new Datastore();"; $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"Local LDAP Server\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$ldap->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",{$ldap->ldap_port});"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$suffix}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"cn={$ldap->ldap_admin},{$suffix}\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; if ($EnableOpenLdapProxy == 1) { echo "slapd: [INFO] phpldapadmin adding LDAP-META Server settings\n"; $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"Local LDAP-META Server\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$ldap->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",{$ldap->ldap_port});"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$OpenLdapProxySuffix}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"cn={$ldap->ldap_admin},{$OpenLdapProxySuffix}\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; } if ($sock->SQUID_IS_EXTERNAL_LDAP()) { $EXTERNAL_LDAP_AUTH_PARAMS = unserialize(base64_decode($sock->GET_INFO("SquidExternalAuth"))); $ldap_server = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_server"]; $ldap_port = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_port"]; $userdn = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_user"]; $ldap_password = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_password"]; $ldap_suffix = $EXTERNAL_LDAP_AUTH_PARAMS["ldap_suffix"]; echo "slapd: [INFO] phpldapadmin adding LDAP Server for proy settings\n"; $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"Remote {$ldap_server}\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$ldap_server}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",{$ldap_port});"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$ldap_suffix}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"{$userdn}\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; } if ($EnableKerbAuth == 1) { $ad = new ActiveDirectory(); $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"ActiveDirectory {$ad->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$ad->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",{$ad->ldap_port});"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$ad->suffix}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"{$ad->ldap_dn_user}\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; } if ($EnableSambaActiveDirectory == 1) { $array = unserialize(base64_decode($sock->getFrameWork("cmd.php?net-ads-info=yes"))); $ActiveDirectoryCredentials["suffix"] = $array["Bind Path"]; $ActiveDirectoryCredentials["host"] = $array["LDAP server"]; if ($ActiveDirectoryCredentials["host"] != null) { if ($EnableParamsInPhpldapAdmin == 1) { $bind_id = "{$ActiveDirectoryCredentials["bind_dn"]},{$ActiveDirectoryCredentials["suffix"]}"; $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"ActiveDirectory {$ActiveDirectoryCredentials["host"]}\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$ActiveDirectoryCredentials["host"]}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",389);"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$ActiveDirectoryCredentials["suffix"]}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"{$bind_id}\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; } } } $pattern = "(objectClass=AdLinker)"; $sr = @ldap_search($ldap->ldap_connection, $ldap->suffix, $pattern, array("dn")); $hash = ldap_get_entries($ldap->ldap_connection, $sr); if ($hash["count"] > 0) { include_once dirname(__FILE__) . '/ressources/class.activedirectory.inc'; for ($i = 0; $i < $hash["count"]; $i++) { if (preg_match("#cn=adlinker,ou=(.+?),dc=organizations,#", $hash[$i]["dn"], $re)) { echo "Starting lighttpd............: Build connexion for Active Directory Linker on \"{$re[1]}\" OU\n"; $wad = new wad($re[1]); $f[] = "\$servers->newServer(\"ldap_pla\");"; $f[] = "\$servers->setValue(\"server\",\"name\",\"ActiveDirectory {$wad->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"host\",\"{$wad->ldap_host}\");"; $f[] = "\$servers->setValue(\"server\",\"port\",389);"; $f[] = "\$servers->setValue(\"server\",\"base\",array(\"{$wad->suffix}\"));"; $f[] = "\$servers->setValue(\"login\",\"auth_type\",\"session\");"; $f[] = "\$servers->setValue(\"login\",\"bind_id\",\"\");"; $f[] = "\$servers->setValue(\"login\",\"bind_pass\",\"\");"; $f[] = "\$servers->setValue(\"server\",\"tls\",false);"; $f[] = ""; } } } $f[] = "?>"; echo "slapd: [INFO] phpldapadmin success\n"; @file_put_contents("/usr/share/phpldapadmin/config/config.php", @implode("\n", $f)); @chmod("/usr/share/phpldapadmin/config/config.php", 0666); }