Skip to content

Commit

Permalink
1.0.5.k update
Browse files Browse the repository at this point in the history
Bug rename server after match, seems to be the match name with “ “
Fixed on 1.0.5.k update

Remove Spaces in zip filename Fixed on 1.0.5.k update (Archive Blue vs
LYNX°°°°SM Team¬_201404211949.zip created successfully.)
  • Loading branch information
w1lla committed Apr 21, 2014
1 parent f0c7f5f commit cd11970
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 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: 15-4-2014
Date: 21-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.5j');
$this->setVersion('1.0.5k');

$this->logger = new Log($this->storage->serverLogin);
$this->mapdirectory = $this->connection->getMapsDirectory();
Expand Down Expand Up @@ -406,8 +406,9 @@ function onReady() {
}

$this->ServerName = $this->connection->getServerName();
$this->connection->setServerTag('server_name', $this->ServerName, true);
$this->connection->setServerTag('server_name', json_encode($this->ServerName), true);
$this->connection->setServerName($this->ServerName);
$this->connection->executeMulticall();

}

Expand Down Expand Up @@ -988,10 +989,13 @@ function onXmlRpcEliteBeginTurn(JsonCallbacks\BeginTurn $content) {
$MatchName = '' . $bluename->Clublink_Name_Clean . ' vs ' . $redname->Clublink_Name_Clean . '';
// set servername with clublinks....

$this->connection->setServerTag('server_name', json_encode($MatchName), true);
try
{
$this->connection->setServerName($MatchName);

$this->connection->executeMulticall();
} catch (\Exception $e) {
echo $e;
}

}

Expand Down Expand Up @@ -1231,8 +1235,9 @@ function updateClublink($url) {

if ($execute->recordCount() == 0) {
$this->logger->Debug("Insert Clublinks");
$name = \ManiaLib\Utils\Formatting::stripStyles($xml->name);
$name = preg_replace('/[^A-Za-z0-9 _\-\+\&]/','',$name);
$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;
$qBlueClublink = "INSERT INTO `clublinks` (
`Clublink_Name`,
`Clublink_Name_Clean`,
Expand Down Expand Up @@ -1580,7 +1585,7 @@ function onXmlRpcEliteEndMatch(JsonCallbacks\EndMatch $content) {
$dataDir = str_replace('\\', '/', $dataDir);
$file = $this->connection->getServername();
$name = \ManiaLib\Utils\Formatting::stripStyles($file);
$challengeFile = $dataDir . "Replays/" . $name."/";
$challengeFile = $dataDir."Replays/".$name."/";

$mapReplaysStructure = $challengeFile;
if (!file_exists($mapReplaysStructure)) {
Expand All @@ -1591,7 +1596,7 @@ function onXmlRpcEliteEndMatch(JsonCallbacks\EndMatch $content) {
}

$sourcefolder = "$challengeFile"; // Default: "./"
$zipfilename = $dataDir. "ToUpload/" . $this->competition_id."/".$name."_".date('YmdHi').".zip"; // Default: "myarchive.zip"
$zipfilename = $dataDir."ToUpload/".$this->competition_id."/".$name."_".date('YmdHi').".zip"; // Default: "myarchive.zip"
$zipfilename2 = $name."_".date('YmdHi').".zip"; // Default: "myarchive.zip"
$timeout = 5000; // Default: 5000

Expand Down Expand Up @@ -1626,7 +1631,7 @@ function onXmlRpcEliteEndMatch(JsonCallbacks\EndMatch $content) {
$zip->close();
echo "Archive ". $zipfilename2 . " created successfully.";

$challengeFile = $dataDir . "Replays/" . $name;
$challengeFile = $dataDir."Replays/".$name;
//Rename folder
$newfolder = "$challengeFile"."_".date('YmdHi');
rename($challengeFile,$newfolder);
Expand All @@ -1643,8 +1648,15 @@ function onXmlRpcEliteEndMatch(JsonCallbacks\EndMatch $content) {
// set server back to old value.
$data = $this->connection->getServerTags();
if ($data[0]['Name'] == "server_name"){
$server_name_value = $data[0]['Value'];
$this->connection->setServerName($server_name_value);
$server_name_value = json_decode($data[0]['Value']);

try
{
$this->connection->setServerName($server_name_value);
$this->connection->executeMulticall();
} catch (\Exception $e) {
echo $e;
}
}
}

Expand Down

0 comments on commit cd11970

Please sign in to comment.