Subversion Repositories ALCASAR

Rev

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

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