Subversion Repositories ALCASAR

Rev

Rev 1306 | Rev 1426 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1306 Rev 1345
1
<?php
1
<?php
2
# $Id: index.php 1306 2014-01-16 10:37:45Z richard $
2
# $Id: index.php 1345 2014-05-10 10:24:39Z richard $
3
#
3
#
4
# index.php for ALCASAR captive portal
4
# index.php for ALCASAR captive portal
5
# by REXY
5
# by REXY
6
# UI & css style by stephane ERARD
6
# UI & css style by stephane ERARD
7
# The contents of this file may be used under the terms of the GNU
7
# The contents of this file may be used under the terms of the GNU
8
# General Public License Version 2, provided that the above copyright
8
# General Public License Version 2, provided that the above copyright
9
# notice and this permission notice is included in all copies or
9
# notice and this permission notice is included in all copies or
10
# substantial portions of the software.
10
# substantial portions of the software.
11
/****************************************************************
11
/****************************************************************
12
*			GLOBAL FILE PATHS			*
12
*			GLOBAL FILE PATHS			*
13
*****************************************************************/
13
*****************************************************************/
14
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
14
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
15
 
15
 
16
/****************************************************************
16
/****************************************************************
17
*			FILE reading test			*
17
*			FILE reading test			*
18
*****************************************************************/
18
*****************************************************************/
19
$conf_files=array(CONF_FILE);
19
$conf_files=array(CONF_FILE);
20
foreach ($conf_files as $file){
20
foreach ($conf_files as $file){
21
	if (!file_exists($file)){
21
	if (!file_exists($file)){
22
		exit("File ".$file." unknown");
22
		exit("File ".$file." unknown");
23
	}
23
	}
24
	if (!is_readable($file)){
24
	if (!is_readable($file)){
25
		exit("You don't have read rights on the file ".$file);
25
		exit("You don't have read rights on the file ".$file);
26
	}
26
	}
27
}
27
}
28
/****************************************************************
28
/****************************************************************
29
*			Read CONF_FILE				*
29
*			Read CONF_FILE				*
30
*****************************************************************/
30
*****************************************************************/
31
$ouvre=fopen(CONF_FILE,"r");
31
$ouvre=fopen(CONF_FILE,"r");
32
if ($ouvre){
32
if ($ouvre){
33
	while (!feof ($ouvre))
33
	while (!feof ($ouvre))
34
	{
34
	{
35
		$tampon = fgets($ouvre, 4096);
35
		$tampon = fgets($ouvre, 4096);
36
		if (strpos($tampon,"=")!==false){
36
		if (strpos($tampon,"=")!==false){
37
			$tmp = explode("=",$tampon);
37
			$tmp = explode("=",$tampon);
38
			$conf[$tmp[0]] = $tmp[1];
38
			$conf[$tmp[0]] = $tmp[1];
39
		}
39
		}
40
	}
40
	}
41
}else{
41
}else{
42
	exit("Error opening the file ".CONF_FILE);
42
	exit("Error opening the file ".CONF_FILE);
43
}
43
}
44
fclose($ouvre);
44
fclose($ouvre);
-
 
45
$organisme = trim($conf["ORGANISM"]);
-
 
46
$domainname = trim($conf["DOMAIN"]);
45
$hostname = alcasar.".".$conf["DOMAIN"];
47
$hostname = "alcasar.".$domainname;
46
$network_pb = False;
48
$network_pb = False;
47
$cert_add = "http://$hostname/certs";
49
$cert_add = "http://$hostname/certs";
48
$direct_access = False;
50
$direct_access = False;
49
$diagnostic = "can't contact the default router";
51
$diagnostic = "can't contact the default router";
50
$remote_ip = ($_SERVER['REMOTE_ADDR']);
52
$remote_ip = ($_SERVER['REMOTE_ADDR']);
51
$tab = array();$user = array();
53
$tab = array();$user = array();
52
$connection_history =  "";
54
$connection_history =  "";
53
$nb_connection_history = 3;
55
$nb_connection_history = 3;
54
 
56
 
55
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
57
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
56
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname/", $_SERVER['HTTP_HOST']))
58
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$organisme$/", $_SERVER['HTTP_HOST']))
57
	{
59
	{
58
	$direct_access=True;
60
	$direct_access=True;
59
	exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
61
	exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
60
	$user = explode (" ", $tab[0]);
62
	$user = explode (" ", $tab[0]);
61
	}
63
	}
