Subversion Repositories ALCASAR

Rev

Rev 2216 | Rev 2250 | 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 2234 2017-05-18 21:20:10Z richard $
1249 richard 3
#
2085 richard 4
# index.php for ALCASAR by Rexy
1249 richard 5
# UI & css style by stephane ERARD
6
# The contents of this file may be used under the terms of the GNU
7
# General Public License Version 2, provided that the above copyright
8
# notice and this permission notice is included in all copies or
9
# substantial portions of the software.
10
/****************************************************************
11
*			GLOBAL FILE PATHS			*
12
*****************************************************************/
13
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
2186 tom.houday 14
define ("DOMAIN_ALLOWED_LIST", "/usr/local/etc/alcasar-uamdomain");
1249 richard 15
 
16
/****************************************************************
17
*			FILE reading test			*
18
*****************************************************************/
2186 tom.houday 19
$conf_files = array(CONF_FILE);
20
foreach ($conf_files as $file) {
21
	if (!file_exists($file)) {
1249 richard 22
		exit("File ".$file." unknown");
23
	}
2186 tom.houday 24
	if (!is_readable($file)) {
1249 richard 25
		exit("You don't have read rights on the file ".$file);
26
	}
27
}
28
/****************************************************************
29
*			Read CONF_FILE				*
30
*****************************************************************/
2186 tom.houday 31
$file_conf = fopen(CONF_FILE, 'r');
32
if (!$file_conf) {
33
	exit('Error opening the file '.CONF_FILE);
34
}
35
while (!feof($file_conf)) {
2234 richard 36
	$buffer = fgets($file_conf, 4096);
37
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
38
		$tmp = explode('=', $buffer);
2186 tom.houday 39
		$conf[$tmp[0]] = trim($tmp[1]);
1249 richard 40
	}
41
}
2186 tom.houday 42
fclose($file_conf);
43
 
2234 richard 44
$organisme = $conf["ORGANISM"];
45
$hostname  = $conf["HOSTNAME"].'.'.$conf["DOMAIN"];
2127 richard 46
$network_pb = False; # "alcasar-watchdog.sh" changes this value if a network issue is detected
2136 richard 47
$diagnostic = "can't contact the default router"; # "alcasar-watchdog.sh" changes this value if a network issue is detected
1249 richard 48
$cert_add = "http://$hostname/certs";
360 richard 49
$direct_access = False;
1452 richard 50
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
363 richard 51
$tab = array();$user = array();
566 stephane 52
$connection_history =  "";
53
$nb_connection_history = 3;
1992 richard 54
$Language = 'en';
55
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
2127 richard 56
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
57
	$Language = strtolower(substr(chop($Langue[0]),0,2));
58
}
1999 richard 59
$redirect_link = "www.euronews.com"; # Default redirection for HTTPS interception (beware, this website must run in HTTP)
566 stephane 60
 
1987 richard 61
# Retrieve the user info behind the remote ip
2116 franck 62
exec ("sudo /usr/sbin/chilli_query list | grep -Ew $remote_ip" , $tab);
1818 raphael.pi 63
$user = explode (" ", $tab[0]);
1820 raphael.pi 64
 
1992 richard 65
# Test if it's a direct connexion to ALCASAR
2186 tom.houday 66
if (isset($_SERVER['HTTP_HOST']) && (($_SERVER['HTTP_HOST'] === $_SERVER['SERVER_ADDR']) || ($_SERVER['HTTP_HOST'] === 'alcasar') || ($_SERVER['HTTP_HOST'] === $hostname) || ($_SERVER['HTTP_HOST'] === $organisme))) {
67
	$direct_access = true;
1992 richard 68
}
2186 tom.houday 69
 
1987 richard 70
# Function to adapt time connexion in seconds to H,M,S
566 stephane 71
function secondsToDuration($seconds = null){
72
	if ($seconds == null) return "";
73
	$temp = $seconds % 3600;
74
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
732 richard 75
	$time[2] = $temp % 60 ;				// seconds
566 stephane 76
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
732 richard 77
	return $time[0]." h ".$time[1]." m ".$time[2]." s";
566 stephane 78
}
509 richard 79
 
2127 richard 80
# if user need to be warned
2234 richard 81
if (isset($_GET['warn']) && isset($_GET['url'])) {
82
	$direct_access = false;
2010 raphael.pi 83
}
84
 
