Subversion Repositories ALCASAR

Rev

Rev 2134 | Rev 2274 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2134 Rev 2265
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- written by Rexy -->
2
<HTML><!-- written by Rexy -->
3
<head>
3
<head>
4
<META HTTP-EQUIV="Refresh" CONTENT="30">
4
<META HTTP-EQUIV="Refresh" CONTENT="30">
5
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
5
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
6
<title>Activity</title>
6
<title>Activity</title>
7
<link rel="stylesheet" href="/css/style.css">
7
<link rel="stylesheet" href="/css/style.css">
8
</head>
8
</head>
9
<body>
9
<body>
10
<table width="100%" border="0" cellspacing="0" cellpadding="0">
10
<table width="100%" border="0" cellspacing="0" cellpadding="0">
11
<?
11
<?
-
 
12
/********************
-
 
13
* READ CONF FILES   *
-
 
14
*********************/
-
 
15
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
-
 
16
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers");
-
 
17
$conf_files=array(CONF_FILE,ETHERS_FILE);
-
 
18
foreach ($conf_files as $file){
-
 
19
if (!file_exists($file)){
-
 
20
	exit("Requested file ".$file." isn't present");}
-
 
21
if (!is_readable($file)){
-
 
22
	exit("Can't read the file ".$file);}
-
 
23
}
12
#retrieve IP_address of ALCASAR
24
#retrieve IP_address of ALCASAR
13
$alcasar_conf_file="/usr/local/etc/alcasar.conf";
25
$alcasar_conf_file="/usr/local/etc/alcasar.conf";
14
$ouvre=fopen("$alcasar_conf_file","r");
26
$ouvre=fopen("$alcasar_conf_file","r");
15
if ($ouvre){
27
if ($ouvre){
16
	while (!feof ($ouvre))
28
	while (!feof ($ouvre))
17
	{
29
	{
18
		$tampon = fgets($ouvre, 4096);
30
		$tampon = fgets($ouvre, 4096);
19
		if (strpos($tampon,"=")!==false){
31
		if (strpos($tampon,"=")!==false){
20
			$tmp = explode("=",$tampon);
32
			$tmp = explode("=",$tampon);
21
			$conf[$tmp[0]] = $tmp[1];
33
			$conf[$tmp[0]] = $tmp[1];
22
		}
34
		}
23
	}
35
	}
24
}else{
-
 
25
	exit("Erreur d'ouverture du fichier $alcasar_conf_file");
-
 
26
}
36
}
27
fclose($ouvre);
37
fclose($ouvre);
28
$tmp = explode("/",$conf["PRIVATE_IP"]);
38
$tmp = explode("/",$conf["PRIVATE_IP"]);
29
$intif = $conf["INTIF"];
39
$intif = $conf["INTIF"];
30
$private_ip=$tmp[0];
40
$private_ip=$tmp[0];
31
require('/etc/freeradius-web/config.php');
41
require('/etc/freeradius-web/config.php');
32
# Choice of language
42
# Choice of language
33
$Language = 'en';
43
$Language = 'en';
34
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
44
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
35
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
45
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
36
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
46
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
37
if($Language == 'fr'){
47
if($Language == 'fr'){
38
  $l_activity = "Activité sur le réseau de consultation";
48
  $l_activity = "Activité sur le réseau de consultation";
39
  $l_ip_adr = "Adresse IP";
49
  $l_ip_adr = "Adresse IP";
40
  $l_mac_adr = "Adresse MAC";
50
  $l_mac_adr = "Adresse MAC";
41
  $l_user = "Usager";
51
  $l_user = "Usager";
42
  $l_mac_allowed = "@MAC autorisée";
52
  $l_mac_allowed = "@MAC autorisée";
43
  $l_mac_temporarily_allowed = "@MAC autorisée temporairement";
53
  $l_mac_temporarily_allowed = "@MAC autorisée temporairement";
44
  $l_action = "Action";
54
  $l_action = "Action";
45
  $l_dissociate = "Dissocier @IP";
55
  $l_dissociate = "Dissocier @IP";
46
  $l_disconnect = "Déconnecter";
56
  $l_disconnect = "Déconnecter";
47
  $l_refresh = "Cette page est rafraichie toutes les 30 secondes";
57
  $l_refresh = "Cette page est rafraichie toutes les 30 secondes";
48
  $l_edit_user = "Editer l'utilisateur"; 
58
  $l_edit_user = "Editer l'utilisateur"; 
49
  $l_connect = "Autoriser temporairement";
59
  $l_connect = "Autoriser temporairement";
50
}
60
}
51
else {
61
else {
52
  $l_activity = "Activity on the consultation LAN";
62
  $l_activity = "Activity on the consultation LAN";
53
  $l_ip_adr = "IP Adress";
63
  $l_ip_adr = "IP Adress";
54
  $l_mac_adr = "MAC Adress";
64
  $l_mac_adr = "MAC Adress";
55
  $l_user = "User";
65
  $l_user = "User";
56
  $l_mac_allowed = "@MAC allowed";
66
  $l_mac_allowed = "@MAC allowed";
57
  $l_mac_temporarily_allowed = "@MAC temporarily allowed";
67
  $l_mac_temporarily_allowed = "@MAC temporarily allowed";
58
  $l_action = "Action";
68
  $l_action = "Action";
59
  $l_dissociate = "Dissociate @IP";
69
  $l_dissociate = "Dissociate @IP";
60
  $l_disconnect = "Disconnect";
70
  $l_disconnect = "Disconnect";
61
  $l_refresh = "This frame is refreshed every 30'";
71
  $l_refresh = "This frame is refreshed every 30'";
62
  $l_edit_user = "Edit user"; 
72
  $l_edit_user = "Edit user"; 
63
  $l_connect = "Temporarily authorize";
73
  $l_connect = "Temporarily authorize";
64
}
74
}
65
echo "<tr><th>$l_activity</th></tr>
75
echo "<tr><th>$l_activity</th></tr>
66
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td></tr>
76
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td></tr>
67
</table>";
77
</table>";
68
if (isset($_POST['action'])){
78
if (isset($_POST['action'])){
69
	switch ($_POST['action']){
79
	switch ($_POST['action']){
70
		case "$l_disconnect" :
80
		case "$l_disconnect" :
71
			exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
81
			exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
72
			unset ($_POST['mac_addr']);
82
			unset ($_POST['mac_addr']);
73
		break;
83
		break;
74
		case "$l_dissociate" :
84
		case "$l_dissociate" :
75
			exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
85
			exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
76
			unset ($_POST['mac_addr']);
86
			unset ($_POST['mac_addr']);
77
		break;
87
		break;
78
		case "$l_connect" :
88
		case "$l_connect" :
79
			exec ("sudo /usr/sbin/chilli_query authorize mac $_POST[mac_addr]");
89
			exec ("sudo /usr/sbin/chilli_query authorize mac $_POST[mac_addr]");
80
			unset ($_POST['mac_addr']);
90
			unset ($_POST['mac_addr']);
81
		break;
91
		break;
82
	}
92
	}
83
}
93
}
84
?>
94
?>
85
<table width="100%" border=1 cellspacing=0 cellpadding=1>
95
<table width="100%" border=1 cellspacing=0 cellpadding=1>
86
	<tr><td valign="middle" align="center"><? echo "$l_refresh";?><br>
