public function defaultAction() { $result['image'] = true; $result['top_image'] = IndexPageConfig::$IMAGE_TOP; $this->orgWord = HttpNamespace::getGET('kw'); $this->typeId = HttpNamespace::getGET('type'); $this->params['query'] = $this->orgWord; //搜索作者 if ($this->typeId == 'author') { $this->params['author'] = true; //通过uid搜索作者 } elseif (strtolower($this->typeId) == 'uid') { $user = UserNamespace::getUserById($this->orgWord); if ($user) { $this->params['uid'] = true; $this->params['username'] = $user['nick_name']; $this->orgWord = $this->params['username']; } //搜索日记本通过id } elseif (strtolower($this->typeId) == 'bookid') { $this->params['bookid'] = true; $book = DiaryBookNamespace::getUserById($this->orgWord); if ($book) { $this->params['diarybook'] = $book['book_name']; $this->orgWord = $this->params['diarybook']; } //搜索日记本通过kw } elseif (strtolower($this->typeId) == 'bookname') { $this->params['bookname'] = true; //搜索个关键词 } else { $this->typeId = (int) $this->typeId; $pa = CategoryNamespace::getById($this->typeId); $this->type = $pa['type']; $this->params[$pa['type']] = $pa; } $page = HttpNamespace::getGET('p'); list($result['article'], $result['count'], $this->cutWord) = DBXapian::searchByQuery($this->params, $page, self::$PAGE_SIZE); $result['cutword'] = $this->createUrlByWord($this->cutWord); $result['kw'] = $this->orgWord; $result['title'] = $this->orgWord; $result['type_id'] = $this->typeId; $result['page'] = $this->_showPage($result['count']); $this->assign($result); $this->display(); }
function defaultAction() { $this->result['top_image'] = IndexPageConfig::$IMAGE_TOP; if (HttpNamespace::isPost()) { $username = HttpNamespace::getPOST('username'); $password = HttpNamespace::getPOST('password'); if (empty($username) || empty($password)) { $this->result['error'] = '用户名和密码不能为空'; } else { if (UserNamespace::login($username, $password)) { if (self::$REQUEST['url']) { HttpNamespace::redirect(self::$REQUEST['url']); } HttpNamespace::redirect(__APP__); } $this->result['error'] = '用户名或密码错误'; } } $this->assign($this->result); $this->display(); }
private function _validator() { if ($this->_username == '') { $this->error['username'] = '******'; return false; } $len = mb_strlen($this->_username, 'utf8'); $badCharactors = '`~!@#$%^&*()-=+[]{}\\|;:\'",.<>/?'; // 除_之外的其它字符 for ($i = 0, $n = strlen($badCharactors); $i < $n; ++$i) { if (strpos($this->_username, $badCharactors[$i]) !== false) { $this->error['username'] = '******'; return false; } } if ($len < 4 || $len > 20) { $this->error['username'] = '******'; return false; } if (UserNamespace::getUserInfo($this->_username)) { $this->error['username'] = '******'; return false; } $this->error['name'] = $this->_username; if ($this->_password == '') { $this->error['password'] = '******'; return false; } if ($this->_password != $this->_password2) { $this->error['password'] = '******'; return false; } if (strlen($this->_password) < 3 || strlen($this->_password) > 20) { $this->error['password'] = '******'; return false; } return true; }