Subversion Repositories ALCASAR

Rev

Rev 2240 | Rev 2370 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2240 Rev 2346
1
<?php
1
<?php
2
# $Id: status.php 2240 2017-05-20 21:46:11Z tom.houdayer $
2
# $Id: status.php 2346 2017-07-21 23:09:06Z tom.houdayer $
3
#
3
#
4
# status.php for ALCASAR captive portal
4
# status.php for ALCASAR captive portal
5
# by steweb57 & Rexy
5
# by steweb57 & Rexy
6
# 
6
# 
7
/****************************************************************
7
/****************************************************************
8
*			GLOBAL FILE PATHS			*
8
*			GLOBAL FILE PATHS			*
9
*****************************************************************/
9
*****************************************************************/
10
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
10
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
11
 
11
 
12
/****************************************************************
12
/****************************************************************
13
*			FILE reading test			*
13
*			FILE reading test			*
14
*****************************************************************/
14
*****************************************************************/
15
$conf_files = array(CONF_FILE);
15
$conf_files = array(CONF_FILE);
16
foreach ($conf_files as $file) {
16
foreach ($conf_files as $file) {
17
	if (!file_exists($file)) {
17
	if (!file_exists($file)) {
18
		exit("Fichier $file non présent");
18
		exit("Fichier $file non présent");
19
	}
19
	}
20
	if (!is_readable($file)) {
20
	if (!is_readable($file)) {
21
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
21
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
22
	}
22
	}
23
}
23
}
24
 
24
 
25
/****************************************************************
25
/****************************************************************
26
*			Read CONF_FILE				*
26
*			Read CONF_FILE				*
27
*****************************************************************/
27
*****************************************************************/
28
$file_conf = fopen(CONF_FILE, 'r');
28
$file_conf = fopen(CONF_FILE, 'r');
29
if (!$file_conf) {
29
if (!$file_conf) {
30
	exit('Error opening the file '.CONF_FILE);
30
	exit('Error opening the file '.CONF_FILE);
31
}
31
}
32
while (!feof($file_conf)) {
32
while (!feof($file_conf)) {
33
	$buffer = fgets($file_conf, 4096);
33
	$buffer = fgets($file_conf, 4096);
34
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
34
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
35
		$tmp = explode('=', $buffer);
35
		$tmp = explode('=', $buffer);
36
		$conf[$tmp[0]] = trim($tmp[1]);
36
		$conf[trim($tmp[0])] = trim($tmp[1]);
37
	}
37
	}
38
}
38
}
39
fclose($file_conf);
39
fclose($file_conf);
40
 
40
 
41
$organisme = $conf['ORGANISM'];
41
$organisme = $conf['ORGANISM'];
42
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
42
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
43
$cn = '';
43
$cn = '';
44
$connection_history = '';
44
$connection_history = '';
45
$nb_connection_history = 3;
45
$nb_connection_history = 3;
-
 
46
$homepage_url = (($conf['HTTPS_LOGIN'] === 'on') ? 'https' : 'http' ).'://'.$conf['HOSTNAME'].'.'.$conf['DOMAIN'].'/';
46
 
47
 