96
	<tr><td valign="middle" align="center"><? echo "$l_refresh";?><br>
87
	<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
97
	<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
88
		<tr bgcolor="#d0ddb0">
98
		<tr bgcolor="#d0ddb0">
89
<? echo "		<th>#</th>
99
<? echo "		<th>#</th>
90
		<th>$l_ip_adr</th>
100
		<th>$l_ip_adr</th>
91
		<th>$l_mac_adr</th>
101
		<th>$l_mac_adr</th>
92
		<th>$l_user</th>
102
		<th>$l_user</th>
93
		<th>$l_action</th>
103
		<th>$l_action</th>
94
		</tr>";
104
		</tr>";
95
		$output = array(); $detail = array(); $nb_ligne = 0;
105
		$output = array(); $detail = array(); $nb_ligne = 0;
96
		exec ("sudo /sbin/ip link show $intif", $output); // retrieve ALCASAR MAC address
106
		exec ("sudo /sbin/ip link show $intif", $output); // retrieve ALCASAR MAC address
97
		$detail = explode (" " , $output[1]);
107
		$detail = explode (" " , $output[1]);
98
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
108
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
99
		unset ($output);unset ($detail);
109
		unset ($output);unset ($detail);
100
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
110
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
101
		while (list(,$ligne) = each($output)){
111
		while (list(,$ligne) = each($output)){
102
			$detail = explode (" ", $ligne);
112
			$detail = explode (" ", $ligne);
103
			$nb_ligne ++;
113
			$nb_ligne ++;
104
			echo "<tr valign=\"middle\">";
114
			echo "<tr valign=\"middle\">";
105
			echo "<td>".$nb_ligne."</td>";
115
			echo "<td>".$nb_ligne."</td>";
106
			echo "<td>".$detail[1]."</td>";
116
			echo "<td>".$detail[1]."</td>";
107
			if(file_exists('/usr/share/arp-scan/ieee-oui.txt')) // for each device on LAN, retrieve the MAC manufacturer
117
			if(file_exists('/usr/share/arp-scan/ieee-oui.txt')) // for each device on LAN, retrieve the MAC manufacturer
108
			{
118
			{
109
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
119
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
110
				exec ("grep $oui_id /usr/share/arp-scan/ieee-oui.txt | cut -f2", $mac_manufacturer);
120
				exec ("grep $oui_id /usr/share/arp-scan/ieee-oui.txt | cut -f2", $mac_manufacturer);
111
				if(empty($mac_manufacturer[0]))
121
				if(empty($mac_manufacturer[0]))
112
                {
122
				{
113
                	$mac_manufacturer[0] = "Unknown";
123
					$mac_manufacturer[0] = "Unknown";
114
                }
-
 
115
 
124
				}
116
				echo "<td>$detail[0] ($mac_manufacturer[0])</td>";
125
				echo "<td>$detail[0] <font size=\"1\">($mac_manufacturer[0])</font>";
117
				unset($mac_manufacturer);
126
				unset($mac_manufacturer);
118
			}
127
			}
119
			else
128
			else
120
			{
129
			{
121
				echo "<td>$detail[0]</td>";
130
				echo "<td>$detail[0]";
122
			}
131
			}
-
 
132
			exec ("grep $detail[0] /usr/local/etc/alcasar-ethers |cut -d' ' -f3", $mac_in_ether_file);
-
 
133
			if (!empty($mac_in_ether_file[0]))
-
 
134
			{
-
 
135
				echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
-
 
136
			}
123
			echo "<td>";
137
			echo "</td><td>";
124
			if ($detail[4] == "1"){ // authenticated equipment
138
			if ($detail[4] == "1"){ // authenticated equipment
125
				$login = $detail[5];
139
				$login = $detail[5];
126
				unset ($found_users); unset ($cn);
140
				unset ($found_users); unset ($cn);
127
				$search = $login; $search_IN = 'username'; // is user in database ?
141
				$search = $login; $search_IN = 'username'; // is user in database ?
128
				if (is_file("../lib/sql/find.php"))
142
				if (is_file("../lib/sql/find.php"))
129
					include("../lib/sql/find.php");
143
					include("../lib/sql/find.php");
130
				if (isset ($found_users)) // user is in database
144
				if (isset ($found_users)) // user is in database
131
				{
145
				{
132
					if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
146
					if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
133
						include("../lib/sql/user_info.php");
147
						include("../lib/sql/user_info.php");
134
				}
148
				}
135
				if (! isset ($cn)){ $cn='-';}
149
				if (! isset ($cn)){ $cn='-';}
136
				# The user is an allowed MAC address
150
				# The user is an allowed MAC address
137
					if ($detail[5] == $detail[0]){
151
					if ($detail[5] == $detail[0]){
138
						if (isset ($found_users)) { #MAC is in database
152
						if (isset ($found_users)) { #MAC is in database
139
							echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
153
							echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
140
							echo "</td><td>";
154
							echo "</td><td>";
141
						}
155
						}
142
						else { #MAC is temporarily allowed
156
						else { #MAC is temporarily allowed
143
							echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_temporarily_allowed</a>";
157
							echo "<b>$l_mac_temporarily_allowed</b>";
144
							echo "</td><td>";
158
							echo "</td><td>";
145
							echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
159
							echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
146
							echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
160
							echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
147
							echo "<INPUT type=submit name='action' value='$l_disconnect'>";
161
							echo "<INPUT type=submit name='action' value='$l_disconnect'>";
148
							echo "</FORM></TD>";
162
							echo "</FORM></TD>";
149
						}
163
						}
150
						# Disable temporarily @MAC access
164
						# Disable temporarily @MAC access
151
					}
165
					}
152
				# The user is a humanoide ;-)
166
				# The user is a humanoide ;-)
153
					else {
167
					else {
154
						if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
168
						if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
155
						else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
169
						else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
156
						echo "<TD>";
170
						echo "<TD>";
157
						echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
171
						echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
158
						echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
172
						echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
159
						echo "<INPUT type=submit name='action' value='$l_disconnect'>";
173
						echo "<INPUT type=submit name='action' value='$l_disconnect'>";
160
						echo "</FORM></TD>";
174
						echo "</FORM></TD>";
161
						}
175
						}
162
					}
176
					}
163
			# equipment without authenticated user
177
			# equipment without authenticated user
164
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
178
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
165
				echo "ALCASAR system";
179
				echo "ALCASAR system";
166
				echo "<TD>";
180
				echo "<TD>";
167
				echo "&nbsp;";
181
				echo "&nbsp;";
168
				echo "</TD>";
182
				echo "</TD>";
169
				}	
183
				}	
