Subversion Repositories ALCASAR

Rev

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

Rev 2276 Rev 2299
Line 20... Line 20...
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
Line 76... Line 77...
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>
Line 101... Line 102...
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)){