Subversion Repositories ALCASAR

Rev

Rev 2818 | Rev 2822 | 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 2819 2020-05-17 21:59:10Z 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";
2090 richard 156
	$l_category = "catégorie :";
2250 tom.houday 157
	if (!$user->connected) {
2766 rexy 158
		$l_logout_explain = "Aucune session n'est actuellement ouverte";
2819 rexy 159
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Ouvrir une session</a>";
2250 tom.houday 160
	} else {
161
		if ($user->username != $user->mac) { // authentication exception or not
2819 rexy 162
			$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 163
			$l_logout = "<a href=\"$logout_link\">Se déconnecter d'internet</a>";
2250 tom.houday 164
		} else {
165
			$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 166
			$l_logout = "<a href=\"\">Information des connexions</a>";
2090 richard 167
		}
832 richard 168
	}
2272 tom.houday 169
	$l_password_change = "<a href=\"https://$hostname/password.php\">Changer votre mot de passe</a>";
2090 richard 170
	$l_back_page = "<a href=\"javascript:history.back()\">Page précédente</a>";
171
	$l_explain_warn = "L'administrateur a créé une archive contenant vos journaux de connexion dans le cadre d'une affaire judiciaire.";
2250 tom.houday 172
	if (isset($_GET['url'])) {
2186 tom.houday 173
		$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 174
	} else {
2186 tom.houday 175
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Je comprends et je souhaite continuer ma navigation.</a>";
2127 richard 176
	}
2090 richard 177
	$l_title_warn="Cher utilisateur, ";
178
	$l_explain_warn_name="Une personne sous le nom de ";
179
	$l_explain_warn_ip="sous cette IP : ";
180
	$l_explain_warn_date="a consulté vos journaux de connexion le ";
181
	$l_explain_warn_reason="Raison invoquée : ";
2186 tom.houday 182
	$l_uam_domain = "Sites autorisés : ";
