1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2"http://www.w3.org/TR/html4/loose.dtd">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
6<meta HTTP-EQUIV="Expires" CONTENT="-1">
7<title>Untitled Document</title>
8<style type="text/css"></style>
9<link href="/form_style.css" rel="stylesheet" type="text/css" />
10<link href="/NM_style.css" rel="stylesheet" type="text/css" />
11
12
13<script type="text/javascript" src="/state.js"></script>
14<script type="text/javascript" src="/client_function.js"></script>
15<script type="text/javascript" src="/alttxt.js"></script> 
16<script>
17// for client_function.js
18<% login_state_hook(); %>
19
20var list_of_BlockedClient = [<% get_nvram_list("FirewallConfig", "MFList"); %>];
21
22var list_of_ClientPriority = [<% get_nvram_list("PrinterStatus", "x_USRRuleList"); %>];
23var list_of_changedPriority = new Array();
24
25var leases = [<% dhcp_leases(); %>];	// [[hostname, MAC, ip, lefttime], ...]
26var arps = [<% get_arp_table(); %>];		// [[ip, x, x, MAC, x, type], ...]
27var arls = [<% get_arl_table(); %>];		// [[MAC, port, x, x], ...]
28var wireless = [<% wl_auth_list(); %>];	// [[MAC, associated, authorized], ...]
29
30var ipmonitor = [<% get_static_client(); %>];	// [[IP, MAC, DeviceName, Type, http, printer, iTune], ...]
31var networkmap_fullscan = '<% nvram_match_x("", "networkmap_fullscan", "0", "done"); %>'; //2008.07.24 Add.  0 stands for complete, (null) stands for scanning.
32
33var clients = getclients(1); //_noMonitor
34var unblocked_clients = new Array();
35var blocked_clients = new Array();
36var rule_array;
37var page_modified = 0;
38
39
40function initial(){
41	flash_button();
42	
43	parent.show_client_status(clients.length);
44	
45	isFullscanDone();
46	
47	// organize the clients
48	set_client_is_blocked();
49	
50	show_clients();
51	
52	parent.hideLoading();		
53}
54
55function isFullscanDone(){	
56	if(networkmap_fullscan == "done"){
57		$("LoadingBar").style.display = "none";
58		
59		//$("refresh_list").disabled = false;
60	}
61	else{
62		$("LoadingBar").style.display = "block";
63		
64		//$("refresh_list").disabled = true;
65	}
66}
67
68function get_client_priority(client_ip){
69	for(var i = 0; i < list_of_ClientPriority.length; ++i){
70		if(list_of_ClientPriority[i][0] == "client_priority"&&
71				list_of_ClientPriority[i][1] == client_ip)
72			return list_of_ClientPriority[i][3];
73	}
74	
75	return 4;
76}
77
78function get_priority_list_order(client_ip){
79	for(var i = 0; i < list_of_ClientPriority.length; ++i){
80		if(list_of_ClientPriority[i][0] == "client_priority"&&
81				list_of_ClientPriority[i][1] == client_ip)
82			return i;
83	}
84	
85	return -1;
86}
87
88function get_changed_priority(obj){
89	var start = "client_priority_".length;
90	var end = obj.id.length;
91	var client_order = parseInt(obj.id.substring(start, end));
92	var changed_priority = obj.value;
93	var len = 0;	
94	
95	for(var i = 0; i < unblocked_clients.length; ++i){
96		if(unblocked_clients[i] == client_order){ 
97			if(clients[i][10] != changed_priority){
98				if(checkDuplicateName(clients[i][1], list_of_changedPriority)){
99					for(var j = 0; j < list_of_changedPriority.length; ++j){
100						if(list_of_changedPriority[j][0] == clients[i][1]){
101							list_of_changedPriority[j][1] = changed_priority;
102							
103							return;
104						}
105					}
106				}
107				else{
108					len = list_of_changedPriority.length;
109					
110					list_of_changedPriority[len] = new Array(3);
111					list_of_changedPriority[len][0] = clients[i][1];	// client's ip
112					list_of_changedPriority[len][1] = changed_priority;	// new priority
113					
114					return;
115				}
116			}
117			else{
118				if(checkDuplicateName(clients[i][1], list_of_changedPriority)){
119					for(var j = 0; j < list_of_changedPriority.length; ++j){
120						if(list_of_changedPriority[j][0] == clients[i][1]){
121							list_of_changedPriority.splice(j, 1);
122							return;
123						}
124					}
125				}				
126				return;
127			}
128		}
129	}
130}
131
132var unblocked_clients, blocked_clients = new Array;
133function set_client_is_blocked(){
134	if(list_type == '1'){  // when MAC filter is in "Accept mode".
135		for(var i = 0; i < clients.length; ++i){
136			if(checkDuplicateName(clients[i][2], list_of_BlockedClient)){
137				clients[i][9] = "u";
138				unblocked_clients[i] = i;
139			}
140			else{
141				clients[i][9] = "b";
142				blocked_clients[i] = i;
143			}
144		}
145		$("alert_block").style.display = "block";
146	}
147	else{                  // when MAC filter is in "Reject mode" or disabled.
148		for(var i = 0; i < clients.length; ++i){
149			if(!checkDuplicateName(clients[i][2], list_of_BlockedClient)){
150				clients[i][9] = "u";
151				unblocked_clients[i] = i;
152			}
153			else{
154				clients[i][9] = "b";
155				blocked_clients[i] = i;
156			}
157		}
158		$("alert_block").style.display = "none";
159	}
160}
161
162function simplyName(orig_name){
163	if(orig_name != null){
164		if(orig_name.length > 17)
165			shown_client_name = orig_name.substring(0, 15) + "...";
166		else
167			shown_client_name = orig_name;
168	}
169	else
170		shown_client_name = "";
171		
172	return;
173}
174
175var DEVICE_TYPE = ["", "<#Device_type_01_PC#>", "<#Device_type_02_RT#>", "<#Device_type_03_AP#>", "<#Device_type_04_NAS#>", "<#Device_type_05_IC#>", "<#Device_type_06_OD#>"];
176var shown_client_name = "";
177
178function show_clients(){
179	
180	
181	var addClient, clientType, clientName, clientIP, clientPriority, clientBlock;		
182	
183	for(var j=0, i=0, k=0; j < clients.length; j++){
184		if(clients[j][9] == "u"){
185			
186		  addClient = $('Clients_table').insertRow(k+2);
187		  clientType = addClient.insertCell(0);
188	  	clientName = addClient.insertCell(1);
189		  clientIP = addClient.insertCell(2);
190		  clientPriority = addClient.insertCell(3);
191	
192			simplyName(clients[j][0]);
193		  	  	  	  
194		  clients[j][5] = (clients[j][5] == undefined)?6:clients[j][5];		  
195		  	 	  
196		  var isPrt = "";
197			switch(clients[j][7]){
198				case "1":
199					isPrt = "<br/><strong><#Device_service_Printer#> </strong>YES(LPR)";
200					break;
201				case "2":
202					isPrt = "<br/><strong><#Device_service_Printer#> </strong>YES(RAW)";
203					break;
204				case "3":
205					isPrt = "<br/><strong><#Device_service_Printer#> </strong>YES(SMB)";
206					break;
207				default:
208					;
209		  };
210		  
211		  var isITu = (clients[j][8] == "1")?"<br/><strong><#Device_service_iTune#> </strong>YES":"";
212		  var isWL = (clients[j][3] == "10")?"<br/><strong><#Device_service_Wireless#> </strong>YES":"";
213		  
214		  clientType.style.textAlign = "center";	  
215		  clientType.innerHTML = "<img title='"+ DEVICE_TYPE[clients[j][5]]+"' src='/images/wl_device/" + clients[j][5] +".gif'>";
216		  clientName.innerHTML = shown_client_name;
217		  clients[j][0] = (clients[j][0] == null)?"":clients[j][0];
218		  clientName.abbr = clients[j][0] + 
219		  									"<br/><strong>MAC: </strong>"+ clients[j][2] + isPrt + isITu + isWL;
220	
221		  clientName.onmouseover = function(){		  		
222		  		writetxt(this.abbr);
223		  };
224		  clientName.onmouseout = function(){ writetxt(0); };
225		  
226	  	clientIP.innerHTML = (clients[j][6] == "1")?"<a href=http://"+ clients[j][1] +" target='blank'>" + clients[j][1] + "</a>":""+ clients[j][1];
227		  
228		  clients[j][10] = get_client_priority(clients[j][1]);
229		  
230	   	var selected_one = ["","",""];
231			if(clients[j][10] == 1)
232				selected_one[0] = "selected";
233			else if(clients[j][10] == 4)
234				selected_one[1] = "selected";
235			else if(clients[j][10] == 6)
236				selected_one[2] = "selected";
237			else
238				selected_one[1] = "selected";   
239	
240			if(clients[j][1].length > 0){
241		  	clientPriority.innerHTML = "<select id='client_priority_"+j+"' class='input' onchange='get_changed_priority(this);'><option value='1' "+selected_one[0]+"><#Priority_Level_1#></option><option value='4' "+selected_one[1]+"><#Priority_Level_2#></option><option value='6'  "+selected_one[2]+"><#Priority_Level_3#></option></select>";
242			}
243			else{
244				clientPriority.innerHTML = "<select disabled=disabled class='input'><option value=1><#btn_Disabled#></option></select>";
245			}
246		  
247		  if(list_type != "1"){
248			  clientBlock = addClient.insertCell(4);
249			  clientBlock.style.textAlign = "center";
250			  clientBlock.innerHTML = '<img src="/images/icon-01.gif" id=unblock_client'+j+' onClick="blockClient('+j+')" style="cursor:pointer;">\n'
251		  }
252		  k++; //for insertRow();
253		}
254		else if(clients[j][9] == "b"){  //show blocked device..
255
256			simplyName(clients[j][0]);
257				
258			add_xClient = $('xClients_table').insertRow(i+2); //here use i for create row
259			xClientType = add_xClient.insertCell(0);
260			xClientName = add_xClient.insertCell(1);
261			xClientIP = add_xClient.insertCell(2);
262			xClientMAC = add_xClient.insertCell(3);
263
264		  var isPrt = (clients[j][7] == "1")?"<br/><strong><#Device_service_Printer#> </strong>YES":"";
265		  var isITu = (clients[j][8] == "1")?"<br/><strong><#Device_service_iTune#> </strong>YES":"";
266		  var isWL = (clients[j][3] == "10")?"<br/><strong><#Device_service_Wireless#> </strong>YES":"";
267		  		  	  
268			clients[j][5] = (clients[j][5] == undefined)?6:clients[j][5];
269		  clients[j][0] = (clients[j][0] == null)?"":clients[j][0];
270		  	
271			xClientType.style.textAlign = "center";
272		  xClientType.innerHTML = "<img title='" +DEVICE_TYPE[clients[j][5]]+"' src='/images/wl_device/" + clients[j][5] +".gif'>";
273		  xClientName.innerHTML = shown_client_name;
274		  xClientName.abbr = clients[j][0] + isPrt + isITu + isWL;
275		  									
276			xClientIP.innerHTML = clients[j][1];
277			xClientMAC.innerHTML = clients[j][2];	  									
278	
279		  xClientName.onmouseover = function(){	  		
280		  		writetxt(this.abbr);
281		  };
282		  xClientName.onmouseout = function(){ writetxt(0); };
283			
284			if(list_type != "1"){
285				xClientunBlock = add_xClient.insertCell(4);
286				xClientunBlock.style.textAlign = "center";
287				xClientunBlock.innerHTML = '<img src="/images/icon-02.gif" onClick="unBlockClient('+j+')" style="cursor:pointer;">\n'
288			}
289			i++; //for insertRow();
290		}
291	}	
292}
293
294
295function blockClient(unBlockedClient_order){
296	var str = "";
297	
298	if(list_type == "1"){
299		alert("<#macfilter_alert_str1#>");
300		return;
301	}	
302	this.selectedClientOrder = unBlockedClient_order;
303	
304	str += '<#block_Comfirm1#>" ';
305	str += (clients[unBlockedClient_order][0] == null)?clients[unBlockedClient_order][2]:clients[unBlockedClient_order][0];
306	str += '" ?\n';
307	str += '<#block_Comfirm2#>';
308	
309	if(confirm(str)){
310		set_filter_rule("add");
311		do_block_client();
312	}
313}
314
315function unBlockClient(blockedClient_order){
316	var str = "";
317	
318	if(list_type == "1"){
319		alert("<#macfilter_alert_str1#>");
320		return;
321	}
322	
323	this.selectedClientOrder = blockedClient_order;
324	
325	str += '<#unblock_Comfirm1#>" ';	
326	str += (clients[blockedClient_order][0] == null)?clients[blockedClient_order][2]:clients[blockedClient_order][0];
327	str += ' "<#unblock_Comfirm2#>';
328	
329	if(confirm(str)){
330		set_filter_rule("del");
331		do_unblock_client();
332	}
333}
334
335function do_block_client(){
336	parent.showLoading();
337	
338	document.macfilterForm.action_mode.value = " Add ";
339	document.macfilterForm.macfilter_list_x_0.value = clients[this.selectedClientOrder][2];
340	
341	document.macfilterForm.submit();
342}
343
344function do_unblock_client(){
345	parent.showLoading();
346	
347	document.macfilterForm.action_mode.value = " Del ";
348	
349	document.macfilterForm.submit();
350}
351
352function set_filter_rule(action){
353	if(action == "add")
354		;
355	else if(action == "del"){
356		for(var i = 0; i < list_of_BlockedClient.length; ++i){
357			if(list_of_BlockedClient[i] == clients[this.selectedClientOrder][2]){
358				free_options($("MFList_s"));
359				add_option($("MFList_s"), null, i, 1);
360			}
361		}
362	}
363}
364
365function done_validating(action, group_id){
366	$("applyFrame").src = "";
367	page_modified = 1;
368	
369	if(group_id == "MFList"){
370		if(action == " Add ")
371			refreshpage();
372		else if(action == " Del ")
373			refreshpage();
374	}
375	else if(group_id == "x_USRRuleList"){
376		if(action == " Del "){
377			submit_add_qosrule();
378		}
379		else if(action == " Add "){
380			if(list_of_changedPriority.length > 0)
381				submit_add_qosrule();
382			else
383				submit_apply_qosrule();
384		}
385		else if(action == " Restart "){
386			if(document.macfilterForm.modified.value == "1")
387				setTimeout("build_submitrule();", 3000);	// wait to finish restarting QoS.
388			else
389				//parent.refreshpage();
390				refreshpage();
391		}
392	}
393}
394
395function submit_macfilter(){
396	document.macfilterForm.target = "";
397	document.macfilterForm.action_mode.value = " Restart ";
398	document.macfilterForm.next_page.value = location.pathname;
399	
400	document.macfilterForm.submit();
401}
402
403function submit_apply_qosrule(){
404	document.qosForm.action_mode.value = " Restart ";
405	document.qosForm.action_script.value = "goonsetting";
406	
407	document.qosForm.submit();
408}
409
410function submit_add_qosrule(){
411	document.qosForm.action_mode.value = " Add ";
412	document.qosForm.action_script.value = "";
413	
414	document.qosForm.qos_service_name_x_0.value = "client_priority";
415	document.qosForm.qos_ip_x_0.value = list_of_changedPriority[0][0];
416	document.qosForm.qos_port_x_0.value = "";
417	document.qosForm.qos_prio_x_0.value = list_of_changedPriority[0][1];
418	
419	list_of_changedPriority.shift();
420	
421	document.qosForm.submit();
422}
423
424function submit_del_qosrule(){
425	var beDeletedOrder;
426	
427	for(var i = 0; i < list_of_changedPriority.length; ++i){
428		beDeletedOrder = get_priority_list_order(list_of_changedPriority[i][0]);
429		if(beDeletedOrder == -1)
430			continue;
431		
432		add_option($("x_USRRuleList_s"), null, beDeletedOrder, 1);
433	}
434	
435	document.qosForm.action_mode.value = " Del ";
436	document.qosForm.action_script.value = "";
437	
438	document.qosForm.submit();
439}
440
441function build_submitrule(){
442	if(list_of_changedPriority.length > 0)
443		submit_del_qosrule();
444	else if(document.macfilterForm.modified.value == "1"){
445		if(list_type != "1")
446			submit_macfilter();
447		else
448			//parent.refreshpage();
449			refreshpage();
450	}
451	else
452		//parent.refreshpage();
453		refreshpage();
454}
455
456function applyRule(){
457	parent.showLoading();
458	
459	build_submitrule();
460}
461
462function showLoading(restart_time2){
463	parent.showLoading(restart_time2);
464}
465
466function networkmap_update(s){
467	document.form.action_mode.value = "";
468	document.form.action_script.value = s;
469	document.form.flag.value = "nodetect";
470	document.form.submit();
471}
472</script>
473</head>
474
475<body class="statusbody" >
476
477<iframe name="applyFrame" id="applyFrame" src="" width="0" height="0" frameborder="0" scrolling="no"></iframe>
478
479<div id="LoadingBar" class="popup_bar_bg" style=""><#Device_Searching#>
480<!--[if lte IE 6.5]><iframe class="hackiframe"></iframe><![endif]-->
481</div>
482<div id="loadingBarBlock" class="loadingBarBlock" align="center">		
483</div>
484
485<form method="post" name="macfilterForm" id="macfilterForm" action="/start_apply.htm" target="applyFrame">
486<input type="hidden" name="action_mode" value="">
487<input type="hidden" name="sid_list" value="FirewallConfig;General;">
488<input type="hidden" name="group_id" value="MFList">
489<input type="hidden" name="current_page" value="/device-map/clients.asp">
490<input type="hidden" name="next_page" value="/device-map/clients.asp">
491<input type="hidden" name="modified" value="<% nvram_get_x("", "page_modified"); %>">
492
493<!-- for enable rule in MACfilter -->
494<input type="hidden" name="macfilter_enable_x" value="2">
495
496<!-- for add rule in MACfilter -->
497<input type="hidden" name="macfilter_list_x_0" value="">
498
499<!-- for del rule in MACfilter -->
500<select name="MFList_s" id="MFList_s" multiple="true" style="visibility:hidden; width:0px; height:0px;"></select>
501</form>
502
503<div id="unBlockedClients_table"></div>
504
505<table id="Clients_table" width="95%" align="center" cellpadding="1"  class="table1px">
506<tr>
507    <td colspan="5" class="Tablehead"><#ConnectedClient#></td>
508</tr>
509</table>
510
511<div id="navtxt" class="navtext" style="position:absolute; top:50px; left:-100px; visibility:hidden; font-family:Arial, Verdana"></div>
512<br />
513
514<div id="blockedClients_table"></div>
515<table id="xClients_table" width="95%" align="center" class="table1px">
516<tr>
517    <td colspan="5" class="Tablehead"><#BlockedClient#></td>
518</tr>
519</table>
520
521<br />
522
523
524<input type="button" id="applyClient" class="button" onclick="applyRule();" value="<#CTL_apply#>" style="float:right; clear:right;">
525<input type="button" id="refresh_list" class="button" onclick="networkmap_update('networkmap_refresh');" value="<#CTL_refresh#>" style="float:right;">
526
527<p><div id="alert_block" class="DMhint" style="margin-top:40px;">
528 	<a href="/Advanced_MACFilter_Content.asp" target="_parent"><#menu5_5_3#></a><#macfilter_alert_str1#>
529</div></p>
530
531
532<form method="post" name="qosForm" id="qosForm" action="/start_apply.htm" target="applyFrame">
533<input type="hidden" name="action_mode" value="">
534<input type="hidden" name="action_script" value="">
535<input type="hidden" name="sid_list" value="PrinterStatus;">
536<input type="hidden" name="group_id" value="x_USRRuleList">
537<input type="hidden" name="current_page" value="/device-map/clients.asp">
538<input type="hidden" name="next_page" value="/device-map/clients.asp">
539
540<input type="hidden" name="qos_service_name_x_0" value="">
541<input type="hidden" name="qos_ip_x_0" value="">
542<input type="hidden" name="qos_port_x_0" value="">
543<input type="hidden" name="qos_prio_x_0" value="">
544
545<select name="x_USRRuleList_s" id="x_USRRuleList_s" multiple="true" style="visibility:hidden; width:0px; height:0px;"></select>	
546</form>
547
548<form method="post" name="form" id="refreshForm" action="/start_apply.htm" target="">
549<input type="hidden" name="sid_list" value="LANHostConfig;">
550<input type="hidden" name="group_id" value="">
551<input type="hidden" name="action_mode" value="">
552<input type="hidden" name="action_script" value="">
553<input type="hidden" name="current_page" value="/device-map/clients.asp">
554<input type="hidden" name="next_page" value="/device-map/clients.asp">
555<input type="hidden" name="flag" value="">
556</form>
557
558<script>
559	// 0: disable, 1: Accept, 2: Reject.
560	var list_type = '<% nvram_get_x("FirewallConfig", "macfilter_enable_x"); %>';
561	//var list_type = '0';
562	var list_of_BlockedClient = [<% get_nvram_list("FirewallConfig", "MFList"); %>];
563	
564	addClientTitle = $('Clients_table').insertRow(1);
565	addClientTitle.insertCell(0).innerHTML = "<#Type#>"
566  addClientTitle.insertCell(1).innerHTML = "<#Computer_Name#>";
567	addClientTitle.insertCell(2).innerHTML = "<#LAN_IP#>";
568	addClientTitle.insertCell(3).innerHTML = "<#Priority#>";
569	
570  if(list_type != "1"){
571	  addClientTitle.insertCell(4).innerHTML = "<#Block#>";
572	}
573		  
574  addClientTitle.style.textAlign = "center";
575<!------------------>
576
577	addblockedClientTitle = $('xClients_table').insertRow(1);
578	addblockedClientTitle.style.textAlign = "center";
579	addblockedClientTitle.insertCell(0).innerHTML = "<#Type#>";
580	addblockedClientTitle.insertCell(1).innerHTML = "<#Computer_Name#>";
581	addblockedClientTitle.insertCell(2).innerHTML = "<#LAN_IP#>";
582	addblockedClientTitle.insertCell(3).innerHTML = "<#MAC_Address#>";
583	
584	if(list_type != "1")
585		addblockedClientTitle.insertCell(4).innerHTML = "<#unBlock#>";
586		
587	if(list_of_BlockedClient.length == 0){
588		var Nodata = $('xClients_table').insertRow(2).insertCell(0);
589		Nodata.innerHTML = "<#Nodata#>";
590		Nodata.colSpan = "5";
591		Nodata.style.color = "#C00";
592		Nodata.style.textAlign = "center";
593	}
594</script>
595
596<script>
597	initial();
598	
599	function loading() {        
600    $("loadingBarBlock").style.display = "none";
601  }
602
603
604  if (window.attachEvent) {
605    window.attachEvent('onload', loading);
606  } else {
607    window.addEventListener('load', loading, false);
608  }
609</script>
610</body>
611</html>
612