Subversion Repositories ALCASAR

Rev

Rev 2809 | Rev 2819 | 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 2818 2020-05-10 21:53:28Z rexy $
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) !== '#')) {
2450 tom.houday 40
		$tmp = explode('=', $buffer, 2);
2370 tom.houday 41
		$conf[trim($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"];
2612 tom.houday 48
$ssl_enable = ($conf['HTTPS_LOGIN'] === 'on');
2370 tom.houday 49
$useHTTPS = ((isset($_SERVER['HTTPS'])) && (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] !== 'off'));
2250 tom.houday 50
$network_pb = false; // "alcasar-watchdog.sh" changes this value if a network issue is detected
51
$diagnostic = "can't contact the default router"; // "alcasar-watchdog.sh" changes this value if a network issue is detected
2370 tom.houday 52
$certCa_link = (($useHTTPS) ? 'https' : 'http')."://$hostname/certs/certificat_alcasar_ca.crt";
2409 tom.houday 53
$logout_link = ((($conf['HTTPS_CHILLI'] === 'on') && $useHTTPS) ? 'https://'.$hostname.':3991' : 'http://'.$hostname.':3990').'/logoff';
2250 tom.houday 54
$direct_access = false;
55
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
56
$connection_history = '';
566 stephane 57
$nb_connection_history = 3;
2250 tom.houday 58
$redirect_link = 'www.euronews.com'; // Default redirection for HTTPS interception (beware, this website must run in HTTP)
59
 
60
// Check if the SMS service is enable
2600 tom.houday 61
$service_SMS_status = ($conf['SMS'] === 'on');
2250 tom.houday 62
 
63
// Retrieve the user info behind the remote ip
64
$output = [];
2612 tom.houday 65
exec('sudo /usr/sbin/chilli_query list ip '.escapeshellarg($remote_ip), $output);
2250 tom.houday 66
if (!empty($output)) {
67
	$userRaw = explode(' ', $output[0]);
68
	$user = (object) [
69
		'mac'       =>  $userRaw[0],
70
		'connected' => ($userRaw[4] === '1'),
71
		'username'  =>  $userRaw[5]
72
	];
73
} else {
74
	// CoovaChilli does not know the user
75
	$user = (object) [
76
		'mac'       => '',
77
		'connected' => false,
78
		'username'  => ''
79
	];
2127 richard 80
}
566 stephane 81
 
2688 lucas.echa 82
// Test if it's a direct connection to ALCASAR
2186 tom.houday 83
if (isset($_SERVER['HTTP_HOST']) && (($_SERVER['HTTP_HOST'] === $_SERVER['SERVER_ADDR']) || ($_SERVER['HTTP_HOST'] === 'alcasar') || ($_SERVER['HTTP_HOST'] === $hostname) || ($_SERVER['HTTP_HOST'] === $organisme))) {
84
	$direct_access = true;
1992 richard 85
}
2186 tom.houday 86
 
2688 lucas.echa 87
// Function to adapt time connection in seconds to H,M,S
566 stephane 88
function secondsToDuration($seconds = null){
89
	if ($seconds == null) return "";
90
	$temp = $seconds % 3600;
91
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
732 richard 92
	$time[2] = $temp % 60 ;				// seconds
566 stephane 93
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
2250 tom.houday 94
	return $time[0].' h '.$time[1].' m '.$time[2].' s';
566 stephane 95
}
509 richard 96
 
2250 tom.houday 97
// if user need to be warned
2234 richard 98
if (isset($_GET['warn']) && isset($_GET['url'])) {
99
	$direct_access = false;
2010 raphael.pi 100
}
101
 
2250 tom.houday 102
if ($user->connected) { // the user is authenticated
103
	if (isset($_GET['redirect'])) { // if user has been warned, we redirect him to his website
2186 tom.houday 104
		header('Location: '.$_GET['url'], true, 307);
2234 richard 105
		exit();
2010 raphael.pi 106
	}
2234 richard 107
 
2250 tom.houday 108
	// We retrieve his three last connections
109
	if ((is_file('./acc/manager/lib/sql/drivers/mysql/functions.php'))&&(is_file('/etc/freeradius-web/config.php'))){
110
		include_once('/etc/freeradius-web/config.php');
111
		include_once('./acc/manager/lib/sql/drivers/mysql/functions.php');
112
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user->username' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
2085 richard 113
		$link = @da_sql_pconnect($config);
2250 tom.houday 114
		if ($link) {
2085 richard 115
			$res = @da_sql_query($link,$config,$sql);
2250 tom.houday 116
			if ($res) {
117
				$connection_history .= '<ul>';
118
				while (($row = @da_sql_fetch_array($res,$config))) {
119
					$connected = '';
120
					if ($row['acctstoptime'] === '') {
121
						$connected = ' (active)';
122
					}
123
					$sessionTimeFormated = secondsToDuration($row['acctsessiontime']);
124
					$connection_history .= "<li title=\"$row[username] $row[acctstarttime] $row[acctstoptime] ($sessionTimeFormated)\">$row[acctstarttime] ($sessionTimeFormated) $connected</li>";
566 stephane 125
				}
2250 tom.houday 126
				$connection_history .= '</ul>';
566 stephane 127
			}
128
		}
129
	}
2250 tom.houday 130
} else { // the user isn't authenticated
131
	if (isset($_GET['url'])) { // it's the second stage (when user has clicked on the button "open a connection")
2234 richard 132
		$redir = 'http://'.$_GET['url'];
133
		header("Location: $redir", true, 307);
2688 lucas.echa 134
		exit();
1989 raphael.pi 135
	}
1818 raphael.pi 136
}
2250 tom.houday 137
 
138
// Choice of language
139
$Language = 'en';
140
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
141
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
142
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
143
}
144
if ($Language === 'fr') {		// French
2090 richard 145
	$l_access_denied = "Contrôle d'accès";
146
	$l_access_welcome = "Bienvenue sur ALCASAR";
147
	$l_access_unavailable = "ACCÈS INDISPONIBLE";
148
	$l_required_domain = "Site WEB demandé";
149
	$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.";
150
	$l_explain_access_deny = "Vous tentez d'accéder à une ressource dont le contenu est réputé contenir des informations inappropriées.";
151
	$l_explain_net_pb = "Votre portail détecte que l'accès à Internet est indisponible.";
152
	$l_contact_access_deny = "Contactez le responsable de la séurité (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
153
	$l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
2743 rexy 154
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Créer votre compte par SMS</a>";
2293 tom.houday 155
	$l_install_certif = "Installer le certificat racine";
2609 rexy 156
	$l_install_certif_more = "Installation du certificat de l'autorité racine d'ALCASAR";
2766 rexy 157
	$l_certif_explain = "Permet une communication sécurisées entre vous et ALCASAR.<br>";
2090 richard 158
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
159
	$l_category = "catégorie :";
2250 tom.houday 160
	if (!$user->connected) {
2766 rexy 161
		$l_logout_explain = "Aucune session n'est actuellement ouverte";
2605 tom.houday 162
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Ouvrir une session Internet</a>";
2250 tom.houday 163
	} else {
164
		if ($user->username != $user->mac) { // authentication exception or not
2370 tom.houday 165
			$l_logout_explain = "Ferme la session de l'usager actuellement connecté. <br><br>Utilisateur connecté : <a href=\"$logout_link\" title=\"Deconnecter l'utilisateur $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history dernières connexions :$connection_history";
166
			$l_logout = "<a href=\"$logout_link\">Se déconnecter d'internet</a>";
2250 tom.houday 167
		} else {
168
			$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 169
			$l_logout = "Information des connexions";
170
		}
832 richard 171
	}
2272 tom.houday 172
	$l_password_change = "<a href=\"https://$hostname/password.php\">Changer votre mot de passe</a>";
2766 rexy 173
	$l_password_change_explain = "Vous devez avoir un compte internet valide.";
2090 richard 174
	$l_back_page = "<a href=\"javascript:history.back()\">Page précédente</a>";
175
	$l_explain_warn = "L'administrateur a créé une archive contenant vos journaux de connexion dans le cadre d'une affaire judiciaire.";
2250 tom.houday 176
	if (isset($_GET['url'])) {
2186 tom.houday 177
		$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 178
	} else {
2186 tom.houday 179
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Je comprends et je souhaite continuer ma navigation.</a>";
2127 richard 180
	}
2090 richard 181
	$l_title_warn="Cher utilisateur, ";
182
	$l_explain_warn_name="Une personne sous le nom de ";
183
	$l_explain_warn_ip="sous cette IP : ";
184
	$l_explain_warn_date="a consulté vos journaux de connexion le ";
185
	$l_explain_warn_reason="Raison invoquée : ";
2186 tom.houday 186
	$l_uam_domain = "Sites autorisés : ";
2250 tom.houday 187
} else if ($Language === 'pt') {	// Portuguese
2090 richard 188
	$l_access_denied = "Controle de acesso";
189
	$l_access_welcome = "Bem-vindo ao Alcasar";
190
	$l_access_unavailable = "ACESSO INDISPONÍVEL";
191
	$l_required_domain = "Site WEB Obrigatório";
192
	$l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
193
	$l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
194
	$l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
195
	$l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
196
	$l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
2743 rexy 197
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Crie a conta por SMS</a>";
2293 tom.houday 198
	$l_install_certif = "Instalar Certificado Alcasar AC";
199
	$l_install_certif_more = "Instalar Certificado Alcasar AC";
2090 richard 200
	$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>";
201
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Essa foi uma ajuda complementar</a>";
202
	$l_category = "categoria :";
2250 tom.houday 203
	if (!$user->connected) {
2090 richard 204
		$l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
2605 tom.houday 205
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Abrir uma conexão de Internet</a>";
2250 tom.houday 206
	} else {
207
		if ($user->username != $user->mac) { // authentication exception or not
2370 tom.houday 208
			$l_logout_explain = "Se desejar, feche a conexão do usuário atual conectado.<br> Usuário conectado : <a href=\"$logout_link\" title=\"Disconnect user $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history logins últimos :$connection_history";
209
			$l_logout = "<a href=\"$logout_link\">Sair da Internet</a>";
2250 tom.houday 210
		} else {
211
			$l_logout_explain = "O sistema ($user->username) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
2090 richard 212
			$l_logout = "Informações de conexões";
213
		}
214
	}
2272 tom.houday 215
	$l_password_change = "<a href=\"https://$hostname/password.php\">Mudar sua senha</a>";
2090 richard 216
	$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.";
217
	$l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
2688 lucas.echa 218
	$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 219
	if (isset($_GET['url'])) {
2186 tom.houday 220
		$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 221
	} else {
2186 tom.houday 222
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Lo comprendo y deseo continuar mi navegación.</a>";
2127 richard 223
	}
2090 richard 224
	$l_title_warn="Estimado usuario,";
225
	$l_explain_warn_name="El usario ";
226
	$l_explain_warn_ip="con este IP : ";
227
	$l_explain_warn_date="consultó a sus registros de conexión el ";
228
	$l_explain_warn_reason="con la siguiente razón : ";
2186 tom.houday 229
	$l_uam_domain = "Sites autorizados : ";
2250 tom.houday 230
} else if ($Language === 'zn') {	// Chinese
2090 richard 231
	$l_access_denied = "访问控制";
232
	$l_access_welcome = "欢迎来到ALCASAR";
233
	$l_access_unavailable = "不可访问";
234
	$l_required_domain = "访问的网站";
235
	$l_explain_acc_access = "管理中心能管理门户,您必须通过超级用户或者管理用户来访问。";
236
	$l_explain_access_deny = "您试图访问一个含有不当信息的资源。";
237
	$l_explain_net_pb = "您的门户检测因特网不可用。";
238
	$l_contact_access_deny = "如果您认为该过滤不当,请联系安全负责人(OSSI/RSSI)。";
239
	$l_contact_net_pb = "请联系IT负责人或网络服务商来了解更多信息。";
2743 rexy 240
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">通過短信創建您的帳戶</a>";
2293 tom.houday 241
	$l_install_certif = "安装根证书";
242
	$l_install_certif_more = "安装根证书";
2090 richard 243
	$l_certif_explain = "允许您的计算机与ALCASAR门户进行安全数据交换。<BR>如果该证书未包含在您的计算机中,您的浏览器将出现一些安全提醒。<br><br>";
244
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">额外帮助</a>";
245
	$l_category = "类别 :";
2250 tom.houday 246
	if (!$user->connected) {
2090 richard 247
		$l_logout_explain = "您的系统目前没有打开任何网络咨询进程。";
2605 tom.houday 248
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">打开一个网络进程</a>";
2250 tom.houday 249
	} else {
250
		if ($user->username != $user->mac) { // authentication exception or not
2370 tom.houday 251
			$l_logout_explain = "关闭当前连接进程。<br> 已连接用户:<a href=\"$logout_link\" title=\" $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history 最后连接 :$connection_history";
252
			$l_logout = "<a href=\"$logout_link\">断开网络</a>";
2250 tom.houday 253
		} else {
254
			$l_logout_explain = "您的系统($user->username)验证例外<br><br>$nb_connection_history 最后连接: $connection_history";
2090 richard 255
			$l_logout = "连接信息";
256
		}
257
	}
2272 tom.houday 258
	$l_password_change = "<a href=\"https://$hostname/password.php\">更改您的密码</a>";
2090 richard 259
	$l_password_change_explain = "重新指向密码修改页面。<br><br> 您需要一个可用的网络账户。";
260
	$l_back_page = "<a href=\"javascript:history.back()\">上一页</a>";
261
	$l_explain_warn = "管理员创建了一份可用于司法调查的连接日志文档。";
2250 tom.houday 262
	if (isset($_GET['url'])) {
2186 tom.houday 263
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">我明白并希望继续浏览。</a>";
2250 tom.houday 264
	} else {
2186 tom.houday 265
		$l_continue_link = "<a href=\"index.php\" class=\"button\">我明白并希望继续浏览。</a>";
2127 richard 266
	}
2090 richard 267
	$l_title_warn="亲爱的用户,";
268
	$l_explain_warn_name="一人名为";
269
	$l_explain_warn_ip="在此IP:";
270
	$l_explain_warn_date="查看您的连接日志于";
271
	$l_explain_warn_reason=" 如下原因:";
2186 tom.houday 272
	$l_uam_domain = "授权网站 : ";
2250 tom.houday 273
} else if ($Language === 'ar') {	// Arabic
2111 richard 274
	$l_access_denied = "مراقبة الدخول";
275
	$l_access_welcome = "ALCASAR مرحبا بك في";
276
	$l_access_unavailable = "الدخول غير متوفر";
277
	$l_required_domain = "موقع إنترنيت مطلوب";
278
	$l_explain_acc_access = "مركز التحكم يمكنك من إدارة البوابة. يلزمك التوفر على حساب الادارة للدخول.";
279
	$l_explain_access_deny = "محاولة لدخول موارد تحتوي على معلومات غير ملائمة المحتوى";
280
	$l_explain_net_pb = "بوابتك تكتشف ان الدخول على الانترنت غير متوفر";
281
	$l_contact_access_deny = "المرجو الاتصال بضابط أمن (OSS / RSS) إذا اعتقدت ان هذه التصفية غير قانونية";
282
	$l_contact_net_pb = "المرجو الاتصال بمدير المعلومات أو مورد الأنترنت للمزيد من المعلومات";
283
	$auto_save_sms_text = "تسجيل ذاتي على";
2743 rexy 284
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">إنشاء حسابك لا SMS</a>";
2293 tom.houday 285
	$l_install_certif = "ركب جذر الشهادة";
286
	$l_install_certif_more = "ALCASAR تركيب شهادة السلطة؛ جذر الكزار";
2111 richard 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 = "فئة :";
2250 tom.houday 292
	if (!$user->connected) {
2111 richard 293
		$l_logout_explain = "و لا جلسة استفسار للإنترنت مفتوحة حاليا على نظامك";
294
		$close_session_text = "فتح جلسة الإنترنت";
2605 tom.houday 295
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">$close_session_text</a>";
2250 tom.houday 296
	} else {
297
		if ($user->username != $user->mac) { // authentication exception or not
2111 richard 298
			$close_session_text = "إقفال جلسة المستخدم المتصل حاليا";
2250 tom.houday 299
			$userlogged_text = "المستخدم متصل";
2111 richard 300
			$disconnect_user_text = "قطع الاتصال على المستخدم";
2370 tom.houday 301
			$l_logout_explain = "Ferme la session de l'usager actuellement connecté. <br><br>Utilisateur connecté : <a href=\"$logout_link\" title=\"Deconnecter l'utilisateur $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history dernières connexions :$connection_history";
2111 richard 302
			$logout_internet_text = "قطع الاتصال على الإنترنت";
2370 tom.houday 303
			$l_logout = "<a href=\"$logout_link\">$logout_internet_text</a>";
2250 tom.houday 304
		} else {
2111 richard 305
			$your_system_text = "نظامك";
306
			$auth_except_text = "على توثيق استثنائي";
307
			$last_conn_text = "اتصالات مشاركة";
2250 tom.houday 308
			$l_logout_explain = "$connection_history :$last_conn_text $nb_connection_history<br><br>$auth_except_text ($user->username) $your_system_text";
2111 richard 309
			$l_logout = "معلومات على الاتصالات ";
310
		}
311
	}
312
	$change_pass_text = "غير كلمتك السرية";
2272 tom.houday 313
	$l_password_change = "<a href=\"https://$hostname/password.php\">$change_pass_text</a>";
2111 richard 314
	$redirect_pass_text = "يوجهك على صفحة تغيير الكلمة السرية لحساب الإنترنت الخاص بك";
315
	$valid_account_text = "يجب ان يكون حساب الإنترنت الخاص بك صالحاً";
316
	$l_password_change_explain = "$valid_account_text<br><br>.$redirect_text";
317
	$redirect_sms_text = "يوجهك على الصفحة التفسيرية للتسجيل الذاتي بطريقة";
318
	$login_text = "تسجيل الدخول";
319
	$your_phone_text = "رقم الهاتف الخاص بك";
320
	$pass_text = "كلمة السر";
321
	$your_message_text = "رسالتك";
322
	$previous_text = "الصفحة السابقة";
323
	$l_back_page = "<a href=\"javascript:history.back()\">$previous_text</a>";
324
	$l_explain_warn = "المسؤول أنشأ أرشيفاً تحتوي على سجلات الاتصال في إطار تحقيق قضائي";
325
	$understand_text = "أنا متفهم و أريد ان أواصل التصفح";
2250 tom.houday 326
	if (isset($_GET['url'])) {
2186 tom.houday 327
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">$understand_text</a>";
2250 tom.houday 328
	} else {
2186 tom.houday 329
		$l_continue_link = "<a href=\"index.php\" class=\"button\">$understand_text</a>";
2111 richard 330
	}
331
	$l_title_warn = "عزيزي المستعمل, ";
332
	$l_explain_warn_name = "شخص مسمىٰ ";
333
	$l_explain_warn_ip = "تحت هذا IP: ";
334
	$l_explain_warn_date = "إطّلع على سجلات الاتصال الخاصة بك في";
335
	$l_explain_warn_reason = "السبب المسرّح به: ";
2186 tom.houday 336
	$l_uam_domain = ":المواقع المسموحة ";
2766 rexy 337
} else if ($Language === 'de') {		// German
338
	$l_access_denied = "Zugangskontrolle";
339
	$l_access_welcome = "Willkommen bei ALCASAR";
340
	$l_access_unavailable = "ZUGANG NICHT MÖGLICH";
341
	$l_required_domain = "Website benötigt";
342
	$l_explain_acc_access = "Hier ist das Kontrollcenter. Sie benötigen einen Account mit Administratorrechten.";
343
	$l_explain_access_deny = "Sie haben versucht sich mit einer Seite zu verbinden, die möglicherweise unangemessene Inhalte beinhaltet.";
344
	$l_explain_net_pb = "Offenbar funktioniert ihr Internetzugriff nicht.";
345
	$l_contact_access_deny = "Kontaktieren Sie ihren Sicherheitsbeauftragten wenn Sie denken dass diese Filterung unangemessen ist.";
346
	$l_contact_net_pb = "Kontaktieren Sie Ihren Netzwerkbeauftragten oder Ihren Internetanbieter für weitere Informationen.";
347
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Einen Account per SMS erstellen</a>";
348
	$l_install_certif = "Das ALCASAR AC Zertifikat installieren";
349
	$l_install_certif_more = "Das ALCASAR AC Zertifikat installieren";
350
	$l_certif_explain = "Ermöglicht einen sicheren Datenaustausch zwischen Ihrem Computer und ALCASAR.<BR>Wenn dieses Zertifikat nicht in Ihrem Browser installiert ist, könnten Sicherheitswarnungen in Ihrem Browser erscheinen.<br><br>";
351
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Weitere Informationen</a>";
352
	$l_category = "Kategorie:";
353
	if (!$user->connected) {
354
		$l_logout_explain = "Zurzeit ist keine Internetsitzung auf Ihrem System aktiv";
355
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Eine neue Internetzsitzung eröffnen</a>";
356
	} else {
357
		if ($user->username != $user->mac) { // authentication exception or not
358
			$l_logout_explain = "Die Sitzung des aktuell eingeloggten Users beenden.<br> Aktuell eingeloggter User: <a href=\"$logout_link\" title=\"Ausloggen $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history letzte Verbindungen:$connection_history";
359
			$l_logout = "<a href=\"$logout_link\">Aus dem Internet ausloggen</a>";
360
		} else {
361
			$l_logout_explain = "Ihr System ($user->username) ist nicht authentifiziert.<br><br>$nb_connection_history Letzte Verbindungen:$connection_history";
362
			$l_logout = "Informationen zur Verbindung";
363
		}
364
	}
365
	$l_password_change = "<a href=\"https://$hostname/password.php\">Passwort ändern</a>";
366
	$l_password_change_explain = "Leitet Sie auf die Seite der Passwortänderung weiter.<br><br> Sie sollten bereits einen Account für den Internetzugriff haben.";
367
	$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
368
	$l_explain_warn = "Der Administrator wird ein Archiv erstellen, welches Ihre Logdaten für den Fall einer gerichtlichen Untersuchung beinhaltet.";
369
	if (isset($_GET['url'])) {
370
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">Ich verstehe und möchte fortfahren.</a>";
371
	} else {
372
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Ich verstehe und möchte fortfahren.</a>";
373
	}
374
	$l_title_warn="Lieber Benutzer,";
375
	$l_explain_warn_name="Jemand namens ";
376
	$l_explain_warn_ip="mit dieser IP: ";
377
	$l_explain_warn_date="hat Ihre Verbindungsdaten eingesehen, für den ";
378
	$l_explain_warn_reason="Grund: ";
379
	$l_uam_domain = "Authorisierte Webseiten: ";
380
 
2250 tom.houday 381
} else {	// English
2090 richard 382
	$l_access_denied = "Access control";
2766 rexy 383
	$l_access_welcome = "Welcome to ALCASAR";
2090 richard 384
	$l_access_unavailable = "ACCESS UNAVAILABLE";
385
	$l_required_domain = "Required WEB site";
386
	$l_explain_acc_access = "This center control the portal. You must have an administrative account.";
387
	$l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
388
	$l_explain_net_pb = "Your portal has just detected that the Internet access is down";
389
	$l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
2688 lucas.echa 390
	$l_contact_net_pb = "Contact your network responsive or your Internet provider for further information.";
2743 rexy 391
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Create your account by SMS</a>";
2293 tom.houday 392
	$l_install_certif = "Install ALCASAR AC Certificate";
393
	$l_install_certif_more = "Install ALCASAR AC Certificate";
2766 rexy 394
	$l_certif_explain = "This will allow secure communications for your browser and ALCASAR<br>";
2090 richard 395
	$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
2688 lucas.echa 396
	$l_category = "category:";
2250 tom.houday 397
	if (!$user->connected) {
2766 rexy 398
		$l_logout_explain = "No session is currently open";
2605 tom.houday 399
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Open an Internet session</a>";
2250 tom.houday 400
	} else {
401
		if ($user->username != $user->mac) { // authentication exception or not
2766 rexy 402
			$l_logout_explain = "Close the session<br> User logged-on: <a href=\"$logout_link\" title=\"Disconnect user $user->username\"><b>$user->username</b></a><br><br>$nb_connection_history last connections:$connection_history";
403
			$l_logout = "<a href=\"$logout_link\">Logoff from the Internet</a>";
2250 tom.houday 404
		} else {
2688 lucas.echa 405
			$l_logout_explain = "Your system ($user->username) is in exception of authentication.<br><br>$nb_connection_history Last logins:$connection_history";
2090 richard 406
			$l_logout = "Connections information";
407
		}
408
	}
2272 tom.houday 409
	$l_password_change = "<a href=\"https://$hostname/password.php\">Change your password</a>";
2766 rexy 410
	$l_password_change_explain = "You should already have an Internet access account.";
2090 richard 411
	$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
412
	$l_explain_warn = "The administrator created an archive which contains your imputabilities logs for a judicial investigation.";
2250 tom.houday 413
	if (isset($_GET['url'])) {
2186 tom.houday 414
		$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 415
	} else {
2186 tom.houday 416
		$l_continue_link = "<a href=\"index.php\" class=\"button\">I understand and I wish to continue.</a>";
2127 richard 417
	}
2090 richard 418
	$l_title_warn="Dear user,";
419
	$l_explain_warn_name="Someone called ";
2688 lucas.echa 420
	$l_explain_warn_ip="with this IP: ";
421
	$l_explain_warn_date="has read your connection logs at ";
422
	$l_explain_warn_reason="For this reason: ";
423
	$l_uam_domain = "Authorized websites: ";
360 richard 424
}
1987 richard 425
 
2234 richard 426
$l_title   = ($direct_access ? $l_access_welcome     : ($network_pb ? $l_access_unavailable : $l_access_denied));
427
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb     : $l_explain_access_deny));
509 richard 428
 
