Subversion Repositories ALCASAR

Rev

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