2250 tom.houday 183
} else if ($Language === 'pt') {	// Portuguese
2090 richard 184
	$l_access_denied = "Controle de acesso";
185
	$l_access_welcome = "Bem-vindo ao Alcasar";
186
	$l_access_unavailable = "ACESSO INDISPONÍVEL";
187
	$l_required_domain = "Site WEB Obrigatório";
188
	$l_explain_acc_access = "Este é o centro de controle do portal para acessar você deve ter uma conta administrativa valida.";
189
	$l_explain_access_deny = "Você tenta se conectar a um recurso cujo conteúdo é considerado inadequado no conteúdo de informações.";
190
	$l_explain_net_pb = "O sistema detectou que o acesso é de risco, não será permitido o acesso";
191
	$l_contact_access_deny = "Entre em contato com o administrador do sistema de segurança se acha que essa filtragem é abusiva.";
192
	$l_contact_net_pb = "Entre em contato com a empresa fornecedora de Internet para mais informações";
2743 rexy 193
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Crie a conta por SMS</a>";
2293 tom.houday 194
	$l_install_certif = "Instalar Certificado Alcasar AC";
2090 richard 195
	$l_category = "categoria :";
2250 tom.houday 196
	if (!$user->connected) {
2090 richard 197
		$l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?";
2605 tom.houday 198
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Abrir uma conexão de Internet</a>";
2250 tom.houday 199
	} else {
200
		if ($user->username != $user->mac) { // authentication exception or not
2819 rexy 201
			$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 202
			$l_logout = "<a href=\"$logout_link\">Sair da Internet</a>";
2250 tom.houday 203
		} else {
204
			$l_logout_explain = "O sistema ($user->username) detctou exesso de autenticação.<br><br>$nb_connection_history logins últimos :$connection_history";
2819 rexy 205
			$l_logout = "<a href=\"\">Informações de conexões</a>";
2090 richard 206
		}
207
	}
2272 tom.houday 208
	$l_password_change = "<a href=\"https://$hostname/password.php\">Mudar sua senha</a>";
2090 richard 209
	$l_back_page = "<a href=\"javascript:history.back()\">Página anterior</a>";
2688 lucas.echa 210
	$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 211
	if (isset($_GET['url'])) {
2186 tom.houday 212
		$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 213
	} else {
2186 tom.houday 214
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Lo comprendo y deseo continuar mi navegación.</a>";
2127 richard 215
	}
2090 richard 216
	$l_title_warn="Estimado usuario,";
217
	$l_explain_warn_name="El usario ";
218
	$l_explain_warn_ip="con este IP : ";
219
	$l_explain_warn_date="consultó a sus registros de conexión el ";
220
	$l_explain_warn_reason="con la siguiente razón : ";
2186 tom.houday 221
	$l_uam_domain = "Sites autorizados : ";
2250 tom.houday 222
} else if ($Language === 'zn') {	// Chinese
2090 richard 223
	$l_access_denied = "访问控制";
224
	$l_access_welcome = "欢迎来到ALCASAR";
225
	$l_access_unavailable = "不可访问";
226
	$l_required_domain = "访问的网站";
227
	$l_explain_acc_access = "管理中心能管理门户,您必须通过超级用户或者管理用户来访问。";
228
	$l_explain_access_deny = "您试图访问一个含有不当信息的资源。";
229
	$l_explain_net_pb = "您的门户检测因特网不可用。";
230
	$l_contact_access_deny = "如果您认为该过滤不当,请联系安全负责人(OSSI/RSSI)。";
231
	$l_contact_net_pb = "请联系IT负责人或网络服务商来了解更多信息。";
2743 rexy 232
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">通過短信創建您的帳戶</a>";
2293 tom.houday 233
	$l_install_certif = "安装根证书";
2090 richard 234
	$l_category = "类别 :";
2250 tom.houday 235
	if (!$user->connected) {
2090 richard 236
		$l_logout_explain = "您的系统目前没有打开任何网络咨询进程。";
2605 tom.houday 237
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">打开一个网络进程</a>";
2250 tom.houday 238
	} else {
239
		if ($user->username != $user->mac) { // authentication exception or not
2819 rexy 240
			$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 241
			$l_logout = "<a href=\"$logout_link\">断开网络</a>";
2250 tom.houday 242
		} else {
243
			$l_logout_explain = "您的系统($user->username)验证例外<br><br>$nb_connection_history 最后连接: $connection_history";
2819 rexy 244
			$l_logout = "<a href=\"\">连接信息</a>";
2090 richard 245
		}
246
	}
2272 tom.houday 247
	$l_password_change = "<a href=\"https://$hostname/password.php\">更改您的密码</a>";
2090 richard 248
	$l_back_page = "<a href=\"javascript:history.back()\">上一页</a>";
249
	$l_explain_warn = "管理员创建了一份可用于司法调查的连接日志文档。";
2250 tom.houday 250
	if (isset($_GET['url'])) {
2186 tom.houday 251
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">我明白并希望继续浏览。</a>";
2250 tom.houday 252
	} else {
2186 tom.houday 253
		$l_continue_link = "<a href=\"index.php\" class=\"button\">我明白并希望继续浏览。</a>";
2127 richard 254
	}
2090 richard 255
	$l_title_warn="亲爱的用户,";
256
	$l_explain_warn_name="一人名为";
257
	$l_explain_warn_ip="在此IP:";
258
	$l_explain_warn_date="查看您的连接日志于";
259
	$l_explain_warn_reason=" 如下原因:";
2186 tom.houday 260
	$l_uam_domain = "授权网站 : ";
2250 tom.houday 261
} else if ($Language === 'ar') {	// Arabic
2111 richard 262
	$l_access_denied = "مراقبة الدخول";
263
	$l_access_welcome = "ALCASAR مرحبا بك في";
264
	$l_access_unavailable = "الدخول غير متوفر";
265
	$l_required_domain = "موقع إنترنيت مطلوب";
266
	$l_explain_acc_access = "مركز التحكم يمكنك من إدارة البوابة. يلزمك التوفر على حساب الادارة للدخول.";
267
	$l_explain_access_deny = "محاولة لدخول موارد تحتوي على معلومات غير ملائمة المحتوى";
268
	$l_explain_net_pb = "بوابتك تكتشف ان الدخول على الانترنت غير متوفر";
269
	$l_contact_access_deny = "المرجو الاتصال بضابط أمن (OSS / RSS) إذا اعتقدت ان هذه التصفية غير قانونية";
270
	$l_contact_net_pb = "المرجو الاتصال بمدير المعلومات أو مورد الأنترنت للمزيد من المعلومات";
271
	$auto_save_sms_text = "تسجيل ذاتي على";
2743 rexy 272
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">إنشاء حسابك لا SMS</a>";
2293 tom.houday 273
	$l_install_certif = "ركب جذر الشهادة";
2111 richard 274
	$l_category = "فئة :";
2250 tom.houday 275
	if (!$user->connected) {
2111 richard 276
		$l_logout_explain = "و لا جلسة استفسار للإنترنت مفتوحة حاليا على نظامك";
277
		$close_session_text = "فتح جلسة الإنترنت";
2605 tom.houday 278
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">$close_session_text</a>";
2250 tom.houday 279
	} else {
280
		if ($user->username != $user->mac) { // authentication exception or not
2111 richard 281
			$close_session_text = "إقفال جلسة المستخدم المتصل حاليا";
2250 tom.houday 282
			$userlogged_text = "المستخدم متصل";
2111 richard 283
			$disconnect_user_text = "قطع الاتصال على المستخدم";
2819 rexy 284
			$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 285
			$logout_internet_text = "قطع الاتصال على الإنترنت";
2370 tom.houday 286
			$l_logout = "<a href=\"$logout_link\">$logout_internet_text</a>";
2250 tom.houday 287
		} else {
2111 richard 288
			$your_system_text = "نظامك";
289
			$auth_except_text = "على توثيق استثنائي";
290
			$last_conn_text = "اتصالات مشاركة";
2250 tom.houday 291
			$l_logout_explain = "$connection_history :$last_conn_text $nb_connection_history<br><br>$auth_except_text ($user->username) $your_system_text";
2819 rexy 292
			$l_logout = "<a href=\"\">معلومات على الاتصالات </a>";
2111 richard 293
		}
294
	}
295
	$change_pass_text = "غير كلمتك السرية";
2272 tom.houday 296
	$l_password_change = "<a href=\"https://$hostname/password.php\">$change_pass_text</a>";
2111 richard 297
	$redirect_sms_text = "يوجهك على الصفحة التفسيرية للتسجيل الذاتي بطريقة";
298
	$login_text = "تسجيل الدخول";
299
	$your_phone_text = "رقم الهاتف الخاص بك";
300
	$pass_text = "كلمة السر";
301
	$your_message_text = "رسالتك";
302
	$previous_text = "الصفحة السابقة";
303
	$l_back_page = "<a href=\"javascript:history.back()\">$previous_text</a>";
304
	$l_explain_warn = "المسؤول أنشأ أرشيفاً تحتوي على سجلات الاتصال في إطار تحقيق قضائي";
305
	$understand_text = "أنا متفهم و أريد ان أواصل التصفح";
2250 tom.houday 306
	if (isset($_GET['url'])) {
2186 tom.houday 307
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">$understand_text</a>";
2250 tom.houday 308
	} else {
2186 tom.houday 309
		$l_continue_link = "<a href=\"index.php\" class=\"button\">$understand_text</a>";
2111 richard 310
	}
311
	$l_title_warn = "عزيزي المستعمل, ";
312
	$l_explain_warn_name = "شخص مسمىٰ ";
313
	$l_explain_warn_ip = "تحت هذا IP: ";
314
	$l_explain_warn_date = "إطّلع على سجلات الاتصال الخاصة بك في";
315
	$l_explain_warn_reason = "السبب المسرّح به: ";
2186 tom.houday 316
	$l_uam_domain = ":المواقع المسموحة ";
2766 rexy 317
} else if ($Language === 'de') {		// German
318
	$l_access_denied = "Zugangskontrolle";
319
	$l_access_welcome = "Willkommen bei ALCASAR";
320
	$l_access_unavailable = "ZUGANG NICHT MÖGLICH";
321
	$l_required_domain = "Website benötigt";
322
	$l_explain_acc_access = "Hier ist das Kontrollcenter. Sie benötigen einen Account mit Administratorrechten.";
323
	$l_explain_access_deny = "Sie haben versucht sich mit einer Seite zu verbinden, die möglicherweise unangemessene Inhalte beinhaltet.";
324
	$l_explain_net_pb = "Offenbar funktioniert ihr Internetzugriff nicht.";
325
	$l_contact_access_deny = "Kontaktieren Sie ihren Sicherheitsbeauftragten wenn Sie denken dass diese Filterung unangemessen ist.";
326
	$l_contact_net_pb = "Kontaktieren Sie Ihren Netzwerkbeauftragten oder Ihren Internetanbieter für weitere Informationen.";
327
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Einen Account per SMS erstellen</a>";
328
	$l_install_certif = "Das ALCASAR AC Zertifikat installieren";
329
	$l_category = "Kategorie:";
330
	if (!$user->connected) {
331
		$l_logout_explain = "Zurzeit ist keine Internetsitzung auf Ihrem System aktiv";
332
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Eine neue Internetzsitzung eröffnen</a>";
333
	} else {
334
		if ($user->username != $user->mac) { // authentication exception or not
2819 rexy 335
			$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 336
			$l_logout = "<a href=\"$logout_link\">Aus dem Internet ausloggen</a>";
337
		} else {
338
			$l_logout_explain = "Ihr System ($user->username) ist nicht authentifiziert.<br><br>$nb_connection_history Letzte Verbindungen:$connection_history";
2819 rexy 339
			$l_logout = "<a href=\"\">Informationen zur Verbindung</a>";
2766 rexy 340
		}
341
	}
342
	$l_password_change = "<a href=\"https://$hostname/password.php\">Passwort ändern</a>";
343
	$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
344
	$l_explain_warn = "Der Administrator wird ein Archiv erstellen, welches Ihre Logdaten für den Fall einer gerichtlichen Untersuchung beinhaltet.";
345
	if (isset($_GET['url'])) {
346
		$l_continue_link = "<a href=\"index.php?redirect=1&url=".urlencode($_GET['url'])."\" class=\"button\">Ich verstehe und möchte fortfahren.</a>";
347
	} else {
348
		$l_continue_link = "<a href=\"index.php\" class=\"button\">Ich verstehe und möchte fortfahren.</a>";
349
	}
350
	$l_title_warn="Lieber Benutzer,";
351
	$l_explain_warn_name="Jemand namens ";
352
	$l_explain_warn_ip="mit dieser IP: ";
353
	$l_explain_warn_date="hat Ihre Verbindungsdaten eingesehen, für den ";
354
	$l_explain_warn_reason="Grund: ";
355
	$l_uam_domain = "Authorisierte Webseiten: ";
356
 
2250 tom.houday 357
} else {	// English
2090 richard 358
	$l_access_denied = "Access control";
2766 rexy 359
	$l_access_welcome = "Welcome to ALCASAR";
2090 richard 360
	$l_access_unavailable = "ACCESS UNAVAILABLE";
361
	$l_required_domain = "Required WEB site";
362
	$l_explain_acc_access = "This center control the portal. You must have an administrative account.";
363
	$l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
364
	$l_explain_net_pb = "Your portal has just detected that the Internet access is down";
365
	$l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
2688 lucas.echa 366
	$l_contact_net_pb = "Contact your network responsive or your Internet provider for further information.";
2743 rexy 367
	$l_sms_access = "<a href=\"//$hostname/autoregistrationinfo.php\">Create your account by SMS</a>";
2293 tom.houday 368
	$l_install_certif = "Install ALCASAR AC Certificate";
2688 lucas.echa 369
	$l_category = "category:";
2250 tom.houday 370
	if (!$user->connected) {
2766 rexy 371
		$l_logout_explain = "No session is currently open";
2605 tom.houday 372
		$l_logout = "<a href=\"//$hostname/index.php?url=$redirect_link\">Open an Internet session</a>";
2250 tom.houday 373
	} else {
374
		if ($user->username != $user->mac) { // authentication exception or not
2819 rexy 375
			$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 376
			$l_logout = "<a href=\"$logout_link\">Logoff from the Internet</a>";
2250 tom.houday 377
		} else {
2688 lucas.echa 378
			$l_logout_explain = "Your system ($user->username) is in exception of authentication.<br><br>$nb_connection_history Last logins:$connection_history";
2819 rexy 379
			$l_logout = "<a href=\"\">Connections information</a>";
2090 richard 380
		}
381
	}
2272 tom.houday 382
	$l_password_change = "<a href=\"https://$hostname/password.php\">Change your password</a>";
2090 richard 383
	$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
384
	$l_explain_warn = "The administrator created an archive which contains your imputabilities logs for a judicial investigation.";
2250 tom.houday 385
	if (isset($_GET['url'])) {
2186 tom.houday 386
		$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 387
	} else {
2186 tom.houday 388
		$l_continue_link = "<a href=\"index.php\" class=\"button\">I understand and I wish to continue.</a>";
2127 richard 389
	}
2090 richard 390
	$l_title_warn="Dear user,";
391
	$l_explain_warn_name="Someone called ";
2688 lucas.echa 392
	$l_explain_warn_ip="with this IP: ";
393
	$l_explain_warn_date="has read your connection logs at ";
394
	$l_explain_warn_reason="For this reason: ";
395
	$l_uam_domain = "Authorized websites: ";
360 richard 396
}
1987 richard 397
 
