<%
include("language.html")
if _SESSION["logined"] ~= nil then
%>
<!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>Connection List</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
html, body {height: 100%;}
<%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:12px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%end%>
img {border:0px;}
span{
	vertical-align:middle;
}

button{
border:none;background:none;padding:0;
margin:0;width:auto;overflow:visible;text-align:center;
white-space:nowrap;height:24px;line-height:24px;
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{
font-size:8pt;
padding-left:12px;
background:url("images/button_left.gif") no-repeat 0 0;
}
<%if _COOKIE["admin_lang"] == "schinese" or _COOKIE["admin_lang"] == "tchinese" or _COOKIE["admin_lang"] == "japanese" then%>
button em{
font-style:normal;padding-right:14px;
background:url("images/button.gif") no-repeat 101% 0;
}
<%else%>
button em{
font-style:normal;padding-right:10px;
background:url("images/button.gif") no-repeat 100% 0;
}
<%end%>
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;
}


.listhead
{
		border-top: 1px solid white; border-right: 1px solid #ACA899; border-left: 1px solid white; border-bottom: 2px solid #E1E2E3;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #EFEFEF; overflow:hidden; height:22px;
}

.listhead2
{
		border-top: 1px solid white; border-right: 1px solid #ACA899; border-left: 1px solid white; border-bottom: 2px solid #FCC247;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #FAF9F4; overflow:hidden; height:22px;
}

.listhead3
{
		border-top: 1px solid white; border-right: 1px solid white; border-left: 1px solid white; border-bottom: 2px solid #E1E2E3;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #EFEFEF; overflow:hidden; height:22px;
}

.listhead4
{
		border-top: 1px solid white; border-right: 1px solid white; border-left: 1px solid white; border-bottom: 2px solid #FCC247;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #FAF9F4; overflow:hidden; height:22px;
}

.listtr01
{
		background-color: #FFFFFF;
		text-align: left;
		padding: 3px;
}

.listtr02
{
		background-color: #3366CC;
		color: #FFF;
		text-align: left;
		padding: 3px;
}

.resizeblock{
	background-color:transparent;
	width:2px;
	float:right;
	cursor:e-resize;
}

</style>

<!–[if IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie6.css" />
<![endif]–>

<script language="javascript" src="include/common.js"></script>
<script language="javascript">
var domain = "<%=_GET['domain']%>";
var ajaxlock = false;
var selectedRow = null;
var lastObj = null;
var lastObjIndex = -1;
var _TIMER_GETCONN = null;

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()
{
	ajaxlock = false;
	$("waitingdiv").style.display = "none";
	if (xmlhttp.readyState == 4)
	{
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_get_lastconn':	getLastconn();break;
				}
			}
			catch(e)
			{
			}
		}
		else
		{
		}
	}
}

