示例#1
0
 public static function accounts($id = null)
 {
     if (isset($id)) {
         $account = Accounts::find(['id' => $id])->fetch(\PDO::FETCH_CLASS);
         $categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
         View::render('admin/account-all', ['account' => $account, 'categories' => $categories]);
     } else {
         $type = Request::GET()->type;
         $accounts = Accounts::find(['type' => $type], true)->fetchAll(\PDO::FETCH_CLASS);
         $categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
         View::render('admin/account-all', ['accounts' => $accounts, 'categories' => $categories]);
     }
 }
示例#2
0
 /**
  * Add member post
  *
  */
 public static function add()
 {
     if (!Request::is_authenticated()) {
         Session::push('flash-message', 'You must login before!');
         Response::redirect('login');
     }
     if ("POST" == Request::method()) {
         $id_member = Request::POST()->member_id;
         $id_post = Request::POST()->post_id;
         $comment = Request::POST()->comment;
         Comments::create($id_post, $id_member, $comment);
         Response::redirect(isset($_GET['next']) ? Request::GET()->next . '#comment' : '');
     } else {
         Response::redirect('');
     }
 }
 /**
  * Action Login
  *
  */
 public static function login()
 {
     # if user was login before
     if (Request::is_authenticated()) {
         # redirect to main page
         Response::redirect('');
     }
     # if request path contain ?next=page
     if (Request::GET()->next) {
         if (Session::flash()->has('next')) {
             Session::pop('next');
         }
         # push next request page in the session
         Session::push('next', Request::GET()->next);
     }
     if ("POST" == Request::method()) {
         $username = Request::POST()->username;
         # $_POST['username']
         $password = Request::POST()->password;
         # auth by base controller
         $auth = self::auth($username, $password);
         if ($auth) {
             # if session path contain next request page
             if (Session::flash()->has('next')) {
                 # redirect to that request page
                 Response::redirect(Session::pop('next'));
             } else {
                 #
                 Response::redirect('');
             }
         } else {
             # if authenticated failure
             # pust a flash message
             Session::push('flash-message', 'Authenticated failure!');
             View::render('login');
         }
     } else {
         View::render('login');
     }
 }