Subversion Repositories ALCASAR

Rev

Rev 2450 | Rev 2810 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2450 Rev 2770
Line 46... Line 46...
46
	$l_mac_allowed = "@MAC autorisée";
46
	$l_mac_allowed = "@MAC autorisée";
47
	$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
47
	$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
48
	$l_action = "Action";
48
	$l_action = "Action";
49
	$l_dissociate = "Dissocier @IP";
49
	$l_dissociate = "Dissocier @IP";
50
	$l_disconnect = "Déconnecter";
50
	$l_disconnect = "Déconnecter";
-
 
51
	$l_stop_capture_disconnect = "Arrêter la capture et se déconnecter";
51
	$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
52
	$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
52
	$l_edit_user = "Editer l'utilisateur"; 
53
	$l_edit_user = "Editer l'utilisateur";
53
	$l_connect = "Autoriser temporairement";
54
	$l_connect = "Autoriser temporairement";
-
 
55
	$l_captureon = "Autoriser et capturer";
-
 
56
	$l_captureoff = "Arrêter la capture";
-
 
57
	$l_captureonly_on = "Capturer";
-
 
58
 
54
} else {
59
} else {
55
	$l_activity = "Activity on the consultation LAN";
60
	$l_activity = "Activity on the consultation LAN";
56
	$l_ip_adr = "IP Adress";
61
	$l_ip_adr = "IP Adress";
57
	$l_mac_adr = "MAC Adress";
62
	$l_mac_adr = "MAC Adress";
58
	$l_user = "User";
63
	$l_user = "User";
59
	$l_mac_allowed = "@MAC allowed";
64
	$l_mac_allowed = "@MAC allowed";
60
	$l_mac_temporarily_allowed = "@MAC temporarily allowed";
65
	$l_mac_temporarily_allowed = "@MAC temporarily allowed";
61
	$l_action = "Action";
66
	$l_action = "Action";
62
	$l_dissociate = "Dissociate @IP";
67
	$l_dissociate = "Dissociate @IP";
63
	$l_disconnect = "Disconnect";
68
	$l_disconnect = "Disconnect";
-
 
69
	$l_stop_capture_disconnect = "Stop capture and disconnect";
64
	$l_refresh = "This frame is refreshed every 30'";
70
	$l_refresh = "This frame is refreshed every 30'";
65
	$l_edit_user = "Edit user"; 
71
	$l_edit_user = "Edit user";
66
	$l_connect = "Temporarily authorize";
72
	$l_connect = "Temporarily authorize";
-
 
73
	$l_captureon = "Authorize and capture";
-
 
74
	$l_captureoff = "Stop capture";
-
 
75
	$l_captureonly_on = "Capture";
-
 
76
 
67
}
77
}
68
 
78
 
69
if (isset($_POST['action'])){
79
if (isset($_POST['action'])){
70
	switch ($_POST['action']){
80
	switch ($_POST['action']){
71
		case "$l_disconnect" :
81
		case "$l_disconnect" :
-
 
82
			$mac= $_POST['mac_addr'];
72
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
83
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
73
			unset($_POST['mac_addr']);
84
			unset($_POST['mac_addr']);
74
		break;
85
		break;
-
 
86
		case "$l_stop_capture_disconnect" :
-
 
87
			$mac= $_POST['mac_addr'];
-
 
88
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
-
 
89
			$file = '/tmp/capture_'.$mac.'.pcap';
-
 
90
			if (file_exists($file))
-
 
91
			{
-
 
92
				header('Content-Description : File Transfer');
-
 
93
				header('Content-Type: application/octet-stream');
-
 
94
				header('Content-disposition: attachement; filename='.basename($file).'');
-
 
95
				header('Expires: 0');
-
 
96
				header('Cache-Control: must-revalidate');
-
 
97
				header('Pragma: public');
-
 
98
				header('Content-Lenght: '.filesize($file));
-
 
99
				readfile($file);
-
 
100
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$macc);
-
 
101
				exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
-
 
102
				unset($_POST['mac_addr']);
-
 
103
				exit;
-
 
104
			}
-
 
105
 
-
 
106
		break;
75
		case "$l_dissociate" :
107
		case "$l_dissociate" :
76
			exec("sudo /usr/sbin/chilli_query dhcp-release ".escapeshellarg($_POST['mac_addr']));
108
			exec("sudo /usr/sbin/chilli_query dhcp-release ".escapeshellarg($_POST['mac_addr']));
77
			unset($_POST['mac_addr']);
109
			unset($_POST['mac_addr']);
78
		break;
110
		break;
79
		case "$l_connect" :
111
		case "$l_connect" :
80
			exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr']));
112
			exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr']));
81
			unset($_POST['mac_addr']);
113
			unset($_POST['mac_addr']);
82
		break;
114
		break;
-
 
115
		case "$l_captureon" :
-
 
116
			$mac= $_POST['mac_addr'];
-
 
117
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
-
 
118
			exec("sudo /usr/sbin/chilli_query authorize mac ".escapeshellarg($_POST['mac_addr']));
-
 
119
			unset($_POST['mac_addr']);
-
 
120
		break;
-
 
121
		case "$l_captureonly_on" :
-
 
122
			$mac= $_POST['mac_addr'];
-
 
123
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
-
 
124
		break;	
-
 
125
		case "$l_captureoff" :
-
 
126
			$mac= $_POST['mac_addr'];
-
 
127
			exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
-
 
128
			$file = '/tmp/capture_'.$mac.'.pcap';
-
 
129
			if (file_exists($file))
-
 
130
			{
-
 
131
				header('Content-Description : File Transfer');
-
 
132
				header('Content-Type: application/octet-stream');
-
 
133
				header('Content-disposition: attachement; filename='.basename($file).'');
-
 
134
				header('Expires: 0');
-
 
135
				header('Cache-Control: must-revalidate');
-
 
136
				header('Pragma: public');
-
 
137
				header('Content-Lenght: '.filesize($file));
-
 
138
				readfile($file);
-
 
139
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -f '.$mac);
-
 
140
				unset($_POST['mac_addr']);
-
 
141
				exit;
-
 
142
			}
-
 
143
		break;
83
	}
144
	}
84
}
145
}
85
?>
146
?>
86
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
147
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
87
<HTML><!-- written by Rexy -->
148
<HTML><!-- written by Rexy -->
Line 105... Line 166...
105
			<th><?= $l_mac_adr ?></th>
