fix: do not rely on /etc/timezone to get the time zone. timedatectl does not update it immediately (anymore), it only gets updated after a reboot
This commit is contained in:
+6
-20
@@ -4,27 +4,13 @@
|
||||
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
|
||||
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
|
||||
|
||||
$sys_timezone = "";
|
||||
// If we can get the timezome from the systems timezone file ust that
|
||||
if (file_exists('/etc/timezone')) {
|
||||
$tz_data = file_get_contents('/etc/timezone');
|
||||
if ($tz_data !== false) {
|
||||
$sys_timezone = trim($tz_data);
|
||||
}
|
||||
} else {
|
||||
// else get timezone from the timedatectl command
|
||||
$tz_data = shell_exec('timedatectl show');
|
||||
$tz_data_array = parse_ini_string($tz_data);
|
||||
if (is_array($tz_data_array) && array_key_exists('Timezone', $tz_data_array)) {
|
||||
$sys_timezone = $tz_data_array['Timezone'];
|
||||
}
|
||||
}
|
||||
// finally if we have a valod timezone, set it as the one PHP uses
|
||||
if ($sys_timezone !== "") {
|
||||
date_default_timezone_set($sys_timezone);
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
if(!isset($_SESSION['my_timezone'])) {
|
||||
$_SESSION['my_timezone'] = trim(shell_exec('timedatectl show --value --property=Timezone'));
|
||||
}
|
||||
date_default_timezone_set($_SESSION['my_timezone']);
|
||||
|
||||
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
|
||||
$user = trim($user);
|
||||
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
|
||||
|
||||
Reference in New Issue
Block a user