Esempio n. 1
0
 public function login()
 {
     if ($this->username != 'admin') {
         $this->errorMessages[] = 'Username or password invalid';
         return;
     }
     if ($this->firstTime) {
         file_put_contents(Di::secretFilePath(), md5('admin'));
     }
     $secret = file_get_contents(Di::secretFilePath());
     if (md5($this->password) != $secret) {
         $this->errorMessages[] = 'Username or password invalid';
         return;
     }
     Di::isLogged(true);
     header('Location: /admin');
 }
Esempio n. 2
0
 public function __construct()
 {
     $uri = $_SERVER['REQUEST_URI'];
     if (strpos($uri, '/admin') === 0) {
         $this->content = new \NetBricks\SimpleCms\View\Back();
     } else {
         if (strpos($uri, '/login') === 0) {
             $this->content = new \NetBricks\SimpleCms\View\Login();
         } else {
             if (strpos($uri, '/logout') === 0) {
                 Di::isLogged(false);
                 header('Location: /');
             } else {
                 $this->content = new \NetBricks\SimpleCms\View\Front();
             }
         }
     }
 }