62
#### Affichage des 3 dernières connexions de $user[5]
64
#### Affichage des 3 dernières connexions de $user[5]
63
function secondsToDuration($seconds = null){
65
function secondsToDuration($seconds = null){
64
	if ($seconds == null) return "";
66
	if ($seconds == null) return "";
65
 
67
 
66
	$temp = $seconds % 3600;
68
	$temp = $seconds % 3600;
67
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
69
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
68
	$time[2] = $temp % 60 ;				// seconds
70
	$time[2] = $temp % 60 ;				// seconds
69
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
71
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
70
	
72
	
71
	return $time[0]." h ".$time[1]." m ".$time[2]." s";
73
	return $time[0]." h ".$time[1]." m ".$time[2]." s";
72
}
74
}
73
 
75
 
74
$l_connected = "connected"; // a traduire (choix de la langue ci-dessous mais nécessitant de $connection_history)
76
$l_connected = "connected"; // a traduire (choix de la langue ci-dessous mais nécessitant de $connection_history)
75
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
77
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
76
if ((isset ($user[4])) && ($user[4] != "0")){
78
if ((isset ($user[4])) && ($user[4] != "0")){
77
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
79
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
78
		include_once("/etc/freeradius-web/config.php");
80
		include_once("/etc/freeradius-web/config.php");
79
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
81
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
80
		
82
		
81
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
83
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
82
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
84
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
83
		
85
		
84
		if ($link){
86
		if ($link){
85
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
87
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
86
			
88
			
87
			if ($res){
89
			if ($res){
88
				$connection_history.= "<ul>";
90
				$connection_history.= "<ul>";
89
				while(($row = @da_sql_fetch_array($res,$config))){
91
				while(($row = @da_sql_fetch_array($res,$config))){
90
					$connected = "";
92
					$connected = "";
91
					if ($row[acctstoptime] == "") $connected = " ($l_connected)";
93
					if ($row[acctstoptime] == "") $connected = " ($l_connected)";
92
					$connection_history.="<li title='$row[username] $row[acctstarttime] $row[acctstoptime] (".secondsToDuration($row[acctsessiontime]).")'>$row[acctstarttime] (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
94
					$connection_history.="<li title='$row[username] $row[acctstarttime] $row[acctstoptime] (".secondsToDuration($row[acctsessiontime]).")'>$row[acctstarttime] (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
93
				}
95
				}
94
				$connection_history.="</ul>";
96
				$connection_history.="</ul>";
95
			}
97
			}
96
		}
98
		}
97
	}
99
	}
98
}
100
}
99
####
101
####
100
 
102
 
