diff --git a/core/Configuration/Configuration.class.php b/core/Configuration/Configuration.class.php
index 2a93ca9..0a0bca3 100644
--- a/core/Configuration/Configuration.class.php
+++ b/core/Configuration/Configuration.class.php
@@ -66,7 +66,7 @@ class Configuration {
public function __construct() {
\$this->key = '$key';
}
-
+
public function getKey() {
return \$this->key;
}
@@ -110,7 +110,7 @@ class Configuration {
?>", false);
}
- return file_put_contents($path, $code);
+ return @file_put_contents($path, $code);
}
public function delete($className) {
@@ -121,6 +121,24 @@ class Configuration {
return true;
}
+
+ public static function checkPermissions() {
+ $classes = array(
+ \Configuration\Database::class,
+ \Configuration\Mail::class,
+ \Configuration\JWT::class
+ );
+
+ $files = array();
+ foreach($classes as $class) {
+ $file = getClassPath($class);
+ if(!is_writeable($file)) {
+ $files[] = $file;
+ }
+ }
+
+ return $files;
+ }
};
?>
diff --git a/core/Documents/Install.class.php b/core/Documents/Install.class.php
index e2dd071..83dabdc 100644
--- a/core/Documents/Install.class.php
+++ b/core/Documents/Install.class.php
@@ -62,19 +62,10 @@ namespace Documents\Install {
const FINISH_INSTALLATION = 5;
//
- private $configDirectory;
- private $databaseConfiguration;
- private $mailConfiguration;
- private $jwtConfiguration;
private $errorString;
function __construct($document) {
parent::__construct($document);
-
- $this->configDirectory = getWebRoot() . '/core/Configuration';
- $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 = "";
}
@@ -139,25 +130,14 @@ namespace Documents\Install {
$success = true;
$failedRequirements = array();
- $writeableFiles = array(
- $this->configDirectory,
- $this->databaseConfiguration,
- $this->mailConfiguration,
- $this->jwtConfiguration,
- );
-
- foreach($writeableFiles as $file) {
- if(!is_writeable($file)) {
+ $unwriteableFiles = \Configuration\Configuration::checkPermissions();
+ if(!empty($unwriteableFiles)) {
+ foreach($unwriteableFiles as $file) {
$failedRequirements[] = "$file is not writeable. Try running chmod 600";
$success = false;
}
}
- if(!is_writeable($this->configDirectory)) {
- $failedRequirements[] = "$this->configDirectory is not writeable. Try running chmod 600";
- $success = false;
- }
-
if(version_compare(PHP_VERSION, '7.1', '<')) {
$failedRequirements[] = "PHP Version >= 7.1 is required. Got: " . PHP_VERSION . "";
$success = false;
diff --git a/index.php b/index.php
index aced544..8d25306 100644
--- a/index.php
+++ b/index.php
@@ -6,10 +6,6 @@ function getClassPath($class, $suffix=true) {
return "core/$path$suffix.php";
}
-function getWebRoot() {
- return dirname(__FILE__);
-}
-
function createError($msg) {
return json_encode(array("success" => false, "msg" => $msg));
}