166
			<th><?= $l_mac_adr ?></th>
106
			<th><?= $l_user ?></th>
167
			<th><?= $l_user ?></th>
107
			<th><?= $l_action ?></th>
168
			<th><?= $l_action ?></th>
108
		</tr>
169
		</tr>
109
		<?php
170
		<?php
-
 
171
		$IoT_capture = $conf["IOT_CAPTURE"];
110
		$output = array(); $detail = array(); $nb_ligne = 0;
172
		$output = array(); $detail = array(); $nb_ligne = 0;
111
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR MAC address
173
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR MAC address
112
		$detail = explode (" " , $output[1]);
174
		$detail = explode (" " , $output[1]);
113
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
175
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
114
		unset ($output);unset ($detail);
176
		unset ($output);unset ($detail);
Line 143... Line 205...
143
			if ($detail[4] == "1"){ // authenticated equipment
205
			if ($detail[4] == "1"){ // authenticated equipment
144
				$login = $detail[5];
206
				$login = $detail[5];
145
				unset ($found_users); unset ($cn);
207
				unset ($found_users); unset ($cn);
146
				$search = $login; $search_IN = 'username'; // is user in database ?
208
				$search = $login; $search_IN = 'username'; // is user in database ?
147
				if (is_file("../lib/sql/find.php"))
209
				if (is_file("../lib/sql/find.php"))
148
					include("../lib/sql/find.php");
210
				include("../lib/sql/find.php");
149
				if (isset ($found_users)) // user is in database
211
				if (isset ($found_users)) // user is in database
150
				{
212
				{
151
					if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
213
					if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
152
						include("../lib/sql/user_info.php");
214
						include("../lib/sql/user_info.php");
153
				}
215
				}
Line 161... Line 223...
161
						else { #MAC is temporarily allowed
223
						else { #MAC is temporarily allowed
162
							echo "<b>$l_mac_temporarily_allowed</b>";
224
							echo "<b>$l_mac_temporarily_allowed</b>";
163
							echo "</td><td>";
225
							echo "</td><td>";
164
							echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
226
							echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
165
							echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
227
							echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
-
 
228
 
-
 
229
							if($IoT_capture == "on")
-
 
230
							{
-
 
231
								if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
-
 
232
								{
-
 
233
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_stop_capture_disconnect\">";
-
 
234
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
-
 
235
								}
-
 
236
 								else
-
 
237
								{
-
 
238
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
239
									echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
240
								}
-
 
241
							}
-
 
242
							else
166
							echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
243
								echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
-
 
244
 
167
							echo "</FORM></TD>";
245
							echo "</FORM></TD>";
168
						}
246
						}
169
						# Disable temporarily @MAC access
247
						# Disable temporarily @MAC access
170
					}
248
					}
171
				# The user is a humanoide ;-)
249
				# The user is a humanoide ;-)
Line 196... Line 274...
196
				if (empty($mac_in_ether_file[1]))
274
				if (empty($mac_in_ether_file[1]))
197
				{
275
				{
198
					echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
276
					echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
199
				}
277
				}
200
				echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
278
				echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
-
 
279
				
-
 
280
				if($IoT_capture == "on")
-
 
281
				{
-
 
282
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON")
-
 
283
					{
-
 
284
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureoff\">";
-
 
285
					}
-
 
286
					else
-
 
287
					{
-
 
288
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureon\">";
-
 
289
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_captureonly_on\">";
-
 
290
					}
-
 
291
				}
201
				echo "</FORM></TD>";
292
				echo "</FORM></TD>";
202
			}
293
			}
203
			unset ($mac_in_ether_file);
294
			unset ($mac_in_ether_file);
204
			echo "</tr>";
295
			echo "</tr>";
205
		}
296
		}