101
# Choice of language
103
# Choice of language
102
$Language = 'en';
104
$Language = 'en';
103
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
105
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
104
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
106
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
105
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
107
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
106
if($Language == 'fr'){
108
if($Language == 'fr'){
107
  $l_access_denied = "ACC&Egrave;S REFUS&Eacute;";
109
  $l_access_denied = "ACC&Egrave;S REFUS&Eacute;";
108
  $l_access_welcome = "Bienvenue sur ALCASAR";
110
  $l_access_welcome = "Bienvenue sur ALCASAR";
109
  $l_access_unavailable = "ACC&Egrave;S INDISPONIBLE";
111
  $l_access_unavailable = "ACC&Egrave;S INDISPONIBLE";
110
  $l_required_domain = "Site WEB demand&eacute;";
112
  $l_required_domain = "Site WEB demand&eacute;";
111
  $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.";
113
  $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.";
112
  $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.";
114
  $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.";
113
  $l_explain_net_pb = "Votre portail d&eacute;tecte que l'acc&egrave;s &agrave; Internet est indisponible.";
115
  $l_explain_net_pb = "Votre portail d&eacute;tecte que l'acc&egrave;s &agrave; Internet est indisponible.";
114
  $l_contact_access_deny = "Contactez le responsable de la s&eacute;curit&eacute; (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
116
  $l_contact_access_deny = "Contactez le responsable de la s&eacute;curit&eacute; (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
115
  $l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
117
  $l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
116
  $l_welcome = "Page principale de votre portail captif";
118
  $l_welcome = "Page principale de votre portail captif";
117
  $l_acc_access = "<a href=\"https://$hostname/acc\">Acc&egrave;s au centre de gestion</a>";
119
  $l_acc_access = "<a href=\"https://$hostname/acc\">Acc&egrave;s au centre de gestion</a>";
118
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installer le certificat racine</a>";
120
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installer le certificat racine</a>";
119
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installation du certificat de l'autorit&eacute; racine d'ALCASAR</a>";
121
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installation du certificat de l'autorit&eacute; racine d'ALCASAR</a>";
120
  $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>";
122
  $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>";
121
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
123
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
122
  $l_category = "catégorie :";
124
  $l_category = "catégorie :";
123
if ((isset ($user[4])) && ($user[4] == "0")) {
125
if ((isset ($user[4])) && ($user[4] == "0")) {
124
	  $l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre syst&egrave;me.";
126
	  $l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre syst&egrave;me.";
125
	  $l_logout = "<a href=\"http://www.qwant.com/lang/fr_FR/\">Ouvrir une session Internet</a>";}
127
	  $l_logout = "<a href=\"http://www.qwant.com/lang/fr_FR/\">Ouvrir une session Internet</a>";}
126
  else {
128
  else {
127
	  if ($user[5] != $user[0]) // authentication exception or not
129
	  if ($user[5] != $user[0]) // authentication exception or not
128
	  {
130
	  {
129
	  	$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";
131
	  	$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";
130
		$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;connecter d'internet</a>";
132
		$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;connecter d'internet</a>";
131
	  }
133
	  }
132
	  else
134
	  else
133
	  {
135
	  {
134
		  $l_logout_explain = "Votre système ($user[5]) est en exception d'authentication.<br><br>$nb_connection_history last connections :$connection_history";
136
		  $l_logout_explain = "Votre système ($user[5]) est en exception d'authentication.<br><br>$nb_connection_history last connections :$connection_history";
135
		  $l_logout = "Information des connexions";
137
		  $l_logout = "Information des connexions";
136
	  }
138
	  }
137
	}
139
	}
138
  $l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
140
  $l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
139
  $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.";
141
  $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.";
140
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;dente</a>";
142
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;dente</a>";
141
}
143
}
142
else if($Language == 'pt'){
144
else if($Language == 'pt'){
143
  $l_access_denied = "Acesso negado";
145
  $l_access_denied = "Acesso negado";
144
  $l_access_welcome = "Bem-vindo ao Alcasar";
146
  $l_access_welcome = "Bem-vindo ao Alcasar";
145
  $l_access_unavailable = "ACESSO INDISPONÍVEL";
147
  $l_access_unavailable = "ACESSO INDISPONÍVEL";
146
  $l_required_domain = "Site WEB Obrigatório";
148
  $l_required_domain = "Site WEB Obrigatório";
147
  $l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
149
  $l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
148
  $l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
150
  $l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
149
  $l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
151
  $l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
150
  $l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
152
  $l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
151
  $l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
153
  $l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
152
  $l_welcome = "Página do portal";
154
  $l_welcome = "Página do portal";
153
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Controle Center</a>";
155
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Controle Center</a>";
154
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Instalar Certificado Alcasar AC</a>";
156
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Instalar Certificado Alcasar AC</a>";
155
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Instalar Certificado Alcasar AC</a>";
157
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Instalar Certificado Alcasar AC</a>";
156
  $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>";
158
  $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>";
157
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Essa foi uma ajuda complementar</a>";
159
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Essa foi uma ajuda complementar</a>";
158
  $l_category = "categoria :";
160
  $l_category = "categoria :";
159
if ((isset ($user[4])) && ($user[4] == "0")) {
161
if ((isset ($user[4])) && ($user[4] == "0")) {
160
	  $l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
162
	  $l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
161
	  $l_logout = "<a href=\"http://www.qwant.com/lang/pt_BR/\">Abrir uma conexão de Internet</a>";}
163
	  $l_logout = "<a href=\"http://www.qwant.com/lang/pt_BR/\">Abrir uma conexão de Internet</a>";}
162
  else {
164
  else {
163
	  if ($user[5] != $user[0]) // authentication exception or not
165
	  if ($user[5] != $user[0]) // authentication exception or not
164
	  {
166
	  {
165
		  $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";
167
		  $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";
166
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Sair da Internet</a>";
168
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Sair da Internet</a>";
167
	  }
169
	  }
168
	  else
170
	  else
169
	  {
171
	  {
170
		  $l_logout_explain = "O sistema ($user[5]) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
172
		  $l_logout_explain = "O sistema ($user[5]) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
171
		  $l_logout = "Informações de conexões";
173
		  $l_logout = "Informações de conexões";
172
	  }
174
	  }
173
  	}
175
  	}
174
  $l_password_change = "<a href=\"https://$hostname/pass\">Mudar sua senha</a>";
176
  $l_password_change = "<a href=\"https://$hostname/pass\">Mudar sua senha</a>";
175
  $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.";
177
  $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.";
176
  $l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
178
  $l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
177
}
179
}
178
else {
180
else {
179
  $l_access_denied = "ACCESS DENIED";
181
  $l_access_denied = "ACCESS DENIED";
180
  $l_access_welcome = "Welcome on ALCASAR";
182
  $l_access_welcome = "Welcome on ALCASAR";
181
  $l_access_unavailable = "ACCESS UNAVAILABLE";
183
  $l_access_unavailable = "ACCESS UNAVAILABLE";
182
  $l_required_domain = "Required WEB site";
184
  $l_required_domain = "Required WEB site";
183
  $l_explain_acc_access = "This center control the portal. You must have an administrative account.";
185
  $l_explain_acc_access = "This center control the portal. You must have an administrative account.";
184
  $l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
186
  $l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
185
  $l_explain_net_pb = "Your portal has just detected that the Internet access is down";
187
  $l_explain_net_pb = "Your portal has just detected that the Internet access is down";
186
  $l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
188
  $l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
187
  $l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
189
  $l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
188
  $l_welcome = "Your captive portal main page";
190
  $l_welcome = "Your captive portal main page";
189
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
191
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
190
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
192
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
191
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
193
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
192
  $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>";
194
  $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>";
193
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
195
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
194
  $l_category = "category :";
196
  $l_category = "category :";
195
if ((isset ($user[4])) && ($user[4] == "0")) {
197
if ((isset ($user[4])) && ($user[4] == "0")) {
196
	  $l_logout_explain = "No Internet consultation session is actualy open on your system";
198
	  $l_logout_explain = "No Internet consultation session is actualy open on your system";
197
	  $l_logout = "<a href=\"http://www.qwant.com/lang/en_GB/\">Open an Internet session</a>";}
199
	  $l_logout = "<a href=\"http://www.qwant.com/lang/en_GB/\">Open an Internet session</a>";}
198
  else {
200
  else {
199
	  if ($user[5] != $user[0]) // authentication exception or not
201
	  if ($user[5] != $user[0]) // authentication exception or not
200
	  {
202
	  {
201
		  $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";
203
		  $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";
202
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
204
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
203
	  }
205
	  }
204
	  else
206
	  else
205
	  {
207
	  {
206
		  $l_logout_explain = "Your system ($user[5]) is in exception of authentication.<br><br>$nb_connection_history Last logins :$connection_history";
208
		  $l_logout_explain = "Your system ($user[5]) is in exception of authentication.<br><br>$nb_connection_history Last logins :$connection_history";
207
		  $l_logout = "Connections information";
209
		  $l_logout = "Connections information";
208
	  }
210
	  }
209
  	}
211
  	}
210
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
212
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
211
  $l_password_change_explain = "Redirect you on password change page.<br><br> You should already have an Internet access account.";
213
  $l_password_change_explain = "Redirect you on password change page.<br><br> You should already have an Internet access account.";
212
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
214
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
213
}
215
}
214
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
216
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
215
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
217
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
216
 
