diff --git a/Shootmania/Elite/Elite.php b/Shootmania/Elite/Elite.php index 221190c..2de31fe 100644 --- a/Shootmania/Elite/Elite.php +++ b/Shootmania/Elite/Elite.php @@ -2,7 +2,7 @@ /** Name: Willem 'W1lla' van den Munckhof - Date: 21-4-2014 + Date: 22-4-2014 Version: 2 (GA2K14) Project Name: ESWC Elite Statistics @@ -70,7 +70,7 @@ class Elite extends \ManiaLive\PluginHandler\Plugin { private $playerIDs = array(); function onInit() { - $this->setVersion('1.0.5k'); + $this->setVersion('1.0.5l'); $this->logger = new Log($this->storage->serverLogin); $this->mapdirectory = $this->connection->getMapsDirectory(); @@ -905,10 +905,10 @@ function onXmlRpcEliteMatchStart(JsonCallbacks\BeginMatch $content) { `competition_id` ) VALUES ( " . $this->db->quote($MatchName) . ", - " . $this->db->quote($this->getTeamid($blue->name)) . ", + " . $this->db->quote($this->getTeamid($blue->clubLinkUrl)) . ", " . $this->db->quote($blue->emblemUrl) . ", " . $this->db->quote($blue->rGB) . ", - " . $this->db->quote($this->getTeamid($red->name)) . ", + " . $this->db->quote($this->getTeamid($red->clubLinkUrl)) . ", " . $this->db->quote($red->emblemUrl) . ", " . $this->db->quote($red->rGB) . ", '0', @@ -1000,7 +1000,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { } $qmmsb = "UPDATE `matches` - SET teamBlue = " . $this->db->quote($this->getTeamid($blue->name)) . ", + SET teamBlue = " . $this->db->quote($this->getTeamid($blue->clubLinkUrl)) . ", teamBlue_emblem = " . $this->db->quote($blue->emblemUrl) . ", teamBlue_RGB = " . $this->db->quote($blue->rGB) . " WHERE `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . " AND `id` = " . $this->db->quote($this->MatchNumber) . ""; @@ -1008,7 +1008,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { $this->db->execute($qmmsb); $qmmsr = "UPDATE `matches` - SET teamRed = " . $this->db->quote($this->getTeamid($red->name)) . ", + SET teamRed = " . $this->db->quote($this->getTeamid($red->clubLinkUrl)) . ", teamRed_emblem = " . $this->db->quote($red->emblemUrl) . ", teamRed_RGB = " . $this->db->quote($red->rGB) . " WHERE `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . " AND `id` = " . $this->db->quote($this->MatchNumber) . ""; @@ -1062,7 +1062,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { " . $this->db->quote($this->MatchNumber) . ", " . $this->db->quote($this->getPlayerId($login)) . ", " . $this->db->quote($this->MapNumber) . ", - " . $this->db->quote($this->getTeamid($teams[($player->teamId + 1)]->name)) . ", + " . $this->db->quote($this->getTeamid($teams[($player->teamId + 1)]->clubLinkUrl)) . ", " . $this->db->quote($this->storage->serverLogin) . " )"; //var_dump($pmi); @@ -1075,7 +1075,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { $attackingClan = $teams[$content->attackingClan]; - $q = "SELECT * FROM `match_details` WHERE `map_id` = " . $this->db->quote($this->getMapid()) . " and `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->name)) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ";"; + $q = "SELECT * FROM `match_details` WHERE `map_id` = " . $this->db->quote($this->getMapid()) . " and `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->clubLinkUrl)) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ";"; $this->logger->Debug($q); $execute = $this->db->execute($q); if ($execute->recordCount() == 0) { @@ -1092,7 +1092,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { `matchServerLogin` ) VALUES ( " . $this->db->quote($this->MatchNumber) . ", - " . $this->db->quote($this->getTeamid($attackingClan->name)) . ", + " . $this->db->quote($this->getTeamid($attackingClan->clubLinkUrl)) . ", " . $this->db->quote($this->getMapid()) . ", '0', '0', @@ -1113,7 +1113,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { $q = "SELECT * FROM `match_details` WHERE `map_id` = " . $this->db->quote($this->getMapid()) . " AND `match_id` = " . $this->db->quote($this->MatchNumber) . " AND - `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->name)) . " AND + `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->clubLinkUrl)) . " AND `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ";"; $this->logger->Debug($q); $execute = $this->db->execute($q); @@ -1132,7 +1132,7 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) { `matchServerLogin` ) VALUES ( " . $this->MatchNumber . ", - " . $this->db->quote($this->getTeamid($defendingClan->name)) . ", + " . $this->db->quote($this->getTeamid($defendingClan->clubLinkUrl)) . ", " . $this->db->quote($this->getMapid()) . ", '0', '0', @@ -1228,16 +1228,15 @@ function updateClublink($url) { $zone[2] = "World"; } - $qcblnk = "SELECT * FROM `clublinks` WHERE `Clublink_Name` = " . $this->db->quote($xml->name) . ";"; + $qcblnk = "SELECT * FROM `clublinks` WHERE `Clublink_URL` = " . $this->db->quote($url) . ";"; $this->logger->Debug($qcblnk); $execute = $this->db->execute($qcblnk); $this->logger->Debug("Select Clublinks"); if ($execute->recordCount() == 0) { $this->logger->Debug("Insert Clublinks"); - $string = preg_replace('/(?name); - $string = preg_replace('/(?name); - $name = $string; + $name = \ManiaLib\Utils\Formatting::stripCodes($xml->name, 'wosn'); + $name = preg_replace('/[^A-Za-z0-9 _\-\+\&]/','',$name); $qBlueClublink = "INSERT INTO `clublinks` ( `Clublink_Name`, `Clublink_Name_Clean`, @@ -1280,13 +1279,13 @@ function onXmlRpcEliteEndTurn(JsonCallbacks\EndTurn $content) { $qatk = "UPDATE `match_details` SET `attack` = attack + 1 - WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->name)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; + WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; $this->logger->Debug($qatk); $this->db->execute($qatk); if ($content->winType == 'Capture') { $qcapture = "UPDATE `match_details` - SET `capture` = capture + 1 WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->name)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; + SET `capture` = capture + 1 WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; $this->logger->Debug($qcapture); $this->db->execute($qcapture); @@ -1300,7 +1299,7 @@ function onXmlRpcEliteEndTurn(JsonCallbacks\EndTurn $content) { if ($content->winType == 'DefenseEliminated') { $qawe = "UPDATE `match_details` SET `attackWinEliminate` = attackWinEliminate + 1 - WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->name)) . " and + WHERE `team_id` = " . $this->db->quote($this->getTeamid($attackingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; @@ -1316,14 +1315,14 @@ function onXmlRpcEliteEndTurn(JsonCallbacks\EndTurn $content) { $qdef = "UPDATE `match_details` SET `defence` = defence + 1 - WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->name)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; + WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; $this->logger->Debug($qdef); $this->db->execute($qdef); if ($content->winType == 'TimeLimit') { $qtl = "UPDATE `match_details` SET `timeOver` = timeOver + 1 - WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->name)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; + WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; $this->logger->Debug($qtl); $this->db->execute($qtl); @@ -1337,7 +1336,7 @@ function onXmlRpcEliteEndTurn(JsonCallbacks\EndTurn $content) { if ($content->winType == 'AttackEliminated') { $qde = "UPDATE `match_details` SET `defenceWinEliminate` = defenceWinEliminate + 1 - WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->name)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; + WHERE `team_id` = " . $this->db->quote($this->getTeamid($defendingClan->clubLinkUrl)) . " and `map_id` = " . $this->db->quote($this->getMapid()) . " and `match_id` = " . $this->db->quote($this->MatchNumber) . " and `matchServerLogin` = " . $this->db->quote($this->storage->serverLogin) . ""; $this->logger->Debug($qde); $this->db->execute($qde); } @@ -1670,8 +1669,8 @@ function getMapid(){ return $this->db->execute($q)->fetchObject()->id; } - function getTeamid($teamname){ - $q = "SELECT id FROM `clublinks` WHERE `Clublink_Name` = " . $this->db->quote($teamname) . ""; + function getTeamid($clubLinkUrl){ + $q = "SELECT id FROM `clublinks` WHERE `Clublink_URL` = " . $this->db->quote($clubLinkUrl) . ""; $this->logger->Debug($q); return $this->db->execute($q)->fetchObject()->id; }