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

local type = _GET["type"] or _POST["type"]
local domain = _GET["domain"] or _POST["domain"]
%>
<!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>Event Manager</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;}

.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;
		padding: 3px;
}

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

#maintable td
{
	border-bottom:1px solid #E1E2E3; padding:4px;
} 
</style>

<script language="javascript" src="include/common.js"></script>
<script language="javascript">
var selectedRow = null;
var lastObj = null;
var domain = "<%=domain%>";

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;
	}
	else
	{
		var type = selectedRow.cells[0].getAttribute("type");
		var event = selectedRow.cells[1].getAttribute("index");
		var eventName = urlEncode(selectedRow.cells[1].innerHTML);
		var frametag = new Date().getTime();
		showMessagebox(type+" "+eventName,"<iframe src='admin_event_editor.html?domain="+domain+"&type="+type+"&event="+event+"&eventName="+eventName+"&seeds=" + Math.random() +"' width=680 height=460 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",callback_return,680,460);
	}

	return false;
}

function callback_return(value)
{
	if(value != null)
	{
		if(isFirefox)
		{
			try
			{
				var httpObject = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
				if(httpObject) 
				{
					httpObject.open("GET","admin_get_eventlist.html?domain=<%=domain%>&type=<%=type%>&r="+Math.random(),false);
					httpObject.send("");
					var result = trim(httpObject.responseText);
					$("maintable").innerHTML = result;
				}
			}
			catch(e)
			{
				window.location.reload();
			}
		}
		else
		{
			window.location.reload();
		}
	}
	return true;
}

</script>
</head>
<body style="background-color:#E6E6E6;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<div style="background-color:#E6E6E6;">
	<div id="listview_div" style="background-color:#FFF; margin-top:3px; margin-left:5px; border:1px solid #919B9C; width:98%; height:500px; overflow:auto; overflow-x:hidden;">
		<table id="listtable" width="100%" border="0" cellpadding="2" cellspacing="0" style="table-layout:fixed;">
		<thead><tr>
		<td class="listhead" width="13%" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 0)"><%=LANG["title_protocol"]%></td>
		<td class="listhead" width="32%" onmouseover="className='listhead2';" onmouseout="className='listhead';" onmousedown="sortTable(this,'listtable', 1)"><%=LANG["title_event"]%></td>
		<td class="listhead3" width="55%" onmouseover="className='listhead4';" onmouseout="className='listhead3';" onmousedown="sortTable(this,'listtable', 2)"><%=LANG["title_expanation"]%></td>
		</tr></thead>
		<tbody id="maintable">
		<%
			local i = 0
			if type == "ftp" then
				for key,value in ipairs(FTP_EVENT_KEY) do
					local val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14 = c_GetFTPEvent(domain,i)
					if value ~= "OnIPIsBanned" and value ~= "OnSiteCommandMessage" then
						if val1 == true or val4 == true or val7 == true or val13 == true then
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='FTP'>FTP <img src='images/markicon.gif'></td><td index='"..i.."'>"..value.."</td><td><i>"..FTP_EVENT_VALUE[i+1].."</i></td></tr>")
						else
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='FTP'>FTP</td><td index='"..i.."'>"..value.."</td><td><i>"..FTP_EVENT_VALUE[i+1].."</i></td></tr>")
						end
					end
					i = i + 1
				end
			elseif type == "ssh" then
				for key,value in ipairs(SSH_EVENT_KEY) do
					local val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14 = c_GetSSHEvent(domain,i)
					if value ~= "OnIPIsBanned" then
						if val1 == true or val4 == true or val7 == true or val13 == true then
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='SSH'>SSH <img src='images/markicon.gif'></td><td index='"..i.."'>"..value.."</td><td><i>"..SSH_EVENT_VALUE[i+1].."</i></td></tr>")
						else
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='SSH'>SSH</td><td index='"..i.."'>"..value.."</td><td><i>"..SSH_EVENT_VALUE[i+1].."</i></td></tr>")
						end
					end
					i = i + 1
				end
			elseif type == "http" then
				for key,value in ipairs(WEB_EVENT_KEY) do
					local val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13,val14 = c_GetHTTPEvent(domain,i)
					if value ~= "OnIPIsBanned" then
						if val1 == true or val4 == true or val7 == true or val13 == true then
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='HTTP'>HTTP <img src='images/markicon.gif'></td><td index='"..i.."'>"..value.."</td><td><i>"..WEB_EVENT_VALUE[i+1].."</i></td></tr>")
						else
							print("<tr class='listtr01' onmouseup='do_list_click(this);'><td type='HTTP'>HTTP</td><td index='"..i.."'>"..value.."</td><td><i>"..WEB_EVENT_VALUE[i+1].."</i></td></tr>")
						end
					end
					i = i + 1
				end
			end
		%>	
		</tbody>
		</table>
	</div>
</div>


</body>
</html>

<% 
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>