2234 richard 85
if ((isset($user[4])) && ($user[4] != "0")) { # the user is authenticated
86
	if (isset($_GET['redirect'])) { # if user has been warned, we redirect him to his website
2186 tom.houday 87
		header('Location: '.$_GET['url'], true, 307);
2234 richard 88
		exit();
2010 raphael.pi 89
	}
2234 richard 90
 
2127 richard 91
	# we retrieve his three last connections
2105 richard 92
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
566 stephane 93
		include_once("/etc/freeradius-web/config.php");
94
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
95
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
2085 richard 96
		$link = @da_sql_pconnect($config);
566 stephane 97
		if ($link){
2085 richard 98
			$res = @da_sql_query($link,$config,$sql);
566 stephane 99
			if ($res){
100
				$connection_history.= "<ul>";
101
				while(($row = @da_sql_fetch_array($res,$config))){
102
					$connected = "";
1987 richard 103
					if ($row['acctstoptime'] == "") $connected = " (active)";
1678 richard 104
					$connection_history.="<li title='$row[username] $row[acctstarttime] $row[acctstoptime] (".secondsToDuration($row['acctsessiontime']).")'>$row[acctstarttime] (".secondsToDuration($row['acctsessiontime']).") $connected</li>";
566 stephane 105
				}
106
				$connection_history.="</ul>";
107
			}
108
		}
109
	}
