Subversion Repositories ALCASAR

Rev

Rev 955 | Rev 1124 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
452 richard 1
<?php
958 franck 2
# $Id: index.php 958 2012-07-19 09:01:30Z franck $
498 richard 3
$hostname = "alcasar";
784 richard 4
$network_pb = False;
509 richard 5
$cert_add = "http://alcasar/certs";
360 richard 6
$direct_access = False;
832 richard 7
$diagnostic = "can't contact the default router";
363 richard 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)
783 richard 14
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname/", $_SERVER['HTTP_HOST']))
522 richard 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
732 richard 26
	$time[2] = $temp % 60 ;				// seconds
566 stephane 27
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
28
 
732 richard 29
	return $time[0]." h ".$time[1]." m ".$time[2]." s";
566 stephane 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
783 richard 34
if ((isset ($user[4])) && ($user[4] != "0")){
566 stephane 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>";
688 richard 79
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
832 richard 80
if ((isset ($user[4])) && ($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 {
832 richard 84
	  if ($user[5] != $user[0]) // authentication exception or not
85
	  {
86
	  	$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";
87
		$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;connecter d'internet</a>";
88
	  }
89
	  else
90
	  {
91
		  $l_logout_explain = "Votre système ($user[5]) est en exception d'authentication.<br><br>$nb_connection_history last connections :$connection_history";
92
		  $l_logout = "Information des connexions";
93
	  }
94
	}
566 stephane 95
  $l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
536 franck 96
  $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 97
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;dente</a>";
98
}
912 richard 99
else if($Language == 'pt'){
100
  $l_access_denied = "Acesso negado";
101
  $l_access_welcome = "Bem-vindo ao Alcasar";
102
  $l_access_unavailable = "ACESSO INDISPONÍVEL";
103
  $l_required_domain = "Site WEB Obrigatório";
955 richard 104
  $l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
912 richard 105
  $l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
955 richard 106
  $l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
912 richard 107
  $l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
108
  $l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
955 richard 109
  $l_welcome = "Página do portal";
110
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Controle Center</a>";
912 richard 111
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Instalar Certificado Alcasar AC</a>";
112
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Instalar Certificado Alcasar AC</a>";
113
  $l_certif_explain = "O certificado Permiti a troca de dados seguro entre seu computador e o portal Alcasar.<BR>Se este certificado não estiver incorporado no seu computador, alguns alertas de segurança deverá aparecer no navegador.<br><br>";
955 richard 114
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Essa foi uma ajuda complementar</a>";
912 richard 115
if ((isset ($user[4])) && ($user[4] == "0")) {
955 richard 116
	  $l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
922 richard 117
	  $l_logout = "<a href=\"http://www.google.pt\">Abrir uma conexão de Internet</a>";}
912 richard 118
  else {
119
	  if ($user[5] != $user[0]) // authentication exception or not
120
	  {
955 richard 121
		  $l_logout_explain = "Se desejar, feche a conexão do usuário atual conectado.<br> Usuário conectado : <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";
922 richard 122
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Sair da Internet</a>";
912 richard 123
	  }
124
	  else
125
	  {
955 richard 126
		  $l_logout_explain = "O sistema ($user[5]) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
922 richard 127
		  $l_logout = "Informações de conexões";
912 richard 128
	  }
129
  	}
922 richard 130
  $l_password_change = "<a href=\"https://$hostname/pass\">Mudar sua senha</a>";
955 richard 131
  $l_password_change_explain = "Você será redirecionado à página de alteração de senha.<br><br> e deverá ter uma conta de usuário valido para efetuar a troca e acessar à Internet.";
922 richard 132
  $l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
912 richard 133
}
360 richard 134
else {
135
  $l_access_denied = "ACCESS DENIED";
369 richard 136
  $l_access_welcome = "Welcome on ALCASAR";
360 richard 137
  $l_access_unavailable = "ACCESS UNAVAILABLE";
138
  $l_required_domain = "Required WEB site";
369 richard 139
  $l_explain_acc_access = "This center control the portal. You must have an administrative account.";
801 richard 140
  $l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
360 richard 141
  $l_explain_net_pb = "Your portal has just detected that the Internet access is down";
142
  $l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
143
  $l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
369 richard 144
  $l_welcome = "Your captive portal main page";
566 stephane 145
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
611 franck 146
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
566 stephane 147
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
688 richard 148
  $l_certif_explain = "Allow secure data exchange between your computer and ALCASAR portal.<BR>If this certificate isn't incorporated in your computer, some security alerts should appear in your browser.<br><br>";
149
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
783 richard 150
if ((isset ($user[4])) && ($user[4] == "0")) {
369 richard 151
	  $l_logout_explain = "No Internet consultation session is actualy open on your system";
912 richard 152
	  $l_logout = "<a href=\"http://www.google.com\">Open an Internet session</a>";}
369 richard 153
  else {
832 richard 154
	  if ($user[5] != $user[0]) // authentication exception or not
155
	  {
922 richard 156
		  $l_logout_explain = "Close the session of the user currently connected.<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";
783 richard 157
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
832 richard 158
	  }
159
	  else
160
	  {
922 richard 161
		  $l_logout_explain = "Your system ($user[5]) is in exception of authentication.<br><br>$nb_connection_history Last logins :$connection_history";
832 richard 162
		  $l_logout = "Connections information";
163
	  }
783 richard 164
  	}
566 stephane 165
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
799 richard 166
  $l_password_change_explain = "Redirect you on password change page.<br><br> You should already have an Internet access account.";
360 richard 167
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
168
}
369 richard 169
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
360 richard 170
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
509 richard 171
 
172
# Attribution des icones / images
173
$img_rep = "images/";
174
$img_organisme = "organisme.png";
175
$img_access = "globe_acces_70.png";
176
$img_connect = "globe_70.png";
177
$img_warning = "globe_warning_70.png";
178
$img_pwd = "cle_ombre.png";
179
$img_certificate = "certificat.png";
180
$img_acc = "logo-alcasar_70.png";
181
$img_false = "interdit.png";
182
$img_internet = $img_connect;
183
 
783 richard 184
if ((isset ($user[4])) && ($user[4] == "0")) {
509 richard 185
	if (! $network_pb) {
186
		$img_internet = $img_access;
187
		}
188
		else {
189
		$img_internet = $img_warning;
190
	}
191
}
192
else {
193
	$img_internet = $img_connect;
194
}
195
 
452 richard 196
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
360 richard 197
?>
566 stephane 198
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
199
	<html>
200
	<head>
201
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
202
	<title>ALCASAR - <?php echo $l_title; ?></title>
203
	<meta http-equiv="Cache-control" content="no-cache">
204
	<meta http-equiv="Pragma" content="no-cache">
205
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
206
	<script type="text/javascript">
509 richard 207
		function valoriserDiv5(param){
208
			document.getElementById("box_info").innerHTML = param.innerHTML;
209
		}
210
	</script>
360 richard 211
</head>
566 stephane 212
<body onload="valoriserDiv5(text_conn);">
509 richard 213
<?php
360 richard 214
if ($direct_access){
215
	echo "
566 stephane 216
		<div id=\"cadre_titre\" class=\"titre_controle\">
217
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
509 richard 218
	if ($network_pb) {
566 stephane 219
		echo "	<span>$l_explain_net_pb</span>";
509 richard 220
		}
360 richard 221
	}
509 richard 222
	else {
223
		echo"
566 stephane 224
			<div id=\"cadre_titre\" class=\"titre_refus\">
225
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
363 richard 226
	}
360 richard 227
?>
566 stephane 228
			<div id="boite_logo">
229
				<img src="images/organisme.png">
230
			</div>
231
		</div>
232
		<div id="contenu_acces">
233
			<div id="box_url">
509 richard 234
				<?php if (! $direct_access){echo "$l_required_domain : $_SERVER[HTTP_HOST]";}?>
566 stephane 235
			</div>
509 richard 236
<?php
237
if ($direct_access){
566 stephane 238
	echo "	<div id=\"box_bienvenue\">
360 richard 239
				$l_welcome
566 stephane 240
			</div>
241
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
242
				<span>$l_logout</span>
243
				<img src=\"$img_rep$img_internet\">
244
			</div>
245
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
246
				<span>$l_install_certif</span>
247
				<img src=\"$img_rep$img_certificate\">
248
			</div>
249
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
250
				<img src=\"$img_rep$img_pwd\">
251
				<span>$l_password_change</span>
252
			</div>		
253
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
254
				<span>$l_acc_access</span>
255
				<img src=\"$img_rep$img_acc\">
256
			</div>
257
			<div class=\"div-cache\" id=\"text_conn\">
258
				<h2>$l_logout</h2>
259
				<p>$l_logout_explain</p>
260
				<img src=\"$img_rep$img_internet\">
261
			</div>
262
			<div class=\"div-cache\" id=\"text_certif\">
263
				<h2>$l_install_certif_more</h2>
264
				<p>$l_certif_explain $l_certif_explain_help</p>
265
				<img src=\"$img_rep$img_certificate\">				
266
			</div>
267
			<div class=\"div-cache\" id=\"text_mdp\">
268
				<h2>$l_password_change</h2>
269
				<p>$l_password_change_explain</p>
270
				<img src=\"$img_rep$img_pwd\">
271
			</div>
272
			<div class=\"div-cache\" id=\"text_acc\">
273
				<h2>$l_acc_access</h2>
274
				<p>$l_explain</p>
275
				<img src=\"$img_rep$img_acc\">
276
			</div>
277
			<div id=\"box_info\">
278
			</div>";
509 richard 279
	}
280
	else {
281
		echo "
566 stephane 282
			<div id=\"box_refuse\">
509 richard 283
				<img src=\"$img_rep$img_false\">
566 stephane 284
				<p>$l_explain</p>
285
			</div>
286
			<div id=\"liens_redir\">
287
				<p>$l_back_page</p>
288
			</div>";
509 richard 289
		}
290
	if (($network_pb)&&(! $direct_access)) {
566 stephane 291
	echo "	<span>Diagnostic : $diagnostic</span>";
509 richard 292
	}
363 richard 293
?>
566 stephane 294
		</div>
295
	</body>
360 richard 296
</html>