mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-15 07:55:31 +00:00
Added online check
This commit is contained in:
parent
b589b69beb
commit
bf5df18170
@ -26,6 +26,9 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function UPnP_PortForward($port){
|
function UPnP_PortForward($port){
|
||||||
|
if(Utils::$online === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(Utils::getOS() != "win" or !class_exists("COM")){
|
if(Utils::getOS() != "win" or !class_exists("COM")){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -44,6 +47,9 @@ function UPnP_PortForward($port){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function UPnP_RemovePortForward($port){
|
function UPnP_RemovePortForward($port){
|
||||||
|
if(Utils::$online === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(Utils::getOS() != "win" or !class_exists("COM")){
|
if(Utils::getOS() != "win" or !class_exists("COM")){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,19 @@ define("LITTLE_ENDIAN", 0x01);
|
|||||||
define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? BIG_ENDIAN:LITTLE_ENDIAN));
|
define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? BIG_ENDIAN:LITTLE_ENDIAN));
|
||||||
|
|
||||||
class Utils extends Thread{
|
class Utils extends Thread{
|
||||||
|
public static $online = true;
|
||||||
public function run(){
|
public function run(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isOnline(){
|
||||||
|
return (checkdnsrr("google.com", "ANY") && checkdnsrr("yahoo.com", "ANY") && checkdnsrr("microsoft.com", "ANY"));
|
||||||
|
}
|
||||||
|
|
||||||
public static function getIP(){
|
public static function getIP(){
|
||||||
|
if(Utils::$online === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$ip = "";//trim(Utils::curl_get("http://automation.whatismyip.com/n09230945.asp"));
|
$ip = "";//trim(Utils::curl_get("http://automation.whatismyip.com/n09230945.asp"));
|
||||||
if($ip != ""){
|
if($ip != ""){
|
||||||
return $ip;
|
return $ip;
|
||||||
@ -332,6 +339,9 @@ class Utils extends Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function curl_get($page){
|
public static function curl_get($page){
|
||||||
|
if(Utils::$online === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$ch = curl_init($page);
|
$ch = curl_init($page);
|
||||||
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_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);
|
||||||
@ -346,6 +356,9 @@ class Utils extends Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function curl_post($page, $args, $timeout = 10){
|
public static function curl_post($page, $args, $timeout = 10){
|
||||||
|
if(Utils::$online === false){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$ch = curl_init($page);
|
$ch = curl_init($page);
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
||||||
@ -516,4 +529,8 @@ class Utils extends Thread{
|
|||||||
return strrev(str_pad($long->toBytes(true), 8, "\x00", STR_PAD_LEFT));
|
return strrev(str_pad($long->toBytes(true), 8, "\x00", STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Utils::isOnline() === false){
|
||||||
|
Utils::$online = false;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user