Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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);
 }