mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Send optional usage data
This commit is contained in:
parent
8e3efa0b7e
commit
f476cf6943
@ -102,6 +102,7 @@ class ServerAPI{
|
||||
"level-name" => false,
|
||||
"server-id" => false,
|
||||
"upnp-forwarding" => false,
|
||||
"send-usage" => true,
|
||||
));
|
||||
$this->parseProperties();
|
||||
define("DEBUG", $this->getProperty("debug"));
|
||||
@ -223,6 +224,18 @@ class ServerAPI{
|
||||
|
||||
$this->server->loadEntities();
|
||||
}
|
||||
|
||||
public function sendUsage(){
|
||||
console("[INTERNAL] Sending usage data...", true, true, 3);
|
||||
Utils::curl_post("http://www.pocketmine.org/usage.php", array(
|
||||
"serverid" => $this->server->serverID,
|
||||
"os" => Utils::getOS(),
|
||||
"version" => MAJOR_VERSION,
|
||||
"protocol" => CURRENT_PROTOCOL,
|
||||
"online" => count($this->clients),
|
||||
"max" => $this->maxClients,
|
||||
));
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
foreach($this->apiList as $ob){
|
||||
@ -295,6 +308,10 @@ class ServerAPI{
|
||||
}
|
||||
|
||||
public function init(){
|
||||
if($this->getProperty("send-usage") !== false){
|
||||
$this->server->schedule(36000, array($this, "sendUsage"), array(), true); //Send usage data every 30 minutes
|
||||
$this->sendUsage();
|
||||
}
|
||||
$this->server->init();
|
||||
unregister_tick_function(array($this->server, "tick"));
|
||||
$this->__destruct();
|
||||
|
@ -49,27 +49,23 @@ class Utils extends Thread{
|
||||
if(Utils::$online === false){
|
||||
return false;
|
||||
}
|
||||
$ip = "";//trim(Utils::curl_get("http://automation.whatismyip.com/n09230945.asp"));
|
||||
if($ip != ""){
|
||||
return $ip;
|
||||
$ip = trim(strip_tags(Utils::curl_get("http://checkip.dyndns.org/")));
|
||||
if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||
return $matches[1];
|
||||
}else{
|
||||
trim(strip_tags(Utils::curl_get("http://checkip.dyndns.org/")));
|
||||
if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||
$ip = Utils::curl_get("http://www.checkip.org/");
|
||||
if(preg_match('#">([0-9a-fA-F\:\.]*)</span>#', $ip, $matches) > 0){
|
||||
return $matches[1];
|
||||
}else{
|
||||
$ip = Utils::curl_get("http://www.checkip.org/");
|
||||
if(preg_match('#">([0-9a-fA-F\:\.]*)</span>#', $ip, $matches) > 0){
|
||||
$ip = Utils::curl_get("http://checkmyip.org/");
|
||||
if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||
return $matches[1];
|
||||
}else{
|
||||
$ip = Utils::curl_get("http://checkmyip.org/");
|
||||
if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||
return $matches[1];
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getOS(){
|
||||
|
@ -60,6 +60,8 @@ define("MC_UPDATE_BLOCK", 0x97);
|
||||
|
||||
define("MC_EXPLOSION", 0x99);
|
||||
|
||||
define("MC_LEVEL_EVENT", 0x9a);
|
||||
|
||||
define("MC_ENTITY_EVENT", 0x9c);
|
||||
define("MC_REQUEST_CHUNK", 0x9d);
|
||||
define("MC_CHUNK_DATA", 0x9e);
|
||||
|
@ -61,6 +61,8 @@ $dataName = array(
|
||||
MC_UPDATE_BLOCK => "UpdateBlock",
|
||||
|
||||
MC_EXPLOSION => "Explosion",
|
||||
|
||||
MC_LEVEL_EVENT => "LevelEvent",
|
||||
|
||||
MC_ENTITY_EVENT => "EntityEvent",
|
||||
MC_REQUEST_CHUNK => "RequestChunk",
|
||||
|
Loading…
x
Reference in New Issue
Block a user