47
// Wait for chilli (update its tables)
48
// Wait for chilli (update its tables)
48
sleep(1); // TODO: wait after login only?
49
sleep(1); // TODO: wait after login only?
49
// Retrieve user info in tab $user[]
50
// Retrieve user info in tab $user[]
50
exec("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
51
exec("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
51
if (isset($tab[0])) {
52
if (isset($tab[0])) {
52
	$user = explode(' ', $tab[0]);
53
	$user = explode(' ', $tab[0]);
53
}
54
}
54
 
55
 
55
// Time conversion 
56
// Time conversion 
56
function secondsToDuration($seconds = null) {
57
function secondsToDuration($seconds = null) {
57
	if ($seconds === null) return '';
58
	if ($seconds === null) return '';
58
	$temp = $seconds % 3600;
59
	$temp = $seconds % 3600;
59
	$time[2] = $temp % 60 ;			// seconds
60
	$time[2] = $temp % 60 ;			// seconds
60
	$time[1] = ($temp - $time[2]) / 60;	// minutes
61
	$time[1] = ($temp - $time[2]) / 60;	// minutes
61
	$time[0] = ($seconds - $temp) / 3600 ;	// hours
62
	$time[0] = ($seconds - $temp) / 3600 ;	// hours
62
	return $time[0].' h '.$time[1].' m '.$time[2].' s';
63
	return $time[0].' h '.$time[1].' m '.$time[2].' s';
63
}
64
}
64
 
65
 
65
# Choice of language
66
# Choice of language
66
// TODO: reste quelques traductions à faire
67
// TODO: reste quelques traductions à faire
67
$Language = 'en';
68
$Language = 'en';
68
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
69
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
69
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
70
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
70
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
71
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
71
}
72
}
72
if ($Language === 'es') {		// Spanish
73
if ($Language === 'es') {		// Spanish
73
	$l_login1			= "El éxito de la autenticación";
74
	$l_login1			= "El éxito de la autenticación";
74
	$l_logout			= "Conexión de cierre";
75
	$l_logout			= "Conexión de cierre";
75
	$l_logout_question		= "¿Seguro que desea desconectar?";
76
	$l_logout_question		= "¿Seguro que desea desconectar?";
76
	$l_loggedout			= "Su sesión se cierra";
77
	$l_loggedout			= "Su sesión se cierra";
77
	$l_wait				= "Por favor, espere un momento ...";
78
	$l_wait				= "Por favor, espere un momento ...";
78
	$l_state_label			= "Estado";
79
	$l_state_label			= "Estado";
79
	$l_session_id_label		= "Sesión ID";
80
	$l_session_id_label		= "Sesión ID";
80
	$l_max_session_time_label	= "Tiempo máximo de sesión";
81
	$l_max_session_time_label	= "Tiempo máximo de sesión";
81
	$l_max_idle_time_label		= "Tiempo de inactividad autorizado";
82
	$l_max_idle_time_label		= "Tiempo de inactividad autorizado";
82
	$l_start_time_label		= "Start Time";	// to translate
83
	$l_start_time_label		= "Start Time";	// to translate
83
	$l_session_time_label		= "Tiempo de conexión";
84
	$l_session_time_label		= "Tiempo de conexión";
84
	$l_idle_time_label		= "Idle Time";	// to translate
85
	$l_idle_time_label		= "Idle Time";	// to translate
85
	$l_downloaded_label		= "Downloaded";	// to translate
86
	$l_downloaded_label		= "Downloaded";	// to translate
86
	$l_uploaded_label		= "Uploaded";	// to translate
87
	$l_uploaded_label		= "Uploaded";	// to translate
87
	$l_original_url_label		= "Original URL";	// to translate
88
	$l_original_url_label		= "Original URL";	// to translate
88
	$l_not_available		= "Not available";	// to translate
89
	$l_not_available		= "Not available";	// to translate
89
	$l_error			= "error";		// to translate
90
	$l_error			= "error";		// to translate
90
	$l_welcome			= "Welcome";	// to translate
91
	$l_welcome			= "Welcome";	// to translate
91
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
92
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
92
	$l_connected 			= "logged"; // to translate
93
	$l_connected 			= "logged"; // to translate
93
	$l_a_connection			= "You have"; // to translate
94
	$l_a_connection			= "You have"; // to translate
94
	$l_a_connection_time		= "active connections on the network"; // to translate
95
	$l_a_connection_time		= "active connections on the network"; // to translate
95
	$l_close_warning		= "Advertencia: se desconectará si cierra esta ventana";
96
	$l_close_warning		= "Advertencia: se desconectará si cierra esta ventana";
-
 
97
	$l_back_homepage		= "Volver a la página de inicio";
96
} else if ($Language === 'zh') {	// Chinese
98
} else if ($Language === 'zh') {	// Chinese
97
	$l_login1			= "验证通过";
99
	$l_login1			= "验证通过";
98
	$l_logout			= "关闭连接";
100
	$l_logout			= "关闭连接";
99
	$l_logout_question		= "您确定需要断开连接吗?";
101
	$l_logout_question		= "您确定需要断开连接吗?";
100
	$l_loggedout			= "您已登出";
102
	$l_loggedout			= "您已登出";
101
	$l_wait				= "请等待 ...";
103
	$l_wait				= "请等待 ...";
102
	$l_state_label			= "连接状态";
104
	$l_state_label			= "连接状态";
103
	$l_session_id_label		= "连接ID";
105
	$l_session_id_label		= "连接ID";
104
	$l_max_session_time_label	= "最大连接时间";
106
	$l_max_session_time_label	= "最大连接时间";
105
	$l_max_idle_time_label		= "最大闲置时间";
107
	$l_max_idle_time_label		= "最大闲置时间";
106
	$l_start_time_label		= "起始连接时间";
108
	$l_start_time_label		= "起始连接时间";
107
	$l_session_time_label		= "连接时间";
109
	$l_session_time_label		= "连接时间";
108
	$l_idle_time_label		= "闲置时间";
110
	$l_idle_time_label		= "闲置时间";
109
	$l_downloaded_label		= "数据下载";
111
	$l_downloaded_label		= "数据下载";
110
	$l_uploaded_label		= "数据上传";
112
	$l_uploaded_label		= "数据上传";
111
	$l_original_url_label		= "初始网址";
113
	$l_original_url_label		= "初始网址";
112
	$l_not_available		= "不可用";
114
	$l_not_available		= "不可用";
113
	$l_error			= "出错";
115
	$l_error			= "出错";
114
	$l_welcome			= "欢迎";
116
	$l_welcome			= "欢迎";
115
	$l_conn_history			= "您最近的{$nb_connection_history}次连接";
117
	$l_conn_history			= "您最近的{$nb_connection_history}次连接";
116
	$l_connected 			= "已登录";  
118
	$l_connected 			= "已登录";  
117
	$l_a_connection			= "您已经有";
119
	$l_a_connection			= "您已经有";
118
	$l_a_connection_time		= "在线时间";
120
	$l_a_connection_time		= "在线时间";
119
	$l_close_warning		= "警告: 您将会断开连接如果您在关闭此窗口";
121
	$l_close_warning		= "警告: 您将会断开连接如果您在关闭此窗口";
-
 
122
	$l_back_homepage		= "回到主页";
120
} else if ($Language === 'ar') {	// Arabic
123
} else if ($Language === 'ar') {	// Arabic
121
	$l_login1			= "نجاح المصادقة";
124
	$l_login1			= "نجاح المصادقة";
122
	$l_logout			= "إغلاق الدورة";
125
	$l_logout			= "إغلاق الدورة";
123
	$l_logout_question		= "هل تريد فعلاً قطع الاتصال؟";
126
	$l_logout_question		= "هل تريد فعلاً قطع الاتصال؟";
124
	$l_loggedout			= "دورتكَ مُغلَقة";
127
	$l_loggedout			= "دورتكَ مُغلَقة";
125
	$l_wait				= "...إنتظر بعض اللحظات";
128
	$l_wait				= "...إنتظر بعض اللحظات";
126
	$l_state_label			= "وَضْع";
129
	$l_state_label			= "وَضْع";
127
	$l_session_id_label		= "معرف الدورة";
130
	$l_session_id_label		= "معرف الدورة";
128
	$l_max_session_time_label	= "الوقت المسموح للإتصال";
131
	$l_max_session_time_label	= "الوقت المسموح للإتصال";
129
	$l_max_idle_time_label		= "الحد الأقصى لعدم التنشيط";
132
	$l_max_idle_time_label		= "الحد الأقصى لعدم التنشيط";
130
	$l_start_time_label		= "بداية الإتصال";
133
	$l_start_time_label		= "بداية الإتصال";
131
	$l_session_time_label		= "مدة الإتصال";
134
	$l_session_time_label		= "مدة الإتصال";
132
	$l_idle_time_label		= "انعدام التنشيط";
135
	$l_idle_time_label		= "انعدام التنشيط";
133
	$l_downloaded_label		= "تم تحميل المعطيات";
136
	$l_downloaded_label		= "تم تحميل المعطيات";
134
	$l_uploaded_label		= "تم إرسال المعطيات";
137
	$l_uploaded_label		= "تم إرسال المعطيات";
135
	$l_original_url_label		= "تم طلب URL";
138
	$l_original_url_label		= "تم طلب URL";
136
	$l_not_available		= "غير متوفّر";
139
	$l_not_available		= "غير متوفّر";
137
	$l_na				= "N/D";
140
	$l_na				= "N/D";
138
	$l_error			= "خطأ";
141
	$l_error			= "خطأ";
139
	$l_welcome			= "مرحباً بك";
142
	$l_welcome			= "مرحباً بك";
140
	$l_conn_history			= "($nb_connection_history) سِجِل اتصالاتك الاخيرة";
143
	$l_conn_history			= "($nb_connection_history) سِجِل اتصالاتك الاخيرة";
141
	$l_connected 			= "دورة ناشطة";  
144
	$l_connected 			= "دورة ناشطة";  
142
	$l_a_connection			= "لديك";
145
	$l_a_connection			= "لديك";
143
	$l_a_connection_time		= "اتصالات ناشطة على الشبكة";
146
	$l_a_connection_time		= "اتصالات ناشطة على الشبكة";
144
	$l_close_warning		= "تحذير: سيتم قطع الاتصال إذا قمت بإغلاق هذه النافذة";
147
	$l_close_warning		= "تحذير: سيتم قطع الاتصال إذا قمت بإغلاق هذه النافذة";
-
 
148
	$l_back_homepage		= "الرجوع إلى الصفحة الرئيسية";
145
} else if ($Language === 'pt') {	// Portuguese
149
} else if ($Language === 'pt') {	// Portuguese
146
	$l_login1			= "Autenticação bem sucedida.";
150
	$l_login1			= "Autenticação bem sucedida.";
147
	$l_logout			= "Fechando a conexão";
151
	$l_logout			= "Fechando a conexão";
148
	$l_logout_question		= "Tem certeza de que deseja desconectar agora?";
152
	$l_logout_question		= "Tem certeza de que deseja desconectar agora?";
149
	$l_loggedout			= "Sua conexão será fechada";
153
	$l_loggedout			= "Sua conexão será fechada";
150
	$l_wait				= "Por favor, aguarde um momento ...";
154
	$l_wait				= "Por favor, aguarde um momento ...";
151
	$l_state_label			= "Estado da conexão";
155
	$l_state_label			= "Estado da conexão";
152
	$l_session_id_label		= "Sessão ID";
156
	$l_session_id_label		= "Sessão ID";
153
	$l_max_session_time_label	= "Restante em horas da conexão";
157
	$l_max_session_time_label	= "Restante em horas da conexão";
154
	$l_max_idle_time_label		= "Restante máximo liberado por dia";
158
	$l_max_idle_time_label		= "Restante máximo liberado por dia";
155
	$l_start_time_label		= "Dia, mês, ano e hora da conexão";
159
	$l_start_time_label		= "Dia, mês, ano e hora da conexão";
156
	$l_session_time_label		= "Duração da conexão";
160
	$l_session_time_label		= "Duração da conexão";
157
	$l_idle_time_label		= "Tempo de Espera";
161
	$l_idle_time_label		= "Tempo de Espera";
158
	$l_downloaded_label		= "Recebidos";
162
	$l_downloaded_label		= "Recebidos";
159
	$l_uploaded_label		= "Enviados";
163
	$l_uploaded_label		= "Enviados";
160
	$l_original_url_label		= "URL Original";
164
	$l_original_url_label		= "URL Original";
161
	$l_not_available		= "Não disponível";
165
	$l_not_available		= "Não disponível";
162
	$l_error			= "Erro";
166
	$l_error			= "Erro";
163
	$l_welcome			= "Bem-vindo(a)";
167
	$l_welcome			= "Bem-vindo(a)";
164
	$l_conn_history			= "Suas últimos conexões : $nb_connection_history";
168
	$l_conn_history			= "Suas últimos conexões : $nb_connection_history";
165
	$l_connected 			= "Conectado"; 
169
	$l_connected 			= "Conectado"; 
166
	$l_a_connection			= "Conexão ativa já detectada para essa LAN";
170
	$l_a_connection			= "Conexão ativa já detectada para essa LAN";
167
	$l_a_connection_time		= "Tempo (s)";
171
	$l_a_connection_time		= "Tempo (s)";
168
	$l_close_warning		= "Aviso: você será desconectado se fechar esta janela";
172
	$l_close_warning		= "Aviso: você será desconectado se fechar esta janela";
-
 
173
	$l_back_homepage		= "Voltar à página inicial";
169
} else if ($Language === 'de') {	// German
174
} else if ($Language === 'de') {	// German
170
	$l_login1			= "Erfolgreiche Authentifizierung";
175
	$l_login1			= "Erfolgreiche Authentifizierung";
171
	$l_logout			= "Beenden der Verbindung";
176
	$l_logout			= "Beenden der Verbindung";
172
	$l_logout_question		= "Möchten Sie die Verbindung jetzt wirklich trennen?";
177
	$l_logout_question		= "Möchten Sie die Verbindung jetzt wirklich trennen?";
173
	$l_loggedout			= "Ihre Sitzung ist geschlossen";
178
	$l_loggedout			= "Ihre Sitzung ist geschlossen";
174
	$l_wait				= "Bitte warten Sie einen Moment ...";
179
	$l_wait				= "Bitte warten Sie einen Moment ...";
175
	$l_state_label			= "State";		// to translate
180
	$l_state_label			= "State";		// to translate
176
	$l_session_id_label		= "Session ID";	// to translate
181
	$l_session_id_label		= "Session ID";	// to translate
177
	$l_max_session_time_label	= "Max Session Time";	// to translate
182
	$l_max_session_time_label	= "Max Session Time";	// to translate
178
	$l_max_idle_time_label		= "Max Idle Time";		// to translate
183
	$l_max_idle_time_label		= "Max Idle Time";		// to translate
179
	$l_start_time_label		= "Start Time";	// to translate
184
	$l_start_time_label		= "Start Time";	// to translate
180
	$l_session_time_label		= "Online-zeit";
185
	$l_session_time_label		= "Online-zeit";
181
	$l_idle_time_label		= "Idle Time";	// to translate
186
	$l_idle_time_label		= "Idle Time";	// to translate
182
	$l_downloaded_label		= "Downloaded";	// to translate
187
	$l_downloaded_label		= "Downloaded";	// to translate
183
	$l_uploaded_label		= "Uploaded";	// to translate
188
	$l_uploaded_label		= "Uploaded";	// to translate
184
	$l_original_url_label		= "Original URL";	// to translate
189
	$l_original_url_label		= "Original URL";	// to translate
185
	$l_not_available		= "Not available";	// to translate
190
	$l_not_available		= "Not available";	// to translate
186
	$l_error			= "error";		// to translate
191
	$l_error			= "error";		// to translate
187
	$l_welcome			= "Welcome"; 	// to translate
192
	$l_welcome			= "Welcome"; 	// to translate
188
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
193
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
189
	$l_connected 			= "logged"; // to translate 
194
	$l_connected 			= "logged"; // to translate 
190
	$l_a_connection			= "You have"; // to translate
195
	$l_a_connection			= "You have"; // to translate
191
	$l_a_connection_time		= "active connections on the network"; // to translate
196
	$l_a_connection_time		= "active connections on the network"; // to translate
192
	$l_close_warning		= "Warnung: Sie werden getrennt, wenn Sie dieses Fenster schließen";
197
	$l_close_warning		= "Warnung: Sie werden getrennt, wenn Sie dieses Fenster schließen";
-
 
198
	$l_back_homepage		= "Zurück zur Startseite";
193
} else if ($Language === 'nl') {	// Dutch
199
} else if ($Language === 'nl') {	// Dutch
194
	$l_login1			= "Succesvolle authenticatie";
200
	$l_login1			= "Succesvolle authenticatie";
195
	$l_logout			= "Slotkoers verbinding";
201
	$l_logout			= "Slotkoers verbinding";
196
	$l_logout_question		= "Bent u zeker dat u wilt nu los te koppelen?";
202
	$l_logout_question		= "Bent u zeker dat u wilt nu los te koppelen?";
197
	$l_loggedout			= "Uw sessie is gesloten";
203
	$l_loggedout			= "Uw sessie is gesloten";
198
	$l_wait				= "Wacht een moment ...";
204
	$l_wait				= "Wacht een moment ...";
199
	$l_state_label			= "State";		// to translate
205
	$l_state_label			= "State";		// to translate
200
	$l_session_id_label		= "Session ID";	// to translate
206
	$l_session_id_label		= "Session ID";	// to translate
201
	$l_max_session_time_label	= "Max Session Time";	// to translate
207
	$l_max_session_time_label	= "Max Session Time";	// to translate
202
	$l_max_idle_time_label		= "Max Idle Time";		// to translate
208
	$l_max_idle_time_label		= "Max Idle Time";		// to translate
203
	$l_start_time_label		= "Start Time";	// to translate
209
	$l_start_time_label		= "Start Time";	// to translate
204
	$l_session_time_label		= "Online tijd";
210
	$l_session_time_label		= "Online tijd";
205
	$l_idle_time_label		= "Idle Time";	// to translate
211
	$l_idle_time_label		= "Idle Time";	// to translate
206
	$l_downloaded_label		= "Downloaded";	// to translate
212
	$l_downloaded_label		= "Downloaded";	// to translate
207
	$l_uploaded_label		= "Uploaded";	// to translate
213
	$l_uploaded_label		= "Uploaded";	// to translate
208
	$l_original_url_label		= "Original URL";	// to translate
214
	$l_original_url_label		= "Original URL";	// to translate
209
	$l_not_available		= "Not available";	// to translate
215
	$l_not_available		= "Not available";	// to translate
210
	$l_error			= "error";		// to translate
216
	$l_error			= "error";		// to translate
211
	$l_welcome			= "Welcome";	// to translate
217
	$l_welcome			= "Welcome";	// to translate
212
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
218
	$l_conn_history			= "Your last $nb_connection_history connections";	// to translate
213
	$l_connected 			= "logged"; // to translate 
219
	$l_connected 			= "logged"; // to translate 
214
	$l_a_connection			= "You have"; // to translate
220
	$l_a_connection			= "You have"; // to translate
215
	$l_a_connection_time		= "active connections on the network"; // to translate
221
	$l_a_connection_time		= "active connections on the network"; // to translate
216
	$l_close_warning		= "Waarschuwing: u zal worden afgebroken als u dit venster sluiten";
222
	$l_close_warning		= "Waarschuwing: u zal worden afgebroken als u dit venster sluiten";
-
 
223
	$l_back_homepage		= "Terug naar de homepage";
217
} else if ($Language === 'fr') {	// French
224
} else if ($Language === 'fr') {	// French
218
	$l_login1			= "Authentification réussie";
225
	$l_login1			= "Authentification réussie";
219
	$l_logout			= "Fermeture de la session";
226
	$l_logout			= "Fermeture de la session";
220
	$l_logout_question		= "Êtes vous sûr de vouloir vous déconnecter?";
227
	$l_logout_question		= "Êtes vous sûr de vouloir vous déconnecter?";
221
	$l_loggedout			= "Votre session est fermée";
228
	$l_loggedout			= "Votre session est fermée";
222
	$l_wait				= "Patientez un instant ....";
229
	$l_wait				= "Patientez un instant ....";
223
	$l_state_label			= "État";
230
	$l_state_label			= "État";
224
	$l_session_id_label		= "Session ID";
231
	$l_session_id_label		= "Session ID";
225
	$l_max_session_time_label	= "Temps de connexion autorisé";
232
	$l_max_session_time_label	= "Temps de connexion autorisé";
226
	$l_max_idle_time_label		= "Temps d'inactivité autorisé";
233
	$l_max_idle_time_label		= "Temps d'inactivité autorisé";
227
	$l_start_time_label		= "Début de connexion";
234
	$l_start_time_label		= "Début de connexion";
228
	$l_session_time_label		= "Durée de connexion";
235
	$l_session_time_label		= "Durée de connexion";
229
	$l_idle_time_label		= "Inactivité";
236
	$l_idle_time_label		= "Inactivité";
230
	$l_downloaded_label		= "Données téléchargées";
237
	$l_downloaded_label		= "Données téléchargées";
231
	$l_uploaded_label		= "Données envoyées";
238
	$l_uploaded_label		= "Données envoyées";
232
	$l_original_url_label		= "URL demandée";
239
	$l_original_url_label		= "URL demandée";
233
	$l_not_available		= "Non disponible";
240
	$l_not_available		= "Non disponible";
234
	$l_error			= "erreur";
241
	$l_error			= "erreur";
235
	$l_welcome			= "Bienvenue";
242
	$l_welcome			= "Bienvenue";
236
	$l_conn_history			= "Vos $nb_connection_history dernières connexions";
243
	$l_conn_history			= "Vos $nb_connection_history dernières connexions";
237
	$l_connected 			= "session active";  
244
	$l_connected 			= "session active";  
238
	$l_a_connection			= "Vous avez";
245
	$l_a_connection			= "Vous avez";
239
	$l_a_connection_time		= "connexions actives sur le réseau";
246
	$l_a_connection_time		= "connexions actives sur le réseau";
240
	$l_close_warning		= "Attention : vous serez déconnecté si vous fermez cette fenêtre";
247
	$l_close_warning		= "Attention : vous serez déconnecté si vous fermez cette fenêtre";
-
 
248
	$l_back_homepage		= "Revenir à la page d'accueil";
241
} else {				// English
249
} else {				// English
242
	$l_login1			= "Successful authentication.";
250
	$l_login1			= "Successful authentication.";
243
	$l_logout			= "Closing connection";
251
	$l_logout			= "Closing connection";
244
	$l_logout_question		= "Are you sure you want to disconnect now?";
252
	$l_logout_question		= "Are you sure you want to disconnect now?";
245
	$l_loggedout			= "Your session is closed";
253
	$l_loggedout			= "Your session is closed";
246
	$l_wait				= "Please wait a moment ...";
254
	$l_wait				= "Please wait a moment ...";
247
	$l_state_label			= "State";
255
	$l_state_label			= "State";
248
	$l_session_id_label		= "Session ID";
256
	$l_session_id_label		= "Session ID";
249
	$l_max_session_time_label	= "Max Session Time";
257
	$l_max_session_time_label	= "Max Session Time";
250
	$l_max_idle_time_label		= "Max Idle Time";
258
	$l_max_idle_time_label		= "Max Idle Time";
251
	$l_start_time_label		= "Start Time";
259
	$l_start_time_label		= "Start Time";
252
	$l_session_time_label		= "Session Time";
260
	$l_session_time_label		= "Session Time";
253
	$l_idle_time_label		= "Idle Time";
261
	$l_idle_time_label		= "Idle Time";
254
	$l_downloaded_label		= "Downloaded";
262
	$l_downloaded_label		= "Downloaded";
255
	$l_uploaded_label		= "Uploaded";
263
	$l_uploaded_label		= "Uploaded";
256
	$l_original_url_label		= "Original URL";
264
	$l_original_url_label		= "Original URL";
257
	$l_not_available		= "Not available";
265
	$l_not_available		= "Not available";
258
	$l_error			= "error";
266
	$l_error			= "error";
259
	$l_welcome			= "Welcome";
267
	$l_welcome			= "Welcome";
260
	$l_conn_history			= "Your last $nb_connection_history connections";
268
	$l_conn_history			= "Your last $nb_connection_history connections";
261
	$l_connected 			= "logged"; 
269
	$l_connected 			= "logged"; 
262
	$l_a_connection			= "You have";
270
	$l_a_connection			= "You have";
263
	$l_a_connection_time		= "active connections on the network";
271
	$l_a_connection_time		= "active connections on the network";
264
	$l_close_warning		= "Warning: you will be disconnected if you close this window";
272
	$l_close_warning		= "Warning: you will be disconnected if you close this window";
-
 
273
	$l_back_homepage		= "Back to homepage";
265
}
274
}
266
 
