Example #1
0
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $blackbox = new blackboxes($_GET["nodeid"]);
    $squid = new squidbee();
    $hostid = $_GET["hostid"];
    $t = time();
    $tpl = new templates();
    $t = time();
    $tr = array();
    $ini = new Bs_IniHandler();
    $ini->loadString($blackbox->SquidSMPStatus);
    while (list($index, $line) = each($ini->_params)) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . "::" . __LINE__ . "::{$index} -> DAEMON_STATUS_ROUND<br>\n";
        }
        $tr[] = DAEMON_STATUS_ROUND($index, $ini, null, 1);
    }
    if (count($tr) > 0) {
        $tr[] = squid_booster_smp($blackbox->BoosterSMPStatus);
        $smpstatus = CompileTr3($tr);
    }
    $actions[] = Paragraphe32("reload_proxy_service", "reload_proxy_service_text", "SquidNodeReload{$t}()", "reload-32.png");
    $actions[] = Paragraphe32("restart_proxy_service", "restart_proxy_service_text", "SquidNodeRestart{$t}()", "service-restart-32.png");
    $actions[] = Paragraphe32("reconfigure_proxy_service", "reconfigure_proxy_service_text", "SquidNodeReconf{$t}()", "reconfigure-32.png");
    $actions[] = Paragraphe32("configuration_file", "display_generated_configuration_file", "Loadjs('nodes.squid.conf.php?nodeid={$_GET["nodeid"]}')", "script-32.png");
    $action = CompileTr3($actions);
    $nodes_names = $squid->visible_hostname;
    if (isset($squid->nodes_names[$hostid])) {
        $nodes_names = $squid->nodes_names[$hostid];
    }
    $html = "\n\t<div id='{$t}'></div>\n\t<table style='width:99%' class=form>\n\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:14px'>{ipaddr}:</td>\n\t\t\t\t<td><strong style='font-size:14px'><strong style='font-size:14px'>{$blackbox->ipaddress}:{$blackbox->port}</td>\n\t\t\t</tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:14px'>{APP_SQUID}:</td>\n\t\t\t\t<td><strong style='font-size:14px'><strong style='font-size:14px'>{$blackbox->squid_version}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:14px'>{visible_hostname}:</td>\n\t\t\t\t<td><strong style='font-size:14px'><strong style='font-size:14px'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('{$page}?visible-hostname-js=yes&hostid={$hostid}&nodeid={$_GET["nodeid"]}');\"\n\t\t\t\t\t style='font-size:14px;text-decoration:underline;font-weight:bold'>{$nodes_names}</a>\n\t\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:14px'>{last_status}:</td>\n\t\t\t\t<td><strong style='font-size:14px'>{$blackbox->laststatus}</td>\n\t\t\t</tr>\t\t\n\t\t\t</table>\n\t\t\n\t\t\n\t\t\n\t{$smpstatus}\n\t{$action}\n\t\n\t<script>\n\tvar x_SquidNodeReload{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){alert(res);}\n\t\tdocument.getElementById('{$t}').innerHTML='';\n\t\tif(document.getElementById('main_squid_quicklinks_tabs{$_GET["nodeid"]}')){\n\t\t\tRefreshTab('main_squid_quicklinks_tabs{$_GET["nodeid"]}');\n\t\t}\n\t}\t\n\n\n\tfunction SquidNodeReload{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('reconfigure-squid','{$hostid}');\n\t\tAnimateDiv('{$t}');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SquidNodeReload{$t});\n\t}\n\t\n\tfunction SquidNodeRestart{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('restart-squid','{$hostid}');\n\t\tAnimateDiv('{$t}');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SquidNodeReload{$t});\n\t}\n\n\tfunction SquidNodeReconf{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('reconf-squid','{$hostid}');\n\t\tAnimateDiv('{$t}');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SquidNodeReload{$t});\t\n\t\n\t}\n\t\n\tLoadAjax('{$t}-filters','{$page}?filters-specific=yes&hostid={$hostid}');\n\t\n\t</script>\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function all_status($asroot=false){
	
	if($asroot){$GLOBALS["AS_ROOT"]=true;}
	
	if(!$GLOBALS["AS_ROOT"]){
		if(is_file("/usr/share/artica-postfix/ressources/logs/web/squid.services.html")){
			$tpl=new templates();
			echo $tpl->_ENGINE_parse_body(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/squid.services.html"));
			return;
		}
	
	}
	
	if(GET_CACHED(__FILE__, __FUNCTION__,__FUNCTION__)){return;}
	
	$page=CurrentPageName();
	$sock=new sockets();
	$ini=new Bs_IniHandler();
	$tpl=new templates();
	$users=new usersMenus();
	$squid=new squidbee();
	$t=time();
	
	$APP_SAMBA_WINBIND=null;
	$winbind=null;
	$UseDynamicGroupsAclsTR=null;
	$ufdbbutt=null;
	$cicapButt=null;
	
	if(!isset($_GET["miniadmin"])){
	
	$SecondScript="
		function RefreshAdKer$t(){	
			LoadAjaxTiny('squid-adker-status','squid.adker.php?status=yes&t=squid-adker-status');
		}
		RefreshAdKer$t();
		setTimeout('RefreshAdKer$t()',2000);	
	";
	
	}
	
	



	$Authenticator_cacheFile="/usr/share/artica-postfix/ressources/logs/web/ntlmauthenticator.cache";
	$cacheSwap="/usr/share/artica-postfix/ressources/logs/web/squid_swap_status.html";
	$ini->loadString(base64_decode($sock->getFrameWork('cmd.php?squid-ini-status=yes')));
	
	
	
	$DisableAnyCache=$sock->GET_INFO("DisableAnyCache");
	$SquidActHasReverse=$sock->GET_INFO("SquidActHasReverse");
	$AsSquidLoadBalancer=$sock->GET_INFO("AsSquidLoadBalancer");
	$EnableRemoteStatisticsAppliance=$sock->GET_INFO("EnableRemoteStatisticsAppliance");
	$EnableKerbAuth=$sock->GET_INFO("EnableKerbAuth");
	if(!is_numeric($DisableAnyCache)){$DisableAnyCache=0;}
	$SquidBoosterMem=$sock->GET_INFO("SquidBoosterMem");
	$WizardStatsApplianceSeen=$sock->GET_INFO("WizardStatsApplianceSeen");
	
	if(!is_numeric($EnableKerbAuth)){$EnableKerbAuth=0;}
	if(!is_numeric($SquidBoosterMem)){$SquidBoosterMem=0;}
	if(!is_numeric($DisableAnyCache)){$DisableAnyCache=0;}
	if(!is_numeric($SquidActHasReverse)){$SquidActHasReverse=0;}	
	if(!is_numeric($AsSquidLoadBalancer)){$AsSquidLoadBalancer=0;}
	if(!is_numeric($AsSquidLoadBalancer)){$AsSquidLoadBalancer=0;}
	if(!is_numeric($WizardStatsApplianceSeen)){$WizardStatsApplianceSeen=0;}		
	$UnlockWebStats=$sock->GET_INFO("UnlockWebStats");
	if(!is_numeric($UnlockWebStats)){$UnlockWebStats=0;}
	if($UnlockWebStats==1){$EnableRemoteStatisticsAppliance=0;}	
	
	$squid_status=DAEMON_STATUS_ROUND("SQUID",$ini,null,1);
	$dansguardian_status=DAEMON_STATUS_ROUND("DANSGUARDIAN",$ini,null,1);
	$kav=DAEMON_STATUS_ROUND("KAV4PROXY",$ini,null,1);
	$cicap=DAEMON_STATUS_ROUND("C-ICAP",$ini,null,1);
	$APP_PROXY_PAC=DAEMON_STATUS_ROUND("APP_PROXY_PAC",$ini,null,1);
	$APP_SQUIDGUARD_HTTP=DAEMON_STATUS_ROUND("APP_SQUIDGUARD_HTTP",$ini,null,1);
	$APP_UFDBGUARD=DAEMON_STATUS_ROUND("APP_UFDBGUARD",$ini,null,1);
	$APP_UFDBGUARD_CLIENT=DAEMON_STATUS_ROUND("APP_UFDBGUARD_CLIENT",$ini,null,1);
	$APP_UFDBCAT=DAEMON_STATUS_ROUND("APP_UFDBCAT",$ini,null,1);
	$APP_HYPERCACHE_WEB=DAEMON_STATUS_ROUND("APP_HYPERCACHE_WEB",$ini,null,1);
	$APP_FRESHCLAM=DAEMON_STATUS_ROUND("APP_FRESHCLAM",$ini,null,1);
	$APP_ARTICADB=DAEMON_STATUS_ROUND("APP_ARTICADB",$ini,null,1);
	$APP_SQUID_DB=DAEMON_STATUS_ROUND("APP_SQUID_DB",$ini,null,1);
	$APP_HAARP=DAEMON_STATUS_ROUND("APP_HAARP",$ini,null,1);
	$APP_CNTLM=DAEMON_STATUS_ROUND("APP_CNTLM",$ini,null,1);
	$APP_CNTLM_PARENT=DAEMON_STATUS_ROUND("APP_CNTLM_PARENT",$ini,null,1);
	$APP_SQUID_NAT=DAEMON_STATUS_ROUND("APP_SQUID_NAT",$ini,null,1);
	

	$CLAMAV=DAEMON_STATUS_ROUND("CLAMAV",$ini,null,1);
	$DNSCACHE=DAEMON_STATUS_ROUND("DNSMASQ_SQUID",$ini,null,1);
	$UCARP_MASTER=DAEMON_STATUS_ROUND("UCARP_MASTER",$ini,null,1);
	$UCARP_SLAVE=DAEMON_STATUS_ROUND("UCARP_SLAVE",$ini,null,1);
	$HOTSPOT_WWW=DAEMON_STATUS_ROUND("HOTSPOT_WWW",$ini,null,1);
	$HOTSPOT_FW=DAEMON_STATUS_ROUND("HOTSPOT_FW",$ini,null,1);
	$HOTSPOT_SERVICE=DAEMON_STATUS_ROUND("HOTSPOT_SERVICE",$ini,null,1);
	$APP_ZIPROXY=DAEMON_STATUS_ROUND("APP_ZIPROXY",$ini,null,1);
	$APP_SARG=DAEMON_STATUS_ROUND("APP_SARG",$ini,null,1);
	
	//$APP_CONNTRACKD=DAEMON_STATUS_ROUND("APP_CONNTRACKD",$ini,null,1);
	if($users->PROXYTINY_APPLIANCE){$APP_ARTICADB=null;}
	if($EnableRemoteStatisticsAppliance==1){$APP_ARTICADB=null;}
	$APP_FTP_PROXY=DAEMON_STATUS_ROUND("APP_FTP_PROXY",$ini,null,1);
	$CacheManagement2=$sock->GET_INFO("CacheManagement2");
	if(!is_numeric($CacheManagement2)){$CacheManagement2=0;}

	
	
	if($EnableKerbAuth==1){
		$APP_SAMBA_WINBIND=DAEMON_STATUS_ROUND("SAMBA_WINBIND",$ini,null,1);
	}	
	$tr[]="<div id='squid-mem-status'></div><script>LoadAjaxTiny('squid-mem-status','$page?squid-mem-status=yes');</script>";
	$tr[]="<div id='squid-stores-status'></div>";
	$tr[]="<div id='squid-info-status'></div>";
	
	
	
	if(is_file($cacheSwap)){
		$tr[]=@file_get_contents($cacheSwap);
	}
	
	
	if(is_file($Authenticator_cacheFile)){
		$tr[]="<div id='squid-ntlmauth-status'></div><script>LoadAjaxTiny('squid-ntlmauth-status','$page?squid-ntlmauth-status=yes');</script>";
	}
	
	$cacheFile="/usr/share/artica-postfix/ressources/logs/web/dnsperformances.cache";
	$data=@file_get_contents($cacheFile);
	if(strlen($data)>10){
		$tr[]=$data;
	}
	

	
	
	$md=md5(date('Ymhis'));
	if(!$users->WEBSTATS_APPLIANCE){
		$swappiness=intval($sock->getFrameWork("cmd.php?sysctl-value=yes&key=".base64_encode("vm.swappiness")));
		$sock=new sockets();
		$swappiness_saved=unserialize(base64_decode($sock->GET_INFO("kernel_values")));
		if(!is_numeric($swappiness_saved["swappiness"])){
			if($swappiness>30){
				$tr[]=DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png","{high_swap_value}",
				"{high_swap_value_text}","Loadjs('squid.perfs.php')");
			}
			
		}
		
		$q=new mysql();
		$SquidAsSeenCache=$sock->GET_INFO("SquidAsSeenCache");
		if(!is_numeric($SquidAsSeenCache)){$SquidAsSeenCache=0;}
		if($q->COUNT_ROWS("squid_speed", "artica_backup")==0){
			if($SquidAsSeenCache==0){
				$tr[]=DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png","{cached_rules_not_set}",
				"{cached_rules_not_set_explain}","Loadjs('squid.caches.rules.php')");
			}
				
		}
			
		$SquidAsSeenCacheCenter=$sock->GET_INFO("SquidAsSeenCacheCenter");
		if(!is_numeric($SquidAsSeenCacheCenter)){$SquidAsSeenCacheCenter=0;}
			
		if($CacheManagement2==0){
			if($SquidAsSeenCacheCenter==0){
				$tr[]=DAEMON_STATUS_ROUND_TEXT("48-infos.png","{CacheManagement2}",
						"{CacheManagement2_explain}","Loadjs('squid.caches.ManagementChoose.php')");
					
				}
				
			}
			
			
			if($WizardStatsApplianceSeen==0){
				$tr[]=DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png","{use_remote_server_stats}",
				"{use_remote_server_stats_explain}","Loadjs('squid.stats-appliance.php')");
				
			}
	}
	
	
	
	$CicapEnabled=0;
	if($users->C_ICAP_INSTALLED){
		$CicapEnabled=$sock->GET_INFO("CicapEnabled");
		if(!is_numeric($CicapEnabled)){$CicapEnabled=0;}
	}
	
	
	
		$squid_status=null;
		
		$ini=new Bs_IniHandler();
		$ini->loadString(base64_decode($sock->getFrameWork('squid.php?smp-status=yes')));
		
		if(is_array($ini->_params)){
			while (list ($index, $line) = each ($ini->_params) ){
				if($GLOBALS["VERBOSE"]){echo __FUNCTION__."::".__LINE__."::$index -> DAEMON_STATUS_ROUND<br>\n";}
				$tr[]=DAEMON_STATUS_ROUND($index,$ini,null,1);
				
			}
		}
		
	
	

	
	if($SquidBoosterMem>0){
		
			if($DisableAnyCache==0){
				$tr[]=squid_booster_smp();
			}
		
	}
	
	
	$tr[]=$squid_status;
	$tr[]=$APP_SQUID_NAT;
	$tr[]=$APP_HAARP;
	$tr[]=$APP_HYPERCACHE_WEB;
	$tr[]=$APP_SAMBA_WINBIND;
	$tr[]=$APP_CNTLM;
	$tr[]=$APP_CNTLM_PARENT;
	$tr[]=$dansguardian_status;
	$tr[]=$kav;
	$tr[]=$cicap;
	$tr[]=$DNSCACHE;
	$tr[]=$CLAMAV;
	$tr[]=$APP_PROXY_PAC;
	$tr[]=$APP_SQUIDGUARD_HTTP;
	$tr[]=$APP_SARG;
	$tr[]=$HOTSPOT_WWW;
	$tr[]=$HOTSPOT_SERVICE;
	
	$tr[]=$HOTSPOT_FW;
	$tr[]=$APP_ZIPROXY;
	$tr[]=$APP_UFDBGUARD;
	$tr[]=$APP_UFDBGUARD_CLIENT;
	$tr[]=$APP_UFDBCAT;
	$tr[]=$APP_ARTICADB;
	$tr[]=$APP_SQUID_DB;
	$tr[]=$APP_FTP_PROXY;

	$tr[]=$UCARP_MASTER;
	$tr[]=$UCARP_SLAVE;
	
	if(isset($_GET["miniadmin"])){
		echo $tpl->_ENGINE_parse_body(CompileTr3($tr,true));
		return;
		
	}
	$EnableUfdbGuard=$sock->EnableUfdbGuard();
	if(!is_numeric($EnableUfdbGuard)){$EnableUfdbGuard=0;}
	if(!$users->APP_UFDBGUARD_INSTALLED){$EnableUfdbGuard=0;}
	
	$tables[]="<div style='min-height:350px;'>
		<table style='width:100%' class='TableRemove TableMarged'><tr>";
	$t=0;
	while (list ($key, $line) = each ($tr) ){
			$line=trim($line);
			if($line==null){continue;}
			$t=$t+1;
			$tables[]="<td valign='top'>$line</td>";
			if($t==2){$t=0;$tables[]="</tr><tr>";}
			}
	
	if($t<2){
		for($i=0;$i<=$t;$i++){
			$tables[]="<td valign='top'>&nbsp;</td>";				
		}
	}
	

	

	$SquidBoosterMemText="
		<tr>
			<td width=1%><img src='img/memory-32.png'></td>
			<td><div id='ptx-status'></div></td>
		</tr>
	";
	
	
	
	if($EnableKerbAuth==1){	
		$winbind="
			<tr>
		<td width=1%><img src='img/32-logs.png'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('winbindd.events.php');\"
		style='font-size:12px;text-decoration:underline'>{APP_SAMBA_WINBIND}</a></td>
		</tr>
	";

		$UseDynamicGroupsAcls=$sock->GET_INFO("UseDynamicGroupsAcls");
		if(!is_numeric($UseDynamicGroupsAcls)){$UseDynamicGroupsAcls=0;}
		
		if($UseDynamicGroupsAcls==1){
			$UseDynamicGroupsAclsTR="
			<tr>
		<td width=1%><img src='img/32-logs.png'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('DynamicGroupsAcls.events.php');\"
		style='font-size:12px;text-decoration:underline'>{dynamicgroupsAcls_events}</a></td>
		</tr>
	";			
		}
		
		
	}
	
	if($EnableUfdbGuard==1){
		$ufdbbutt="
			<tr>
		<td width=1%><img src='img/service-check-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:ReconfigureUfdb();\" 
		style='font-size:12px;text-decoration:underline'>{reconfigure_webfilter_service}</a></td>
		</tr>	
	";
	}
	
	if($CicapEnabled==1){
		$cicapButt="
			<tr>
		<td width=1%><img src='img/icon-antivirus-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('c-icap.index.php');\" 
		style='font-size:12px;text-decoration:underline'>{antivirus_parameters}</a></td>
		</tr>	
	";		
		
	}
	
	
	