218
 
217
# Attribution des icones / images
219
# Attribution des icones / images
218
$img_rep = "images/";
220
$img_rep = "images/";
219
$img_organisme = "organisme.png";
221
$img_organisme = "organisme.png";
220
$img_access = "globe_acces_70.png";
222
$img_access = "globe_acces_70.png";
221
$img_connect = "globe_70.png";
223
$img_connect = "globe_70.png";
222
$img_warning = "globe_warning_70.png";
224
$img_warning = "globe_warning_70.png";
223
$img_pwd = "cle_ombre.png";
225
$img_pwd = "cle_ombre.png";
224
$img_certificate = "certificat.png";
226
$img_certificate = "certificat.png";
225
$img_acc = "logo-alcasar_70.png";
227
$img_acc = "logo-alcasar_70.png";
226
$img_false = "interdit.png";
228
$img_false = "interdit.png";
227
$img_internet = $img_connect;
229
$img_internet = $img_connect;
228
 
230
 
229
if ((isset ($user[4])) && ($user[4] == "0")) {
231
if ((isset ($user[4])) && ($user[4] == "0")) {
230
	if (! $network_pb) {
232
	if (! $network_pb) {
231
		$img_internet = $img_access;
233
		$img_internet = $img_access;
232
		}
234
		}
233
		else {
235
		else {
234
		$img_internet = $img_warning;
236
		$img_internet = $img_warning;
235
	}
237
	}
236
}
238
}
237
else {
239
else {
238
	$img_internet = $img_connect;
240
	$img_internet = $img_connect;
239
}
241
}
240
 
