Subversion Repositories ALCASAR

Rev

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