Subversion Repositories ALCASAR

Rev

Rev 3180 | Details | Compare with Previous | Last modification | View Log

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