Subversion Repositories ALCASAR

Rev

Rev 566 | Rev 628 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
452 richard 1
<?php
2
$private_ip = "192.168.182.1";
498 richard 3
$hostname = "alcasar";
360 richard 4
$network_pb = False;
509 richard 5
$cert_add = "http://alcasar/certs";
360 richard 6
$direct_access = False;
363 richard 7
$diagnostic = "eth0 link down";
8
$remote_ip = ($_SERVER['REMOTE_ADDR']);
9
$tab = array();$user = array();
566 stephane 10
$connection_history =  "";
11
$nb_connection_history = 3;
12
 
522 richard 13
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
14
if (($_SERVER['HTTP_HOST'] == $private_ip) || preg_match ("/^alcasar/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname/", $_SERVER['HTTP_POST']))
15
	{
16
	$direct_access=True;
17
	exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
18
	$user = explode (" ", $tab[0]);
19
	}
566 stephane 20
#### Affichage des 3 dernières connexions de $user[5]
21
function secondsToDuration($seconds = null){
22
	if ($seconds == null) return "";
509 richard 23
 
566 stephane 24
	$temp = $seconds % 3600;
25
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
26
	$time[2] = $temp % 60 ;						// seconds
27
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
28
 
29
	return $time[0]." h ".$time[2]." m ".$time[1]." s";
30
}
509 richard 31
 
566 stephane 32
$l_connected = "connected"; // a traduire (choix de la langue ci-dessous mais nécessitant de $connection_history)
33
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
34
if ($user[4] != "0"){
35
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
36
		include_once("/etc/freeradius-web/config.php");
37
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
38
 
39
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
40
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
41
 
42
		if ($link){
43
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
44
 
45
			if ($res){
46
				$connection_history.= "<ul>";
47
				while(($row = @da_sql_fetch_array($res,$config))){
48
					$connected = "";
49
					if ($row[acctstoptime] == "") $connected = " ($l_connected)";
50
					$connection_history.="<li title='$row[username] $row[acctstarttime] $row[acctstoptime] (".secondsToDuration($row[acctsessiontime]).")'>$row[acctstarttime] (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
51
				}
52
				$connection_history.="</ul>";
53
			}
54
		}
55
	}
56
}
509 richard 57
####
58
 
