public function showImage()
 {
     $result['image'] = true;
     $result['topic'] = IndexPageConfig::$TOPIC;
     $name_id = HttpNamespace::getGET('name');
     if ($name_id) {
         $image = DetailNamespace::getNameById($name_id);
         if (!$image) {
             HttpNamespace::redirect(UrlNamespace::categoryUrl(self::$CATEGORY['id']));
         }
     } else {
         $category = self::$CATEGORY;
         $category['table'] = 'image';
         list($page, $list) = CommonNamespace::showPage($category, self::$MAJORY, 'id', 10);
         foreach ($list as $key => $value) {
             $list[$key]['list'] = $this->getHotImage(self::$MAJORY['id'], $value['id'], 4);
         }
         $this->assign('title', self::$MAJORY['name']);
         $this->assign('list', $list);
         $this->assign('image', true);
         $this->assign('page', $page);
         $this->display('majory/list.php');
     }
     $page = HttpNamespace::getGET('p');
     list($list, $result['count']) = DBXapian::searchImageByName($name_id, $page, 16);
     //组合list
     $result['list'] = array(array('id' => $image['id'], 'majory_id' => self::$MAJORY['id'], 'name' => $image['name'], 'list' => $list));
     $result['title'] = self::$MAJORY['name'] . '-' . $image['name'];
     $result['type_id'] = $this->typeId;
     $result['page'] = $this->_showPage($result['count']);
     $this->assign($result);
     $this->display('majory/list.php');
 }
 public function getGet()
 {
     foreach ($_REQUEST as $key => $value) {
         $_REQUEST[$key] = HttpNamespace::getREQUEST($key);
     }
     return $_REQUEST;
 }
 public function defaultAction()
 {
     $disease = HttpNamespace::getGET('disease');
     $province = HttpNamespace::getGET('province');
     $city = HttpNamespace::getGET('city');
     $district = HttpNamespace::getGET('district');
     $level = HttpNamespace::getGET('level');
     $page = HttpNamespace::getGET('page');
     $keyword = HttpNamespace::getGET('keyword');
     $result = DBXapian::searchHospital($disease, $province, $city, $district, '', $level, $keyword, $page, self::$PAGE_SIZE);
     echo json_encode($result);
     exit;
 }
 /**
  * 
  * @brief 分页
  * @param unknown_type $model
  * @param unknown_type $pageSize
  * @param unknown_type $map
  * @param unknown_type $order
  * @param unknown_type $join
  * @param unknown_type $field
  */
 public static function showPage($majory, $order = 'puid', $limit = 30)
 {
     $field = self::_getFields();
     $where = "`majory_id` = {$majory['id']}";
     $sqlCount = "SELECT count(*) as count FROM " . self::$TABLE_DIARY . " WHERE {$where}";
     $page = HttpNamespace::getGET('p', 1);
     $offset = ($page - 1) * $limit;
     $sql = "SELECT " . implode(',', $field) . " FROM " . self::$TABLE_DIARY . " WHERE {$where} ORDER BY `" . $order . "` desc LIMIT {$offset},{$limit}";
     $num = DBMysqli::getInstance()->getRow($sqlCount);
     $page = new Page($num['count'], $limit);
     $result[] = $page->show();
     $result[] = DBMysqli::getInstance()->getAll($sql);
     return $result;
 }
 public function defaultAction()
 {
     self::$TYPE = (int) HttpNamespace::getGET('type', 1);
     if (empty(self::$CATEGORY) || empty(self::$PUID)) {
         $this->_error();
     }
     self::$ARTICLE = DetailNamespace::getArticle(self::$CATEGORY, self::$PUID);
     if (empty(self::$ARTICLE)) {
         $this->_error();
     }
     self::$ARTICLE['title'] = self::$ARTICLE['title'] . ' > ' . self::$ARTICLE['author'] . ' - 大头狗日记';
     self::$URL = 'http://datougou.cn' . UrlNamespace::detailUrl(self::$MAJORY['id'], self::$PUID);
     $this->_bulidUrl();
     DetailNamespace::increaseShareTimes(self::$CATEGORY, self::$PUID);
     HttpNamespace::redirect($this->_getUrl());
 }
 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();
 }
 public function defaultAction()
 {
     $this->result['top_image'] = IndexPageConfig::$IMAGE_TOP;
     if (empty(self::$MAJORY) || empty(self::$CATEGORY)) {
         HttpNamespace::redirect(__APP__ . '/pub');
     }
     if (self::$CATEGORY['id'] == 20) {
         //发表日记类型文章
         $this->result['diary'] = true;
     }
     if (HttpNamespace::isPost()) {
         $title = HttpNamespace::getPOST('title');
         $content = htmlspecialchars($_POST['content']);
     }
     $this->assign($this->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();
 }
 public function defaultAction()
 {
     if (HttpNamespace::isPost()) {
         $this->_username = HttpNamespace::getPOST('username');
         $this->_password = HttpNamespace::getPOST('password');
         $this->_password2 = HttpNamespace::getPOST('password2');
         if ($this->_validator()) {
             if (UserNamespace::saveUser($this->_username, $this->_password)) {
                 if (UserNamespace::login($this->_username, $this->_password)) {
                     if (self::$REQUEST['url']) {
                         HttpNamespace::redirect(self::$REQUEST['url']);
                     }
                     HttpNamespace::redirect(__APP__);
                 } else {
                     HttpNamespace::redirect(UrlNamespace::loginUrl());
                 }
             }
         }
     }
     $this->assign($this->error);
     $this->display();
 }
 public function defaultAction()
 {
     $content = addslashes(HttpNamespace::getPOST('content'));
     $puid = HttpNamespace::getPOST('puid');
     $backUrl = UrlNamespace::detailUrl(self::$MAJORY['id'], $puid);
     if (empty(self::$CATEGORY)) {
         $error = ErrorConfig::EMPTY_VALUE;
         if (strpos($backUrl, '?') === false) {
             $backUrl .= '?error=' . $error;
         }
         $backUrl .= '&error=' . $error;
         HttpNamespace::redirect($backUrl);
     }
     if (empty($content)) {
         //error = 1
         $error = ErrorConfig::EMPTY_VALUE;
         if (strpos($backUrl, '?') === false) {
             $backUrl .= '?error=' . $error;
         }
         $backUrl .= '&error=' . $error;
         HttpNamespace::redirect($backUrl);
     }
     if (isset($_SESSION['login']) && $_SESSION['login']) {
         $userId = $_SESSION['user']['id'];
         $nick_name = addslashes($_SESSION['user']['nick_name']);
     } else {
         $userId = 0;
         $nick_name = '匿名用户';
     }
     $ua = 0;
     $sql = "INSERT INTO " . self::$CATEGORY['table'] . "_comment (`puid`,`user_id`,\n               `nick_name`,`content`,`times`,`ua`)VALUES({$puid},{$userId},'" . $nick_name . "',\n               '" . $content . "'," . time() . ",{$ua})";
     if (DBMysqli::getInstance()->execute($sql) > 0) {
         $sql = "UPDATE " . self::$CATEGORY['table'] . " set comment_times=comment_times+1,weight=weight+1 WHERE puid={$puid}";
         DBMysqli::getInstance()->execute($sql);
     }
     HttpNamespace::redirect($backUrl);
 }
 public static function saveUser($username, $password)
 {
     $sql = "INSERT INTO `user`(`user_name`, `nick_name`, `last_login_time`, `last_login_ip`, \n            `password`, `register_time`)VALUES('" . $username . "','" . $username . "','" . time() . "',\n            '" . HttpNamespace::getIp() . "','" . md5($password) . "','" . time() . "')";
     return DBMysqli::getInstance()->execute($sql);
 }
 public static function getErrorCode()
 {
     return (int) HttpNamespace::getGET('error', 0);
 }
 public function _error()
 {
     HttpNamespace::redirect(__APP__ . '/search');
 }