Subversion Repositories ALCASAR

Rev

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

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