Subversion Repositories ALCASAR

Rev

Rev 2276 | Rev 2411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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