Subversion Repositories ALCASAR

Rev

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

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