Subversion Repositories ALCASAR

Rev

Rev 768 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 richard 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- written by Rexy -->
3
<head>
4
<META HTTP-EQUIV="Refresh" CONTENT="30">
5
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
6
<title>&Eacute;tat du r&eacute;seau</title>
7
<link rel="stylesheet" href="/css/style.css">
8
</head>
9
<body>
10
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
11
<?
830 richard 12
#retrieve IP_address of ALCASAR
13
$ouvre=fopen("/usr/local/etc/alcasar.conf","r");
14
if ($ouvre){
15
	while (!feof ($ouvre))
16
	{
17
		$tampon = fgets($ouvre, 4096);
18
		if (strpos($tampon,"=")!==false){
19
			$tmp = explode("=",$tampon);
20
			$conf[$tmp[0]] = $tmp[1];
21
		}
22
	}
23
}else{
24
	exit("Erreur d'ouverture du fichier ".ALCASAR_ETH1);
25
}
26
fclose($ouvre);
27
$tmp = explode("/",$conf["PRIVATE_IP"]);
28
$private_ip=$tmp[0];
318 richard 29
# Choice of language
609 richard 30
$mac_allowed_list="/usr/local/etc/alcasar-macallowed";
318 richard 31
$Language = 'en';
32
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
33
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
34
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
35
if($Language == 'fr'){
36
  $l_activity = "Activit&eacute; sur le r&eacute;seau de consultation";
37
  $l_ip_adr = "Adresse IP";
38
  $l_mac_adr = "Adresse MAC";
39
  $l_user = "Usager";
40
  $l_mac_allowed = "@MAC autoris&eacute;e";
41
  $l_action = "Action";
42
  $l_dissociate = "Dissocier";
43
  $l_disconnect = "D&eacute;connecter";
44
  $l_refresh = "Cette page est rafraichie toutes les 30 secondes";
609 richard 45
  $l_error_open_file = "Erreur d'ouverture du fichier"; 
318 richard 46
}
47
else {
48
  $l_activity = "Activity on the consultation LAN";
49
  $l_ip_adr = "IP Adress";
50
  $l_mac_adr = "MAC Adress";
51
  $l_user = "User";
52
  $l_mac_allowed = "@MAC allowed";
53
  $l_action = "Action";
54
  $l_dissociate = "Dissociate";
55
  $l_disconnect = "Disconnect";
56
  $l_refresh = "This frame is refreshed every 30'";
609 richard 57
  $l_error_open_file = "File open error"; 
318 richard 58
}
59
echo "
60
<tr><th>$l_activity</th></tr>
61
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\"
62
height=\"2\"></td></tr>
63
</TABLE>";
64
if (isset($_POST['action'])){
65
	switch ($_POST['action']){
674 richard 66
		case 'user_disconnect' :
67
			exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
318 richard 68
			unset ($_POST['user']);
674 richard 69
			unset ($_POST['mac_addr']);
318 richard 70
			unset ($_POST['choix']);
71
		break;
674 richard 72
		case 'mac_disconnect' :
73
			exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
318 richard 74
			unset ($_POST['mac_addr']);
75
			unset ($_POST['choix']);
76
		break;
77
	}
78
}
79
?>
80
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
81
	<tr><td valign="middle" align="left">
82
	<center>
83
<? echo "$l_refresh";?>
84
	<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" width="100%" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
85
		<tr bgcolor="#d0ddb0">
86
<? echo "
87
		<th>#</th>
88
		<th>$l_ip_adr</th>
89
		<th>$l_mac_adr</th>
90
		<th>$l_user</th>
91
		<th>$l_action</th>
92
		</tr>";
93
		$output = array(); $nb_ligne = 0;
94
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output);
95
		while (list(,$ligne) = each($output)){
96
			$detail = explode (" ", $ligne);
830 richard 97
			if ($detail[1] != $private_ip){
318 richard 98
				$nb_ligne ++;
99
				echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
100
				echo "<TR>";
830 richard 101
				echo "<TD>".$nb_ligne."</TD>";
102
				echo "<TD>".$detail[1]."</TD>";
103
				echo "<TD>".$detail[0]."</TD>";
318 richard 104
				echo "<TD>";
830 richard 105
				# authorized equipment 
318 richard 106
				if ($detail[4] == "1"){
830 richard 107
				# by MAC address
108
					if ($detail[5] == $detail[0]){
609 richard 109
						echo "$l_mac_allowed";
110
						if (is_file ($mac_allowed_list)) # le fichier existe
111
							{
112
							$tab=file($mac_allowed_list);
113
							if ($tab) # le fichier n'est pas vide
114
								{
115
								foreach ($tab as $line)
116
									{
117
									$field=explode("#", $line);
118
									$mac_addr=trim($field[0],"macallowed=");
768 richard 119
									if (strcasecmp (trim($detail[0]), trim($mac_addr)) == 0)
609 richard 120
										{
121
										echo " ( $field[1])";
122
										break;	
123
										}
124
									}
125
								}
126
							}
127
						else { echo "$l_error_open_file $mac_allowed_list";}
128
						echo "</TD><TD>&nbsp;";
129
					}
830 richard 130
				# by user
318 richard 131
					else {
335 richard 132
						echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"Editer l'utilisateur $detail[5]\">$detail[5]</a>";
318 richard 133
						echo "</TD>";
134
						echo "<TD>";
674 richard 135
						echo "<INPUT type='hidden' name='action' value='user_disconnect'>";
318 richard 136
						echo "<INPUT type='hidden' name='user' value='$detail[5]'>";
137
						echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
138
						echo "<INPUT type=submit value='$l_disconnect'>";
139
						}
140
					}
830 richard 141
				# equipment without authenticated user
318 richard 142
				else { 
143
					echo "&nbsp;";
144
					echo "</TD>";
145
					echo "<TD>";
674 richard 146
					echo "<INPUT type='hidden' name='action' value='mac_disconnect'>";
318 richard 147
					echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
148
					echo "<INPUT type='submit' value='$l_dissociate'>";
149
				}
150
				echo "</TD></TR></FORM>";
151
			}
152
		}
153
		?>
154
		</td></tr>
155
	</table>
156
	</td></tr>
157
</table>
158
</html>