242
 
241
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
243
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
242
?>
244
?>
243
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
245
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
244
	<html>
246
	<html>
245
	<head>
247
	<head>
246
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
248
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
247
	<title>ALCASAR - <?php echo $l_title; ?></title>
249
	<title>ALCASAR - <?php echo $l_title; ?></title>
248
	<meta http-equiv="Cache-control" content="no-cache">
250
	<meta http-equiv="Cache-control" content="no-cache">
249
	<meta http-equiv="Pragma" content="no-cache">
251
	<meta http-equiv="Pragma" content="no-cache">
250
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
252
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
251
	<script type="text/javascript">
253
	<script type="text/javascript">
252
		function valoriserDiv5(param){
254
		function valoriserDiv5(param){
253
			document.getElementById("box_info").innerHTML = param.innerHTML;
255
			document.getElementById("box_info").innerHTML = param.innerHTML;
254
		}
256
		}
255
	</script>
257
	</script>
256
</head>
258
</head>
257
<body onload="valoriserDiv5(text_conn);">
259
<body onload="valoriserDiv5(text_conn);">
258
<?php
260
<?php
259
if ($direct_access){
261
if ($direct_access){
260
	echo "
262
	echo "
261
		<div id=\"cadre_titre\" class=\"titre_controle\">
263
		<div id=\"cadre_titre\" class=\"titre_controle\">
262
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
264
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
263
	if ($network_pb) {
265
	if ($network_pb) {
264
		echo "	<span>$l_explain_net_pb</span>";
266
		echo "	<span>$l_explain_net_pb</span>";
265
		}
267
		}
266
	}
268
	}
267
	else {
269
	else {
268
		echo"
270
		echo"
269
			<div id=\"cadre_titre\" class=\"titre_refus\">
271
			<div id=\"cadre_titre\" class=\"titre_refus\">
270
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
272
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
271
	}
273
	}
272
?>
274
?>
273
			<div id="boite_logo">
275
			<div id="boite_logo">
274
				<img src="images/organisme.png">
276
				<img src="images/organisme.png">
275
			</div>
277
			</div>
276
		</div>
278
		</div>
277
		<div id="contenu_acces">
279
		<div id="contenu_acces">
278
			<div id="box_url">
280
			<div id="box_url">
279
<?php 
281
<?php 
280
//search in the blacklist categories
282
//search in the blacklist categories
281
if ((! $direct_access) && (! $network_pb)){
283
if ((! $direct_access) && (! $network_pb)){
282
	$pattern = preg_replace('/www./','',$_SERVER['HTTP_HOST']);
284
	$pattern = preg_replace('/www./','',$_SERVER['HTTP_HOST']);
283
	exec("grep -Re ^$pattern$ /etc/dansguardian/lists/blacklists/*/domains|cut -d'/' -f6", $output);
285
	exec("grep -Re ^$pattern$ /etc/dansguardian/lists/blacklists/*/domains|cut -d'/' -f6", $output);
284
	unset ($line);
286
	unset ($line);
285
	foreach ($output as $row) {
287
	foreach ($output as $row) {
286
		$line=$line.(trim($row)).", ";
288
		$line=$line.(trim($row)).", ";
287
	} 
289
	} 
288
	echo "$l_required_domain : $_SERVER[HTTP_HOST]";
290
	echo "$l_required_domain : $_SERVER[HTTP_HOST]";
289
	if ($line != "") { echo "<BR>".rtrim ("$l_category $line", ", ");}
291
	if ($line != "") { echo "<BR>".rtrim ("$l_category $line", ", ");}
290
}
292
}
291
?>
293
?>
292
			</div>
294
			</div>
293
 
295
 
