Skip to content

Commit

Permalink
1.05.l update
Browse files Browse the repository at this point in the history
Change to clubLinkUrl to make it unique.
Hopefully fix for StripCodes and Colors :P
  • Loading branch information
w1lla committed Apr 22, 2014
1 parent cd11970 commit e48eb72
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions Shootmania/Elite/Elite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -1000,15 +1000,15 @@ 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) . "";
$this->logger->Debug($qmmsb);
$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) . "";
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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',
Expand All @@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -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('/(?<!\$)((?:\$\$)*)\$[^$0-9a-hlpton]/iu', '$1', $xml->name);
$string = preg_replace('/(?<!\$)((?:\$\$)*)\$(?:g|[0-9a-fton][^\$]{0,2})/iu', '$1', $xml->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`,
Expand Down Expand Up @@ -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);

Expand All @@ -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) . "";
Expand All @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e48eb72

Please sign in to comment.