$supportpckg="
			<tr>
		<td width=1%><img src='img/technical-support-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.support.package.php');\" 
		style='font-size:12px;text-decoration:underline'>{build_support_package}</a></td>
		</tr>	
	";	

$dns_query="
			<tr>
		<td width=1%><img src='img/dns-32.png' id='events-dns-32-squid'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('system.dns.query.php?img=events-rotate-32-squid&src=events-dns-32-squid');\" 
		style='font-size:12px;text-decoration:underline'>{dns_query}</a></td>
		</tr>	
	";

$squid_rotate="
			<tr>
		<td width=1%><img src='img/events-rotate-32.png' id='events-rotate-32-squid'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('squid.perf.logrotate.php?img=events-rotate-32-squid&src=events-rotate-32.png');\"
		style='font-size:12px;text-decoration:underline'>{squid_logrotate_perform}</a></td>
		</tr>
	";


$reconfigure="
			<tr>
		<td width=1%><img src='img/reconfigure-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.compile.progress.php');\"
		style='font-size:12px;text-decoration:underline'>{reconfigure}</a></td>
		</tr>	
	";	
$debug_compile="
			<tr>
		<td width=1%><img src='img/32-logs.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.debug.compile.php');\" 
		style='font-size:12px;text-decoration:underline'>{compile_in_debug}</a></td>
		</tr>	
	";	

