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 {
public function __construct($user) {
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 $databaseScript;
private $databaseConfiguration;
private $mailConfiguration;
private $jwtConfiguration;
private $errorString;
function __construct($document) {
parent::__construct($document);
// TODO: make better
$this->configDirectory = getWebRoot() . '/core/Configuration';
$this->databaseScript = getWebRoot() . '/core/Configuration/database.sql';
$this->databaseConfiguration = getWebRoot() . '/core/Configuration/Database.class.php';
$this->mailConfiguration = getWebRoot() . '/core/Configuration/Mail.class.php';
$this->jwtConfiguration = getWebRoot() . '/core/Configuration/JWT.class.php';
$this->errorString = "";
}
@ -136,13 +139,22 @@ namespace Documents\Install {
$success = true;
$failedRequirements = array();
if(!is_writeable($this->configDirectory)) {
$failedRequirements[] = "<b>$this->configDirectory</b> is not writeable. Try running <b>chmod 600</b>";
$writeableFiles = array(
$this->configDirectory,
$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)) {
$failedRequirements[] = "<b>$this->databaseScript</b> is not readable.";
if(!is_writeable($this->configDirectory)) {
$failedRequirements[] = "<b>$this->configDirectory</b> is not writeable. Try running <b>chmod 600</b>";
$success = false;
}

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