275
 
267
if (isset($user[5])) {
276
if (isset($user[5])) {
268
	if ((is_file('acc/manager/lib/sql/drivers/mysql/functions.php')) && (is_file('/etc/freeradius-web/config.php'))) {
277
	if ((is_file('acc/manager/lib/sql/drivers/mysql/functions.php')) && (is_file('/etc/freeradius-web/config.php'))) {
269
		require_once('/etc/freeradius-web/config.php');
278
		require_once('/etc/freeradius-web/config.php');
270
		require_once('acc/manager/lib/sql/drivers/mysql/functions.php');
279
		require_once('acc/manager/lib/sql/drivers/mysql/functions.php');
271
		$link = @da_sql_pconnect($config);
280
		$link = @da_sql_pconnect($config);
272
		if ($link) {
281
		if ($link) {
273
			// Retrieve the last connections
282
			// Retrieve the last connections
274
			$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0, $nb_connection_history";
283
			$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0, $nb_connection_history";
275
			$res = @da_sql_query($link, $config, $sql);
284
			$res = @da_sql_query($link, $config, $sql);
276
			if ($res) {
285
			if ($res) {
277
				$a_connection = '';
286
				$a_connection = '';
278
				$a_connected = 0;
287
				$a_connected = 0;
279
				$connection_history = '<ul>';
288
				$connection_history = '<ul>';
280
				while (($row = @da_sql_fetch_array($res,$config))) {
289
				while (($row = @da_sql_fetch_array($res,$config))) {
281
					$start_conn = date_create($row['acctstarttime']);
290
					$start_conn = date_create($row['acctstarttime']);
282
					if (empty($row['acctstoptime'])) {
291
					if (empty($row['acctstoptime'])) {
283
						$connected = $l_connected;
292
						$connected = $l_connected;
284
						$a_connected++;
293
						$a_connected++;
285
					} else {
294
					} else {
286
						$connected = secondsToDuration($row['acctsessiontime']);
295
						$connected = secondsToDuration($row['acctsessiontime']);
287
					}
296
					}
288
					$connection_history .= '<li>'.date_format($start_conn, 'd M Y - H:i:s')." - ($connected)</li>";
297
					$connection_history .= '<li>'.date_format($start_conn, 'd M Y - H:i:s')." - ($connected)</li>";
289
				}
298
				}
290
				$connection_history .= '</ul>';
299
				$connection_history .= '</ul>';
291
				if ($a_connected > 1) {
300
				if ($a_connected > 1) {
292
					$a_connection = $l_a_connection.' '.$a_connected.' '.$l_a_connection_time;
301
					$a_connection = $l_a_connection.' '.$a_connected.' '.$l_a_connection_time;
293
				}
302
				}
294
			}
303
			}
295
 
304
 
296
			// Retrieve first name & last name
305
			// Retrieve first name & last name
297
			$sql = "SELECT Name FROM userinfo WHERE UserName='$user[5]'";
306
			$sql = "SELECT Name FROM userinfo WHERE UserName='$user[5]'";
298
			$res = @da_sql_query($link, $config, $sql);
307
			$res = @da_sql_query($link, $config, $sql);
299
			if ($res) {
308
			if ($res) {
300
				$row = @da_sql_fetch_array($res,$config);
309
				$row = @da_sql_fetch_array($res,$config);
301
				$cn = (!empty($row['name'])) ? $row['name'] : $user[5];
310
				$cn = (!empty($row['name'])) ? $row['name'] : $user[5];
302
			}
311
			}
303
		}
312
		}
304
 
313
 
305
		// Store the user @IP in a file (to test if he is still active).
314
		// Store the user @IP in a file (to test if he is still active).
306
		$filename = '/var/tmp/havp/current_users.txt';
315
		$filename = '/var/tmp/havp/current_users.txt';
307
		if (file_exists($filename)) {
316
		if (file_exists($filename)) {
308
			$current_users_file = fopen($filename, 'r');
317
			$current_users_file = fopen($filename, 'r');
309
			$content = file($filename);
318
			$content = file($filename);
310
			fclose($current_users_file);
319
			fclose($current_users_file);
311
			if (empty($content)) {
320
			if (empty($content)) {
312
				file_put_contents($filename, $_SERVER['REMOTE_ADDR']);
321
				file_put_contents($filename, $_SERVER['REMOTE_ADDR']);
313
			} else {
322
			} else {
314
				$change_me = 1; // avoid duplicate user @IP
323
				$change_me = 1; // avoid duplicate user @IP
315
				// if we found duplicate IP, we will not write user @IP (just set change_me = 0)
324
				// if we found duplicate IP, we will not write user @IP (just set change_me = 0)
316
				foreach ($content as $line) {
325
				foreach ($content as $line) {
317
				        $line = preg_replace('/\s+/', '', $line);
326
				        $line = preg_replace('/\s+/', '', $line);
318
				        if ($line === $_SERVER['REMOTE_ADDR']) {
327
				        if ($line === $_SERVER['REMOTE_ADDR']) {
319
				                $change_me = 0;
328
				                $change_me = 0;
320
				        }
329
				        }
321
				}
330
				}
322
				// if user @IP does not exist, we write it
331
				// if user @IP does not exist, we write it
323
				if ($change_me) {
332
				if ($change_me) {
324
				        file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL, FILE_APPEND);
333
				        file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL, FILE_APPEND);
325
				}
334
				}
326
			}
335
			}
327
		} else {
336
		} else {
328
			// we create filename and we write user @IP.
337
			// we create filename and we write user @IP.
329
			file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
338
			file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL);
330
		}
339
		}
331
	}
