{=include-block:Y_Blocks.txt;head=}
{=include-block:Y_Blocks.txt;js_jquery=}
<script src="/Y_Baselib.js"></script>
<script>
function do_start(){
	jQuery('#statusline').show();
	do_check();
}
function do_stop(){
	jQuery('#statusline').hide();
}
/*sLog*/
var sLog_body;
var sLog_line_number;
function sLog_init(){
	sLog_line_number = 0;
	sLog_body=id("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 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:/var/tuxbox/config/nhttpd.conf;mod_auth.authenticate;false=}~false~~
		sLog_addRow(sLog_body, "yellow", "WebServer: Authentication is on. ", "notice");
	=}
	{=if-equal:{=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.port;80=}~80~~
		sLog_addRow(sLog_body, "yellow",
		"WebServer: not set to Standard-Port. Actual: {=ini-get:/var/tuxbox/config/nhttpd.conf;WebsiteMain.port;80=}", "notice");
	=}
	/*settings*/
	{=if-empty:{=ini-get:/var/tuxbox/config/yWeb.conf;management_ip=}~~
		sLog_addRow(sLog_body, "yellow",
		"Settings: Management IP(1) is set to {=ini-get:/var/tuxbox/config/yWeb.conf;management_ip=} ! Your IP is {=func:get_request_data client_addr=}.", "notice");
	=}
	{=if-empty:{=ini-get:/var/tuxbox/config/yWeb.conf;management_ip2=}~~
		sLog_addRow(sLog_body, "yellow",
		"Settings: Management IP(2) is set to {=ini-get:/var/tuxbox/config/yWeb.conf;management_ip2=} ! Your IP is {=func:get_request_data client_addr=}.", "notice");
	=}

	/*programs*/
	{=var-set:grab={=find-exec:grab=}=}
	{=if-empty:{=var-get:grab=}~
		sLog_addRow(sLog_body, "red", "Programs: grab is not installed. OSD Screenshot is disabled. ", "failed");
	~
		sLog_addRow(sLog_body, "green", "Programs: grab is installed at: {=var-get:grab=}. OSD Screenshot is enabled.", "ok");
	=}
	{=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: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");
	=}

	do_stop();
}
</script>
{=include-block:Y_Blocks.txt;head_close=}
<body>
<div class="work_box">
	<div class="work_box_head"><div class="work_box_head_h2">
	{=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>
	window.setTimeout("do_start();",500);
</script>
</body>
</html>