2250 tom.houday 429
// Set the icons
430
$img_rep         = '/images/';
431
$img_organisme   = 'organisme.png';
432
$img_access      = 'globe_acces_70.png';
433
$img_connect     = 'globe_70.png';
434
$img_warning     = 'globe_warning_70.png';
435
$img_pwd         = 'cle_ombre.png';
436
$img_certificate = 'certificat.png';
437
$img_acc         = 'logo-alcasar_70.png';
438
$img_sms         = 'sms.png';
439
$img_false       = 'interdit.png';
440
$img_adm         = 'adm.png';
509 richard 441
 
2250 tom.houday 442
$img_internet    = (($user->connected) ? $img_connect : ($network_pb ? $img_warning : $img_access));
509 richard 443
 
2234 richard 444
if ($direct_access) {
2186 tom.houday 445
	// Read the "Domain allowed" file
2250 tom.houday 446
	$domainsAllowed = [];
2766 rexy 447
	$fileContent = file(DOMAIN_ALLOWED_LIST); if ($fileContent) { // the file isn't empty
448
       	foreach ($fileContent as $line) {
2250 tom.houday 449
			if (!empty(trim($line))) {
450
				$domain_fields = explode('#', $line);
451
				if (!empty(trim($domain_fields[1]))) {
452
					$domain = explode('"', $domain_fields[0]);
453
					$domain[1] = ltrim($domain[1], '.'); // remove every '.' from the beginning of domain
454
					$domainsAllowed[] = (object) [
455
						'name'   => trim($domain_fields[1]),
456
						'domain' => trim($domain[1])
457
					];
2766 rexy 458
 
2186 tom.houday 459
				}
460
			}
461
		}
462
	}
2250 tom.houday 463
} else {
464
	 if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] === '1') {
465
		// user need to be warned that someone reads his logs
2186 tom.houday 466
		$filename = '/var/www/html/acc/backup/log_info.txt';
467
		if (file_exists($filename)) {
468
			$fichier = fopen($filename, 'r');
2127 richard 469
			$content = file($filename);
2186 tom.houday 470
			foreach ($content as $line) {
471
				$infos = explode('|||', $line);
2250 tom.houday 472
				$log_date   = $infos[0];
473
				$log_user   = $infos[1];
474
				$log_reason = $infos[2];
475
				$log_ip     = $infos[3];
2127 richard 476
			}
2186 tom.houday 477
			$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 478
		} else {
479
			$l_explain_warn = 'Log error!';
2127 richard 480
		}
509 richard 481
	}