2234 richard 398
$l_title   = ($direct_access ? $l_access_welcome     : ($network_pb ? $l_access_unavailable : $l_access_denied));
399
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb     : $l_explain_access_deny));
509 richard 400
 
2250 tom.houday 401
// Set the icons
402
$img_rep         = '/images/';
403
$img_organisme   = 'organisme.png';
404
$img_access      = 'globe_acces_70.png';
405
$img_connect     = 'globe_70.png';
406
$img_warning     = 'globe_warning_70.png';
407
$img_pwd         = 'cle_ombre.png';
408
$img_certificate = 'certificat.png';
409
$img_acc         = 'logo-alcasar_70.png';
410
$img_sms         = 'sms.png';
411
$img_false       = 'interdit.png';
412
$img_adm         = 'adm.png';
509 richard 413
 
2250 tom.houday 414
$img_internet    = (($user->connected) ? $img_connect : ($network_pb ? $img_warning : $img_access));
509 richard 415
 
2234 richard 416
if ($direct_access) {
2186 tom.houday 417
	// Read the "Domain allowed" file
2250 tom.houday 418
	$domainsAllowed = [];
2766 rexy 419
	$fileContent = file(DOMAIN_ALLOWED_LIST); if ($fileContent) { // the file isn't empty
420
       	foreach ($fileContent as $line) {
2250 tom.houday 421
			if (!empty(trim($line))) {
422
				$domain_fields = explode('#', $line);
423
				if (!empty(trim($domain_fields[1]))) {
424
					$domain = explode('"', $domain_fields[0]);
425
					$domain[1] = ltrim($domain[1], '.'); // remove every '.' from the beginning of domain
426
					$domainsAllowed[] = (object) [
427
						'name'   => trim($domain_fields[1]),
428
						'domain' => trim($domain[1])
429
					];
2766 rexy 430
 
2186 tom.houday 431
				}
432
			}
433
		}
434
	}
2250 tom.houday 435
} else {
436
	 if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] === '1') {
437
		// user need to be warned that someone reads his logs
2186 tom.houday 438
		$filename = '/var/www/html/acc/backup/log_info.txt';
439
		if (file_exists($filename)) {
440
			$fichier = fopen($filename, 'r');
2127 richard 441
			$content = file($filename);
2186 tom.houday 442
			foreach ($content as $line) {
443
				$infos = explode('|||', $line);
2250 tom.houday 444
				$log_date   = $infos[0];
445
				$log_user   = $infos[1];
446
				$log_reason = $infos[2];
447
				$log_ip     = $infos[3];
2127 richard 448
			}
2186 tom.houday 449
			$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 450
		} else {
451
			$l_explain_warn = 'Log error!';
2127 richard 452
		}
509 richard 453
	}
