Subversion Repositories ALCASAR

Rev

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