2010 raphael.pi 482
}
2250 tom.houday 483
 
484
// Search blacklist categories
485
if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))) {
486
	$pattern = str_replace('www.', '', $_SERVER['HTTP_HOST']);
2688 lucas.echa 487
	$categories = [];
488
	exec('grep -Re ' . escapeshellarg('^'.$pattern.'$') . " /etc/e2guardian/lists/blacklists/*/domains | cut -d'/' -f6", $categories);
2250 tom.houday 489
 
490
	$filteredUrlHtml = $l_required_domain.' : '.htmlspecialchars($_SERVER['HTTP_HOST']);
2688 lucas.echa 491
	if (!empty($categories)) {
492
		$filteredUrlHtml .= "<br>$l_category ".implode(', ', $categories);
2134 richard 493
	}
2250 tom.houday 494
}
2766 rexy 495
////////////////////////////////////////////////////////////////////////
496
/////////////////////////// TEST VARIABLES /////////////////////////////
2818 rexy 497
////////////////////////////////////////////////////////////////////////
2766 rexy 498
//$service_SMS_status = true;
499
//$direct_access = true;
500
//$network_pb = false;
501
//$domainsAllowed[] = (object) [
502
//	'name'   => 'name_test',
503
//	'domain' => 'domain_test' 
504
//];
2818 rexy 505
/////////////////////////////////////////////////////////////////////////
2250 tom.houday 506
 