2010 raphael.pi 454
}
2250 tom.houday 455
 
456
// Search blacklist categories
457
if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))) {
458
	$pattern = str_replace('www.', '', $_SERVER['HTTP_HOST']);
2688 lucas.echa 459
	$categories = [];
460
	exec('grep -Re ' . escapeshellarg('^'.$pattern.'$') . " /etc/e2guardian/lists/blacklists/*/domains | cut -d'/' -f6", $categories);
2250 tom.houday 461
 
462
	$filteredUrlHtml = $l_required_domain.' : '.htmlspecialchars($_SERVER['HTTP_HOST']);
2688 lucas.echa 463
	if (!empty($categories)) {
464
		$filteredUrlHtml .= "<br>$l_category ".implode(', ', $categories);
2134 richard 465
	}
2250 tom.houday 466
}
2766 rexy 467
////////////////////////////////////////////////////////////////////////
468
/////////////////////////// TEST VARIABLES /////////////////////////////
2818 rexy 469
////////////////////////////////////////////////////////////////////////
2766 rexy 470
//$service_SMS_status = true;
471
//$direct_access = true;
472
//$network_pb = false;
473
//$domainsAllowed[] = (object) [
474
//	'name'   => 'name_test',
475
//	'domain' => 'domain_test' 
476
//];
2818 rexy 477
/////////////////////////////////////////////////////////////////////////
2250 tom.houday 478
 
