php 5.3 compatiblity
This commit is contained in:
committed by
Steffen Schröder
parent
ea9c929ec3
commit
7408ffb4ac
@ -26,7 +26,6 @@ use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Server\Server;
|
||||
use ManiaControl\Server\ServerCommands;
|
||||
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $index => $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_OPENSESSION);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_OPENSESSION);
|
||||
} else if ($index <= 0) {
|
||||
$responseData = $methodResponse[0];
|
||||
$self->dedimaniaData->sessionId = $responseData['SessionId'];
|
||||
@ -213,7 +213,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $index => $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_PLAYERCONNECT);
|
||||
} else if ($index <= 0) {
|
||||
$responseData = $methodResponse[0];
|
||||
$self->dedimaniaData->addPlayer(new DedimaniaPlayer($responseData));
|
||||
@ -223,8 +223,8 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
$self->fetchDedimaniaRecords(true);
|
||||
}
|
||||
}
|
||||
if ($self->maniaControl->settingManager->getSetting($self, self::SETTING_WIDGET_ENABLE)) {
|
||||
$manialink = $this->buildManialink();
|
||||
if ($self->maniaControl->settingManager->getSetting($self, Dedimania::SETTING_WIDGET_ENABLE)) {
|
||||
$manialink = $self->buildManialink();
|
||||
$self->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_PLAYERDISCONNECT);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -334,11 +334,11 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $this->decode($data);
|
||||
$data = $self->decode($data);
|
||||
if (is_array($data)) {
|
||||
foreach($data as $index => $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SETCHALLENGETIMES);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_SETCHALLENGETIMES);
|
||||
} else {
|
||||
if ($index <= 0) {
|
||||
// Called method response
|
||||
@ -351,6 +351,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
|
||||
// Warnings and TTR
|
||||
$errors = $methodResponse[0]['methods'][0]['errors'];
|
||||
//TODO ?
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -384,7 +385,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATESERVERPLAYERS);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_UPDATESERVERPLAYERS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -616,7 +617,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $index => $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GETRECORDS);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_GETRECORDS);
|
||||
return false;
|
||||
} else if ($index <= 0) {
|
||||
$responseData = $methodResponse[0];
|
||||
@ -633,8 +634,8 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
$self->updateManialink = true;
|
||||
$self->maniaControl->callbackManager->triggerCallback(Dedimania::CB_DEDIMANIA_UPDATED, $self->dedimaniaData->records);
|
||||
return true;
|
||||
}, $content, true);
|
||||
|
||||
@ -662,7 +663,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
|
||||
if (is_array($data)) {
|
||||
foreach($data as $methodResponse) {
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECKSESSION);
|
||||
$self->handleXmlRpcFault($methodResponse, Dedimania::DEDIMANIA_CHECKSESSION);
|
||||
} else {
|
||||
$responseData = $methodResponse[0];
|
||||
if (is_bool($responseData)) {
|
||||
|
@ -331,30 +331,31 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
}
|
||||
|
||||
//Send and Handle the Bill
|
||||
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$player, $amount, $receiver) {
|
||||
$self = $this;
|
||||
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||
switch($status) {
|
||||
case BillManager::DONATED_TO_SERVER:
|
||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $this->maniaControl->settingManager->getSetting($this, self::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
||||
if ($self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSetting($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
||||
$login = null;
|
||||
$message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.';
|
||||
} else {
|
||||
$login = $player->login;
|
||||
$message = 'Donation successful! Thanks.';
|
||||
}
|
||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->index, $amount);
|
||||
$self->maniaControl->chat->sendSuccess($message, $login);
|
||||
$self->maniaControl->statisticManager->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $self->maniaControl->server->index, $amount);
|
||||
break;
|
||||
case BillManager::DONATED_TO_RECEIVER:
|
||||
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
||||
$this->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
break;
|
||||
case BillManager::PLAYER_REFUSED_DONATION:
|
||||
$message = 'Transaction cancelled.';
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
case BillManager::ERROR_WHILE_TRANSACTION:
|
||||
$message = $data;
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
}
|
||||
}, $player, $amount, $message);
|
||||
@ -392,19 +393,20 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
}
|
||||
$message = 'Payout from $<' . $this->maniaControl->client->getServerName() . '$>.';
|
||||
|
||||
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$player, $amount, $receiver) {
|
||||
$self = $this;
|
||||
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||
switch($status) {
|
||||
case BillManager::PAYED_FROM_SERVER:
|
||||
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
||||
$this->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
break;
|
||||
case BillManager::PLAYER_REFUSED_DONATION:
|
||||
$message = 'Transaction cancelled.';
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
case BillManager::ERROR_WHILE_TRANSACTION:
|
||||
$message = $data;
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
}
|
||||
}, $receiver, $amount, $message);
|
||||
|
@ -655,23 +655,24 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$this->mxKarma['connectionInProgress'] = true;
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($mxKarmaCode) {
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use (&$self, $mxKarmaCode) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
$this->mxKarma['session'] = $data->data;
|
||||
$this->activateSession($mxKarmaCode);
|
||||
$self->mxKarma['session'] = $data->data;
|
||||
$self->activateSession($mxKarmaCode);
|
||||
} else {
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
$self->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->log($error);
|
||||
$self->maniaControl->log($error);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, "application/json", 1000);
|
||||
}
|
||||
@ -688,26 +689,27 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey);
|
||||
$query .= '&activationHash=' . urlencode($hash);
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($query) {
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use (&$self, $query) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success && $data->data->activated) {
|
||||
$this->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
$self->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
|
||||
//Fetch the Mx Karma Votes
|
||||
$this->getMxKarmaVotes();
|
||||
$self->getMxKarmaVotes();
|
||||
} else {
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$self->maniaControl->log("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
} else {
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$this->maniaControl->log($error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$self->maniaControl->log($error);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, "application/json", 1000);
|
||||
}
|
||||
@ -756,33 +758,34 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
$content = json_encode($properties);
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_GETMAPRATING . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use (&$player) {
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_GETMAPRATING . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use (&$self, &$player) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
|
||||
//Fetch averages if its for the whole server
|
||||
if (!$player) {
|
||||
$this->mxKarma["voteCount"] = $data->data->votecount;
|
||||
$this->mxKarma["voteAverage"] = $data->data->voteaverage;
|
||||
$this->mxKarma["modeVoteCount"] = $data->data->modevotecount;
|
||||
$this->mxKarma["modeVoteAverage"] = $data->data->modevoteaverage;
|
||||
$self->mxKarma["voteCount"] = $data->data->votecount;
|
||||
$self->mxKarma["voteAverage"] = $data->data->voteaverage;
|
||||
$self->mxKarma["modeVoteCount"] = $data->data->modevotecount;
|
||||
$self->mxKarma["modeVoteAverage"] = $data->data->modevoteaverage;
|
||||
}
|
||||
|
||||
foreach($data->data->votes as $votes) {
|
||||
$this->mxKarma["votes"][$votes->login] = $votes->vote;
|
||||
$self->mxKarma["votes"][$votes->login] = $votes->vote;
|
||||
}
|
||||
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma);
|
||||
$this->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||
$self->updateManialink = true;
|
||||
$self->maniaControl->callbackManager->triggerCallback($self::CB_KARMA_MXUPDATED, $self->mxKarma);
|
||||
$self->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||
} else {
|
||||
$this->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
||||
$self->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: " . $data->data->message . " " . self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey));
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: " . $data->data->message . " " . KarmaPlugin::MX_KARMA_URL . KarmaPlugin::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey));
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->log($error);
|
||||
$self->maniaControl->log($error);
|
||||
}
|
||||
}, $content, false, 'application/json');
|
||||
}
|
||||
@ -911,18 +914,20 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$properties['isimport'] = $import;
|
||||
|
||||
$content = json_encode($properties);
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) {
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use(&$self){
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
$this->maniaControl->log("Votes successfully permitted");
|
||||
$self->maniaControl->log("Votes successfully permitted");
|
||||
} else {
|
||||
$this->maniaControl->log("Error while updating votes: " . $data->data->message);
|
||||
$self->maniaControl->log("Error while updating votes: " . $data->data->message);
|
||||
//TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while updating votes: " . $data->data->message . " " . self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey));
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while updating votes: " . $data->data->message . " " . KarmaPlugin::MX_KARMA_URL . $self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey));
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->log($error);
|
||||
$self->maniaControl->log($error);
|
||||
}
|
||||
}, $content, false, 'application/json');
|
||||
}
|
||||
|
Reference in New Issue
Block a user