$current_sessions="
			<tr>
		<td width=1%><img src='img/32-many-users.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.squidclient.clientlist.php');\" 
		style='font-size:12px;text-decoration:underline'>{display_current_sessions}</a></td>
		</tr>	
	";	

$squidconf="
			<tr>
		<td width=1%><img src='img/script-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('squid.conf.php');\"
		style='font-size:12px;text-decoration:underline'>{configuration_file}</a></td>
		</tr>
	";




$performances="
			<tr>
		<td width=1%><img src='img/performance-tuning-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.squidclient.info.php');\" 
		style='font-size:12px;text-decoration:underline'>{display_performance_status}</a></td>
		</tr>	
	";	

$restart_all_services="	<tr>
		<td width=1%><img src='img/service-restart-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.restart.php');\" 
		style='font-size:12px;text-decoration:underline'>{restart_all_services}</a></td>
	</tr>
	";

$restart_service_only="
	<tr>
		<td width=1%><img src='img/service-restart-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.restart.php?onlySquid=yes');\" 
		style='font-size:12px;text-decoration:underline'>{restart_onlysquid}</a></td>
	</tr>	";

$reloadservice="
	<tr>
		<td width=1%><img src='img/reload-32.png'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('squid.restart.php?onlyreload=yes');\"
		style='font-size:12px;text-decoration:underline'>{reload_service}</a></td>
	</tr>	";

