Exemplo n.º 1
0
 /**
  * 登录限制
  * @param null $rt
  * @param User $user
  * @return null
  */
 public function message_login_restrictions($rt, $user)
 {
     try {
         if (!$this->notice($user->getId(), 'message', 'login_restrictions')) {
             return $rt;
         }
         $mt = new MailTemplate("message_notice/login_restrictions.md");
         $mt->setUserInfo($user->getInfo());
         c_lib()->load('input');
         $input = new Input();
         $mt->setValues(['login_ip' => $input->getRealIP(), 'login_ua' => $input->getUA(), 'login_count' => $user->getErrorLoginCount()]);
         $this->message->addNoticeMsg($mt->getTitle(), $mt->getContent(), $user->getId());
     } catch (\Exception $ex) {
         Log::write(_("NoticeApply message_login_restrictions create a Exception.") . "EX:[" . $ex->getCode() . "]:" . $ex->getMessage(), Log::NOTICE);
     }
     return $rt;
 }
Exemplo n.º 2
0
 /**
  * 插入评论内容
  * @param string $content
  * @param int    $parent
  * @param int    $parent_top
  * @param int    $user_id
  * @return int
  */
 private function insert_comment($content, $parent, $parent_top, $user_id)
 {
     c_lib()->load('input');
     $input = new Input();
     $ip = $input->getIp()->binIp();
     $ua = $input->getUA();
     $write = $this->db->getWriter();
     $write->pdo->beginTransaction();
     $info = ['users_id' => $user_id, 'comment_content' => $content, 'comment_time' => $input->time(), 'comment_parent' => $parent ? $parent : NULL, 'comment_parent_top' => $parent_top ? $parent_top : NULL, 'comment_ip' => $ip, 'comment_agent' => $ua];
     $info['comment_status'] = $this->get_comment_status($info);
     $comment_id = $write->insert("comments", $info);
     if ($comment_id < 1) {
         $write->pdo->rollBack();
         Log::write(implode(",", $write->error()), Log::SQL);
         $this->throwMsg(-5);
     }
     $has_flag = $write->insert($this->relation_table, ['comments_id' => $comment_id, $this->relation_field => $this->id, 'users_id' => $user_id, 'object_users_id' => $this->get_object_users_id()]);
     if ($has_flag < 0) {
         $write->pdo->rollBack();
         Log::write(implode(",", $write->error()), Log::SQL);
         $this->throwMsg(-6);
     }
     $write->pdo->commit();
     $rt = $this->comment_hook($content, $parent, $parent_top, $user_id);
     if ($parent != 0) {
         hook()->apply('Comment_reply', $rt, $this->comment_type, $this->id, $user_id, $parent, $parent_top, $content);
     }
     return $comment_id;
 }