This commit is contained in:
Roman Hergenreder 2020-04-02 21:39:02 +02:00
parent 15762350d2
commit 2611aa2c1b
2 changed files with 25 additions and 13 deletions

@ -4,7 +4,7 @@ namespace Documents {
class Install extends \Elements\Document { class Install extends \Elements\Document {
public function __construct($user) { public function __construct($user) {
parent::__construct($user, Install\Head::class, Install\Body::class); parent::__construct($user, Install\Head::class, Install\Body::class);
$this->databseRequired = false; $this->databaseRequired = false;
} }
} }
} }
@ -63,15 +63,18 @@ namespace Documents\Install {
// //
private $configDirectory; private $configDirectory;
private $databaseScript; private $databaseConfiguration;
private $mailConfiguration;
private $jwtConfiguration;
private $errorString; private $errorString;
function __construct($document) { function __construct($document) {
parent::__construct($document); parent::__construct($document);
// TODO: make better $this->configDirectory = getWebRoot() . '/core/Configuration';
$this->configDirectory = getWebRoot() . '/core/Configuration'; $this->databaseConfiguration = getWebRoot() . '/core/Configuration/Database.class.php';
$this->databaseScript = getWebRoot() . '/core/Configuration/database.sql'; $this->mailConfiguration = getWebRoot() . '/core/Configuration/Mail.class.php';
$this->jwtConfiguration = getWebRoot() . '/core/Configuration/JWT.class.php';
$this->errorString = ""; $this->errorString = "";
} }
@ -136,13 +139,22 @@ namespace Documents\Install {
$success = true; $success = true;
$failedRequirements = array(); $failedRequirements = array();
if(!is_writeable($this->configDirectory)) { $writeableFiles = array(
$failedRequirements[] = "<b>$this->configDirectory</b> is not writeable. Try running <b>chmod 600</b>"; $this->configDirectory,
$success = false; $this->databaseConfiguration,
$this->mailConfiguration,
$this->jwtConfiguration,
);
foreach($writeableFiles as $file) {
if(!is_writeable($file)) {
$failedRequirements[] = "<b>$file</b> is not writeable. Try running <b>chmod 600</b>";
$success = false;
}
} }
if(!is_readable($this->databaseScript)) { if(!is_writeable($this->configDirectory)) {
$failedRequirements[] = "<b>$this->databaseScript</b> is not readable."; $failedRequirements[] = "<b>$this->configDirectory</b> is not writeable. Try running <b>chmod 600</b>";
$success = false; $success = false;
} }

@ -7,13 +7,13 @@ abstract class Document {
protected $head; protected $head;
protected $body; protected $body;
protected $user; protected $user;
protected $databseRequired; protected $databaseRequired;
public function __construct($user, $headClass, $bodyClass) { public function __construct($user, $headClass, $bodyClass) {
$this->head = new $headClass($this); $this->head = new $headClass($this);
$this->body = new $bodyClass($this); $this->body = new $bodyClass($this);
$this->user = $user; $this->user = $user;
$this->databseRequired = true; $this->databaseRequired = true;
} }
public function getHead() { return $this->head; } public function getHead() { return $this->head; }
@ -55,7 +55,7 @@ abstract class Document {
function getCode() { function getCode() {
if ($this->databseRequired) { if ($this->databaseRequired) {
$sql = $this->user->getSQL(); $sql = $this->user->getSQL();
if (is_null($sql)) { if (is_null($sql)) {
die("Database is not configured yet."); die("Database is not configured yet.");