mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +00:00
Show External IP
This commit is contained in:
parent
ab2b519c2e
commit
2665dffdd8
@ -102,6 +102,9 @@ class ServerAPI{
|
|||||||
console("[INFO] [UPnP] Trying to port forward...");
|
console("[INFO] [UPnP] Trying to port forward...");
|
||||||
UPnP_PortForward($this->getProperty("port"));
|
UPnP_PortForward($this->getProperty("port"));
|
||||||
}
|
}
|
||||||
|
if(($ip = Utils::getIP()) !== false){
|
||||||
|
console("[INFO] External IP: ".$ip);
|
||||||
|
}
|
||||||
if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
|
if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
|
||||||
console("[INFO] Checking for new server version");
|
console("[INFO] Checking for new server version");
|
||||||
console("[INFO] Last check: ".date("Y-m-d H:i:s", $this->getProperty("last-update")));
|
console("[INFO] Last check: ".date("Y-m-d H:i:s", $this->getProperty("last-update")));
|
||||||
|
@ -41,6 +41,21 @@ class Utils extends Thread{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getIP(){
|
||||||
|
$ip = trim(Utils::curl_get("http://automation.whatismyip.com/n09230945.asp"));
|
||||||
|
if($ip != ""){
|
||||||
|
return $ip;
|
||||||
|
}else{
|
||||||
|
$ip = trim(Utils::curl_get("http://checkip.dyndns.org/"));
|
||||||
|
$ip = preg_replace("/Current IP Address: (.*)/", '$1', $ip);
|
||||||
|
if($ip != ""){
|
||||||
|
return $ip;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function getOS(){
|
public static function getOS(){
|
||||||
$uname = strtoupper(php_uname("s"));
|
$uname = strtoupper(php_uname("s"));
|
||||||
if(strpos($uname, "WIN") !== false){
|
if(strpos($uname, "WIN") !== false){
|
||||||
@ -310,7 +325,7 @@ class Utils extends Thread{
|
|||||||
|
|
||||||
public static function curl_get($page){
|
public static function curl_get($page){
|
||||||
$ch = curl_init($page);
|
$ch = curl_init($page);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Minecraft PHP Client 2"));
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP"));
|
||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
@ -328,7 +343,7 @@ class Utils extends Thread{
|
|||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Minecraft PHP Client 2"));
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 PocketMine-MP"));
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int) $timeout);
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int) $timeout);
|
||||||
$ret = curl_exec($ch);
|
$ret = curl_exec($ch);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user