110
}
2234 richard 111
else { # the user isn't authenticated
112
	if (isset($_GET['url'])) { # it's the second stage (when user has clicked on the button "open a connection")
113
		$redir = 'http://'.$_GET['url'];
114
		header("Location: $redir", true, 307);
115
		exit(); 
1989 raphael.pi 116
	}
1818 raphael.pi 117
}
360 richard 118
# Choice of language
119
if($Language == 'fr'){
2090 richard 120
	$l_access_denied = "Contrôle d'accès";
121
	$l_access_welcome = "Bienvenue sur ALCASAR";
122
	$l_access_unavailable = "ACCÈS INDISPONIBLE";
123
	$l_required_domain = "Site WEB demandé";
124
	$l_explain_acc_access = "Le centre de gestion permet d'administrer le portail. Vous devez posséder un compte d'administration ou de gestion pour y accéder.";
125
	$l_explain_access_deny = "Vous tentez d'accéder à une ressource dont le contenu est réputé contenir des informations inappropriées.";
126
	$l_explain_net_pb = "Votre portail détecte que l'accès à Internet est indisponible.";
127
	$l_contact_access_deny = "Contactez le responsable de la séurité (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
128
	$l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
129
	$l_sms_access = "<a href=\"https://$hostname/autoregistrationinfo.php\">Auto Enregistrement par SMS</a>";
130
	$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Installer le certificat racine</a>";
131
	$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Installation du certificat de l'autorité; racine d'ALCASAR</a>";
132
	$l_certif_explain = "Permet l'échange de données sécurisées entre votre station de consultation et le portail captif ALCASAR.<BR>Si ce certificat n'est pas enregistré sur votre station de consultation, il est possible que des alertes de sécurité soient émises par votre navigateur.<br><br>";
133
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
134
	$l_category = "catégorie :";
2127 richard 135
	if ((isset ($user[4])) && ($user[4] == "0")){
2090 richard 136
		$l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre système.";
137
		$l_logout = "<a href=\"http://$hostname/index.php?url=$redirect_link\">Ouvrir une session Internet</a>";
1820 raphael.pi 138
	}
2127 richard 139
	else{
140
		if ($user[5] != $user[0]){ # authentication exception or not
2090 richard 141
			$l_logout_explain = "Ferme la session de l'usager actuellement connecté. <br><br>Utilisateur connecté : <a href=\"http://$hostname:3990/logoff\" title=\"Deconnecter l'utilisateur $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history dernières connexions :$connection_history";
142
			$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se déconnecter d'internet</a>";
143
		}
2127 richard 144
		else{
2186 tom.houday 145
			$l_logout_explain = "Votre système ($user[5]) est en exception d'authentication.<br><br>$nb_connection_history dernières connexions :$connection_history";
2090 richard 146
			$l_logout = "Information des connexions";
147
		}
832 richard 148
	}
2090 richard 149
	$l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
150
	$l_password_change_explain = "Vous redirige sur la page de changement du mot de passe de votre compte d'accès à Internet.<br><br>Vous devez avoir un compte internet valide.";
151
	$l_sms_explain = "Vous redirige vers la page explicative de l'auto enregistrement par SMS.<br><br><strong>Identifiant:</strong> votre numéro de téléphone<br><strong>Mot de passe:</strong> votre message";
152
	$l_back_page = "<a href=\"javascript:history.back()\">Page précédente</a>";
153
	$l_service_sms = "Service SMS actif";
154
	$l_service_sms_n = "Service SMS non actif";
155
	$l_acc_sms = "Auto enregistrement par SMS";
156
	$l_explain_warn = "L'administrateur a créé une archive contenant vos journaux de connexion dans le cadre d'une affaire judiciaire.";
2127 richard 157
	if(isset($_GET['url'])){
2186 tom.houday 158
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">Je comprends et je souhaite continuer ma navigation.</a>";
2127 richard 159
	}
160
	else{
2186 tom.houday 161
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Je comprends et je souhaite continuer ma navigation.</a>";
2127 richard 162
	}
2090 richard 163
	$l_title_warn="Cher utilisateur, ";
164
	$l_explain_warn_name="Une personne sous le nom de ";
165
	$l_explain_warn_ip="sous cette IP : ";
166
	$l_explain_warn_date="a consulté vos journaux de connexion le ";
167
	$l_explain_warn_reason="Raison invoquée : ";
2186 tom.houday 168
	$l_uam_domain = "Sites autorisés : ";
360 richard 169
}
912 richard 170
else if($Language == 'pt'){
2090 richard 171
	$l_access_denied = "Controle de acesso";
172
	$l_access_welcome = "Bem-vindo ao Alcasar";
173
	$l_access_unavailable = "ACESSO INDISPONÍVEL";
174
	$l_required_domain = "Site WEB Obrigatório";
175
	$l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
176
	$l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
177
	$l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
178
	$l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
179
	$l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
180
	$l_sms_access = "<a href=\"https://$hostname/autoregistrationinfo.php\">Auto Registration by SMS</a>";
181
	$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Instalar Certificado Alcasar AC</a>";
182
	$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Instalar Certificado Alcasar AC</a>";
183
	$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>";
184
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Essa foi uma ajuda complementar</a>";
185
	$l_category = "categoria :";
2127 richard 186
	if ((isset ($user[4])) && ($user[4] == "0")){
2090 richard 187
		$l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
188
		$l_logout = "<a href=\"http://$hostname/index.php?url=$redirect_link\">Abrir uma conexão de Internet</a>";
1820 raphael.pi 189
	}
2127 richard 190
	else{
191
		if ($user[5] != $user[0]){ # authentication exception or not
2186 tom.houday 192
			$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 logins últimos :$connection_history";
2090 richard 193
			$l_logout = "<a href=\"http://$hostname:3990/logoff\">Sair da Internet</a>";
194
		}
2127 richard 195
		else{
2090 richard 196
			$l_logout_explain = "O sistema ($user[5]) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
197
			$l_logout = "Informações de conexões";
198
		}
199
	}
200
	$l_password_change = "<a href=\"https://$hostname/pass\">Mudar sua senha</a>";
201
	$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.";
202
	$l_sms_explain = "Redirect you on auto registration page.<br><br><strong>Login:</strong> your phone number<br><strong>Password:</strong> SMS content";
203
	$l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
204
	$l_service_sms = "SMS service enable";
205
	$l_service_sms_n = "SMS service disable";
206
	$l_acc_sms = "Auto registration by SMS";
207
	$l_explain_warn = "El administrador ha creado un archivo que contiene los periódicos de inicio de sesión como parte de un proceso judicial."; 
2127 richard 208
	if(isset($_GET['url'])){
2186 tom.houday 209
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">Lo comprendo y deseo continuar mi navegación.</a>";
2127 richard 210
	}
211
	else{
2186 tom.houday 212
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Lo comprendo y deseo continuar mi navegación.</a>";
2127 richard 213
	}
2090 richard 214
	$l_title_warn="Estimado usuario,";
215
	$l_explain_warn_name="El usario ";
216
	$l_explain_warn_ip="con este IP : ";
217
	$l_explain_warn_date="consultó a sus registros de conexión el ";
218
	$l_explain_warn_reason="con la siguiente razón : ";
2186 tom.houday 219
	$l_uam_domain = "Sites autorizados : ";
912 richard 220
}
2090 richard 221
else if($Language == 'zn'){
222
	$l_access_denied = "访问控制";
223
	$l_access_welcome = "欢迎来到ALCASAR";
224
	$l_access_unavailable = "不可访问";
225
	$l_required_domain = "访问的网站";
226
	$l_explain_acc_access = "管理中心能管理门户,您必须通过超级用户或者管理用户来访问。";
227
	$l_explain_access_deny = "您试图访问一个含有不当信息的资源。";
228
	$l_explain_net_pb = "您的门户检测因特网不可用。";
229
	$l_contact_access_deny = "如果您认为该过滤不当,请联系安全负责人(OSSI/RSSI)。";
230
	$l_contact_net_pb = "请联系IT负责人或网络服务商来了解更多信息。";
231
	$l_sms_access = "<a href=\"https://$hostname/autoregistrationinfo.php\">短信自动登录 </a>";
232
	$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.der\">安装根证书 </a>";
233
	$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.der\">安装根证书 </a>";
234
	$l_certif_explain = "允许您的计算机与ALCASAR门户进行安全数据交换。<BR>如果该证书未包含在您的计算机中,您的浏览器将出现一些安全提醒。<br><br>";
235
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">额外帮助</a>";
236
	$l_category = "类别 :";
2127 richard 237
	if ((isset ($user[4])) && ($user[4] == "0")){
2090 richard 238
		$l_logout_explain = "您的系统目前没有打开任何网络咨询进程。";
239
		$l_logout = "<a href=\"http://$hostname/index.php?url=$redirect_link\">打开一个网络进程</a>";
240
	}
2127 richard 241
	else{
242
		if ($user[5] != $user[0]){ # authentication exception or not
2090 richard 243
			$l_logout_explain = "关闭当前连接进程。<br> 已连接用户:<a href=\"http://$hostname:3990/logoff\" title=\" $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history 最后连接 :$connection_history";
244
			$l_logout = "<a href=\"http://$hostname:3990/logoff\">断开网络</a>";
245
		}
2127 richard 246
		else{
2090 richard 247
			$l_logout_explain = "您的系统($user[5])验证例外<br><br>$nb_connection_history 最后连接: $connection_history";
248
			$l_logout = "连接信息";
249
		}
250
	}
251
	$l_password_change = "<a href=\"https://$hostname/pass\">更改您的密码</a>";
252
	$l_password_change_explain = "重新指向密码修改页面。<br><br> 您需要一个可用的网络账户。";
253
	$l_sms_explain = "重新指向短信登录页面。<br><br><strong>用户名:</strong>您的电话号码<br><strong>密码:</strong>您的信息";
254
	$l_back_page = "<a href=\"javascript:history.back()\">上一页</a>";
255
	$l_service_sms = "短信服务可用";
256
	$l_service_sms_n = "短信服务禁用";
257
	$l_acc_sms = "短信自动注册";
258
	$l_explain_warn = "管理员创建了一份可用于司法调查的连接日志文档。";
2127 richard 259
	if(isset($_GET['url'])){
2186 tom.houday 260
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">我明白并希望继续浏览。</a>";
2127 richard 261
	}
262
	else{
2186 tom.houday 263
		$l_continue_link = "<a href=\"index.php\" class=\"button\">我明白并希望继续浏览。</a>";
2127 richard 264
	}
2090 richard 265
	$l_title_warn="亲爱的用户,";
266
	$l_explain_warn_name="一人名为";
267
	$l_explain_warn_ip="在此IP:";
268
	$l_explain_warn_date="查看您的连接日志于";
269
	$l_explain_warn_reason=" 如下原因:";
2186 tom.houday 270
	$l_uam_domain = "授权网站 : ";
2090 richard 271
}
2127 richard 272
else if ($Language == 'ar'){
2111 richard 273
	$l_access_denied = "مراقبة الدخول";
274
	$l_access_welcome = "ALCASAR مرحبا بك في";
275
	$l_access_unavailable = "الدخول غير متوفر";
276
	$l_required_domain = "موقع إنترنيت مطلوب";
277
	$l_explain_acc_access = "مركز التحكم يمكنك من إدارة البوابة. يلزمك التوفر على حساب الادارة للدخول.";
278
	$l_explain_access_deny = "محاولة لدخول موارد تحتوي على معلومات غير ملائمة المحتوى";
279
	$l_explain_net_pb = "بوابتك تكتشف ان الدخول على الانترنت غير متوفر";
280
	$l_contact_access_deny = "المرجو الاتصال بضابط أمن (OSS / RSS) إذا اعتقدت ان هذه التصفية غير قانونية";
281
	$l_contact_net_pb = "المرجو الاتصال بمدير المعلومات أو مورد الأنترنت للمزيد من المعلومات";
282
	$auto_save_sms_text = "تسجيل ذاتي على";
283
	$l_sms_access = "<a href=\"https://$hostname/autoregistrationinfo.php\">SMS $auto_save_sms_text</a>";
284
	$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.der\">ركب جذر الشهادة</a>";
285
	$install_cert_text = "تركيب شهادة السلطة؛ جذر الكزار";
286
	$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.der\">ALCASAR $install_cert_text</a>";
287
	$exchange_data_text = "يمَكن من تبادل البيانات المؤمّنة بين محطة الاستفسار و بوابة الكزار الأسيرة";
288
	$cert_not_saved_text = "إذا لم يتم تسجيل هذه الشهادة على محطة الاستفسار الخاصة بك، فمن الممكن ان يتم إصدار تنبيهات أمنية من متصحفك";
289
	$l_certif_explain = "<br><br>.$cert_not_saved_text<br> .$exchange_data_text";
290
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">مساعدة إضافية </a>";
291
	$l_category = "فئة :";
2127 richard 292
	if ((isset ($user[4])) && ($user[4] == "0")){
2111 richard 293
		$l_logout_explain = "و لا جلسة استفسار للإنترنت مفتوحة حاليا على نظامك";
294
		$close_session_text = "فتح جلسة الإنترنت";
295
		$l_logout = "<a href=\"http://$hostname/index.php?url=$redirect_link\">$close_session_text</a>";
2127 richard 296
	}
297
	else{
298
		if ($user[5] != $user[0]){ # authentication exception or not
2111 richard 299
			$close_session_text = "إقفال جلسة المستخدم المتصل حاليا";
300
			$user_logged_text = "المستخدم متصل";
301
			$disconnect_user_text = "قطع الاتصال على المستخدم";
302
			$l_logout_explain = "Ferme la session de l'usager actuellement connecté. <br><br>Utilisateur connecté : <a href=\"http://$hostname:3990/logoff\" title=\"Deconnecter l'utilisateur $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history dernières connexions :$connection_history";
303
			$logout_internet_text = "قطع الاتصال على الإنترنت";
304
			$l_logout = "<a href=\"http://$hostname:3990/logoff\">$logout_internet_text</a>";
305
		}
2127 richard 306
		else{
2111 richard 307
			$your_system_text = "نظامك";
308
			$auth_except_text = "على توثيق استثنائي";
309
			$last_conn_text = "اتصالات مشاركة";
310
			$l_logout_explain = "$connection_history :$last_conn_text $nb_connection_history<br><br>$auth_except_text ($user[5]) $your_system_text";
311
			$l_logout = "معلومات على الاتصالات ";
312
		}
313
	}
314
	$change_pass_text = "غير كلمتك السرية";
315
	$l_password_change = "<a href=\"https://$hostname/pass\">$change_pass_text</a>";
316
	$redirect_pass_text = "يوجهك على صفحة تغيير الكلمة السرية لحساب الإنترنت الخاص بك";
317
	$valid_account_text = "يجب ان يكون حساب الإنترنت الخاص بك صالحاً";
318
	$l_password_change_explain = "$valid_account_text<br><br>.$redirect_text";
319
	$redirect_sms_text = "يوجهك على الصفحة التفسيرية للتسجيل الذاتي بطريقة";
320
	$login_text = "تسجيل الدخول";
321
	$your_phone_text = "رقم الهاتف الخاص بك";
322
	$pass_text = "كلمة السر";
323
	$your_message_text = "رسالتك";
324
	$l_sms_explain = "$your_message_text <strong>$pass_text</strong><br>$your_phone_text <strong>$login_text</strong><br><br>$redirect_sms_text";
325
	$previous_text = "الصفحة السابقة";
326
	$l_back_page = "<a href=\"javascript:history.back()\">$previous_text</a>";
327
	$l_service_sms = "نشطة SMS خدمة";
328
	$l_service_sms_n = "غير نشطة SMS خدمة";
329
	$l_acc_sms = "تسجيل ذاتي عن طريق SMS";
330
	$l_explain_warn = "المسؤول أنشأ أرشيفاً تحتوي على سجلات الاتصال في إطار تحقيق قضائي";
331
	$understand_text = "أنا متفهم و أريد ان أواصل التصفح";
2127 richard 332
	if(isset($_GET['url'])){
2186 tom.houday 333
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">$understand_text</a>";
2111 richard 334
	}
2127 richard 335
	else{
2186 tom.houday 336
		$l_continue_link = "<a href=\"index.php\" class=\"button\">$understand_text</a>";
2111 richard 337
	}
338
	$l_title_warn = "عزيزي المستعمل, ";
339
	$l_explain_warn_name = "شخص مسمىٰ ";
340
	$l_explain_warn_ip = "تحت هذا IP: ";
341
	$l_explain_warn_date = "إطّلع على سجلات الاتصال الخاصة بك في";
342
	$l_explain_warn_reason = "السبب المسرّح به: ";
2186 tom.houday 343
	$l_uam_domain = ":المواقع المسموحة ";
2111 richard 344
}
2127 richard 345
else{
2090 richard 346
	$l_access_denied = "Access control";
347
	$l_access_welcome = "Welcome on ALCASAR";
348
	$l_access_unavailable = "ACCESS UNAVAILABLE";
349
	$l_required_domain = "Required WEB site";
350
	$l_explain_acc_access = "This center control the portal. You must have an administrative account.";
351
	$l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
352
	$l_explain_net_pb = "Your portal has just detected that the Internet access is down";
353
	$l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
354
	$l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
355
	$l_sms_access = "<a href=\"https://$hostname/autoregistrationinfo.php\">Auto Registration by SMS</a>";
356
	$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Install ALCASAR AC Certificate</a>";
357
	$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.der\">Install ALCASAR AC Certificate</a>";
358
	$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>";
359
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
360
	$l_category = "category :";
2127 richard 361
	if ((isset ($user[4])) && ($user[4] == "0")){
2090 richard 362
		$l_logout_explain = "No Internet consultation session is actualy open on your system";
363
		$l_logout = "<a href=\"http://$hostname/index.php?url=$redirect_link\">Open an Internet session</a>";
1820 raphael.pi 364
	}
2127 richard 365
	else{
366
		if ($user[5] != $user[0]){ # authentication exception or not
2090 richard 367
			$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";
368
			$l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
369
		}
2127 richard 370
		else{
2090 richard 371
			$l_logout_explain = "Your system ($user[5]) is in exception of authentication.<br><br>$nb_connection_history Last logins :$connection_history";
372
			$l_logout = "Connections information";
373
		}
374
	}
375
	$l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
376
	$l_password_change_explain = "Redirect you on password change page.<br><br> You should already have an Internet access account.";
377
	$l_sms_explain = "Redirect you on auto registration page.<br><br><strong>Login:</strong> your phone number<br><strong>Password:</strong> SMS content";
378
	$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
379
	$l_service_sms = "SMS service enable";
380
	$l_service_sms_n = "SMS service disable";
381
	$l_acc_sms = "Auto registration by SMS";
382
	$l_explain_warn = "The administrator created an archive which contains your imputabilities logs for a judicial investigation.";
2127 richard 383
	if(isset($_GET['url'])){
2186 tom.houday 384
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">I understand and I wish to continue.</a>";
2127 richard 385
	}
386
	else{
2186 tom.houday 387
		$l_continue_link = "<a href=\"index.php\" class=\"button\">I understand and I wish to continue.</a>";
2127 richard 388
	}
2090 richard 389
	$l_title_warn="Dear user,";
390
	$l_explain_warn_name="Someone called ";
391
	$l_explain_warn_ip="with this IP : ";
392
	$l_explain_warn_date="has read your connexion logs at ";
393
	$l_explain_warn_reason="For this reason : ";
2186 tom.houday 394
	$l_uam_domain = "Authorized websites : ";
360 richard 395
}
1987 richard 396
 
