Пример #1
0
 /**
  * 检测发帖间隔时间
  */
 private function checkTimesInterval()
 {
     $status = checkTimesInterval(session('userID'), 0);
     if (!$status) {
         $result['status'] = FALSE;
         $result['msg'] = '操作间隔时间为' . C('INTERVAL_TIME') . '分钟!';
     } else {
         $result['status'] = true;
     }
     return $result;
 }
Пример #2
0
 /**
  * 增加社区信息
  */
 public function addSqInfo()
 {
     //判断用户是否需要检查
     $uid = $_SESSION['userID'];
     //检测是否是黑名单用户
     $groupID = M('user')->where(array('userID' => $uid))->getField('groupID');
     if ($groupID == 4) {
         $result['status'] = FALSE;
         $result['massage'] = '你已被加入黑名单,不允许发布~';
         $this->ajaxReturn($result, 'json');
     }
     //新用户审核
     if (!checkNewUserPost($uid, 1)) {
         $result['status'] = FALSE;
         $result['massage'] = '新注册用户请在注册' . C('NEW_USER_POST_TIME') . '分钟后发帖';
         $this->ajaxReturn($result, 'json');
     }
     $idList = array(9, 10, 11, 12);
     $userInfo = M('user')->field('groupID')->where("userID={$uid}")->find();
     if (!in_array($userInfo['groupID'], $idList)) {
         //检测每天只能发送的数量
         if (!checkTimes($uid, 1)) {
             $result['status'] = FALSE;
             $result['massage'] = '每个帐号每天只能发送' . C('POST_NUM') . '条社区资讯!';
             $this->ajaxReturn($result, 'json');
         }
         //检测发帖时间间隔
         if (!checkTimesInterval($uid, 1)) {
             $result['status'] = FALSE;
             $result['massage'] = '每次发帖间隔时间为' . C('INTERVAL_TIME') . '分钟';
             $this->ajaxReturn($result, 'json');
         }
     }
     fliter_script($_POST);
     $dataModel = M('SqData');
     $data['userID'] = $_SESSION['userID'];
     $data['userName'] = $_SESSION['userName'];
     $data['editor'] = $_SESSION['userName'];
     $data['editTime'] = time();
     $data['postTime'] = time();
     $data['gid'] = $_POST['gid'];
     $data['ip'] = $_SERVER['REMOTE_ADDR'];
     $data['cityID'] = $_POST['cityID'];
     $data['title'] = $_POST['title'];
     $data['sid'] = $_POST['classId'];
     $data['from_author'] = $_POST['from_author'];
     $data['from_url'] = $_POST['from_url'];
     $map['content'] = $_POST['content'];
     $thumb = array();
     foreach ($_POST['picUrl'] as $v) {
         $thumbList = explode('.', $v);
         $thumbList['1'] = $thumbList['1'] . '_thumb';
         $thumbList = implode('.', $thumbList);
         $thumb[] = $thumbList;
     }
     if ($_POST['picUrl']) {
         $data['thumb'] = implode('|', $thumb);
         $data['picUrl'] = implode('|', $_POST['picUrl']);
     }
     $dataModel->startTrans();
     $res1 = $dataModel->data($data)->add();
     $map['dataID'] = $res1;
     $res2 = M('SqFdata')->data($map)->add();
     if ($res1 == true && $res2 == true) {
         M('member')->where("uid={$_SESSION['userID']}")->setInc('sqs');
         M('postlog')->data(['days' => date('Ymd'), 'uid' => $data['userID'], 'type' => 1])->add();
         $dataModel->commit();
         $res['status'] = true;
         $res['massage'] = "发布成功";
     } else {
         $dataModel->rollback();
         $res['status'] = false;
         $res['massage'] = "发布失败";
     }
     $this->ajaxReturn($res, 'json');
 }