294
<?php
296
<?php
295
if ($direct_access){
297
if ($direct_access){
296
	echo "	<div id=\"box_bienvenue\">
298
	echo "	<div id=\"box_bienvenue\">
297
				$l_welcome
299
				$l_welcome
298
			</div>
300
			</div>
299
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
301
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
300
				<span>$l_logout</span>
302
				<span>$l_logout</span>
301
				<img src=\"$img_rep$img_internet\">
303
				<img src=\"$img_rep$img_internet\">
302
			</div>
304
			</div>
303
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
305
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
304
				<span>$l_install_certif</span>
306
				<span>$l_install_certif</span>
305
				<img src=\"$img_rep$img_certificate\">
307
				<img src=\"$img_rep$img_certificate\">
306
			</div>
308
			</div>
307
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
309
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
308
				<img src=\"$img_rep$img_pwd\">
310
				<img src=\"$img_rep$img_pwd\">
309
				<span>$l_password_change</span>
311
				<span>$l_password_change</span>
310
			</div>		
312
			</div>		
311
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
313
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
312
				<span>$l_acc_access</span>
314
				<span>$l_acc_access</span>
313
				<img src=\"$img_rep$img_acc\">
315
				<img src=\"$img_rep$img_acc\">
314
			</div>
316
			</div>
315
			<div class=\"div-cache\" id=\"text_conn\">
317
			<div class=\"div-cache\" id=\"text_conn\">
316
				<h2>$l_logout</h2>
318
				<h2>$l_logout</h2>
317
				<p>$l_logout_explain</p>
319
				<p>$l_logout_explain</p>
318
				<img src=\"$img_rep$img_internet\">
320
				<img src=\"$img_rep$img_internet\">
319
			</div>
321
			</div>
320
			<div class=\"div-cache\" id=\"text_certif\">
322
			<div class=\"div-cache\" id=\"text_certif\">
321
				<h2>$l_install_certif_more</h2>
323
				<h2>$l_install_certif_more</h2>
322
				<p>$l_certif_explain $l_certif_explain_help</p>
324
				<p>$l_certif_explain $l_certif_explain_help</p>
323
				<img src=\"$img_rep$img_certificate\">				
325
				<img src=\"$img_rep$img_certificate\">				
324
			</div>
326
			</div>
325
			<div class=\"div-cache\" id=\"text_mdp\">
327
			<div class=\"div-cache\" id=\"text_mdp\">
326
				<h2>$l_password_change</h2>
328
				<h2>$l_password_change</h2>
327
				<p>$l_password_change_explain</p>
329
				<p>$l_password_change_explain</p>
328
				<img src=\"$img_rep$img_pwd\">
330
				<img src=\"$img_rep$img_pwd\">
329
			</div>
331
			</div>
330
			<div class=\"div-cache\" id=\"text_acc\">
332
			<div class=\"div-cache\" id=\"text_acc\">
331
				<h2>$l_acc_access</h2>
333
				<h2>$l_acc_access</h2>
332
				<p>$l_explain</p>
334
				<p>$l_explain</p>
333
				<img src=\"$img_rep$img_acc\">
335
				<img src=\"$img_rep$img_acc\">
334
			</div>
336
			</div>
335
			<div id=\"box_info\">
337
			<div id=\"box_info\">
336
			</div>";
338
			</div>";
337
	}
339
	}
338
	else {
340
	else {
339
		echo "
341
		echo "
340
			<div id=\"box_refuse\">
342
			<div id=\"box_refuse\">
341
				<img src=\"$img_rep$img_false\">
343
				<img src=\"$img_rep$img_false\">
342
				<p>$l_explain</p>
344
				<p>$l_explain</p>
343
			</div>
345
			</div>
344
			<div id=\"liens_redir\">
346
			<div id=\"liens_redir\">
345
				<p>$l_back_page</p>
347
				<p>$l_back_page</p>
346
			</div>";
348
			</div>";
347
		}
349
		}
348
	if (($network_pb)&&(! $direct_access)) {
350
	if (($network_pb)&&(! $direct_access)) {
349
	echo "	<span>Diagnostic : $diagnostic</span>";
351
	echo "	<span>Diagnostic : $diagnostic</span>";
350
	}
352
	}
351
?>
353
?>
352
		</div>
354
		</div>
353
	</body>
355
	</body>
354
</html>
356
</html>
355
 
357