more fixes

This commit is contained in:
Parziphal 2013-10-27 15:19:10 -05:00
parent 30764ffc17
commit 23e213d226

View File

@ -17,51 +17,56 @@ class Installer extends Base
{ {
$this->loadConfig(); $this->loadConfig();
if (!$this->validateSafeIps()) { if ($this->request()->path() == '/') {
# Client not allowed if (!$this->validateSafeIps()) {
if ($this->dataDirExists()) { # Client not allowed
# Updating message if ($this->dataDirExists()) {
$this->renderMessage(self::$PLEASE_WAIT_MESSAGE); # Updating message
$this->renderMessage(self::$PLEASE_WAIT_MESSAGE);
} else {
# Installing message
$this->renderMessage(sprintf(self::$ACCESS_DENIED_MESSAGE, $_SERVER['REMOTE_ADDR']));
}
} else { } else {
# Installing message # Client allowed; serve forms/commit actions
$this->renderMessage(sprintf(self::$ACCESS_DENIED_MESSAGE, $_SERVER['REMOTE_ADDR'])); try {
# To make things nice, check write permissions
# on some paths.
$this->checkWriteablePaths();
if ($this->request()->isGet()) {
# Serve forms
if ($this->dataDirExists()) {
# Update form
$this->renderUpdateForm();
} else {
# Install form
$this->renderInstallForm();
}
} else {
# Commit actions
if ($this->dataDirExists()) {
# Update
$this->commitUpdate();
} else {
# Install
$this->commitInstall();
}
}
} catch (Exception\ExceptionInterface $e) {
$this->renderMessage($e->getMessage());
}
} }
} else { } else {
# Client allowed; serve forms/commit actions # Load application and let it serve the request.
try { $appClass = get_class(Rails::application());
# To make things nice, check write permissions $appClass::dispatchRequest();
# on some paths.
$this->checkWriteablePaths();
if ($this->request()->isGet()) {
# Serve forms
if ($this->dataDirExists()) {
# Update form
$this->renderUpdateForm();
} else {
# Install form
$this->renderInstallForm();
}
} else {
# Commit actions
if ($this->dataDirExists()) {
# Update
$this->commitUpdate();
} else {
# Install
$this->commitInstall();
}
}
} catch (Exception\ExceptionInterface $e) {
$this->renderMessage($e->getMessage());
}
} }
} }
protected function checkWriteablePaths() protected function checkWriteablePaths()
{ {
$paths = [ $paths = [
'/install',
'/log', '/log',
'/tmp', '/tmp',
'/public' '/public'