2234 richard 397
$l_title   = ($direct_access ? $l_access_welcome     : ($network_pb ? $l_access_unavailable : $l_access_denied));
398
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb     : $l_explain_access_deny));
509 richard 399
 
1987 richard 400
# set the icons
1999 richard 401
$img_rep = "/images/";
509 richard 402
$img_organisme = "organisme.png";
403
$img_access = "globe_acces_70.png";
404
$img_connect = "globe_70.png";
405
$img_warning = "globe_warning_70.png";
406
$img_pwd = "cle_ombre.png";
407
$img_certificate = "certificat.png";
408
$img_acc = "logo-alcasar_70.png";
1452 richard 409
$img_sms = "sms.png";
509 richard 410
$img_false = "interdit.png";
1452 richard 411
$img_adm = "adm.png";
509 richard 412
$img_internet = $img_connect;
413
 
2127 richard 414
if ((isset ($user[4])) && ($user[4] == "0")){
415
	if (! $network_pb){
509 richard 416
		$img_internet = $img_access;
2127 richard 417
	}
418
	else{
509 richard 419
		$img_internet = $img_warning;
420
	}
421
}
2127 richard 422
else{
509 richard 423
	$img_internet = $img_connect;
424
}
425
 
1992 richard 426
# cleaning the cache
427
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
428
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
429
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
430
header("Cache-Control: post-check=0, pre-check=0", false);
431
header("Pragma: no-cache");
2186 tom.houday 432
 