507
// Cleaning the cache
508
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
509
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
510
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
511
header('Cache-Control: post-check=0, pre-check=0', false);
512
header('Pragma: no-cache');
363 richard 513
?>
2766 rexy 514
 
2250 tom.houday 515
<!DOCTYPE html>
516
<html>
517
	<head>
518
		<meta charset="UTF-8">
2766 rexy 519
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
2250 tom.houday 520
		<title>ALCASAR - <?= $l_title ?></title>
2766 rexy 521
		<link type="text/css" href="<?= ((!$direct_access) ? "//$hostname" : '') ?>/css/bootstrap.min.css" rel="stylesheet">
2809 rexy 522
		<link type="text/css" href="/css/index.css" rel="stylesheet">
2250 tom.houday 523
	</head>
2766 rexy 524
	<body>
525
	<div class="col-xs-12 col-md-10 col-md-offset-1" id="gui">
526
 
527
		<!-- HeaderBox -->
528
		<div class="row banner">
529
			<!-- Logo box -->
530
			<div id="boite_logo" class="hidden-xs col-sm-2">
531
				<img class="img-responsive img-organisme" src="<?= ((!$direct_access) ? "//$hostname" : '') ?><?= $img_rep.$img_organisme ?>">
532
			</div>
533
 
534
			<!-- Title -->
