public function login() { if (isset($this->request->query['returnurl'])) { //$this->request['url']['returnurl'] $returnurl = $this->request->query['returnurl']; } else { $returnurl = ADMIN_HOME_URL; } $session_user_admin = $this->Session->read(SESSION_USER_ADMIN); if ($session_user_admin) { $this->redirect($returnurl); return; } $this->set('returnurl', $returnurl); // If login (submit) button is press if ($this->request->isPost()) { $admin_access_list_arr = GlobalVar::read("admin_access_list_arr"); $username = $this->data['username']; $password = sha1($this->data['password']); if (isset($this->data['returnurl'])) { $returnurl = $this->data['returnurl']; } if (isset($admin_access_list_arr[$username]) && $admin_access_list_arr[$username] == $password) { $this->Session->write(SESSION_USER_ADMIN, $username); // save user to session $this->redirect($returnurl); } } }
public function index() { $this->set('title_for_layout', "Book's listing "); $searchword = isset($this->params['url']['searchword']) ? $this->params['url']['searchword'] : ''; $searchfield = isset($this->params['url']['searchfield']) ? $this->params['url']['searchfield'] : ''; $this->set('searchword', $searchword); $this->set('searchfield', $searchfield); $con = ''; if ($searchword != '') { $item_search = GlobalVar::read('search_book'); $v = $item_search[$searchfield]; if ($con == '') { $con = $con . " ( book." . $v . " like '%" . $searchword . "%' ) "; } $con = " Book.id_book IN ( select id_book from book where " . $con . " )"; } $this->Paginator->settings = array('fields' => array('Book.id_book', 'Book.img', 'Book.price', 'Book.name', 'wrote.id_author', 'Author.name'), 'joins' => array(array('table' => 'wrote', 'alias' => 'Wrote', 'foreignKey' => false, 'conditions' => array('book.id_book = Wrote.id_book')), array('table' => 'author', 'alias' => 'Author', 'foreignKey' => false, 'conditions' => array('author.id_author = wrote.id_author'))), 'conditions' => array('Book.id_book = wrote.id_book'), 'limit' => ROW_PER_PAGE, 'page' => 1); $data = $this->Paginator->paginate('Book', array($con)); $this->set('Books', $data); }