Subversion Repositories ALCASAR

Rev

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

Rev 2299 Rev 2411
Line 1... Line -...
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>Activity</title>
-
 
7
<link rel="stylesheet" href="/css/style.css">
-
 
8
</head>
-
 
9
<body>
-
 
10
<table width="100%" border="0" cellspacing="0" cellpadding="0">
-
 
11
<?
1
<?php
12
/********************
2
/********************
13
* READ CONF FILES   *
3
* READ CONF FILES   *
14
*********************/
4
*********************/
15
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
5
define("CONF_FILE", "/usr/local/etc/alcasar.conf");
16
define ("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
6
define("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
17
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
7
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
18
foreach ($conf_files as $file){
8
foreach ($conf_files as $file) {
19
if (!file_exists($file)){
9
	if (!file_exists($file)) {
20
	exit("Requested file ".$file." isn't present");}
10
		exit("Requested file ".$file." isn't present");
-
 
11
	}
21
if (!is_readable($file)){
12
	if (!is_readable($file)) {
22
	exit("Can't read the file ".$file);}
13
		exit("Can't read the file ".$file);
-
 
14
	}
23
}
15
}
24
#retrieve IP_address of ALCASAR
-
 
-
 
16
 
25
$alcasar_conf_file = '/usr/local/etc/alcasar.conf';
17
$alcasar_conf_file = '/usr/local/etc/alcasar.conf';
26
$file_conf = fopen($alcasar_conf_file, 'r');
18
$file_conf = fopen($alcasar_conf_file, 'r');
27
if (!$file_conf) {
19
if (!$file_conf) {
28
	exit('Error opening the file '.$alcasar_conf_file);
20
	exit('Error opening the file '.$alcasar_conf_file);
29
}
21
}
Line 40... Line 32...
40
$intif = $conf["INTIF"];
32
$intif = $conf["INTIF"];
41
$private_ip=$tmp[0];
33
$private_ip=$tmp[0];
42
require('/etc/freeradius-web/config.php');
34
require('/etc/freeradius-web/config.php');
43
# Choice of language
35
# Choice of language
44
$Language = 'en';
36
$Language = 'en';
45
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
37
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
46
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
38
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
47
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
39
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
-
 
40
}
48
if($Language == 'fr'){
41
if ($Language === 'fr') {
49
  $l_activity = "Activité sur le réseau de consultation";
42
	$l_activity = "Activité sur le réseau de consultation";
50
  $l_ip_adr = "Adresse IP";
43
	$l_ip_adr = "Adresse IP";
51
  $l_mac_adr = "Adresse MAC";
44
	$l_mac_adr = "Adresse MAC";
52
  $l_user = "Usager";
45
	$l_user = "Usager";
53
  $l_mac_allowed = "@MAC autorisée";
46
	$l_mac_allowed = "@MAC autorisée";
54
  $l_mac_temporarily_allowed = "@MAC autorisée temporairement";
47
	$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
55
  $l_action = "Action";
48
	$l_action = "Action";
56
  $l_dissociate = "Dissocier @IP";
49
	$l_dissociate = "Dissocier @IP";
57
  $l_disconnect = "Déconnecter";
50
	$l_disconnect = "Déconnecter";
58
  $l_refresh = "Cette page est rafraichie toutes les 30 secondes";
51
	$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
59
  $l_edit_user = "Editer l'utilisateur"; 
52
	$l_edit_user = "Editer l'utilisateur"; 
60
  $l_connect = "Autoriser temporairement";
53
	$l_connect = "Autoriser temporairement";
61
}
-
 
62
else {
54
} else {
63
  $l_activity = "Activity on the consultation LAN";
55
	$l_activity = "Activity on the consultation LAN";
64
  $l_ip_adr = "IP Adress";
56
	$l_ip_adr = "IP Adress";
65
  $l_mac_adr = "MAC Adress";
57
	$l_mac_adr = "MAC Adress";
66
  $l_user = "User";
58
	$l_user = "User";
67
  $l_mac_allowed = "@MAC allowed";
59
	$l_mac_allowed = "@MAC allowed";
68
  $l_mac_temporarily_allowed = "@MAC temporarily allowed";
60
	$l_mac_temporarily_allowed = "@MAC temporarily allowed";
69
  $l_action = "Action";
61
	$l_action = "Action";
70
  $l_dissociate = "Dissociate @IP";
62
	$l_dissociate = "Dissociate @IP";
71
  $l_disconnect = "Disconnect";
63
	$l_disconnect = "Disconnect";
72
  $l_refresh = "This frame is refreshed every 30'";
64
	$l_refresh = "This frame is refreshed every 30'";
73
  $l_edit_user = "Edit user"; 
65
	$l_edit_user = "Edit user"; 
74
  $l_connect = "Temporarily authorize";
66
	$l_connect = "Temporarily authorize";
75
}
67
}
76
echo "<tr><th>$l_activity</th></tr>
-
 
77
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td></tr>
-
 
78
</table>";
68
 
79
if (isset($_POST['action'])){
69
if (isset($_POST['action'])){
80
	switch ($_POST['action']){
70
	switch ($_POST['action']){
81
		case "$l_disconnect" :
71
		case "$l_disconnect" :
82
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
72
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($_POST['mac_addr']));
83
			unset($_POST['mac_addr']);
73
			unset($_POST['mac_addr']);
Line 91... Line 81...
91
			unset($_POST['mac_addr']);
81
			unset($_POST['mac_addr']);
92
		break;
82
		break;
93
	}
83
	}
94
}
84
}
95
?>
85
?>
-
 
