Subversion Repositories ALCASAR

Rev

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