170
			else {  
184
			else {  
171
				echo "&nbsp;";
185
				echo "&nbsp;";
172
				echo "<TD>";		
186
				echo "<TD>";		
173
				echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
187
				echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
174
				# Dissociate user (... or other) who is not connected yet
188
				# Dissociate user (... or other) who is not connected yet
175
				echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
189
				echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
-
 
190
				if (empty($mac_in_ether_file[0]))
-
 
191
				{
176
				echo "<INPUT type='submit' name='action' value='$l_dissociate'>";
192
					echo "<INPUT type='submit' name='action' value='$l_dissociate'>"; // Dissociate only MAC not in ether file (dhcp)
177
				# Enable temporarily @MAC access
193
				}
178
				echo "<INPUT type=submit name='action' value='$l_connect'>";
194
				echo "<INPUT type=submit name='action' value='$l_connect'>"; // Enable temporarily @MAC access
179
				echo "</FORM></TD>";
195
				echo "</FORM></TD>";
180
			}
196
			}
-
 
197
			unset ($mac_in_ether_file);
181
			echo "</tr>";
198
			echo "</tr>";
182
		}
199
		}
183
		?>
200
		?>
184
	</table>
201
	</table>
185
	</td></tr>
202
	</td></tr>
186
</table>
203
</table>
187
</html>
204
</html>
188
 
205
 
189
 
206