diff options
Diffstat (limited to 'app/class/application.php')
-rw-r--r-- | app/class/application.php | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/app/class/application.php b/app/class/application.php index 4926a1b..d75df51 100644 --- a/app/class/application.php +++ b/app/class/application.php @@ -2,8 +2,13 @@ class Application { + /** + * @var Modeluser + */ + protected $usermanager; + public function __construct() { - + $this->usermanager = new Modeluser(); } public function wakeup() @@ -21,22 +26,33 @@ class Application header('Location: ./'); exit; } + } elseif(isset($_POST['userinit'])) { + $userdata = $_POST['userinit']; + $userdata['level'] = 10; + $user = new User($userdata); + $this->usermanager->add($user); + header('Location: ./'); + exit; + } else { if(Config::readconfig()) { - if(!Config::checkbasepath() || empty(Config::admin()) || empty(Config::arttable())) { + if(!Config::checkbasepath() || empty(Config::arttable())) { echo '<ul>'; if(!Config::checkbasepath()) { echo '<li>Wrong path</li>'; - } - if(empty(Config::admin())) { - echo '<li>Wrong admin password</li>'; - } + } if(empty(Config::arttable())) { echo '<li>Unset table name</li>'; } echo '</ul>'; $this->configform(); exit; + } else { + if(!$this->usermanager->adminexist()) { + echo 'missing admin user'; + $this->adminform(); + exit; + } } } else { echo 'Missing config file'; @@ -64,18 +80,36 @@ class Application <p><i>Leave it empty if W-CMS is in your root folder, otherwise, indicate the subfolder(s) in witch you installed the CMS</i></p> </div> <div> + <h2> + <label for="arttable">Name of your database table</label> + </h2> + <input type="text" name="configinit[arttable]" value="<?= Config::arttable() ?>" id="arttable"> + <p><i>Set the name of the first folder that is going to store all your work</i></p> + </div> + <input type="submit" value="set"> + </form> + + <?php + } + + public function adminform() + { + ?> + + <form action="" method="post"> <div> <h2> - <label for="admin">Admin Password</label> + <label for="id">Your identifiant</label> </h2> - <input type="password" name="configinit[admin]" value="<?= Config::admin() ?>" id="admin" minlength="4" maxlength="64"> - <p><i>The main password for administration, you can change it later.</i></p> + <input type="text" name="userinit[id]" value="<?= Config::admin() ?>" id="admin" maxlength="64"> + <p><i>Your user id as the first administrator.</i></p> </div> + <div> <h2> - <label for="arttable">Name of your database table</label> + <label for="password">Your password</label> </h2> - <input type="text" name="configinit[arttable]" value="<?= Config::arttable() ?>" id="arttable"> - <p><i>Set the name of the first folder that is going to store all your work</i></p> + <input type="password" name="userinit[password]" value="<?= Config::admin() ?>" id="admin" minlength="4" maxlength="64"> + <p><i>Your user passworder as first administrator.</i></p> </div> <input type="submit" value="set"> </form> |