From 2f44e5e76df63878ae2496eac8c07cc0a0b0709d Mon Sep 17 00:00:00 2001 From: ArkQuark <74979909+ArkQuark@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:19:49 +0300 Subject: [PATCH] Update config.php --- src/config.php | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) mode change 100755 => 100644 src/config.php diff --git a/src/config.php b/src/config.php old mode 100755 new mode 100644 index 197ac88d..331cab11 --- a/src/config.php +++ b/src/config.php @@ -21,24 +21,36 @@ set_time_limit(0); -date_default_timezone_set("GMT"); -if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ - $time = time(); - $time -= $time % 60; - exec("time.exe /T", $hour); - $i = array_map("intval", explode(":", trim($hour[0]))); - exec("date.exe /T", $date); - $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); - $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; +if(ini_get("date.timezone") == ""){ //No Timezone set + date_default_timezone_set("GMT"); + if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ + $time = time(); + $time -= $time % 60; + //TODO: Parse different time & date formats by region. ¬¬ world + //Example: USA + exec("time.exe /T", $hour); + $i = array_map("intval", explode(":", trim($hour[0]))); + exec("date.exe /T", $date); + $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); + $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; + }else{ + exec("date +%s", $t); + $offset = round((intval(trim($t[0])) - time()) / 60) * 60; + } + + $daylight = (int) date("I"); + $d = timezone_name_from_abbr("", $offset, $daylight); + @ini_set("date.timezone", $d); + date_default_timezone_set($d); }else{ - exec("date +%s", $t); - $offset = round((intval(trim($t[0])) - time()) / 60) * 60; + $d = @date_default_timezone_get(); + if(strpos($d, "/") === false){ + $d = timezone_name_from_abbr($d); + @ini_set("date.timezone", $d); + date_default_timezone_set($d); + } } -$daylight = (int) date("I"); - -date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight)); - gc_enable(); error_reporting(E_ALL | E_STRICT); ini_set("allow_url_fopen", 1); @@ -56,7 +68,7 @@ ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); define("MAJOR_VERSION", "1.0 (Alpha_1.3.12)"); -define("CODENAME", "懐かしさ (Nostalgia)"); +define("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha"); define("CURRENT_API_VERSION", 12); define("CURRENT_PHP_VERSION", "5.5"); @@ -65,4 +77,4 @@ if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information! define("GIT_COMMIT", strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master")))); }else{ //Unknown :( define("GIT_COMMIT", str_repeat("00", 20)); -} \ No newline at end of file +}