$checkCaches="
	<tr>
		<td width=1%><img src='img/database-connect-32-2.png'></td>
		<td nowrap><a href=\"javascript:blur();\"
		OnClick=\"javascript:Loadjs('squid.restart.php?CheckCaches=yes');\"
		style='font-size:12px;text-decoration:underline'>{check_caches}</a></td>
	</tr>	";
	
$users=new usersMenus();

if($users->WEBSTATS_APPLIANCE){
	$squid_rotate=null;
	$debug_compile=null;
	$current_sessions=null;
	$restart_service_only=null;
	$performances=null;
	$SquidBoosterMemText=null;
	$supportpckg=null;
	$squidconf=null;
}

if($DisableAnyCache==1){
	$SquidBoosterMemText=null;
}

	$refresh=imgtootltip("refresh-32.png","{refresh}","LoadAjax('squid-services','$page?squid-services=yes&force=yes');");
	$tables[]="
	
	<div id='squid-adker-status'></div>
	</table>
	<div style='text-align:right;margin-top:-15px'>$refresh</div>
	</div>
	<table style='width:99%' class=form>
	<tr>
	<td valign='top' width='50%'>
		<table style='width:100%'>
	$squidconf
	$reconfigure
	$restart_all_services
	$restart_service_only
	$SquidBoosterMemText
	$squid_rotate
	$winbind
	$UseDynamicGroupsAclsTR
	$dns_query
	</table>
	</td>
	<td valign='top' width='50%'>
		<table style='width:100%'>
			$reloadservice
			$checkCaches
			$ufdbbutt
			$debug_compile
			$supportpckg		
			$cicapButt
			$current_sessions
			$performances
		</table>
	</td>
	</tr>
	</table>";
	
	if($asroot){
		$tables[]="<div style='width:100%;text-align:right'><i>". date("H:i:s")."</i></div>";
	}
	
	
	
	
	$html=@implode("\n", $tables)."
	<script>
	var x_ReconfigureUfdb= function (obj) {
		var res=obj.responseText;
		if (res.length>3){alert(res);}
		RefreshTab('squid_main_svc');
	}		
		
	function ReconfigureUfdb(){
			var XHR = new XHRConnection();
		    XHR.appendData('ReconfigureUfdb', 'yes');
		    AnimateDiv('squid-services');
		    XHR.sendAndLoad('$page', 'POST',x_ReconfigureUfdb); 
		
	}
	
	LoadAjaxTiny('ptx-status','$page?ptx-status=yes');

	$SecondScript
