directory access coding improved
This commit is contained in:
parent
8208ab5f6d
commit
bd6e0b5151
@ -161,8 +161,8 @@ class MapManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function updateMapTimestamp($uid) {
|
private function updateMapTimestamp($uid) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
|
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET
|
||||||
mxid = 0,
|
mxid = 0,
|
||||||
changed = NOW()
|
changed = NOW()
|
||||||
WHERE 'uid' = ?";
|
WHERE 'uid' = ?";
|
||||||
@ -288,11 +288,11 @@ class MapManager implements CallbackListener {
|
|||||||
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
||||||
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
||||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||||
$downloadDirectory = $mapDir . DIRECTORY_SEPARATOR . $downloadFolderName . DIRECTORY_SEPARATOR;
|
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
|
||||||
$fullMapFileName = $downloadDirectory . $fileName;
|
$fullMapFileName = $downloadDirectory . $fileName;
|
||||||
|
|
||||||
// Check if it can get written locally
|
// 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
|
// Create download directory if necessary
|
||||||
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory)) {
|
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory)) {
|
||||||
trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.");
|
trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.");
|
||||||
|
@ -34,7 +34,7 @@ class Server implements CallbackListener {
|
|||||||
public $p2pPort = -1;
|
public $p2pPort = -1;
|
||||||
public $login = null;
|
public $login = null;
|
||||||
public $titleId = null;
|
public $titleId = null;
|
||||||
public $dataDirectory = '';
|
public $dataDirectory = null;
|
||||||
public $serverCommands = null;
|
public $serverCommands = null;
|
||||||
public $usageReporter = null;
|
public $usageReporter = null;
|
||||||
public $rankingManager = null;
|
public $rankingManager = null;
|
||||||
@ -199,25 +199,22 @@ class Server implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Maps Directory
|
* Get Maps Directory
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMapsDirectory() {
|
public function getMapsDirectory() {
|
||||||
$dataDirectory = $this->getDataDirectory();
|
$dataDirectory = $this->getDataDirectory();
|
||||||
if (!$dataDirectory) {
|
return $dataDirectory . 'Maps' . DIRECTORY_SEPARATOR;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return "{$dataDirectory}Maps" . DIRECTORY_SEPARATOR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Game Data Directory
|
* Get Game Data Directory
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDataDirectory() {
|
public function getDataDirectory() {
|
||||||
if ($this->dataDirectory == '') {
|
if (!$this->dataDirectory) {
|
||||||
$this->dataDirectory = $this->maniaControl->client->gameDataDirectory();
|
$this->dataDirectory = $this->maniaControl->client->gameDataDirectory();
|
||||||
}
|
}
|
||||||
return $this->dataDirectory;
|
return $this->dataDirectory;
|
||||||
@ -245,7 +242,6 @@ class Server implements CallbackListener {
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TODO temp added 19.04.2014
|
// TODO temp added 19.04.2014
|
||||||
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 330 Server.php" . $e->getMessage());
|
$this->maniaControl->errorHandler->triggerDebugNotice("Exception line 330 Server.php" . $e->getMessage());
|
||||||
|
|
||||||
trigger_error("Couldn't get validation replay of '{$login}'. " . $e->getMessage());
|
trigger_error("Couldn't get validation replay of '{$login}'. " . $e->getMessage());
|
||||||
return null;
|
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
|
* @param string $directory
|
||||||
* @return bool
|
* @return bool
|
||||||
|
Loading…
Reference in New Issue
Block a user