Set Timezone in all places and it needs to be set in and sperated it into a seperate include

This commit is contained in:
johnnyq 2024-04-17 12:53:11 -04:00
parent 7c10bbacd7
commit 888552724a
16 changed files with 59 additions and 31 deletions

View File

@ -22,6 +22,9 @@ if (!isset($_SESSION['logged']) || !$_SESSION['logged']) {
exit;
}
// Set Timezone
require_once "inc_set_timezone.php";
// User IP & UA
$session_ip = sanitizeInput(getIP());
$session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);
@ -52,14 +55,6 @@ $session_company_name = $row['company_name'];
$session_company_country = $row['company_country'];
$session_company_locale = $row['company_locale'];
$session_company_currency = $row['company_currency'];
$session_timezone = $row['config_timezone'];
// Set Timezone to the companies timezone
// 2024-02-08 JQ - The option to set the timezone in PHP was disabled to prevent inconsistencies with MariaDB/MySQL, which utilize the system's timezone, It is now consdered best practice to set the timezone on system itself
//date_default_timezone_set($session_timezone);
// 2024-03-21 JQ - Re-Enabled Timezone setting as new PHP update does not respect System Time but defaulted to UTC
date_default_timezone_set($session_timezone);
//Set Currency Format
$currency_format = numfmt_create($session_company_locale, NumberFormatter::CURRENCY);

View File

@ -5,6 +5,9 @@ chdir(dirname(__FILE__));
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
@ -32,7 +35,6 @@ $config_invoice_from_email = sanitizeInput($row['config_invoice_from_email']);
$config_invoice_from_name = sanitizeInput($row['config_invoice_from_name']);
$config_invoice_late_fee_enable = intval($row['config_invoice_late_fee_enable']);
$config_invoice_late_fee_percent = floatval($row['config_invoice_late_fee_percent']);
$config_timezone = sanitizeInput($row['config_timezone']);
// Mail Settings
$config_smtp_host = $row['config_smtp_host'];
@ -71,9 +73,6 @@ $config_login_remember_me_expire = intval($row['config_login_remember_me_expire'
// Set Currency Format
$currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY);
// Set Timezone
date_default_timezone_set($config_timezone);
$argv = $_SERVER['argv'];
// Check cron is enabled

View File

@ -2,6 +2,9 @@
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
@ -12,10 +15,6 @@ $row = mysqli_fetch_array($sql_settings);
// Company Settings
$config_enable_cron = intval($row['config_enable_cron']);
$config_cron_key = $row['config_cron_key'];
$config_timezone = sanitizeInput($row['config_timezone']);
// Set Timezone
date_default_timezone_set($config_timezone);
$argv = $_SERVER['argv'];

View File

@ -2,6 +2,9 @@
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
@ -12,10 +15,6 @@ $row = mysqli_fetch_array($sql_settings);
// Company Settings
$config_enable_cron = intval($row['config_enable_cron']);
$config_cron_key = $row['config_cron_key'];
$config_timezone = sanitizeInput($row['config_timezone']);
// Set Timezone
date_default_timezone_set($config_timezone);
$argv = $_SERVER['argv'];

View File

@ -1,6 +1,10 @@
<?php
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
$sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1");
@ -15,10 +19,6 @@ $config_smtp_username = $row['config_smtp_username'];
$config_smtp_password = $row['config_smtp_password'];
$config_smtp_port = intval($row['config_smtp_port']);
$config_smtp_encryption = $row['config_smtp_encryption'];
$config_timezone = sanitizeInput($row['config_timezone']);
// Set Timezone
date_default_timezone_set($config_timezone);
$argv = $_SERVER['argv'];

View File

@ -18,6 +18,9 @@ chdir(dirname(__FILE__));
// Get ITFlow config & helper functions
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
// Get settings for the "default" company
@ -31,10 +34,6 @@ $sql = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE companies.
$row = mysqli_fetch_array($sql);
$company_name = sanitizeInput($row['company_name']);
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone']));
$config_timezone = sanitizeInput($row['config_timezone']);
// Set Timezone
date_default_timezone_set($config_timezone);
// Check setting enabled
if ($config_ticket_email_parse == 0) {

View File

@ -8,6 +8,9 @@
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";
require_once "rfc6238.php";

View File

@ -2,6 +2,9 @@
// Not including the guest header as we don't want any HTML output
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";

View File

@ -2,6 +2,9 @@
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";

View File

@ -2,6 +2,9 @@
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
require_once "functions.php";

13
inc_set_timezone.php Normal file
View File

@ -0,0 +1,13 @@
<?php
// Set Timezone to the companies timezone
// 2024-02-08 JQ - The option to set the timezone in PHP was disabled to prevent inconsistencies with MariaDB/MySQL, which utilize the system's timezone, It is now consdered best practice to set the timezone on system itself
//date_default_timezone_set($session_timezone);
// 2024-03-21 JQ - Re-Enabled Timezone setting as new PHP update does not respect System Time but defaulted to UTC
$sql_timezone = mysqli_query($mysqli, "SELECT config_timezone FROM settings WHERE company_id = 1");
$row_timezone = mysqli_fetch_array($sql_timezone);
$session_timezone = $row_timezone['config_timezone'];
date_default_timezone_set($session_timezone);

View File

@ -10,6 +10,8 @@ if (!file_exists('config.php')) {
require_once "config.php";
// Set Timezone
require_once "inc_set_timezone.php";
// Check if the application is configured for HTTPS-only access
if ($config_https_only && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') && (!isset($_SERVER['HTTP_X_FORWARDED_PROTO']) || $_SERVER['HTTP_X_FORWARDED_PROTO'] !== 'https')) {

View File

@ -20,6 +20,9 @@ if (!isset($_SESSION['client_logged_in']) || !$_SESSION['client_logged_in']) {
die;
}
// Set Timezone
require_once "../inc_set_timezone.php";
// User IP & UA
$session_ip = sanitizeInput(getIP());
$session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);

View File

@ -6,12 +6,14 @@
header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.gstatic.com");
$session_company_id = 1;
require_once '../config.php';
// Set Timezone
require_once "../inc_set_timezone.php";
require_once '../functions.php';
require_once ('../get_settings.php');
require_once '../get_settings.php';
if (!isset($_SESSION)) {
// HTTP Only cookies

View File

@ -6,6 +6,9 @@
require_once '../config.php';
// Set Timezone
require_once "../inc_set_timezone.php";
require_once '../functions.php';

View File

@ -6,9 +6,11 @@
header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.gstatic.com");
$session_company_id = 1;
require_once '../config.php';
// Set Timezone
require_once "inc_set_timezone.php";
require_once '../functions.php';
require_once '../get_settings.php';