Subversion Repositories ALCASAR

Rev

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

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