360 richard 433
?>
2127 richard 434
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
435
<html>
436
<head>
2186 tom.houday 437
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
438
	<title>ALCASAR - <?php echo $l_title; ?></title>
439
	<meta http-equiv="Cache-control" content="no-cache">
440
	<meta http-equiv="Pragma" content="no-cache">
441
	<link rel="stylesheet" href="/css/style_intercept.css" type="text/css">
442
	<script type="text/javascript">
1992 richard 443
	function valoriserDiv5(param){
444
		document.getElementById("box_info").innerHTML = param.innerHTML;
1989 raphael.pi 445
	}
2186 tom.houday 446
	</script>
360 richard 447
</head>
566 stephane 448
<body onload="valoriserDiv5(text_conn);">
509 richard 449
<?php
2234 richard 450
if ($direct_access){
360 richard 451
	echo "
2127 richard 452
	<div id=\"cadre_titre\" class=\"titre_controle\">
453
		<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
509 richard 454
	if ($network_pb) {
566 stephane 455
		echo "	<span>$l_explain_net_pb</span>";
360 richard 456
	}
2127 richard 457
}
2134 richard 458
else{ # the user is intercepted
2127 richard 459
	# if user need to be warned that someone reads his logs
2186 tom.houday 460
	if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] == '1') {
2127 richard 461
		echo "
462
		<div id=\"cadre_titre\" class=\"titre_refus\">
463
		<p id=\"acces_controle\" class=\"titre_refus\">$l_title_warn</p>";
363 richard 464
	}