340
	}
332
}
341
}
333
 
342
 
334
// Cleaning the cache
343
// Cleaning the cache
335
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
344
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
336
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
345
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
337
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
346
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
338
header('Cache-Control: post-check=0, pre-check=0', false);
347
header('Cache-Control: post-check=0, pre-check=0', false);
339
header('Pragma: no-cache');
348
header('Pragma: no-cache');
340
?>
349
?>
341
<!DOCTYPE html>
350
<!DOCTYPE html>
342
<html>
351
<html>
343
	<head>
352
	<head>
344
		<meta charset="UTF-8">
353
		<meta charset="UTF-8">
345
		<title>ALCASAR - <?= $organisme ?></title>
354
		<title>ALCASAR - <?= $organisme ?></title>
346
		<link type="text/css" href="css/status.css" rel="stylesheet">
355
		<link type="text/css" href="css/status.css" rel="stylesheet">
347
		<script src="js/ChilliLibrary.js"></script>
356
		<script src="js/ChilliLibrary.js"></script>
348
		<script src="js/statusControler.js"></script>
357
		<script src="js/statusControler.js"></script>
349
	</head>
358
	</head>
350
	<body>
359
	<body>
351
		<div id="Chilli">
360
		<div id="Chilli">
352
			<div id="locationName"></div>
