<%
include("language.html")
if _SESSION["logined"] ~= nil then

local domain = _GET["domain"]
local id = _GET["ID"]
local clientIP = _GET["clientIP"]
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Disconnect Session</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<%if _COOKIE["admin_lang"] == "schinese" or _COOKIE["admin_lang"] == "tchinese" or _COOKIE["admin_lang"] == "japanese" then%>
body,td,span {font:12px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%else%>
body,td,span {font:11px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%end%>
img {border:0px;}

button{
border:none;background:none;padding:0;
margin:0;width:auto;overflow:visible;text-align:center;	
white-space:nowrap;height:24px;line-height:22px;
cursor:pointer;
color:#000;
margin-left:2px;
margin-top:2px;
}
button span, button em{
display:block;height:24px;line-height:22px;margin:0;
}	
button span{
padding-left:14px;
background:url("images/button_left.gif") no-repeat 0 0;
}
button em{
font-style:normal;padding-right:14px;
background:url("images/button.gif") no-repeat 100% 0;
}
button:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
button span:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
.buttonhover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}


</style>

<script language="javascript" src="include/common.js"></script>
<script language="javascript">
var domain = "<%=domain%>";
var id = "<%=id%>";
var ajaxlock = false;

var xmlhttp,page,post;
xmlhttp = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();

function ajaxRequest(pagename,poststring,method)
{
	if(ajaxlock == false)
	{	
		delete xmlhttp;
		xmlhttp = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();

		ajaxlock = true;
		page = pagename;
		post = poststring;

		if(method == "GET")
			xmlhttp.open("GET",page+".html"+post);
		else
			xmlhttp.open("POST",page+".html");

		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = ajaxResponse;
		if(method != "GET")
			xmlhttp.send(post);
		else
			xmlhttp.send("");
	}
}

function ajaxResponse()
{
	if (xmlhttp.readyState == 4)
	{
		ajaxlock = false;
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_kickuser':
					{
						top.closewindow(1);
						break;
					}
				}
			}
			catch(e)
			{
			}
		}
		else
		{
		}
	}
}

function kickUser()
{
	var radios = document.getElementsByName("kickway");
    var kickway = 0;
    for(var i=0;i<radios.length;i++)
	{
        if(radios[i].checked)
		{ 
            kickway = radios[i].value; 
            break; 
        } 
    }
	try
	{
		var ip_block_min = parseInt($("ip_block_min").value);
		var add_blockip_to_user = ($("add_blockip_to_user").checked ? 1:0);
		var add_blockip_to_group = ($("add_blockip_to_group").checked ? 1:0);
		var add_blockip_to_domain = ($("add_blockip_to_domain").checked ? 1:0);
		var disable_user_account = ($("disable_user_account").checked ? 1:0);
		var disconnect_same_ip = ($("disconnect_same_ip").checked ? 1:0);

		if((kickway == 2) && (add_blockip_to_user == 0) && (add_blockip_to_group == 0) && (add_blockip_to_domain == 0))
		{
			alert("Please select a location to add block IP!");
			$("add_blockip_to_user").checked = true;
			$("add_blockip_to_group").checked = true;
			$("add_blockip_to_domain").checked = true;
			return;
		}

		ajaxRequest("admin_kickuser","domain="+domain+"&ID="+id+"&kickway="+kickway+"&ip_block_min="+ip_block_min+"&add_blockip_to_user="+add_blockip_to_user+"&add_blockip_to_group="+add_blockip_to_group+"&add_blockip_to_domain="+add_blockip_to_domain+"&disable_user_account="+disable_user_account+"&disconnect_same_ip="+disconnect_same_ip+"&r="+Math.random());

		$("btn_kick").disable = false;
	}
	catch (e)
	{
	}
	
}

function radioClick()
{
	var radios = document.getElementsByName("kickway");
	$("ip_block_min").disabled = true;
	$("add_blockip_to_user").disabled = true;
	$("add_blockip_to_group").disabled = true;
	$("add_blockip_to_domain").disabled = true;
	$("add_blockip_to_user").checked = false;
	$("add_blockip_to_group").checked = false;
	$("add_blockip_to_domain").checked = false;
	for(var i=0;i<radios.length;i++)
	{
		if(radios[i].checked)
		{
			if(radios[i].value == 1)
			{
				$("ip_block_min").disabled = false;
			}

			if(radios[i].value == 2)
			{
				$("add_blockip_to_user").disabled = false;
				$("add_blockip_to_group").disabled = false;
				$("add_blockip_to_domain").disabled = false;
				$("add_blockip_to_user").checked = true;
				$("add_blockip_to_group").checked = true;
				$("add_blockip_to_domain").checked = true;
			}

			break;
		}
	}
}

</script>
</head>
<body style="margin:0px;background-image:url(images/tabbg.gif);background-repeat:repeat-x;">

<div style="padding:15px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr><td>
	<fieldset>
		<legend><%=LANG["str_action"]%></legend>
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr><td height="30" align="left"><input type="radio" name="kickway" onclick="radioClick()" value="0" checked><%=LANG["str_disconnect"]%>.</td></tr>
			<tr><td height="30" align="left"><input type="radio" name="kickway" onclick="radioClick()" value="1"><%=LANG["str_disconnect_for"]%> <input id="ip_block_min" value="0" type="text" style="width:30px;" onmouseover="this.focus();"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"> <%=LANG["str_minute"]%>.</td></tr>
			<tr><td height="30" align="left"><input type="radio" name="kickway" onclick="radioClick()" value="2"><%=LANG["str_disconnect_blockip"]%>.</td></tr>
			<tr><td height="30" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="add_blockip_to_user" type="checkbox" disabled="true"><%=LANG["str_disconnect_blockip1"]%>.</td></tr>
			<tr><td height="30" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="add_blockip_to_group" type="checkbox" disabled="true"><%=LANG["str_disconnect_blockip2"]%>.</td></tr>
			<tr><td height="30" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="add_blockip_to_domain" type="checkbox" disabled="true"><%=LANG["str_disconnect_blockip3"]%>.</td></tr>
		</table>
	</fieldset>
	</td></tr>
	<tr><td height="30" align="left"><input id="disable_user_account" type="checkbox"><%=LANG["str_disable_account"]%>.</td></tr>
	<tr><td height="30" align="left"><input id="disconnect_same_ip" type="checkbox"><%=LANG["str_disconnect_sameip"]%> (<%=clientIP%>).</td></tr>
	<tr><td align="center" style="padding-top:25px;">
		<button onclick="kickUser();" id="btn_kick"><span><em><%=LANG["button_submit"]%></em></span></button>&nbsp;<button onclick="top.closewindow();"><span><em><%=LANG["button_cancel"]%></em></span></button>
	</td></tr>
</table>
</div>


</body>
</html>

<% 
else
	print("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
	print("<script>alert('"..LANG["session_expire"].."');</script>")
end 
%>

<noscript><center><H2><%=LANG["error_nojavascript"]%></H2></center></noscript>