function getLastconn()
{
	try
	{
		var xmldoc = xmlhttp.responseXML;
		var row = xmldoc.getElementsByTagName("connection");
		var rownum = row.length;

		var headcell = $("listhead").rows[0].cells;
		var htmltext = "<table id='listtable' width='100%' border='0' cellpadding='2' cellspacing='0' style='table-layout:fixed;'><thead><tr height='0'><td width='"+headcell[0].width+"'></td><td width='"+headcell[1].width+"'></td><td width='"+headcell[2].width+"'></td><td width='"+headcell[3].width+"'></td><td width='"+headcell[4].width+"'></td><td width='"+headcell[5].width+"'></td><td width='"+headcell[6].width+"'></td></tr></thead><tbody id='maintable'>";
		for(var i=0; i < rownum; i++)
		{
			var myrow = row[i];
			var f_id = xmlFieldValue(myrow,"id");
			var f_protocol = removeXSS(xmlFieldValue(myrow,"protocol"));
			var f_username = removeXSS(xmlFieldValue(myrow,"username"));
			var f_ip = removeXSS(xmlFieldValue(myrow,"ip"));
			var f_lastcommand = removeXSS(xmlFieldValue(myrow,"lastcommand"));
			var f_directory = removeXSS(xmlFieldValue(myrow,"directory"));
			var f_lastfile = removeXSS(xmlFieldValue(myrow,"lastfile"));
			htmltext += "<tr class='listtr01' onmouseup='do_list_click(this);'><td>"+f_id+"</td><td>"+f_protocol+"</td><td>"+f_username+"</td><td>"+f_ip+"</td><td>"+f_lastcommand+"</td><td>"+f_directory+"</td><td>"+f_lastfile+"</td></tr>";
		}
		htmltext += "</tbody></table>";
		clear("listview_div");
		write("listview_div",htmltext);
		$("current_session").innerHTML = xmlFieldValue(xmldoc,"sessionnum");
		selectedRow = null;
		autoSortTable("listtable");

		if(lastObjIndex >= 0)
		{
			for(var i=0; i < rownum; i++)
			{
				var tempID = parseInt($("maintable").rows[i].cells[0].innerHTML);
				if(tempID == lastObjIndex)
				{
					$("maintable").rows[i].className = "listtr02";
					lastObj = $("maintable").rows[i];
					selectedRow = lastObj;
				}
			}
		}
	}
	catch(e){}

	clearInterval(_TIMER_GETCONN);
	_TIMER_GETCONN = setTimeout("getlist_loop()",3000);
}


function do_list_click(obj)
{
	var row_index = obj.rowIndex-1;
	if(selectedRow != $("maintable").rows[row_index])
	{
		if(lastObj != null)
			lastObj.className = "listtr01";

		selectedRow = $("maintable").rows[row_index];
		obj.className = "listtr02";
		lastObj = obj;
		try{
			lastObjIndex = parseInt(selectedRow.cells[0].innerHTML);
		}catch(e){
			lastObjIndex = -1;
		}
	}
	else
	{
		viewUserlog();
	}

	return false;
}


function kickUser()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['str_selsession_tip']%>");
		return;
	}
	var tempID = selectedRow.cells[0].innerHTML;
	var clientIP = selectedRow.cells[3].innerHTML;
	showMessagebox("<%=LANG['str_kicksession']%>","<iframe src='admin_kickuser_form.html?domain="+domain+"&ID="+tempID+"&clientIP="+clientIP+"' width=540 height=360 border=0 frameborder=0></iframe>",callback_return,540,360);
}

function callback_return(value)
{
	if(value != null)
	{
		getlist_loop();
	}
	return true;
}


function kickAllUser()
{
	if(!confirm("<%=LANG['str_kicksession_tip']%>"))
		return;

	var httpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
	httpObj.open("POST","admin_kickuser.html");
	httpObj.onreadystatechange = function(){getlist_loop(); };
	httpObj.send("domain="+domain+"&killall=1&r=" + Math.random());
}

function viewUserlog()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['str_selsession_tip']%>");
		return;
	}
	var sessionID = selectedRow.cells[0].innerHTML;
	tempID = "0000000"+sessionID;
	var filterStr = urlEncode("("+right(tempID,7)+")");
	showMessagebox("<%=LANG['str_sessionlog']%> "+filterStr,"<iframe src='admin_viewsession.html?domain="+domain+"&filter="+filterStr+"&sessionID="+sessionID+"&r="+Math.random()+"' width=720 height=530 border=0 frameborder=0></iframe>",null,720,530);
}

function doChat()
{
	if(selectedRow == null || selectedRow.cells[1].innerHTML.toLowerCase().indexOf('ftp') == -1)
	{
		alert("<%=LANG['str_selftpsession_tip']%>");
		return;
	}
	var sessionID = selectedRow.cells[0].innerHTML;
	var tempID = "0000000"+sessionID;
	tempID = right(tempID,7);
	showMessagebox("<%=LANG['str_chatwith']%> "+tempID,"<iframe src='admin_chat_form.html?domain="+domain+"&sessionID="+sessionID+"' width=480 height=445 border=0 frameborder=0></iframe>",null,480,445);
}