361
			<div id="locationName"></div>
353
			<div id="chilliPage">
362
			<div id="chilliPage">
354
				<div id="loggedOutPage" class="c1">
363
				<div id="loggedOutPage" class="c1">
355
					<table id="disconnectTable">
364
					<table id="disconnectTable">
356
						<tr>
365
						<tr>
357
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
366
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
-
 
367
							<td>
358
							<td><p class="text_auth"><?= $l_loggedout ?></p></td>
368
								<p class="text_auth"><?= $l_loggedout ?></p>
-
 
369
								<p class="text_homelink"><a href="<?= $homepage_url ?>"><?= $l_back_homepage ?></a></p>
-
 
370
							</td>
359
						</tr>
371
						</tr>
360
					</table>
372
					</table>
361
				</div>
373
				</div>
362
				<div id="statusPage" class="c1">
374
				<div id="statusPage" class="c1">
363
					<table border="0" id="statusTable">
375
					<table border="0" id="statusTable">
364
						<tr>
376
						<tr>
365
							<td colspan="2">
377
							<td colspan="2">
366
								<table border="0" cellpadding="0" cellspacing="0" width="100%">
378
								<table border="0" cellpadding="0" cellspacing="0" width="100%">
367
									<tr>
379
									<tr>
368
										<td valign="top" rowspan="4">