</script>	
";
	

	
if($GLOBALS["AS_ROOT"]){
	@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/squid.services.html", $html);
	@chmod("/usr/share/artica-postfix/ressources/logs/web/squid.services.html",0755);
	return;
}
	
	SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $html);
	if($asroot){ return; }		
	
	echo $tpl->_ENGINE_parse_body($html);
	
}
function services_status()
{
    $page = CurrentPageName();
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    $ini2 = new Bs_IniHandler();
    $tpl = new templates();
    $users = new usersMenus();
    $html = null;
    $ini->loadString(base64_decode($sock->getFrameWork('cmd.php?squid-ini-status=yes')));
    $ini2->loadString(base64_decode($sock->getFrameWork('cmd.php?cicap-ini-status=yes')));
    $DisableAnyCache = $sock->GET_INFO("DisableAnyCache");
    $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse");
    $AsSquidLoadBalancer = $sock->GET_INFO("AsSquidLoadBalancer");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($DisableAnyCache)) {
        $DisableAnyCache = 0;
    }
    $SquidBoosterMem = $sock->GET_INFO("SquidBoosterMem");
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if (!is_numeric($SquidBoosterMem)) {
        $SquidBoosterMem = 0;
    }
    if (!is_numeric($DisableAnyCache)) {
        $DisableAnyCache = 0;
    }
    if (!is_numeric($SquidActHasReverse)) {
        $SquidActHasReverse = 0;
    }
    if (!is_numeric($AsSquidLoadBalancer)) {
        $AsSquidLoadBalancer = 0;
    }
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    $squid_status = DAEMON_STATUS_ROUND("SQUID", $ini, null, 1);
    $dansguardian_status = DAEMON_STATUS_ROUND("DANSGUARDIAN", $ini, null, 1);
    $kav = DAEMON_STATUS_ROUND("KAV4PROXY", $ini, null, 1);
    $cicap = DAEMON_STATUS_ROUND("C-ICAP", $ini2, null, 1);
    $APP_PROXY_PAC = DAEMON_STATUS_ROUND("APP_PROXY_PAC", $ini, null, 1);
    $APP_SQUIDGUARD_HTTP = DAEMON_STATUS_ROUND("APP_SQUIDGUARD_HTTP", $ini, null, 1);
    $APP_UFDBGUARD = DAEMON_STATUS_ROUND("APP_UFDBGUARD", $ini, null, 1);
    $APP_FRESHCLAM = DAEMON_STATUS_ROUND("APP_FRESHCLAM", $ini, null, 1);
    $APP_ARTICADB = DAEMON_STATUS_ROUND("APP_ARTICADB", $ini, null, 1);
    if ($users->PROXYTINY_APPLIANCE) {
        $APP_ARTICADB = null;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        $APP_ARTICADB = null;
    }
    $squid = new squidbee();
    if ($EnableKerbAuth == 1) {
        $APP_SAMBA_WINBIND = DAEMON_STATUS_ROUND("SAMBA_WINBIND", $ini, null, 1);
    }
    $md = md5(date('Ymhis'));
    if ($_SESSION["uid"] != null) {
        if (!$users->WEBSTATS_APPLIANCE) {
            $swappiness = intval($sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.swappiness")));
            $sock = new sockets();
            $swappiness_saved = unserialize(base64_decode($sock->GET_INFO("kernel_values")));
            if (!is_numeric($swappiness_saved["swappiness"])) {
                if ($swappiness > 30) {
                    $tr[] = DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png", "{high_swap_value}", "{high_swap_value_text}", "Loadjs('squid.perfs.php')");
                }
            }
            if ($AsSquidLoadBalancer == 1) {
                $SquidAsSeenDNS = 1;
            }
            if ($SquidActHasReverse == 1) {
                $SquidAsSeenDNS = 1;
            }
            $SquidAsSeenDNS = $sock->GET_INFO("SquidAsSeenDNS");
            if (!is_numeric($SquidAsSeenDNS)) {
                $SquidAsSeenDNS = 0;
            }
            if (count($squid->dns_array) == 0) {
                if ($SquidAsSeenDNS == 0) {
                    $tr[] = DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png", "{add_dns_in_config}", "{add_dns_in_config_perf_explain}", "Loadjs('squid.popups.php?script=dns')");
                }
            }
        }
    }
    $CicapEnabled = 0;
    if ($users->C_ICAP_INSTALLED) {
        $CicapEnabled = $sock->GET_INFO("CicapEnabled");
        if (!is_numeric($CicapEnabled)) {
            $CicapEnabled = 0;
        }
    }
    $squid_status = null;
    $ini = new Bs_IniHandler();
    $ini->loadString(base64_decode($sock->getFrameWork('squid.php?smp-status=yes')));
    while (list($index, $line) = each($ini->_params)) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . "::" . __LINE__ . "::{$index} -> DAEMON_STATUS_ROUND<br>\n";
        }
        $tr[] = DAEMON_STATUS_ROUND($index, $ini, null, 1);
    }
    if ($SquidBoosterMem > 0) {
        if ($DisableAnyCache == 0) {
            $tr[] = squid_booster_smp();
        }
    }
    $tr[] = $squid_status;
    $tr[] = $APP_SAMBA_WINBIND;
    $tr[] = $dansguardian_status;
    $tr[] = $kav;
    $tr[] = $cicap;
    $tr[] = $APP_PROXY_PAC;
    $tr[] = $APP_SQUIDGUARD_HTTP;
    $tr[] = $APP_UFDBGUARD;
    $tr[] = $APP_FRESHCLAM;
    $tr[] = $APP_ARTICADB;
    $html = $tpl->_ENGINE_parse_body(CompileTr4($tr, true, null, true));
    $html = "\n\t\t\t\n\t<div style='float:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('services-status','{$page}?services-status-table=yes');") . "</div>\n\t<center ><div style='width:100%;margin:10px'>{$html}</div></center>";
    echo $html;
}
function all_services_status_build()
{
    $page = CurrentPageName();
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    $tpl = new templates();
    $users = new usersMenus();
    $squid = new squidbee();
    $ini->loadString(base64_decode($sock->getFrameWork('cmd.php?squid-ini-status=yes')));
    if (!is_numeric($MonitConfig["watchdog"])) {
        $MonitConfig["watchdog"] = 1;
    }
    $DisableAnyCache = $sock->GET_INFO("DisableAnyCache");
    $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse");
    $AsSquidLoadBalancer = $sock->GET_INFO("AsSquidLoadBalancer");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric($DisableAnyCache)) {
        $DisableAnyCache = 0;
    }
    $SquidBoosterMem = $sock->GET_INFO("SquidBoosterMem");
    $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel");
    if (!is_numeric($SquidCacheLevel)) {
        $SquidCacheLevel = 4;
    }
    if (!is_numeric($EnableKerbAuth)) {
        $EnableKerbAuth = 0;
    }
    if (!is_numeric($SquidBoosterMem)) {
        $SquidBoosterMem = 0;
    }
    if (!is_numeric($DisableAnyCache)) {
        $DisableAnyCache = 0;
    }
    if (!is_numeric($SquidActHasReverse)) {
        $SquidActHasReverse = 0;
    }
    if (!is_numeric($AsSquidLoadBalancer)) {
        $AsSquidLoadBalancer = 0;
    }
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    $UnlockWebStats = $sock->GET_INFO("UnlockWebStats");
    if (!is_numeric($UnlockWebStats)) {
        $UnlockWebStats = 0;
    }
    if ($UnlockWebStats == 1) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    if ($SquidCacheLevel == 0) {
        $DisableAnyCache = 1;
    }
    $squid_status = DAEMON_STATUS_ROUND("SQUID", $ini, null, 1);
    $dansguardian_status = DAEMON_STATUS_ROUND("DANSGUARDIAN", $ini, null, 1);
    $kav = DAEMON_STATUS_ROUND("KAV4PROXY", $ini, null, 1);
    $cicap = DAEMON_STATUS_ROUND("C-ICAP", $ini, null, 1);
    $APP_PROXY_PAC = DAEMON_STATUS_ROUND("APP_PROXY_PAC", $ini, null, 1);
    $APP_SQUIDGUARD_HTTP = DAEMON_STATUS_ROUND("APP_SQUIDGUARD_HTTP", $ini, null, 1);
    $APP_UFDBGUARD = DAEMON_STATUS_ROUND("APP_UFDBGUARD", $ini, null, 1);
    $APP_FRESHCLAM = DAEMON_STATUS_ROUND("APP_FRESHCLAM", $ini, null, 1);
    $APP_ARTICADB = DAEMON_STATUS_ROUND("APP_ARTICADB", $ini, null, 1);
    $APP_SQUID_DB = DAEMON_STATUS_ROUND("APP_SQUID_DB", $ini, null, 1);
    $APP_HAARP = DAEMON_STATUS_ROUND("APP_HAARP", $ini, null, 1);
    if ($users->PROXYTINY_APPLIANCE) {
        $APP_ARTICADB = null;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        $APP_ARTICADB = null;
    }
    $APP_FTP_PROXY = DAEMON_STATUS_ROUND("APP_FTP_PROXY", $ini, null, 1);
    $squid = new squidbee();
    if ($EnableKerbAuth == 1) {
        $APP_SAMBA_WINBIND = DAEMON_STATUS_ROUND("SAMBA_WINBIND", $ini, null, 1);
    }
    $tr[] = "<div id='squid-mem-status'></div><script>LoadAjaxTiny('squid-mem-status','{$page}?squid-mem-status=yes');</script>";
    $tr[] = "<div id='squid-stores-status'></div><script>LoadAjaxTiny('squid-stores-status','{$page}?squid-stores-status=yes');</script>";
    $md = md5(date('Ymhis'));
    if (!$users->WEBSTATS_APPLIANCE) {
        $swappiness = intval($sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.swappiness")));
        $sock = new sockets();
        $swappiness_saved = unserialize(base64_decode($sock->GET_INFO("kernel_values")));
        if (!is_numeric($swappiness_saved["swappiness"])) {
            if ($swappiness > 30) {
                $tr[] = DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png", "{high_swap_value}", "{high_swap_value_text}", "Loadjs('squid.perfs.php')");
            }
        }
        if ($AsSquidLoadBalancer == 1) {
            $SquidAsSeenDNS = 1;
        }
        if (!$users->IsSquidReverse()) {
            $SquidAsSeenDNS = $sock->GET_INFO("SquidAsSeenDNS");
            if (!is_numeric($SquidAsSeenDNS)) {
                $SquidAsSeenDNS = 0;
            }
            if (count($squid->dns_array) == 0) {
                if ($SquidAsSeenDNS == 0) {
                    $tr[] = DAEMON_STATUS_ROUND_TEXT("warning-panneau-42.png", "{add_dns_in_config}", "{add_dns_in_config_perf_explain}", "Loadjs('squid.popups.php?script=dns')");
                }
            }
        }
    }
    $CicapEnabled = 0;
    if ($users->C_ICAP_INSTALLED) {
        $CicapEnabled = $sock->GET_INFO("CicapEnabled");
        if (!is_numeric($CicapEnabled)) {
            $CicapEnabled = 0;
        }
    }
    $squid_status = null;
    $ini = new Bs_IniHandler();
    $ini->loadString(base64_decode($sock->getFrameWork('squid.php?smp-status=yes')));
    while (list($index, $line) = each($ini->_params)) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . "::" . __LINE__ . "::{$index} -> DAEMON_STATUS_ROUND<br>\n";
        }
        $tr[] = DAEMON_STATUS_ROUND($index, $ini, null, 1);
    }
    if ($SquidBoosterMem > 0) {
        if ($DisableAnyCache == 0) {
            $tr[] = squid_booster_smp();
        }
    }
    $tr[] = $squid_status;
    $tr[] = $APP_HAARP;
    $tr[] = $APP_SAMBA_WINBIND;
    $tr[] = $dansguardian_status;
    $tr[] = $kav;
    $tr[] = $cicap;
    $tr[] = $APP_PROXY_PAC;
    $tr[] = $APP_SQUIDGUARD_HTTP;
    $tr[] = $APP_UFDBGUARD;
    $tr[] = $APP_FRESHCLAM;
    $tr[] = $APP_ARTICADB;
    $tr[] = $APP_SQUID_DB;
    $tr[] = $APP_FTP_PROXY;
    $EnableUfdbGuard = $sock->EnableUfdbGuard();
    if (!is_numeric($EnableUfdbGuard)) {
        $EnableUfdbGuard = 0;
    }
    if (!$users->APP_UFDBGUARD_INSTALLED) {
        $EnableUfdbGuard = 0;
    }
    echo CompileTr3($tr, true);
}