diff --git a/core/Configuration/.gitignore b/core/Configuration/.gitignore index 387c25f..6b0cf63 100644 --- a/core/Configuration/.gitignore +++ b/core/Configuration/.gitignore @@ -1,4 +1,3 @@ Mail\.class\.php JWT\.class\.php Database\.class\.php -Google\.class\.php diff --git a/core/Configuration/Configuration.class.php b/core/Configuration/Configuration.class.php index 88c836f..2a93ca9 100644 --- a/core/Configuration/Configuration.class.php +++ b/core/Configuration/Configuration.class.php @@ -7,7 +7,6 @@ class Configuration { private $database; private $mail; private $jwt; - private $google; function __construct() { } @@ -18,8 +17,7 @@ class Configuration { $classes = array( \Configuration\Database::class => &$this->database, \Configuration\Mail::class => &$this->mail, - \Configuration\JWT::class => &$this->jwt, - \Configuration\Google::class => &$this->google, + \Configuration\JWT::class => &$this->jwt ); $success = true; @@ -54,35 +52,57 @@ class Configuration { $path = getClassPath("\\Configuration\\$className"); if($data) { + if(is_string($data)) { + $key = addslashes($data); + $code = intendCode( + "getHost()); - $port = intval($data->getPort()); - $login = addslashes($data->getLogin()); - $password = addslashes($data->getPassword()); + namespace Configuration; - $properties = ""; - foreach($data->getProperties() as $key => $val) { - $key = addslashes($key); - $val = is_string($val) ? "'" . addslashes($val) . "'" : $val; - $properties .= "\n\$this->setProperty('$key', $val);"; - } + class $className { - $code = intendCode( - "key = '$key'; + } + + public function getKey() { + return \$this->key; + } } + + ?>", false + ); + } else { + $superClass = get_class($data); + $host = addslashes($data->getHost()); + $port = intval($data->getPort()); + $login = addslashes($data->getLogin()); + $password = addslashes($data->getPassword()); + + $properties = ""; + foreach($data->getProperties() as $key => $val) { + $key = addslashes($key); + $val = is_string($val) ? "'" . addslashes($val) . "'" : $val; + $properties .= "\n\$this->setProperty('$key', $val);"; } - ?>", false - ); + $code = intendCode( + "", false + ); + } } else { $code = intendCode( "configDirectory = getWebRoot() . '/core/Configuration'; $this->databaseScript = getWebRoot() . '/core/Configuration/database.sql'; + $this->errorString = ""; } private function getParameter($name) { @@ -98,7 +100,6 @@ namespace Documents\Install { $query = "SELECT * FROM User"; $sql = $user->getSQL(); if(!is_null($sql) && $sql->isConnected()) { - $this->getDocument()->getUser()->setSql($sql); $res = $sql->query($query); if($res) { if($res->num_rows === 0) { @@ -112,7 +113,10 @@ namespace Documents\Install { } if($step == self::ADD_MAIL_SERVICE && $config->isFilePresent("Mail")) { - $step = self::ADD_GOOGLE_SERVICE; + $step = self::FINISH_INSTALLATION; + if(!$config->isFilePresent("JWT") && $config->create("JWT", generateRandomString(32))) { + $this->errorString = "Unable to create jwt file"; + } } return $step; @@ -120,7 +124,7 @@ namespace Documents\Install { private function checkRequirements() { - $msg = ""; + $msg = $this->errorString; $success = true; $failedRequirements = array(); @@ -243,7 +247,7 @@ namespace Documents\Install { $password = $this->getParameter("password"); $confirmPassword = $this->getParameter("confirmPassword"); - $msg = ""; + $msg = $this->errorString; $success = true; $missingInputs = array(); @@ -297,7 +301,7 @@ namespace Documents\Install { } $success = true; - $msg = ""; + $msg = $this->errorString; if($this->getParameter("skip") === "true") { if(!$user->getConfiguration()->create("Mail", null)) { $success = false; @@ -378,10 +382,6 @@ namespace Documents\Install { return array("success" => $success, "msg" => $msg); } - private function addGoogleService() { - // return array("success" => $success, "msg" => $msg); - } - private function performStep() { switch($this->currentStep) { @@ -398,9 +398,6 @@ namespace Documents\Install { case self::ADD_MAIL_SERVICE: return $this->addMailService(); - case self::ADD_GOOGLE_SERVICE: - return $this->addGoogleService(); - default: return array( "success" => false, @@ -555,8 +552,9 @@ namespace Documents\Install { ), "skip" => true ), - self::ADD_GOOGLE_SERVICE => array( - "title" => "Optional: Add Google Services", + self::FINISH_INSTALLATION => array( + "title" => "Finish Installation", + "text" => "Installation finished, you can now customize your own website, check the source code and stuff." ) ); @@ -571,6 +569,11 @@ namespace Documents\Install { $html = "