380
										<td valign="top" rowspan="4">
369
											<img height="150" src="images/logo-alcasar.png" alt="logo">
381
											<img height="150" src="images/logo-alcasar.png" alt="logo">
370
										</td>
382
										</td>
371
										<td class="text_auth_welcom">
383
										<td class="text_auth_welcom">
372
											<?= $l_login1 ?>
384
											<?= $l_login1 ?>
373
										</td>
385
										</td>
374
									</tr>
386
									</tr>
375
									<tr>
387
									<tr>
376
										<td class="text_auth">
388
										<td class="text_auth">
377
											<?= $l_welcome ?><br><?= $cn ?>
389
											<?= $l_welcome ?><br><?= $cn ?>
378
										</td>
390
										</td>
379
									</tr>
391
									</tr>
380
									<tr>
392
									<tr>
381
										<td class="alert">
393
										<td class="alert">
382
											<?= ((isset($a_connection)) ? $a_connection : '') ?>
394
											<?= ((isset($a_connection)) ? $a_connection : '') ?>
383
										</td>
395
										</td>
384
									</tr>
396
									</tr>
385
									<tr>
397
									<tr>
386
										<td colspan="2" align="center" class="link_logout">
398
										<td colspan="2" align="center" class="link_logout">
387
											<a href="#" onclick="return logoutWithConfirmation('<?= $l_logout_question ?>');" class="lien_deco"><?= $l_logout ?></a>
