Subversion Repositories ALCASAR

Rev

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

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