cleanup
This commit is contained in:
parent
ae53958b37
commit
b403ceef31
@ -144,10 +144,7 @@ class DatabaseConverter { //TODO move bind param before loop everywhere, convert
|
||||
|
||||
//Loop through all the players
|
||||
while($row = $result->fetch_object()) {
|
||||
//Strip links and dirty codes
|
||||
$name = preg_replace('/(?<!\$)((?:\$\$)*)\$[hlp](?:\[.*?\])?(.*?)(?:\$[hlp]|(\$z)|$)/iu', '$1$2$3', $row->Name);
|
||||
$name = preg_replace('/(?<!\$)((?:\$\$)*)\$[ow<>]/iu', '$1', $name);
|
||||
$statement->bind_param('ssss', $row->Uid, $name, $row->Author, $row->Environment);
|
||||
$statement->bind_param('ssss', $row->Uid, $row->Name, $row->Author, $row->Environment);
|
||||
$statement->execute();
|
||||
if ($statement->error) {
|
||||
trigger_error($statement->error);
|
||||
|
@ -16,6 +16,7 @@ class Map {
|
||||
*/
|
||||
public $index = -1;
|
||||
public $name = 'undefined';
|
||||
public $rawName = '';
|
||||
public $uid = '';
|
||||
public $fileName = '';
|
||||
public $environment = '';
|
||||
@ -49,6 +50,7 @@ class Map {
|
||||
return;
|
||||
}
|
||||
$this->name = FORMATTER::stripDirtyCodes($mpMap->name);
|
||||
$this->rawName = $mpMap->name;
|
||||
$this->uid = $mpMap->uId;
|
||||
$this->fileName = $mpMap->fileName;
|
||||
$this->authorLogin = $mpMap->author;
|
||||
|
@ -140,7 +140,7 @@ class MapManager implements CallbackListener {
|
||||
trigger_error($mysqli->error);
|
||||
return false;
|
||||
}
|
||||
$mapStatement->bind_param('ssssss', $map->uid, $map->name, $map->authorLogin, $map->fileName, $map->environment, $map->mapType);
|
||||
$mapStatement->bind_param('ssssss', $map->uid, $map->rawName, $map->authorLogin, $map->fileName, $map->environment, $map->mapType);
|
||||
$mapStatement->execute();
|
||||
if ($mapStatement->error) {
|
||||
trigger_error($mapStatement->error);
|
||||
|
@ -17,6 +17,7 @@ class Player {
|
||||
public $pid = -1;
|
||||
public $login = '';
|
||||
public $nickname = '';
|
||||
public $rawNickname = '';
|
||||
public $path = '';
|
||||
public $authLevel = 0;
|
||||
public $language = '';
|
||||
@ -70,6 +71,7 @@ class Player {
|
||||
$this->pid = $mpPlayer->playerId;
|
||||
$this->login = $mpPlayer->login;
|
||||
$this->nickname = Formatter::stripDirtyCodes($mpPlayer->nickName);
|
||||
$this->rawNickname = $mpPlayer->nickName;
|
||||
$this->path = $mpPlayer->path;
|
||||
$this->language = $mpPlayer->language;
|
||||
$this->avatar = $mpPlayer->avatar['FileName'];
|
||||
|
@ -363,7 +363,8 @@ class PlayerManager implements CallbackListener {
|
||||
$player = new Player(false);
|
||||
$player->index = $playerIndex;
|
||||
$player->login = $row->login;
|
||||
$player->nickname = $row->nickname;
|
||||
$player->rawNickname = $row->nickname;
|
||||
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
|
||||
$player->path = $row->path;
|
||||
$player->authLevel = $row->authLevel;
|
||||
|
||||
@ -397,7 +398,8 @@ class PlayerManager implements CallbackListener {
|
||||
$player = new Player(false);
|
||||
$player->index = $row->index;
|
||||
$player->login = $row->login;
|
||||
$player->nickname = $row->nickname;
|
||||
$player->rawNickname = $row->nickname;
|
||||
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
|
||||
$player->path = $row->path;
|
||||
$player->authLevel = $row->authLevel;
|
||||
|
||||
@ -429,7 +431,7 @@ class PlayerManager implements CallbackListener {
|
||||
trigger_error($mysqli->error);
|
||||
return false;
|
||||
}
|
||||
$playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path);
|
||||
$playerStatement->bind_param('sss', $player->login, $player->rawNickname, $player->path);
|
||||
$playerStatement->execute();
|
||||
if ($playerStatement->error) {
|
||||
trigger_error($playerStatement->error);
|
||||
|
@ -181,7 +181,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
// Send Dedimania request
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, $player->nickname, $player->path, $player->isSpectator);
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator);
|
||||
$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data);
|
||||
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) {
|
||||
@ -738,7 +738,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
$mapInfo = array();
|
||||
$mapInfo['UId'] = $map->uid;
|
||||
$mapInfo['Name'] = $map->name;
|
||||
$mapInfo['Name'] = $map->rawName;
|
||||
$mapInfo['Author'] = $map->authorLogin;
|
||||
$mapInfo['Environment'] = $map->environment;
|
||||
$mapInfo['NbCheckpoints'] = $map->nbCheckpoints;
|
||||
|
@ -30,6 +30,7 @@ class DedimaniaPlayer {
|
||||
|
||||
/**
|
||||
* Construct a new Player by its login and maxRank
|
||||
*
|
||||
* @param $login
|
||||
* @param $maxRank
|
||||
*/
|
||||
|
@ -41,6 +41,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
const SETTING_MX_KARMA_ACTIVATED = 'Aktivate MX-Karma';
|
||||
//const MX_KARMA_SETTING_CODE = '$l[http://karma.mania-exchange.com/auth/getapikey?server={serverlogin}]MX Karma Code for ';
|
||||
const MX_IMPORT_TABLE = 'mc_karma_mximport';
|
||||
const MX_KARMA_URL = 'http://karma.mania-exchange.com/api2/';
|
||||
const MX_KARMA_STARTSESSION = 'startSession';
|
||||
const MX_KARMA_ACTIVATESESSION = 'activateSession';
|
||||
@ -341,6 +342,20 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
if ($mysqli->error) {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_KARMA . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`mapIndex` int(11) NOT NULL,
|
||||
`playerIndex` int(11) NOT NULL,
|
||||
`vote` float NOT NULL DEFAULT '-1',
|
||||
`changed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`index`),
|
||||
UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -590,6 +605,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}, "application/json", 1000);
|
||||
}
|
||||
|
||||
public function importVotes(Map $map) {
|
||||
if (!$this->maniaControl->settingManager->getSetting($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Mx Karma Votes at Mapend
|
||||
*/
|
||||
@ -619,14 +640,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$properties['titleid'] = $this->maniaControl->server->titleId;
|
||||
|
||||
$properties['mapname'] = $map->name;
|
||||
$properties['mapname'] = $map->rawName;
|
||||
$properties['mapuid'] = $map->uid;
|
||||
$properties['mapauthor'] = $map->authorLogin;
|
||||
|
||||
$properties['votes'] = array();
|
||||
foreach($this->mxKarma['votes'] as $login => $value) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
array_push($properties['votes'], array("login" => $login, "nickname" => $player->nickname, "vote" => $value));
|
||||
array_push($properties['votes'], array("login" => $login, "nickname" => $player->rawNickname, "vote" => $value));
|
||||
}
|
||||
|
||||
$content = json_encode($properties);
|
||||
|
Loading…
Reference in New Issue
Block a user