399
											<a href="#" onclick="return logoutWithConfirmation('<?= $l_logout_question ?>');" class="lien_deco"><?= $l_logout ?></a>
388
										</td>
400
										</td>
389
									</tr>
401
									</tr>
390
								</table>
402
								</table>
391
							</td>
403
							</td>
392
						</tr>
404
						</tr>
393
<!-- 
405
<!-- 
394
						<tr id="connectRow">
406
						<tr id="connectRow">
395
							<td id="statusMessageLabel" class="chilliLabel"><strong><?= $l_state_label ?></strong></td>
407
							<td id="statusMessageLabel" class="chilliLabel"><strong><?= $l_state_label ?></strong></td>
396
							<td id="statusMessage" class="chilliValue">Connected</td>
408
							<td id="statusMessage" class="chilliValue">Connected</td>
397
						</tr>
409
						</tr>
398
						<tr id="sessionIdRow">
410
						<tr id="sessionIdRow">
399
							<td id="sessionIdLabel" class="chilliLabel"><strong><?= $l_session_id_label ?></strong></td>
411
							<td id="sessionIdLabel" class="chilliLabel"><strong><?= $l_session_id_label ?></strong></td>
400
							<td id="sessionId" class="chilliValue"><?= $l_not_available ?></td>
412
							<td id="sessionId" class="chilliValue"><?= $l_not_available ?></td>
401
						</tr>
413
						</tr>
402
-->
414
-->
403
						<tr id="sessionTimeoutRow">
415
						<tr id="sessionTimeoutRow">
404
							<td id="sessionTimeoutLabel" class="chilliLabel"><?= $l_max_session_time_label ?></td>
416
							<td id="sessionTimeoutLabel" class="chilliLabel"><?= $l_max_session_time_label ?></td>
405
							<td id="sessionTimeout" class="chilliValue"><?= $l_not_available ?></td>
417
							<td id="sessionTimeout" class="chilliValue"><?= $l_not_available ?></td>
406
						</tr>
418
						</tr>
407
						<tr id="idleTimeoutRow">
419
						<tr id="idleTimeoutRow">
408
							<td id="idleTimeoutLabel" class="chilliLabel"><?= $l_max_idle_time_label ?></td>
