mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Send optional usage data
This commit is contained in:
parent
8e3efa0b7e
commit
f476cf6943
@ -102,6 +102,7 @@ class ServerAPI{
|
|||||||
"level-name" => false,
|
"level-name" => false,
|
||||||
"server-id" => false,
|
"server-id" => false,
|
||||||
"upnp-forwarding" => false,
|
"upnp-forwarding" => false,
|
||||||
|
"send-usage" => true,
|
||||||
));
|
));
|
||||||
$this->parseProperties();
|
$this->parseProperties();
|
||||||
define("DEBUG", $this->getProperty("debug"));
|
define("DEBUG", $this->getProperty("debug"));
|
||||||
@ -224,6 +225,18 @@ class ServerAPI{
|
|||||||
$this->server->loadEntities();
|
$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(){
|
public function __destruct(){
|
||||||
foreach($this->apiList as $ob){
|
foreach($this->apiList as $ob){
|
||||||
if(is_callable($ob, "__destruct")){
|
if(is_callable($ob, "__destruct")){
|
||||||
@ -295,6 +308,10 @@ class ServerAPI{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function init(){
|
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();
|
$this->server->init();
|
||||||
unregister_tick_function(array($this->server, "tick"));
|
unregister_tick_function(array($this->server, "tick"));
|
||||||
$this->__destruct();
|
$this->__destruct();
|
||||||
|
@ -49,27 +49,23 @@ class Utils extends Thread{
|
|||||||
if(Utils::$online === false){
|
if(Utils::$online === false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$ip = "";//trim(Utils::curl_get("http://automation.whatismyip.com/n09230945.asp"));
|
$ip = trim(strip_tags(Utils::curl_get("http://checkip.dyndns.org/")));
|
||||||
if($ip != ""){
|
if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||||
return $ip;
|
return $matches[1];
|
||||||
}else{
|
}else{
|
||||||
trim(strip_tags(Utils::curl_get("http://checkip.dyndns.org/")));
|
$ip = Utils::curl_get("http://www.checkip.org/");
|
||||||
if(preg_match('#Current IP Address\: ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
if(preg_match('#">([0-9a-fA-F\:\.]*)</span>#', $ip, $matches) > 0){
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
}else{
|
}else{
|
||||||
$ip = Utils::curl_get("http://www.checkip.org/");
|
$ip = Utils::curl_get("http://checkmyip.org/");
|
||||||
if(preg_match('#">([0-9a-fA-F\:\.]*)</span>#', $ip, $matches) > 0){
|
if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
}else{
|
}else{
|
||||||
$ip = Utils::curl_get("http://checkmyip.org/");
|
return false;
|
||||||
if(preg_match('#Your IP address is ([0-9a-fA-F\:\.]*)#', $ip, $matches) > 0){
|
|
||||||
return $matches[1];
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOS(){
|
public static function getOS(){
|
||||||
|
@ -60,6 +60,8 @@ define("MC_UPDATE_BLOCK", 0x97);
|
|||||||
|
|
||||||
define("MC_EXPLOSION", 0x99);
|
define("MC_EXPLOSION", 0x99);
|
||||||
|
|
||||||
|
define("MC_LEVEL_EVENT", 0x9a);
|
||||||
|
|
||||||
define("MC_ENTITY_EVENT", 0x9c);
|
define("MC_ENTITY_EVENT", 0x9c);
|
||||||
define("MC_REQUEST_CHUNK", 0x9d);
|
define("MC_REQUEST_CHUNK", 0x9d);
|
||||||
define("MC_CHUNK_DATA", 0x9e);
|
define("MC_CHUNK_DATA", 0x9e);
|
||||||
|
@ -62,6 +62,8 @@ $dataName = array(
|
|||||||
|
|
||||||
MC_EXPLOSION => "Explosion",
|
MC_EXPLOSION => "Explosion",
|
||||||
|
|
||||||
|
MC_LEVEL_EVENT => "LevelEvent",
|
||||||
|
|
||||||
MC_ENTITY_EVENT => "EntityEvent",
|
MC_ENTITY_EVENT => "EntityEvent",
|
||||||
MC_REQUEST_CHUNK => "RequestChunk",
|
MC_REQUEST_CHUNK => "RequestChunk",
|
||||||
MC_CHUNK_DATA => "ChunkData",
|
MC_CHUNK_DATA => "ChunkData",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user