535
			<div id="cadre_titre" class="col-xs-12 col-sm-8">
536
				<?php if ($direct_access): ?>
2250 tom.houday 537
				<p id="acces_controle" class="titre_controle"><?= $l_title ?></p>
538
				<?php if ($network_pb): ?>
2766 rexy 539
					<div class="explanation_net_pb"><?= $l_explain_net_pb ?></div>
2250 tom.houday 540
				<?php endif; ?>
2766 rexy 541
				<?php else: // the user is intercepted ?>
2818 rexy 542
					<?php if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] == '1'): // if user need to be warm that someone reads his log ?>
2766 rexy 543
						<div id="cadre_titre" class="titre_refus">
544
							<p id="acces_controle" class="titre_refus"><?= $l_title_warn ?></p>
545
						</div>
546
					<?php else: // the user is blacklisted (or whitelisted) ?>
547
						<div id="cadre_titre" class="titre_refus">
548
							<p id="acces_controle" class="titre_refus"><?= $l_title ?></p>
549
						</div>
550
					<?php endif; ?>
551
				<?php endif; ?>
2250 tom.houday 552
			</div>
553
		</div>
554
 
2766 rexy 555
		<!-- Main content box -->
556
		<div class="row">
557
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
2818 rexy 558
				<?php if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))): // print blacklist categories ?>
