public function _init() { // a listing of articles in the footer $this->view->list = !Fari_User::isAuthenticated('realname') ? Fari_Db::select('articles', 'name, published, slug', array('status' => 1), 'published DESC', BLOG_LIST) : Fari_Db::select('articles', 'name, published, slug', NULL, 'published DESC', BLOG_LIST); // articles archive (no limit on number of articles) $this->view->archive = !Fari_User::isAuthenticated('realname') ? Fari_Db::select('articles', 'name, published, slug', array('status' => 1), 'published DESC') : Fari_Db::select('articles', 'name, published, slug', NULL, 'published DESC'); }
public function _init() { // is user authenticated? if (!Fari_User::isAuthenticated('realname')) { $this->redirect('/secure/'); die; } // get user's credentials $this->view->user = Fari_User::getCredentials(); // get messages for us $this->view->system = Fari_Message::get(); }
public function login() { if (Fari_User::isAuthenticated('realname')) { $this->redirect('/'); } // authenticate user if form data POSTed if (isset($_POST['username'])) { if (Fari_User::authenticate($_POST['username'], $_POST['password'], $_POST['token'], 'realname')) { Fari_Message::success('Welcome back \'' . Fari_User::getCredentials() . '\''); $this->redirect('/'); die; } Fari_Message::fail('Incorrect authentication details'); } // create token & display login form $this->view->token = Fari_Token::create(); // pickup messages for us $this->view->messages = Fari_Message::get(); $this->view->display('/themes/' . BLOG_THEME . '/login'); }
<?php if (!defined('FARI')) { die; } ?> <?php if (Fari_User::isAuthenticated('realname')) { ?> <div id="admin"> <div class="inside"> <a href="<?php $this->url('/blog/create'); ?> ">Add new article</a> | <a href="<?php $this->url('/blog/logout'); ?> ">Logout</a> </div> </div> <?php }