add maps over writefile method
This commit is contained in:
parent
4dabf459a8
commit
cef598cd3e
@ -278,7 +278,7 @@ class Client
|
||||
$request = new Request($method, $args);
|
||||
|
||||
// Check if request is larger than 512 Kbytes
|
||||
if ($request->getLength() > 512*1024-8)
|
||||
if ($request->getLength() > 1024*1024-8) //TODO changed temporary to 1024 * 1024
|
||||
{
|
||||
throw new Exception('transport error - request too large!', -32700);
|
||||
}
|
||||
|
@ -478,7 +478,6 @@ class MapManager implements CallbackListener {
|
||||
return array_search($map, $maps);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a Map from Mania Exchange
|
||||
*
|
||||
@ -496,20 +495,6 @@ class MapManager implements CallbackListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_dir($mapDir)) {
|
||||
trigger_error("ManiaControl doesn't have have access to the maps directory in '{$mapDir}'.");
|
||||
$this->maniaControl->chat->sendError("ManiaControl doesn't have access to the maps directory.", $login);
|
||||
return;
|
||||
}
|
||||
$downloadDirectory = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX');
|
||||
// Create download directory if necessary
|
||||
if (!is_dir($mapDir . $downloadDirectory) && !mkdir($mapDir . $downloadDirectory)) {
|
||||
trigger_error("ManiaControl doesn't have to rights to save maps in '{$mapDir}{$downloadDirectory}'.");
|
||||
$this->maniaControl->chat->sendError("ManiaControl doesn't have the rights to save maps.", $login);
|
||||
return;
|
||||
}
|
||||
$mapDir .= $downloadDirectory . '/';
|
||||
|
||||
// Download the map
|
||||
if (is_numeric($mapId)) {
|
||||
// Load from MX
|
||||
@ -545,14 +530,38 @@ class MapManager implements CallbackListener {
|
||||
// Save map
|
||||
$fileName = $mapId . '_' . $mapInfo->name . '.Map.Gbx';
|
||||
$fileName = FileUtil::getClearedFileName($fileName);
|
||||
|
||||
$downloadDirectory = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX');
|
||||
|
||||
$mapFileName = $downloadDirectory . '/' . $fileName;
|
||||
|
||||
//Check if it can get locally Written
|
||||
if (is_dir($mapDir)) {
|
||||
// Create download directory if necessary
|
||||
if (!is_dir($mapDir . $downloadDirectory) && !mkdir($mapDir . $downloadDirectory)) {
|
||||
trigger_error("ManiaControl doesn't have to rights to save maps in '{$mapDir}{$downloadDirectory}'.");
|
||||
$this->maniaControl->chat->sendError("ManiaControl doesn't have the rights to save maps.", $login);
|
||||
return;
|
||||
}
|
||||
|
||||
$mapDir .= $downloadDirectory . '/';
|
||||
|
||||
if (!file_put_contents($mapDir . $fileName, $file)) {
|
||||
// Save error
|
||||
$this->maniaControl->chat->sendError('Saving map failed!', $login);
|
||||
return;
|
||||
}
|
||||
// Check for valid map
|
||||
$mapFileName = $downloadDirectory . '/' . $fileName;
|
||||
//Write via Write File Method
|
||||
} else {
|
||||
try {
|
||||
$this->maniaControl->client->writeFileFromString($mapFileName, $file);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for valid map
|
||||
try {
|
||||
$this->maniaControl->client->checkMapForCurrentServerParams($mapFileName);
|
||||
} catch(\Exception $e) {
|
||||
|
Loading…
Reference in New Issue
Block a user