mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Fixed #304 Calculate Server Time Offset [gh#304]
This commit is contained in:
parent
ddec63c4d4
commit
2f05a03e51
@ -26,7 +26,29 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
date_default_timezone_set(@date_default_timezone_get());
|
|
||||||
|
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("/", trim($date[0])));
|
||||||
|
$offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60;
|
||||||
|
}else{
|
||||||
|
exec("date +%s", trim($t[0]));
|
||||||
|
$offset = round((intval($t) - time()) / 60) * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
$daylight = (int) date("I");
|
||||||
|
|
||||||
|
if($daylight === 0){
|
||||||
|
$offset -= 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight));
|
||||||
|
|
||||||
gc_enable();
|
gc_enable();
|
||||||
error_reporting(E_ALL ^ E_NOTICE);
|
error_reporting(E_ALL ^ E_NOTICE);
|
||||||
ini_set("allow_url_fopen", 1);
|
ini_set("allow_url_fopen", 1);
|
||||||
|
@ -73,16 +73,12 @@ function safe_var_dump($var, $cnt = 0){
|
|||||||
function kill($pid){
|
function kill($pid){
|
||||||
switch(Utils::getOS()){
|
switch(Utils::getOS()){
|
||||||
case "win":
|
case "win":
|
||||||
ob_start();
|
exec("taskkill.exe /F /PID ".((int) $pid)." > NUL");
|
||||||
passthru("%WINDIR%\\System32\\taskkill.exe /F /PID ".((int) $pid)." > NUL");
|
|
||||||
ob_end_clean();
|
|
||||||
break;
|
break;
|
||||||
case "mac":
|
case "mac":
|
||||||
case "linux":
|
case "linux":
|
||||||
default:
|
default:
|
||||||
ob_start();
|
exec("kill -9 ".((int) $pid)." > /dev/null 2>&1");
|
||||||
passthru("kill -9 ".((int) $pid)." > /dev/null 2>&1");
|
|
||||||
ob_end_clean();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,6 @@ define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? BIG_ENDIAN:LITTLE
|
|||||||
class Utils{
|
class Utils{
|
||||||
public static $online = true;
|
public static $online = true;
|
||||||
public static $ip = false;
|
public static $ip = false;
|
||||||
public function run(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isOnline(){
|
public static function isOnline(){
|
||||||
return ((@fsockopen("google.com", 80) !== false or @fsockopen("www.linux.org", 80) !== false or @fsockopen("www.php.net", 80) !== false) ? true:false);
|
return ((@fsockopen("google.com", 80) !== false or @fsockopen("www.linux.org", 80) !== false or @fsockopen("www.php.net", 80) !== false) ? true:false);
|
||||||
@ -73,11 +70,11 @@ class Utils{
|
|||||||
|
|
||||||
public static function getOS(){
|
public static function getOS(){
|
||||||
$uname = trim(strtoupper(php_uname("s")));
|
$uname = trim(strtoupper(php_uname("s")));
|
||||||
if(strpos($uname, "DARWIN") !== false or $uname === "DARWIN"){
|
if(strpos($uname, "DARWIN") !== false){
|
||||||
return "mac";
|
return "mac";
|
||||||
}elseif(strpos($uname, "WIN") !== false or $uname === "WIN"){
|
}elseif(strpos($uname, "WIN") !== false){
|
||||||
return "win";
|
return "win";
|
||||||
}elseif(strpos($uname, "LINUX") !== false or $uname === "LINUX"){
|
}elseif(strpos($uname, "LINUX") !== false){
|
||||||
return "linux";
|
return "linux";
|
||||||
}else{
|
}else{
|
||||||
return "other";
|
return "other";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user