2134 richard 465
	else{ # the user is blacklisted (or whitelisted)
2127 richard 466
		echo "
467
		<div id=\"cadre_titre\" class=\"titre_refus\">
468
		<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
469
	}
470
}
360 richard 471
?>
2127 richard 472
 
473
		<div id="boite_logo">
474
			<img src="<?php echo "$img_rep$img_organisme"; ?>">
566 stephane 475
		</div>
2127 richard 476
	</div>
566 stephane 477
		<div id="contenu_acces">
478
			<div id="box_url">
2215 tom.houday 479
				<?php 
480
				// Search blacklist categories
2234 richard 481
				if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))) {
2215 tom.houday 482
					$pattern = str_replace('www.', '', $_SERVER['HTTP_HOST']);
483
					exec('grep -Re ' . escapeshellarg('^'.$pattern.'$') . " /etc/dansguardian/lists/blacklists/*/domains | cut -d'/' -f6", $output);
484
					$lists = [];
485
					foreach ($output as $line) {
486
						$lists[] = $line;
487
					}
488
 
489
					echo $l_required_domain.' : '.htmlspecialchars($_SERVER['HTTP_HOST']);
490
					if (!empty($lists)) {
491
						echo "<br>$l_category ".implode(', ', $lists);
492
					}
493
				}