479
// Cleaning the cache
480
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
481
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
482
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
483
header('Cache-Control: post-check=0, pre-check=0', false);
484
header('Pragma: no-cache');
363 richard 485
?>
2250 tom.houday 486
<!DOCTYPE html>
487
<html>
488
	<head>
489
		<meta charset="UTF-8">
2766 rexy 490
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
2250 tom.houday 491
		<title>ALCASAR - <?= $l_title ?></title>
2819 rexy 492
		<link rel="stylesheet" type="text/css" href="<?= ((!$direct_access) ? "//$hostname" : '') ?>/css/bootstrap.min.css">
493
		<link rel="stylesheet" type="text/css" href="/css/index.css">
2250 tom.houday 494
	</head>
2766 rexy 495
	<body>
2819 rexy 496
	<div class="col-xs-12 col-md-10 col-md-offset-1"> 
2766 rexy 497
 
498
		<!-- HeaderBox -->
499
		<div class="row banner">
500
			<!-- Logo box -->
2819 rexy 501
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
2766 rexy 502
				<img class="img-responsive img-organisme" src="<?= ((!$direct_access) ? "//$hostname" : '') ?><?= $img_rep.$img_organisme ?>">
503
			</div>
504
 
505
			<!-- Title -->
2819 rexy 506
			<div id="cadre_titre" class="titre_banner col-xs-12 col-sm-8">