2766 rexy 559
				<div id="box_url">
2818 rexy 560
					<?= $filteredUrlHtml ?>
2612 tom.houday 561
				</div>
2818 rexy 562
				<?php endif; ?>
2250 tom.houday 563
 
2766 rexy 564
				<!-- Menu -->
565
				<div class="menu-container container col_xs_12 col-sm-7">
566
					<?php if ($direct_access): ?>
567
						<div class="box_menu<?= (!$network_pb) ? '' : ' box-menu-disabled' ?>" id="box_conn" <?= (!$network_pb) ? '' : 'title=\'Not available\'' ?>>
568
							<span><?= $l_logout ?></span>
569
							<div class="menu-image">						
570
								<img class="img-responsive" src="<?= $img_rep.$img_internet ?>">
571
							</div>
572
						</div>
573
 
574
						<div class="box_menu_right box_menu<?= ($ssl_enable) ? '' : ' box-menu-disabled' ?>" id="box_certif" <?= ($ssl_enable) ? '' : 'title=\'Not available\'' ?>>
575
							<span><a href="<?= $certCa_link ?>"><?= $l_install_certif ?></a></span>
576
							<div class="menu-image">
577
								<img class="img-responsive" src="<?= $img_rep.$img_certificate ?>">
578
							</div>
