From d4c75ce68af7c15fbd459d0957649f716b93f261 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Sun, 5 Oct 2014 17:40:17 +1030 Subject: [PATCH] Trim system timezone output --- src/pocketmine/PocketMine.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 809a0d88c..1b497efcc 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -133,7 +133,7 @@ function dummy(){ $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); if(!ini_get("date.timezone")){ - if(($timezone = trim(detect_system_timezone())) and date_default_timezone_set($timezone)){ + if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){ //Success! Timezone has already been set and validated in the if statement. //This here is just for redundancy just in case some stupid program wants to read timezone data from the ini. ini_set("date.timezone", $timezone); @@ -171,7 +171,7 @@ function detect_system_timezone(){ exec("systeminfo", $output); - $string = implode("\n", $output); + $string = trim(implode("\n", $output)); //Detect the Time Zone string in systeminfo preg_match($regex, $string, $matches); @@ -189,7 +189,7 @@ function detect_system_timezone(){ if(file_exists('/etc/timezone')){ $data = file_get_contents('/etc/timezone'); if($data){ - return $data; + return trim($data); } } @@ -197,7 +197,7 @@ function detect_system_timezone(){ if(file_exists('/etc/sysconfig/clock')){ $data = parse_ini_file('/etc/sysconfig/clock'); if(!empty($data['ZONE'])){ - return $data['ZONE']; + return trim($data['ZONE']); } } @@ -216,7 +216,7 @@ function detect_system_timezone(){ $filename = readlink('/etc/localtime'); if(strpos($filename, '/usr/share/zoneinfo/') === 0){ $timezone = substr($filename, 20); - return $timezone; + return trim($timezone); } }