2766 rexy 507
				<?php if ($direct_access): ?>
2250 tom.houday 508
				<p id="acces_controle" class="titre_controle"><?= $l_title ?></p>
509
				<?php if ($network_pb): ?>
2766 rexy 510
					<div class="explanation_net_pb"><?= $l_explain_net_pb ?></div>
2250 tom.houday 511
				<?php endif; ?>
2766 rexy 512
				<?php else: // the user is intercepted ?>
2818 rexy 513
					<?php if (isset($_GET['warn']) && isset($_GET['url']) && $_GET['warn'] == '1'): // if user need to be warm that someone reads his log ?>
2766 rexy 514
						<div id="cadre_titre" class="titre_refus">
515
							<p id="acces_controle" class="titre_refus"><?= $l_title_warn ?></p>
516
						</div>
517
					<?php else: // the user is blacklisted (or whitelisted) ?>
518
						<div id="cadre_titre" class="titre_refus">
519
							<p id="acces_controle" class="titre_refus"><?= $l_title ?></p>
520
						</div>
521
					<?php endif; ?>
522
				<?php endif; ?>
2250 tom.houday 523
			</div>
2819 rexy 524
 
525
			<!-- Logo box -->
526
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
527
				<img class="img-responsive img-organisme" src="<?= ((!$direct_access) ? "//$hostname" : '') ?><?= $img_rep.$img_acc ?>">