Пример #3
0
 /**
  * 编辑社区信息
  */
 public function editSqInfo()
 {
     $idList = array(9, 10, 11, 12);
     $uid = $_SESSION['userID'];
     $userInfo = M('user')->field('groupID')->where("userID= " . $uid)->find();
     if (IS_POST) {
         if (!in_array($userInfo['groupID'], $idList)) {
             //检测每天只能发送的数量
             if (!checkTimes($uid, 1)) {
                 $result['status'] = FALSE;
                 $result['massage'] = '每个帐号每天只能操作' . C('POST_NUM') . '条社区资讯!';
                 $this->ajaxReturn($result, 'json');
             }
             //检测发帖时间间隔
             if (!checkTimesInterval($uid, 1)) {
                 $result['status'] = FALSE;
                 $result['massage'] = '每次操作间隔时间为' . C('INTERVAL_TIME') . '分钟';
                 $this->ajaxReturn($result, 'json');
             }
         }
         $id = $_POST['id'];
         $dataModel = M('SqData');
         $data['userID'] = $_SESSION['userID'];
         $data['userName'] = $_SESSION['userName'];
         $data['editor'] = $_SESSION['userName'];
         $data['editTime'] = time();
         $data['postTime'] = time();
         $data['gid'] = $_POST['gid'];
         $data['ip'] = $_SERVER['REMOTE_ADDR'];
         $data['cityID'] = $_POST['cityID'];
         $data['title'] = $_POST['title'];
         $data['sid'] = $_POST['classId'];
         $data['from_author'] = $_POST['from_author'];
         $data['from_url'] = $_POST['from_url'];
         $map['content'] = $_POST['content'];
         $thumb = array();
         foreach ($_POST['picUrl'] as $v) {
             $thumbList = explode('.', $v);
             $thumbList['1'] = $thumbList['1'] . '_thumb';
             $thumbList = implode('.', $thumbList);
             $thumb[] = $thumbList;
         }
         if ($_POST['picUrl']) {
             $data['thumb'] = implode('|', $thumb);
             $data['picUrl'] = implode('|', $_POST['picUrl']);
         }
         $dataModel->startTrans();
         $res1 = $dataModel->where("id={$id}")->data($data)->save();
         $res2 = M('SqFdata')->where("dataID = {$id}")->data($map)->save();
         if ($res1 !== false && $res2 !== false) {
             $dataModel->commit();
             M('postlog')->data(['days' => date('Ymd'), 'uid' => $uid, 'type' => 1])->add();
             $res['status'] = true;
             $res['massage'] = "编辑成功";
         } else {
             $dataModel->rollback();
             $res['status'] = false;
             $res['massage'] = "编辑失败";
         }
         $this->ajaxReturn($res, 'json');
     } else {
         if (!in_array($userInfo['groupID'], $idList)) {
             //检测每天只能发送的数量
             if (!checkTimes($uid, 1)) {
                 $this->error('每个帐号每天只能发送' . C('POST_NUM') . '条社区资讯!');
             }
             //检测发帖时间间隔
             if (!checkTimesInterval($uid, 1)) {
                 $this->error('每次发帖间隔时间为' . C('INTERVAL_TIME') . '分钟');
             }
         }
         $id = intval(I('get.id'));
         $alias = 'a';
         $join = 'join ybirds_sq_fdata as f on a.id = f.dataID';
         $field = 'a.*,f.content';
         $info = M('sq_data')->alias($alias)->field($field)->join($join)->where("a.id = {$id}")->find();
         if ($info['picUrl'] != '') {
             $info['picUrl'] = explode('|', $info['picUrl']);
         }
         //获取所有的国家
         $countryInfo = array('1' => '英国', '6' => '美国', '7' => '爱尔兰');
         //获取所有的栏目
         $classInfo = M('SqClass')->where(array('fid' => 0))->select();
         $this->assign('classInfo', $classInfo);
         $this->assign('countryInfo', $countryInfo);
         $this->assign('info', $info);
         $this->display();
     }
 }
Пример #4
0
 /**
  * 检查用户是否可以发贴.
  * 即用户在一定时间内只能发一次贴的检查.
  * 
  * @access public
  * @param int $uid 用户 ID.
  * @param int $type 类型, 可用的类型: TYPE_CLASSIFIED/TYPE_SQ; 默认 TYPE_CLASSIFIED.
  * @return bool 可以发贴返回 true; 否则返回 false.
  */
 public function checkPostTimeInterval($uid, $type = self::TYPE_CLASSIFIED)
 {
     return checkTimesInterval($uid, $type);
 }