579
						</div>
580
 
581
						<div class="box_menu" id="box_mdp" >
582
							<div class="menu-image">
583
								<img class="img-responsive" src="<?= $img_rep.$img_pwd ?>">
584
							</div>
585
							<span><?= $l_password_change ?></span>
586
						</div>
587
 
588
					<?php if ($service_SMS_status === true): ?>
2818 rexy 589
						<div class="box_menu_right box_menu" id="box_acc">
590
							<span><?= $l_sms_access ?></span>
591
							<div class="menu-image">
592
								<img class="img-responsive menu-image" src="<?= $img_rep.$img_sms ?>">
2766 rexy 593
							</div>
2818 rexy 594
						</div>
2766 rexy 595
					<?php endif; ?>
2250 tom.houday 596
				</div>
597
 
2766 rexy 598
				<!-- Info Box -->
599
				<div class="info-box-container col-sm-5">	
600
					<div id="box_infos">
601
						<h2 class="box_infos_titles"><?= $l_logout ?></h2>
602
						<p class="box_infos_explanations"><?= $l_logout_explain ?>
603
 
604
						<?php if (!empty($domainsAllowed)): ?>
605
							<p class="domain_allowed_title"><?= $l_uam_domain ?></p>
2250 tom.houday 606
							<ul>
