Subversion Repositories ALCASAR

Rev

Rev 3026 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3026 Rev 3165
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: status.php 3026 2022-06-30 21:53:54Z rexy $
2
# $Id: status.php 3165 2024-01-10 10:34:50Z rexy $
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
/****************************************************************
Line 48... Line 48...
48
$useHTTPS = ((isset($_SERVER['HTTPS'])) && (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] !== 'off'));
48
$useHTTPS = ((isset($_SERVER['HTTPS'])) && (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] !== 'off'));
49
$service_wifi4eu_status = ($conf['WIFI4EU'] === 'on');
49
$service_wifi4eu_status = ($conf['WIFI4EU'] === 'on');
50
$service_wifi4eu_code = $conf['WIFI4EU_CODE'];
50
$service_wifi4eu_code = $conf['WIFI4EU_CODE'];
51
$service_wifi4eu_server = 'https://collection.wifi4eu.ec.europa.eu/wifi4eu.min.js';
51
$service_wifi4eu_server = 'https://collection.wifi4eu.ec.europa.eu/wifi4eu.min.js';
52
 
52
 
-
 
53
// Redirection if HTTPS needed and not used
-
 
54
if (($conf['HTTPS_LOGIN'] === 'on') && (!$useHTTPS)) {
-
 
55
	header('HTTP/1.1 301 Moved Permanently');
-
 
56
	header('Location: https://'.$conf['HOSTNAME'].'.'.$conf['DOMAIN'].'/status.php');
-
 
57
	exit();
-
 
58
}
-
 
59
 
53
// Wait for chilli (update its tables)
60
// Wait for chilli (update its tables)
54
sleep(1); // TODO: wait after login only?
61
sleep(1); // TODO: wait after login only?
55
// Retrieve user info in tab $user[]
62
// Retrieve user info in tab $user[]
56
exec("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
63
exec("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
57
if (isset($tab[0])) {
64
if (isset($tab[0])) {
Line 66... Line 73...
66
	$time[1] = ($temp - $time[2]) / 60;	// minutes
73
	$time[1] = ($temp - $time[2]) / 60;	// minutes
67
	$time[0] = ($seconds - $temp) / 3600 ;	// hours
74
	$time[0] = ($seconds - $temp) / 3600 ;	// hours
68
	return $time[0].' h '.$time[1].' m '.$time[2].' s';
75
	return $time[0].' h '.$time[1].' m '.$time[2].' s';
69
}
76
}
70
 
77
 
71
# Choice of language
78
// Choice of language
72
// TODO: reste quelques traductions à faire
-
 
73
$Language = 'en';
79
$Language = 'en';
74
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
80
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
75
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
81
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
76
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
82
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
77
}
83
}
Line 321... Line 327...
321
 
327
 
322
	$filename = '/tmp/current_users.txt';
328
	$filename = '/tmp/current_users.txt';
323
	$user_needKeepOpen = (preg_match("/^$remote_ip:PERM/m", file_get_contents($filename)) === 0);
329
	$user_needKeepOpen = (preg_match("/^$remote_ip:PERM/m", file_get_contents($filename)) === 0);
324
}
330
}
325
 
331
 
326
////////////////////////////////////////////////////////////////////////////////////////
-
 
327
/////////////////////// TEST VARIABLES ///////////////////////
-
 
328
//////////////////////////////////////////////////////////////
-
 
329
//$nb_open_session = 2;      // >2
-
 
330
//$user_needKeepOpen = true;      // true/false
-
 
331
////////////////////////////////////////////////////////////////////////////////////////
-
 
332
 
-
 
333
// Cleaning the cache
332
// Cleaning the cache
334
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
333
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
335
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
334
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
336
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
335
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
337
header('Cache-Control: post-check=0, pre-check=0', false);
336
header('Cache-Control: post-check=0, pre-check=0', false);