Subversion Repositories ALCASAR

Rev

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

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