420
							<td id="idleTimeoutLabel" class="chilliLabel"><?= $l_max_idle_time_label ?></td>
409
							<td id="idleTimeout" class="chilliValue"><?= $l_not_available ?></td>
421
							<td id="idleTimeout" class="chilliValue"><?= $l_not_available ?></td>
410
						</tr>
422
						</tr>
411
						<tr id="startTimeRow">
423
						<tr id="startTimeRow">
412
							<td id="startTimeLabel" class="chilliLabel"><?= $l_start_time_label ?></td>
424
							<td id="startTimeLabel" class="chilliLabel"><?= $l_start_time_label ?></td>
413
							<td id="startTime" class="chilliValue"><?= $l_not_available ?></td>
425
							<td id="startTime" class="chilliValue"><?= $l_not_available ?></td>
414
						</tr>
426
						</tr>
415
						<tr id="sessionTimeRow">
427
						<tr id="sessionTimeRow">
416
							<td id="sessionTimeLabel" class="chilliLabel"><?= $l_session_time_label ?></td>
428
							<td id="sessionTimeLabel" class="chilliLabel"><?= $l_session_time_label ?></td>
417
							<td id="sessionTime" class="chilliValue"><?= $l_not_available ?></td>
429
							<td id="sessionTime" class="chilliValue"><?= $l_not_available ?></td>
418
						</tr>
430
						</tr>
419
						<tr id="idleTimeRow">
431
						<tr id="idleTimeRow">
420
							<td id="idleTimeLabel" class="chilliLabel"><?= $l_idle_time_label ?></td>
432
							<td id="idleTimeLabel" class="chilliLabel"><?= $l_idle_time_label ?></td>
421
							<td id="idleTime" class="chilliValue"><?= $l_not_available ?></td>
433
							<td id="idleTime" class="chilliValue"><?= $l_not_available ?></td>
422
						</tr>
434
						</tr>
423
						<tr id="inputOctetsRow">
435
						<tr id="inputOctetsRow">
424
							<td id="inputOctetsLabel" class="chilliLabel"><?= $l_downloaded_label ?></td>
436
							<td id="inputOctetsLabel" class="chilliLabel"><?= $l_downloaded_label ?></td>
425
							<td id="inputOctets" class="chilliValue"><?= $l_not_available ?></td>
437
							<td id="inputOctets" class="chilliValue"><?= $l_not_available ?></td>
426
						</tr>
438
						</tr>
427
						<tr id="outputOctetsRow">
439
						<tr id="outputOctetsRow">
428
							<td id="outputOctetsLabel" class="chilliLabel"><?= $l_uploaded_label ?></td>
440
							<td id="outputOctetsLabel" class="chilliLabel"><?= $l_uploaded_label ?></td>
429
							<td id="outputOctets" class="chilliValue"><?= $l_not_available ?></td>
441
							<td id="outputOctets" class="chilliValue"><?= $l_not_available ?></td>
430
						</tr>
442
						</tr>
431
<!-- 
443
<!-- 
432
						<tr id="originalURLRow">
444
						<tr id="originalURLRow">
433
							<td id="originalURLLabel" class="chilliLabel"><?= $l_original_url_label ?></td>
445
							<td id="originalURLLabel" class="chilliLabel"><?= $l_original_url_label ?></td>
434
							<td id="originalURL" class="chilliValue"><?= $l_not_available ?></td>
446
							<td id="originalURL" class="chilliValue"><?= $l_not_available ?></td>
435
						</tr>
447
						</tr>
436
 -->
448
 -->
437
						<tr>
449
						<tr>
438
							<td colspan="2" id="conHistoryLabel" class="chilliLabel"><?= $l_conn_history ?></td>
450
							<td colspan="2" id="conHistoryLabel" class="chilliLabel"><?= $l_conn_history ?></td>
439
						</tr>
451
						</tr>
440
						<tr id="conHistoryRow">
452
						<tr id="conHistoryRow">
441
							<td colspan="2" id="conHistory" class="chilliValue"><?= $connection_history ?></td>
453
							<td colspan="2" id="conHistory" class="chilliValue"><?= $connection_history ?></td>
442
						</tr>
454
						</tr>
443
						<tr>
455
						<tr>
444
							<td colspan="2" id="close-warning">(<?= $l_close_warning ?>)</td>
456
							<td colspan="2" id="close-warning">(<?= $l_close_warning ?>)</td>
445
						</tr>
457
						</tr>
446
					</table>
458
					</table>
447
				</div>
459
				</div>
448
				<div id="waitPage">
460
				<div id="waitPage">
449
					<table id="waitTable">
461
					<table id="waitTable">
450
						<tr>
462
						<tr>
451
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
463
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
452
							<td><p class="text_auth"><img src="images/wait.gif" width="16" height="16" class="wait" alt="<?= $l_wait ?>"><?= $l_wait ?></p></td>
464
							<td><p class="text_auth"><img src="images/wait.gif" width="16" height="16" class="wait" alt="<?= $l_wait ?>"><?= $l_wait ?></p></td>
453
						</tr>
465
						</tr>
454
					</table>
466
					</table>
455
				</div>
467
				</div>
456
				<div id="errorPage">
468
				<div id="errorPage">
457
					<table id="errorTable">
469
					<table id="errorTable">
458
						<tr>
470
						<tr>
459
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
471
							<td><img height="150" src="images/logo-alcasar.png" alt="logo"></td>
460
							<td><span id="errorMessage"><?= $l_error ?></span></td>
472
							<td><span id="errorMessage"><?= $l_error ?></span></td>
461
						</tr>
473
						</tr>
462
					</table>
474
					</table>
463
				</div>
475
				</div>
464
			</div>
476
			</div>
465
		</div>
477
		</div>
466
	</body>
478
	</body>
467
</html>
479
</html>
468
 
480