528
			</div>
2250 tom.houday 529
		</div>
530
 
2766 rexy 531
		<!-- Main content box -->
532
		<div class="row">
533
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
2818 rexy 534
				<?php if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))): // print blacklist categories ?>
2766 rexy 535
				<div id="box_url">
2818 rexy 536
					<?= $filteredUrlHtml ?>
2612 tom.houday 537
				</div>
2818 rexy 538
				<?php endif; ?>
2250 tom.houday 539
 
2766 rexy 540
				<!-- Menu -->
541
				<div class="menu-container container col_xs_12 col-sm-7">
542
					<?php if ($direct_access): ?>
543
						<div class="box_menu<?= (!$network_pb) ? '' : ' box-menu-disabled' ?>" id="box_conn" <?= (!$network_pb) ? '' : 'title=\'Not available\'' ?>>
544
							<span><?= $l_logout ?></span>
545
							<div class="menu-image">						
546
								<img class="img-responsive" src="<?= $img_rep.$img_internet ?>">
547
							</div>
548
						</div>
549
 
550
						<div class="box_menu_right box_menu<?= ($ssl_enable) ? '' : ' box-menu-disabled' ?>" id="box_certif" <?= ($ssl_enable) ? '' : 'title=\'Not available\'' ?>>
551
							<span><a href="<?= $certCa_link ?>"><?= $l_install_certif ?></a></span>
552
							<div class="menu-image">
553
								<img class="img-responsive" src="<?= $img_rep.$img_certificate ?>">
554
							</div>
555
						</div>
556
 
557
						<div class="box_menu" id="box_mdp" >
558
							<div class="menu-image">
559
								<img class="img-responsive" src="<?= $img_rep.$img_pwd ?>">
560
							</div>
561
							<span><?= $l_password_change ?></span>
562
						</div>
563
 
564
					<?php if ($service_SMS_status === true): ?>
2818 rexy 565
						<div class="box_menu_right box_menu" id="box_acc">
566
							<span><?= $l_sms_access ?></span>
567
							<div class="menu-image">
568
								<img class="img-responsive menu-image" src="<?= $img_rep.$img_sms ?>">
2766 rexy 569
							</div>
2818 rexy 570
						</div>
2766 rexy 571
					<?php endif; ?>
2250 tom.houday 572
				</div>
573
 
2766 rexy 574
				<!-- Info Box -->
575
				<div class="info-box-container col-sm-5">	
576
					<div id="box_infos">
577
						<p class="box_infos_explanations"><?= $l_logout_explain ?>
578
 
579
						<?php if (!empty($domainsAllowed)): ?>
580
							<p class="domain_allowed_title"><?= $l_uam_domain ?></p>
2250 tom.houday 581
							<ul>
582
								<?php foreach ($domainsAllowed as $domainAllowed): ?>
583
									<li><a href="http://<?= $domainAllowed->domain ?>"><?= $domainAllowed->name ?></a></li>
584
								<?php endforeach; ?>
585
							</ul>
2766 rexy 586
						<?php endif; ?>
2250 tom.houday 587
 
2766 rexy 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="//<?= $hostname.$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="//<?= $hostname.$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
					</div>
2250 tom.houday 608
				</div>
2766 rexy 609
				<?php if (($network_pb) && (!$direct_access)): ?>
610
					<span>Diagnostic : <?= $diagnostic ?></span>
2250 tom.houday 611
				<?php endif; ?>
2766 rexy 612
			</div>
613
			<?php if ($direct_access): // display the admin logo (wheel) at the bottom right ?>
2818 rexy 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>
2766 rexy 618
			</div>
2250 tom.houday 619
		</div>
2766 rexy 620
		<?php endif; ?>
621
	</div>
566 stephane 622
	</body>
1822 raphael.pi 623
</html>