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 = "

$title


"; + if(isset($currentView["text"])) { + $text = $currentView["text"]; + $html .= "
$text
"; + } + if(isset($currentView["progressText"])) { $progressText = $currentView["progressText"]; $html .= "
$progressText$spinnerIcon
"; @@ -597,10 +600,15 @@ namespace Documents\Install { } $buttons = array( - array("title" => "Go Back", "type" => "info", "id" => "btnPrev", "float" => "left", "disabled" => $prevDisabled), - array("title" => "Submit", "type" => "success", "id" => "btnSubmit", "float" => "right") + array("title" => "Go Back", "type" => "info", "id" => "btnPrev", "float" => "left", "disabled" => $prevDisabled) ); + if($this->currentStep != self::FINISH_INSTALLATION) { + $buttons[] = array("title" => "Submit", "type" => "success", "id" => "btnSubmit", "float" => "right"); + } else { + $buttons[] = array("title" => "Finish", "type" => "success", "id" => "btnFinish", "float" => "right"); + } + if(isset($currentView["skip"])) { $buttons[] = array("title" => "Skip", "type" => "secondary", "id" => "btnSkip", "float" => "right"); } @@ -653,8 +661,8 @@ namespace Documents\Install { "title" => "Add Mail Service", "status" => self::NOT_STARTED ), - self::ADD_GOOGLE_SERVICE => array( - "title" => "Add Google Services", + self::FINISH_INSTALLATION => array( + "title" => "Finish Installation", "status" => self::NOT_STARTED ), ); @@ -666,6 +674,10 @@ namespace Documents\Install { $this->steps[$step]["status"] = self::SUCCESFULL; } + if($this->currentStep == self::FINISH_INSTALLATION) { + $this->steps[$this->currentStep]["status"] = self::SUCCESFULL; + } + // POST if($_SERVER['REQUEST_METHOD'] == 'POST') { $response = $this->performStep(); @@ -682,6 +694,7 @@ namespace Documents\Install { $progressSidebar = $this->createProgressSidebar(); $progressMainview = $this->createProgessMainview(); + $errorStyle = ($this->errorString ? '' : ' style="display:none"'); $html .= " @@ -705,7 +718,7 @@ namespace Documents\Install {
$progressMainview -
+
$this->errorString
diff --git a/core/External/jwt.php b/core/External/JWT.class.php similarity index 100% rename from core/External/jwt.php rename to core/External/JWT.class.php diff --git a/core/Objects/User.class.php b/core/Objects/User.class.php index 1131599..ea577b6 100644 --- a/core/Objects/User.class.php +++ b/core/Objects/User.class.php @@ -33,7 +33,6 @@ class User extends ApiObject { } } - public function setSql($sql) { $this->sql = $sql; } public function getId() { return $this->uid; } public function isLoggedIn() { return $this->loggedIn; } public function getUsername() { return $this->username; } diff --git a/index.php b/index.php index 125103b..1ffdfd5 100644 --- a/index.php +++ b/index.php @@ -1,12 +1,5 @@ getCode()); - -// if(!file_exists($configPath)) { -// require_once 'core/objects/User.php'; -// require_once 'core/documents/install.php'; -// -// // $user = new CUser(null); -// // $installPage = new CDocumentInstall($user); -// // die($installPage->getCode()); -// } else { -// $perms = fileperms($configPath); -// if($perms != 0x8600) { -// die("Invalid conf file permissions. expected permissions: 8600, got: $perms"); -// } -// -// require_once $configPath; -// // require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/php/pages/home.php'; -// // CDocument::createDocument(CDocumentHome::class); -// } ?> diff --git a/js/install.js b/js/install.js index 178fc8c..f27ef29 100644 --- a/js/install.js +++ b/js/install.js @@ -120,6 +120,10 @@ $(document).ready(function() { }); }); + $("#btnFinish").click(function() { + window.location.reload(); + }); + $("#btnRetry").click(function() { retry(); });