Subversion Repositories ALCASAR

Rev

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

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