494
				?>
566 stephane 495
			</div>
1452 richard 496
<?php
1987 richard 497
# Check if the SMS service is enable
1506 franck 498
$service_SMS_status="false";
2127 richard 499
if ($service_SMS_status == "true"){
500
	$sms_div='
501
		<div class="box_menu" id="box_acc" onmouseover="valoriserDiv5(text_acc);">
502
			<span>'.$l_sms_access.'</span>
503
			<img src="'.$img_rep.''.$img_sms.'">
504
		</div>
1452 richard 505
';
506
 
2127 richard 507
$sms_div_over='
508
		<div class="div-cache" id="text_acc">
509
			<h2>'.$l_sms_access.'</h2>
510
			<p>'.$l_sms_explain.'</p>
511
			<p><font color="green"><center>'.$l_service_sms.'</center></font></p>
512
			<img src="'.$img_rep.''.$img_sms.'">
513
		</div>
1452 richard 514
';
515
}
1508 richard 516
else {
2127 richard 517
	$sms_div='';
518
	$sms_div_over='';
1508 richard 519
}
2234 richard 520
if ($direct_access) {
521
	if (!$network_pb) {
522
		echo "
2127 richard 523
		<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
524
			<span>$l_logout</span>
525
			<img src=\"$img_rep$img_internet\">
2136 richard 526
		</div>";
527
	}
2186 tom.houday 528
 
529
	// Read the "Domain allowed" file
530
	$domainAllowedHtml = '';
531
	$tab = file(DOMAIN_ALLOWED_LIST);
532
	if ($tab) { // the file isn't empty
533
		$domainAllowedHtml .= '<p>'.$l_uam_domain.'<br><ul>';
534
		foreach ($tab as $line) {
535
			if (trim($line) !== '') { // the line isn't empty
2234 richard 536
				$domain_allowed = explode('#', $line);
2186 tom.houday 537
				if (trim($domain_allowed[1]) !== '') {
538
					$domain = explode('"', $domain_allowed[0]);
539
					// remove every '.' from the beginning of domain
540
					$domain[1] = ltrim($domain[1], '.');
541
					$domainAllowedHtml .= '<li><a href="http://'.trim($domain[1]).'">'.trim($domain_allowed[1]).'</a></li>';
542
				}
543
			}
544
		}
545
		$domainAllowedHtml .= '</ul></p>';
546
	}
547
 
2136 richard 548
	echo "
2127 richard 549
		<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
550
			<span>$l_install_certif</span>
551
			<img src=\"$img_rep$img_certificate\">
552
		</div>
553
		<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
554
			<img src=\"$img_rep$img_pwd\">
555
			<span>$l_password_change</span>
556
		</div>		
557
		$sms_div
558
		<div class=\"div-cache\" id=\"text_conn\">
559
			<h2>$l_logout</h2>
560
			<p>$l_logout_explain</p>
2186 tom.houday 561
			$domainAllowedHtml
2127 richard 562
			<img src=\"$img_rep$img_internet\">
563
		</div>
564
		<div class=\"div-cache\" id=\"text_certif\">
565
			<h2>$l_install_certif_more</h2>
566
			<p>$l_certif_explain $l_certif_explain_help</p>
567
			<img src=\"$img_rep$img_certificate\">				
568
		</div>
569
		<div class=\"div-cache\" id=\"text_mdp\">
570
			<h2>$l_password_change</h2>
571
			<p>$l_password_change_explain</p>
572
			<img src=\"$img_rep$img_pwd\">
573
		</div>
574
		$sms_div_over
575
		<div id=\"box_info\">
576
		</div>";
577
}
578
else {
579
	# user need to be warned that someone reads his logs
2186 tom.houday 580
	if(isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] === '1'){
581
		$filename = '/var/www/html/acc/backup/log_info.txt';
582
		$l_explain_warn = '';
583
		if (file_exists($filename)) {
584
			$fichier = fopen($filename, 'r');
2127 richard 585
			$content = file($filename);
2186 tom.houday 586
			foreach ($content as $line) {
587
				$infos = explode('|||', $line);
588
				$log_date   = $infos[0];	
589
				$log_user   = $infos[1];	
590
				$log_reason = $infos[2];	
591
				$log_ip     = $infos[3];	
2127 richard 592
			}
2186 tom.houday 593
			$l_explain_warn = "$l_explain_warn_name$log_user ($l_explain_warn_ip$log_ip) $l_explain_warn_date$log_date.<br>$l_explain_warn_reason<br>$log_reason";
2127 richard 594
		}
595
		else{
596
			echo "Log error!";
597
		}
598
		echo "
599
			<div id=\"box_refuse\">
600
				<img src=\"$img_rep$img_warning\">
601
				<p>$l_explain_warn</p>
566 stephane 602
			</div>
2127 richard 603
			<div id=\"liens_redir\">
604
				<p>$l_continue_link</p>
566 stephane 605
			</div>";
509 richard 606
	}
2127 richard 607
	else{
509 richard 608
		echo "
566 stephane 609
			<div id=\"box_refuse\">
509 richard 610
				<img src=\"$img_rep$img_false\">
566 stephane 611
				<p>$l_explain</p>
612
			</div>
613
			<div id=\"liens_redir\">
614
				<p>$l_back_page</p>
615
			</div>";
2010 raphael.pi 616
	}
617
}
509 richard 618
	if (($network_pb)&&(! $direct_access)) {
2127 richard 619
		echo "	<span>Diagnostic : $diagnostic</span>";
509 richard 620
	}
2134 richard 621
	echo "</div>";
622
	if($direct_access){ # display the admin logo (wheel) at the bottom right
623
		echo "<div id=\"corner\">";
624
		echo "<div id=\"adm\" class=\"corn\">";
625
		echo "<a href=\"https://$hostname/acc/\"><img src=\"$img_rep$img_adm\"></a>";
626
		echo "</div>";
627
		echo "</div>";
628
	}
363 richard 629
?>
566 stephane 630
	</body>
1822 raphael.pi 631
</html>