function doBroadcast()
{
	showMessagebox("<%=LANG['str_broadcast']%>","<iframe src='admin_broadcast_form.html?domain="+domain+"' width=418 height=250 border=0 frameborder=0></iframe>",null,420,250);
}
</script>
</head>
<body style="background-color:#E6E6E6;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<div id="waitingdiv" style="position:absolute; z-index:100; top:0px; left:0px; width:100%; height:100%; background:#777; filter:alpha(opacity=60); opacity:0.60; display:none;" align="center">
<div style="position:absolute; top:20%; left:20%; width:250px; height:100px;"><img src="images/loading2.gif" border="0">
<H2><b><%=LANG["title_updating"]%></b></H2></div></div>

<div style="padding-top:2px; overflow-x:hidden;">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
	<tr>
	<td width="50%" style="padding-left:5px;">
	<button onclick="kickUser();"><span><em><img src="images/ico_kick.png" align="absmiddle"> <%=LANG["button_kick"]%></em></span></button>
	<button onclick="kickAllUser();"><span><em><img src="images/ico_kickall.png" align="absmiddle"> <%=LANG["button_kickall"]%></em></span></button>
	<button onclick="viewUserlog();"><span><em><img src="images/ico_viewlog.png" align="absmiddle"> <%=LANG["button_viewlog"]%></em></span></button>
	</td>
	<td align="right" style="padding-right:12px;"><%=LANG["str_domain"]%>:<b><%=specialhtml_encode(unescape(_GET["domain"]))%></b>&nbsp;<%=LANG["str_current_session"]%>:<b><span id="current_session">0</span></b></td>
	</tr>
	</table>

</div>


<div style="background-color:#E6E6E6;">
	<div style="margin-top:3px; margin-left:5px; border:1px solid #919B9C; border-bottom:0px; width:98%; overflow-x:hidden;">
		<table id="listhead" width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
			<tr>
			<td class="listhead" width="80" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 0 , 'int')"><div class="resizeblock">&nbsp;</div><%=LANG["title_id"]%></td>
			<td class="listhead" width="100" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 1);"><div class="resizeblock">&nbsp;</div><%=LANG["title_protocol"]%></td>
			<td class="listhead" width="100" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 2);"><div class="resizeblock">&nbsp;</div><%=LANG["title_username"]%></td>
			<td class="listhead" width="120" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 3);"><div class="resizeblock">&nbsp;</div><%=LANG["title_ipaddress"]%></td>
			<td class="listhead" width="120" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 4);"><div class="resizeblock">&nbsp;</div><%=LANG["title_lastcmd"]%></td>
			<td class="listhead" width="120" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 5);"><div class="resizeblock">&nbsp;</div><%=LANG["title_lastdir"]%></td>
			<td class="listhead3" width="120" onmouseover="className='listhead4';" onmouseout="className='listhead3';" onmousedown="sortTable(this,'listtable', 6);" style="text-align:left;"><div class="resizeblock">&nbsp;</div>&nbsp;&nbsp;<%=LANG["title_file"]%></td>
			</tr>
		</table>
	</div>
	<div id="listview_div" style="background-color:#FFF; margin-left:5px; border:1px solid #919B9C; border-top:0px; width:98%; height:460px; overflow:auto; overflow-x:hidden;">
		<table id="listtable" width="100%" border="0" cellpadding="2" cellspacing="0" style="table-layout:fixed;">
		<thead><tr height="0">
		<td width="80"></td>
		<td width="100"></td>
		<td width="100"></td>
		<td width="120"></td>
		<td width="120"></td>
		<td width="120"></td>
		<td width="120"></td>
		</tr></thead>
		<tbody id="maintable"></tbody>
		</table>
	</div>
</div>

</body>
</html>
<script>
function getlist_loop()
{
	ajaxRequest("admin_get_lastconn","domain="+domain+"&r=" + Math.random());
}

clearInterval(_TIMER_GETCONN);
_TIMER_GETCONN = setTimeout("getlist_loop()",3000);
getlist_loop();
</script>

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

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