{=include-block:Y_Blocks.txt;head=}
<script type="text/javascript" src="/Y_Baselib.js"></script>
<script type="text/javascript" src="/prototype.js"></script>
<script type="text/javascript">
//<![CDATA[
function do_start(){
	$('statusline').show();
	do_check();
}
function do_stop(){
	$('statusline').hide();
}
/*sLog*/
var sLog_body;
var sLog_line_number;
function sLog_init(){
	sLog_line_number = 0;
	sLog_body=document.getElementById("slog_list");
}
function sLog_clear(){
	while(sLog_body.childNodes.length > 0)	{
		aChild=sLog_body.firstChild;
		sLog_body.removeChild(aChild);
	}
	sLog_line_number =  0;
}
function sLog_addRow(_body, state, action_text, state_text){
	sLog_line_number++;
	var mycurrent_row = y_add_row_to_table(_body, ((sLog_line_number % 2) ==0)?"a":"b" );
	var __img ="/images/ok.gif";
	switch (state)	{
		case "green":	__img = "/images/accept.png"; break;
		case "yellow":	__img = "/images/alert.gif"; break;
		case "ok":	__img = "/images/accept.png"; break;
		case "red":	__img = "/images/remove.png"; break;
	}
	y_add_html_cell_to_row(mycurrent_row, "icon", "<img src='"+__img+"'>");
	y_add_html_cell_to_row(mycurrent_row, "action_text", action_text);
	y_add_text_cell_to_row(mycurrent_row, "state_text", state_text);
}
/*check*/
function wiki_url(_page){
	return "<a href=\"http://wiki.dbox2-tuning.net/"+_page+"\" target='_blank'><b>[Help]<\/b><\/a>"
}
function do_check(){
	sLog_init();
	sLog_clear();
	sLog_addRow(sLog_body, "ok", "yWeb Version is: {=ini-get:Y_Version.txt;version=} {=ini-get:Y_Version.txt;date=}", "ok");

	/*webserver*/
	var needed_nhttpd_version = "3.2.7";
	var nhttpd_version = loadSyncURL("/control/info?nhttpd_version");
	if(nhttpd_version.search(/error/)!=-1)
		nhttpd_version = "0.0.0-unknown";
	if(nhttpd_version < needed_nhttpd_version)
		sLog_addRow(sLog_body, "red", "WebServer: version: "+nhttpd_version+" version needed: "+needed_nhttpd_version+" ", "fail");
	else
		sLog_addRow(sLog_body, "green", "WebServer: version is "+nhttpd_version, "ok");

	{=if-equal:{=ini-get:%(CONFIGDIR)/nhttpd.conf;mod_auth.authenticate;false=}~false~~
		sLog_addRow(sLog_body, "yellow", "WebServer: Authentication is on. ", "notice");
	=}
	{=if-equal:{=ini-get:%(CONFIGDIR)/nhttpd.conf;WebsiteMain.port;80=}~80~~
		sLog_addRow(sLog_body, "yellow",
		"WebServer: not set to Standard-Port. Actual: {=ini-get:%(CONFIGDIR)/nhttpd.conf;WebsiteMain.port;80=} "+wiki_url("Neutrino:yWeb#Webserver"), "notice");
	=}
	/*settings*/
	{=if-empty:{=ini-get:%(CONFIGDIR)/Y-Web.conf;management_ip=}~~
		sLog_addRow(sLog_body, "yellow",
		"Settings: Management IP(1) is set to {=ini-get:%(CONFIGDIR)/Y-Web.conf;management_ip=} ! Your IP is {=func:get_request_data client_addr=}. "
		+wiki_url("Help-Settings-yWeb"), "notice");
	=}
	{=if-empty:{=ini-get:%(CONFIGDIR)/Y-Web.conf;management_ip2=}~~
		sLog_addRow(sLog_body, "yellow",
		"Settings: Management IP(2) is set to {=ini-get:%(CONFIGDIR)/Y-Web.conf;management_ip2=} ! Your IP is {=func:get_request_data client_addr=}. "
		+wiki_url("Neutrino:yWeb#yWeb"), "notice");
	=}

	/*programs*/
	{=var-set:fbshot={=find-exec:fbshot=}=}
	{=if-empty:{=var-get:fbshot=}~
		sLog_addRow(sLog_body, "red", "Programs: fbshot is not installed. OSD Screenshot is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: fbshot is installed at: {=var-get:fbshot=}. OSD Screenshot is enabled.", "ok");
	=}
	{=var-set:dboxshot={=find-exec:dboxshot=}=}
	{=if-empty:{=var-get:dboxshot=}~
		sLog_addRow(sLog_body, "red", "Programs: dboxshot is not installed. Remote &amp; OSD is disabled.", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: dboxshot is installed at: {=var-get:dboxshot=}. Remote &amp; OSD is enabled.", "ok");
	=}

{=if-not-equal:{=global-var-get:boxtype=}~coolstream~
	{=var-set:fcp={=find-exec:fcp=}=}
	{=if-empty:{=var-get:fcp=}~
		sLog_addRow(sLog_body, "red", "Programs: fcp is not installed. Image flashing is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: fcp is installed at: {=var-get:fcp=}. Image flashing is enabled.", "ok");
	=}
~=}
	
	{=var-set:ether-wake={=find-exec:ether-wake=}=}
	{=if-empty:{=var-get:ether-wake=}~
		sLog_addRow(sLog_body, "red", "Programs: ether-wake is not installed. Wake on LAN is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: ether-wake is installed at: {=var-get:ether-wake=}. Wake on LAN is enabled.", "ok");
	=}
	/*automount*/
	{=var-set:automount={=find-exec:automount=}=}
	{=if-empty:{=var-get:automount=}~
		sLog_addRow(sLog_body, "red", "Programs: automount is not installed. AutoMount is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: automount is installed at: {=var-get:automount=}. AutoMount is enabled.", "ok");
	=}
{=if-not-equal:{=global-var-get:boxtype=}~coolstream~
	/* udp */
	{=var-set:udpstreamts={=find-exec:udpstreamts=}=}
	{=if-empty:{=var-get:udpstreamts=}~
		sLog_addRow(sLog_body, "red", "Programs: udpstreamts is not installed. udp-streaming is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: udpstreamts is installed at: {=var-get:udpstreamts=}. udp-streaming is enabled.", "ok");
	=}
~=}

	do_stop();
}
//]]>
</script>
</head>
<body>
<div class="work_box">
	<div class="work_box_head">
		<div class="work_box_head_h2">
		{=var-set:help_url=Help-Tools-Check_Install=}{=var-set:menu={=L:tools.check_install=}=}{=include-block:Y_Blocks.txt;work_menu=}</div></div>
	<div class="work_box_body">
		<br />
		<div id="statusline"><img border="0" src="/images/wait.gif" width="20" height="20" alt="wait"/>
			<span id="status">collecting information</span></div>
		<form method="post" name="log" action="">
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
			<thead align="left">
			<tr>
				<th class="y_form_header">&nbsp;</th><th class="y_form_header">{=L:action=}</th><th class="y_form_header">{=L:status=}</th>
			</tr>
			</thead>
			<tbody id="slog_list">
			<tr><td></td></tr>
			</tbody>
			</table>
			<br />
		</form>
	</div>
</div>
<script type="text/javascript">
//<![CDATA[
	window.setTimeout("do_start();",500);
//]]>
</script>
</body>
</html>