86
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
 
87
<HTML><!-- written by Rexy -->
-
 
88
<head>
-
 
89
<META HTTP-EQUIV="Refresh" CONTENT="30">
-
 
90
<meta http-equiv="Content-Type" content="text/html; charset=<?= $config['general_charset'] ?>">
-
 
91
<title>Activity</title>
-
 
92
<link rel="stylesheet" type="text/css" href="/css/style.css">
-
 
93
</head>
-
 
94
<body>
-
 
95
<table width="100%" border="0" cellspacing="0" cellpadding="0">
-
 
96
<tr><th><?= $l_activity ?></th></tr>
-
 
97
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
-
 
98
</table>
96
<table width="100%" border=1 cellspacing=0 cellpadding=1>
99
<table width="100%" border=1 cellspacing=0 cellpadding=1>
97
	<tr><td valign="middle" align="center"><? echo "$l_refresh";?><br>
100
	<tr><td valign="middle" align="center"><?= $l_refresh ?><br>
98
	<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
101
	<table border=1 width="80%" cellpadding=2 cellspacing=0>
99
		<tr bgcolor="#d0ddb0">
102
		<tr>
100
<? echo "		<th>#</th>
103
			<th>#</th>
101
		<th>$l_ip_adr</th>
104
			<th><?= $l_ip_adr ?></th>
102
		<th>$l_mac_adr</th>
105
			<th><?= $l_mac_adr ?></th>
103
		<th>$l_user</th>
106
			<th><?= $l_user ?></th>
104
		<th>$l_action</th>
107
			<th><?= $l_action ?></th>
105
		</tr>";
108
		</tr>
-
 
109
		<?php
106
		$output = array(); $detail = array(); $nb_ligne = 0;
110
		$output = array(); $detail = array(); $nb_ligne = 0;
107
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR MAC address
111
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR MAC address
108
		$detail = explode (" " , $output[1]);
112
		$detail = explode (" " , $output[1]);
109
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
113
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
110
		unset ($output);unset ($detail);
114
		unset ($output);unset ($detail);
Line 155... Line 159...
155
							echo "</td><td>";
159
							echo "</td><td>";
156
						}
160
						}
157
						else { #MAC is temporarily allowed
161
						else { #MAC is temporarily allowed
158
							echo "<b>$l_mac_temporarily_allowed</b>";
162
							echo "<b>$l_mac_temporarily_allowed</b>";
159
							echo "</td><td>";
163
							echo "</td><td>";
160
							echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
164
							echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
161
							echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
165
							echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
162
							echo "<INPUT type=submit name='action' value='$l_disconnect'>";
166
							echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
163
							echo "</FORM></TD>";
167
							echo "</FORM></TD>";
164
						}
168
						}
165
						# Disable temporarily @MAC access
169
						# Disable temporarily @MAC access
166
					}
170
					}
167
				# The user is a humanoide ;-)
171
				# The user is a humanoide ;-)
168
					else {
172
					else {
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>";}
173
						if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
170
						else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
174
						else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
171
						echo "<TD>";
175
						echo "<TD>";
172
						echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
176
						echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
173
						echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
177
						echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
174
						echo "<INPUT type=submit name='action' value='$l_disconnect'>";
178
						echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_disconnect\">";
175
						echo "</FORM></TD>";
179
						echo "</FORM></TD>";
176
						}
180
						}
177
					}
181
					}
178
			# equipment without authenticated user
182
			# equipment without authenticated user
179
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
183
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
Line 183... Line 187...
183
				echo "</TD>";
187
				echo "</TD>";
184
				}	
188
				}	
185
			else {  
189
			else {  
186
				echo "&nbsp;";
190
				echo "&nbsp;";
187
				echo "<TD>";		
191
				echo "<TD>";		
188
				echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
192
				echo "<FORM action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
189
				# Dissociate user (... or other) who is not connected yet
193
				# Dissociate user (... or other) who is not connected yet
190
				echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
194
				echo "<INPUT type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
191
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
195
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
192
				if (empty($mac_in_ether_file[1]))
196
				if (empty($mac_in_ether_file[1]))
193
				{
197
				{
194
					echo "<INPUT type='submit' name='action' value='$l_dissociate'>"; // Dissociate only MAC not in ether file (dhcp)
198
					echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
195
				}
199
				}
196
				echo "<INPUT type=submit name='action' value='$l_connect'>"; // Enable temporarily @MAC access
200
				echo "<INPUT type=\"submit\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
197
				echo "</FORM></TD>";
201
				echo "</FORM></TD>";
198
			}
202
			}
199
			unset ($mac_in_ether_file);
203
			unset ($mac_in_ether_file);
200
			echo "</tr>";
204
			echo "</tr>";
201
		}
205
		}