607
								<?php foreach ($domainsAllowed as $domainAllowed): ?>
608
									<li><a href="http://<?= $domainAllowed->domain ?>"><?= $domainAllowed->name ?></a></li>
609
								<?php endforeach; ?>
610
							</ul>
2766 rexy 611
						<?php endif; ?>
2250 tom.houday 612
 
2766 rexy 613
						<h2 class="box_infos_titles"><?= $l_install_certif_more ?></a></h2>
614
						<p class="box_infos_explanations"><?= "$l_certif_explain $l_certif_explain_help" ?></p>
615
						<h2 class="box_infos_titles"><?= $l_password_change ?></h2>
616
						<p class="box_infos_explanations"><?= $l_password_change_explain ?></p>
617
 
618
						<?php else: // the user is intercepted ?>
619
							<?php if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] === '1'): // user need to be warned that someone reads his logs ?>
620
								<div id="box_refuse">
621
									<img src="//<?= $hostname.$img_rep.$img_warning ?>">
622
									<p><?= $l_explain_warn ?></p>
623
								</div>
624
								<div id="liens_redir">
625
									<p><?= $l_continue_link ?></p>
626
								</div>
627
							<?php else: ?>
628
								<div id="box_refuse">
629
									<img src="//<?= $hostname.$img_rep.$img_false ?>">
630
									<p><?= $l_explain ?></p>
631
								</div>
632
								<div id="liens_redir">
633
									<p><?= $l_back_page ?></p>
634
								</div>
635
							<?php endif; ?>
636
						<?php endif; ?>
637
					</div>
2250 tom.houday 638
				</div>
2766 rexy 639
				<?php if (($network_pb) && (!$direct_access)): ?>
640
					<span>Diagnostic : <?= $diagnostic ?></span>
2250 tom.houday 641
				<?php endif; ?>
2766 rexy 642
			</div>
643
			<?php if ($direct_access): // display the admin logo (wheel) at the bottom right ?>
2818 rexy 644
			<div id="corner">
645
				<div id="adm" class="corn">
646
					<a href="<?= "https://$hostname/acc/" ?>"><img src="<?= $img_rep.$img_adm ?>"></a>
647
				</div>
2766 rexy 648
			</div>
2250 tom.houday 649
		</div>
2766 rexy 650
		<?php endif; ?>
651
	</div>
652
	<div class="row col-xs-12">
653
		<div id="boite_logo" class="col-xs-12 hidden-sm hidden-md hidden-lg">
654
			<img class="img-responsive img-organisme" src="<?= ((!$direct_access) ? "//$hostname" : '') ?><?= $img_rep.$img_organisme ?>">
655
		</div>
656
	</div>
566 stephane 657
	</body>
1822 raphael.pi 658
</html>