directory access coding improved

This commit is contained in:
Steffen Schröder 2014-06-14 11:32:09 +02:00
parent 8208ab5f6d
commit bd6e0b5151
2 changed files with 10 additions and 14 deletions

View File

@ -161,8 +161,8 @@ class MapManager implements CallbackListener {
* @return bool
*/
private function updateMapTimestamp($uid) {
$mysqli = $this->maniaControl->database->mysqli;
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
$mysqli = $this->maniaControl->database->mysqli;
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
mxid = 0,
changed = NOW()
WHERE 'uid' = ?";
@ -288,11 +288,11 @@ class MapManager implements CallbackListener {
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
$mapDir = $this->maniaControl->client->getMapsDirectory();
$downloadDirectory = $mapDir . DIRECTORY_SEPARATOR . $downloadFolderName . DIRECTORY_SEPARATOR;
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
$fullMapFileName = $downloadDirectory . $fileName;
// Check if it can get written locally
if (is_dir($mapDir) && is_writable($mapDir)) {
if ($this->maniaControl->server->checkAccess($mapDir)) {
// Create download directory if necessary
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory)) {
trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.");

View File

@ -34,7 +34,7 @@ class Server implements CallbackListener {
public $p2pPort = -1;
public $login = null;
public $titleId = null;
public $dataDirectory = '';
public $dataDirectory = null;
public $serverCommands = null;
public $usageReporter = null;
public $rankingManager = null;
@ -199,25 +199,22 @@ class Server implements CallbackListener {
}
/**
* Fetch Maps Directory
* Get Maps Directory
*
* @return string
*/
public function getMapsDirectory() {
$dataDirectory = $this->getDataDirectory();
if (!$dataDirectory) {
return null;
}
return "{$dataDirectory}Maps" . DIRECTORY_SEPARATOR;
return $dataDirectory . 'Maps' . DIRECTORY_SEPARATOR;
}
/**
* Fetch Game Data Directory
* Get Game Data Directory
*
* @return string
*/
public function getDataDirectory() {
if ($this->dataDirectory == '') {
if (!$this->dataDirectory) {
$this->dataDirectory = $this->maniaControl->client->gameDataDirectory();
}
return $this->dataDirectory;
@ -245,7 +242,6 @@ class Server implements CallbackListener {
} catch (Exception $e) {
// TODO temp added 19.04.2014
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 330 Server.php" . $e->getMessage());
trigger_error("Couldn't get validation replay of '{$login}'. " . $e->getMessage());
return null;
}
@ -292,7 +288,7 @@ class Server implements CallbackListener {
}
/**
* Checks if ManiaControl has Access to the given Directory
* Check if ManiaControl has Access to the given Directory
*
* @param string $directory
* @return bool