360 richard 59
# Choice of language
60
$Language = 'en';
61
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
62
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
63
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
64
if($Language == 'fr'){
65
  $l_access_denied = "ACC&Egrave;S REFUS&Eacute;";
399 franck 66
  $l_access_welcome = "Bienvenue sur ALCASAR";
360 richard 67
  $l_access_unavailable = "ACC&Egrave;S INDISPONIBLE";
68
  $l_required_domain = "Site WEB demand&eacute;";
536 franck 69
  $l_explain_acc_access = "Le centre de gestion permet d'administrer le portail. Vous devez poss&eacute;der un compte d'administration ou de gestion pour y acc&eacute;der.";
360 richard 70
  $l_explain_access_deny = "Vous tentez d'acc&eacute;der &agrave; une ressource dont le contenu est r&eacute;put&eacute; contenir des informations inappropri&eacute;es.";
71
  $l_explain_net_pb = "Votre portail d&eacute;tecte que l'acc&egrave;s &agrave; Internet est indisponible.";
72
  $l_contact_access_deny = "Contactez le responsable de la s&eacute;curit&eacute; (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
509 richard 73
  $l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
399 franck 74
  $l_welcome = "Page principale de votre portail captif";
566 stephane 75
  $l_acc_access = "<a href=\"https://$hostname/acc\">Acc&egrave;s au centre de gestion</a>";
76
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installer le certificat racine</a>";
77
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installation du certificat de l'autorit&eacute; racine d'ALCASAR</a>";
536 franck 78
  $l_certif_explain = "Permet l'&eacute;change de donn&eacute;es s&eacute;curis&eacute;es entre votre station de consultation et le portail captif ALCASAR.<BR>Si ce certificat n'est pas enregistr&eacute; sur votre station de consultation, il est possible que des alertes de s&eacute;curit&eacute;s soient &eacute;mises par votre navigateur.<br><br>";
509 richard 79
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide pour les certificats</a>";
369 richard 80
  if ($user[4] == "0") {
509 richard 81
	  $l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre syst&egrave;me.";
566 stephane 82
	  $l_logout = "<a href=\"http://www.google.fr\">Ouvrir une session Internet</a>";}
369 richard 83
  else {
566 stephane 84
	  $l_logout_explain = "Ferme la session de l'usager actuellement connect&eacute;. <br><br>Utilisateur connect&eacute; : <a href=\"http://$hostname:3990/logoff\" title=\"Deconnecter l'utilisateur $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history derni&egrave;res connexions :$connection_history";
85
	  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;connecter d'internet</a>";}
86
  $l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
536 franck 87
  $l_password_change_explain = "Vous redirige sur la page de changement du mot de passe de votre compte d'acc&egrave;s &agrave; internet.<br><br>Vous devez avoir un compte internet valide.";
360 richard 88
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;dente</a>";
89
}
90
else {
91
  $l_access_denied = "ACCESS DENIED";
369 richard 92
  $l_access_welcome = "Welcome on ALCASAR";
360 richard 93
  $l_access_unavailable = "ACCESS UNAVAILABLE";
94
  $l_required_domain = "Required WEB site";
369 richard 95
  $l_explain_acc_access = "This center control the portal. You must have an administrative account.";
360 richard 96
  $l_explain_access_deny = "Your portal has just detected that the Internet access is down";
97
  $l_explain_net_pb = "Your portal has just detected that the Internet access is down";
98
  $l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
99
  $l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
369 richard 100
  $l_welcome = "Your captive portal main page";
566 stephane 101
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
611 franck 102
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
566 stephane 103
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
509 richard 104
  $l_certif_explain = "A TRADUIRE<br><br>";
105
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Help for ALCASAR certificate</a>";
106
if ($user[4] == "0") {
369 richard 107
	  $l_logout_explain = "No Internet consultation session is actualy open on your system";
566 stephane 108
	  $l_logout = "<a href=\"http://www.google.fr\">Open an Internet session</a>";}
369 richard 109
  else {
566 stephane 110
	  $l_logout_explain = "Close the session of the user actualy connecterd.<br> User logged-on : <a href=\"http://$hostname:3990/logoff\" title=\"Disconnect user $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history last connections :$connection_history";
111
	  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";}
112
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
509 richard 113
  $l_password_change_explain = "Ridirect you on password change page.<br><br> You should already have an Internet access account.";
360 richard 114
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
115
}
369 richard 116
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
360 richard 117
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
509 richard 118
 
119
# Attribution des icones / images
120
$img_rep = "images/";
121
$img_organisme = "organisme.png";
122
$img_access = "globe_acces_70.png";
123
$img_connect = "globe_70.png";
124
$img_warning = "globe_warning_70.png";
125
$img_pwd = "cle_ombre.png";
126
$img_certificate = "certificat.png";
127
$img_acc = "logo-alcasar_70.png";
128
$img_false = "interdit.png";
129
$img_internet = $img_connect;
130
 
131
if ($user[4] == "0") {
132
	if (! $network_pb) {
133
		$img_internet = $img_access;
134
		}
135
		else {
136
		$img_internet = $img_warning;
137
	}
138
}
139
else {
140
	$img_internet = $img_connect;
141
}
142
 
452 richard 143
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
360 richard 144
?>
566 stephane 145
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
146
	<html>
147
	<head>
148
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
149
	<title>ALCASAR - <?php echo $l_title; ?></title>
150
	<meta http-equiv="Cache-control" content="no-cache">
151
	<meta http-equiv="Pragma" content="no-cache">
152
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
153
	<script type="text/javascript">
509 richard 154
		function valoriserDiv5(param){
155
			document.getElementById("box_info").innerHTML = param.innerHTML;
156
		}
157
	</script>
360 richard 158
</head>
566 stephane 159
<body onload="valoriserDiv5(text_conn);">
509 richard 160
<?php
360 richard 161
if ($direct_access){
162
	echo "
566 stephane 163
		<div id=\"cadre_titre\" class=\"titre_controle\">
164
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
509 richard 165
	if ($network_pb) {
566 stephane 166
		echo "	<span>$l_explain_net_pb</span>";
509 richard 167
		}
360 richard 168
	}
509 richard 169
	else {
170
		echo"
566 stephane 171
			<div id=\"cadre_titre\" class=\"titre_refus\">
172
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
363 richard 173
	}
360 richard 174
?>
566 stephane 175
			<div id="boite_logo">
176
				<img src="images/organisme.png">
177
			</div>
178
		</div>
179
		<div id="contenu_acces">
180
			<div id="box_url">
509 richard 181
				<?php if (! $direct_access){echo "$l_required_domain : $_SERVER[HTTP_HOST]";}?>
566 stephane 182
			</div>
509 richard 183
<?php
184
if ($direct_access){
566 stephane 185
	echo "	<div id=\"box_bienvenue\">
360 richard 186
				$l_welcome
566 stephane 187
			</div>
188
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
189
				<span>$l_logout</span>
190
				<img src=\"$img_rep$img_internet\">
191
			</div>
192
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
193
				<span>$l_install_certif</span>
194
				<img src=\"$img_rep$img_certificate\">
195
			</div>
196
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
197
				<img src=\"$img_rep$img_pwd\">
198
				<span>$l_password_change</span>
199
			</div>		
200
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
201
				<span>$l_acc_access</span>
202
				<img src=\"$img_rep$img_acc\">
203
			</div>
204
			<div class=\"div-cache\" id=\"text_conn\">
205
				<h2>$l_logout</h2>
206
				<p>$l_logout_explain</p>
207
				<img src=\"$img_rep$img_internet\">
208
			</div>
209
			<div class=\"div-cache\" id=\"text_certif\">
210
				<h2>$l_install_certif_more</h2>
211
				<p>$l_certif_explain $l_certif_explain_help</p>
212
				<img src=\"$img_rep$img_certificate\">				
213
			</div>
214
			<div class=\"div-cache\" id=\"text_mdp\">
215
				<h2>$l_password_change</h2>
216
				<p>$l_password_change_explain</p>
217
				<img src=\"$img_rep$img_pwd\">
218
			</div>
219
			<div class=\"div-cache\" id=\"text_acc\">
220
				<h2>$l_acc_access</h2>
221
				<p>$l_explain</p>
222
				<img src=\"$img_rep$img_acc\">
223
			</div>
224
			<div id=\"box_info\">
225
			</div>";
509 richard 226
	}
227
	else {
228
		echo "
566 stephane 229
			<div id=\"box_refuse\">
509 richard 230
				<img src=\"$img_rep$img_false\">
566 stephane 231
				<p>$l_explain</p>
232
			</div>
233
			<div id=\"liens_redir\">
234
				<p>$l_back_page</p>
235
			</div>";
509 richard 236
		}
237
	if (($network_pb)&&(! $direct_access)) {
566 stephane 238
	echo "	<span>Diagnostic : $diagnostic</span>";
509 richard 239
	}
363 richard 240
?>
566 stephane 241
		</div>
242
	</body>
360 richard 243
</html>