Esempio n. 1
0
 /**
  * Post a message.
  *
  * @access public
  * @return void
  */
 public function post($type)
 {
     $account = $this->app->user->account;
     $admin = $this->app->user->admin;
     $message = fixer::input('post')->add('date', helper::now())->add('type', $type)->add('status', '0')->setDefault('public', '1')->setIF(isset($_POST['secret']) and $_POST['secret'] == 1, 'public', '0')->setIF($type == 'message', 'to', 'admin')->setIF($account != 'guest', 'account', $account)->setIF($admin == 'super', 'status', '1')->add('ip', $this->server->REMOTE_ADDR)->get();
     if (isset($this->config->site->filterSensitive) and $this->config->site->filterSensitive == 'open') {
         $dicts = !empty($this->config->site->sensitive) ? $this->config->site->sensitive : $this->config->sensitive;
         $dicts = explode(',', $dicts);
         if (!validater::checkSensitive($message, $dicts)) {
             return array('result' => 'fail', 'reason' => 'error', 'message' => $this->lang->error->sensitive);
         }
     }
     $this->dao->insert(TABLE_MESSAGE)->data($message, $skip = 'captcha, secret')->autoCheck()->check('captcha', 'captcha')->check('type', 'in', $this->config->message->types)->checkIF(!empty($message->email), 'email', 'email')->batchCheck($this->config->message->require->post, 'notempty')->exec();
     if (dao::isError()) {
         return array('result' => 'fail', 'message' => dao::getError());
     }
     $this->setCookie($this->dao->lastInsertId());
     return array('result' => 'success', 'message' => $this->lang->message->thanks);
 }
Esempio n. 2
0
 /**
  * Update thread.
  * 
  * @param  int    $threadID 
  * @access public
  * @return void
  */
 public function update($threadID)
 {
     $thread = $this->getByID($threadID);
     $isAdmin = $this->app->user->admin == 'super';
     $canManage = $this->canManage($thread->board);
     $allowedTags = $this->app->user->admin == 'super' ? $this->config->allowedTags->admin : $this->config->allowedTags->front;
     $thread = fixer::input('post')->setIF(!$canManage, 'readonly', 0)->setIF(!$this->post->isLink, 'link', '')->stripTags('content,link', $allowedTags)->setForce('editor', $this->session->user->account)->setForce('editedDate', helper::now())->setDefault('readonly', 0)->remove('files,labels, views, replies, stick, hidden')->get();
     if (isset($this->config->site->filterSensitive) and $this->config->site->filterSensitive == 'open') {
         $dicts = !empty($this->config->site->sensitive) ? $this->config->site->sensitive : $this->config->sensitive;
         $dicts = explode(',', $dicts);
         if (!validater::checkSensitive($thread, $dicts)) {
             return array('result' => 'fail', 'message' => $this->lang->error->sensitive);
         }
     }
     $this->dao->update(TABLE_THREAD)->data($thread, $skip = "{$this->session->captchaInput}, uid, isLink")->autoCheck()->batchCheckIF(!$this->post->isLink, $this->config->thread->require->edit, 'notempty')->batchCheckIF($this->post->isLink, $this->config->thread->require->link, 'notempty')->check($this->session->captchaInput, 'captcha')->where('id')->eq($threadID)->exec();
     $this->loadModel('file')->updateObjectID($this->post->uid, $threadID, 'thread');
     if (dao::isError()) {
         return false;
     }
     /* Upload file.*/
     $this->loadModel('file')->saveUpload('thread', $threadID);
     $thread = $this->getByID($threadID);
     if (empty($thread)) {
         return false;
     }
     return $this->loadModel('search')->save('thread', $thread);
 }
Esempio n. 3
0
 /**
  * Update a reply.
  * 
  * @param  int      $replyID 
  * @access public
  * @return void
  */
 public function update($replyID)
 {
     $allowedTags = $this->app->user->admin == 'super' ? $this->config->allowedTags->admin : $this->config->allowedTags->front;
     $reply = fixer::input('post')->setForce('editor', $this->session->user->account)->setForce('editedDate', helper::now())->stripTags('content', $allowedTags)->remove('files,labels,hidden')->get();
     if (isset($this->config->site->filterSensitive) and $this->config->site->filterSensitive == 'open') {
         $dicts = !empty($this->config->site->sensitive) ? $this->config->site->sensitive : $this->config->sensitive;
         $dicts = explode(',', $dicts);
         if (!validater::checkSensitive($reply, $dicts)) {
             return array('result' => 'fail', 'message' => $this->lang->error->sensitive);
         }
     }
     $this->dao->update(TABLE_REPLY)->data($reply, $skip = 'captcha, uid')->autoCheck()->batchCheck($this->config->reply->require->post, 'notempty')->check('captcha', 'captcha')->where('id')->eq($replyID)->exec();
     $this->loadModel('file')->updateObjectID($this->post->uid, $replyID, 'reply');
     if (!dao::isError()) {
         $this->loadModel('file')->saveUpload('reply', $replyID);
         return true;
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Post a message.
  *
  * @access public
  * @return void
  */
 public function post($type)
 {
     $account = $this->app->user->account;
     $admin = $this->app->user->admin;
     $message = fixer::input('post')->add('date', helper::now())->add('type', $type)->add('status', '0')->setDefault('public', '1')->setIF(isset($_POST['secret']) and $_POST['secret'] == 1, 'public', '0')->setIF($type == 'message', 'to', 'admin')->setIF($account != 'guest', 'account', $account)->setIF($admin == 'super', 'status', '1')->add('ip', $this->server->REMOTE_ADDR)->get();
     if (strlen($message->content) > 29) {
         $repeat = $this->loadModel('guarder')->checkRepeat($message->content);
         if ($repeat) {
             return array('result' => 'fail', 'message' => $this->lang->error->noRepeat);
         }
     }
     if ($this->loadModel('guarder')->matchList($message)) {
         return array('result' => 'fail', 'reason' => 'error', 'message' => $this->lang->error->sensitive);
     }
     if (isset($this->config->site->filterSensitive) and $this->config->site->filterSensitive == 'open') {
         $dicts = !empty($this->config->site->sensitive) ? $this->config->site->sensitive : $this->config->sensitive;
         $dicts = explode(',', $dicts);
         if (!validater::checkSensitive($message, $dicts)) {
             return array('result' => 'fail', 'reason' => 'error', 'message' => $this->lang->error->sensitive);
         }
     }
     $this->dao->insert(TABLE_MESSAGE)->data($message, $skip = $this->session->captchaInput . ', secret')->autoCheck()->check($this->session->captchaInput, 'captcha')->check('type', 'in', $this->config->message->types)->checkIF(!empty($message->email), 'email', 'email')->checkIF(!empty($message->phone), 'phone', 'phone')->batchCheck($this->config->message->require->post, 'notempty')->exec();
     $this->setCookie($this->dao->lastInsertId());
     /* Record post number. */
     $guarder = $this->loadModel('guarder');
     $guarder->logOperation('account', 'postComment');
     $guarder->logOperation('ip', 'postComment');
     if (dao::isError()) {
         $errors = dao::getError();
         if (isset($errors[$this->session->captchaInput])) {
             $guarder->logOperation('ip', 'captchaFail');
             $guarder->logOperation('account', 'captchaFail');
         }
         return array('result' => 'fail', 'message' => $errors);
     }
     return array('result' => 'success', 'message' => $this->lang->message->needCheck);
 }