/** * 检测新注册用户发帖时间 */ private function checkNewUserPost() { $status = checkNewUserPost(session('userID'), 0); if (!$status) { $result['status'] = FALSE; $result['msg'] = '新注册用户请在注册' . C('NEW_USER_POST_TIME') . '分钟后发帖'; } else { $result['status'] = true; } return $result; }
/** * 增加社区信息 */ 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'); }
/** * 检查新用户是否可以发贴. * 即新用户在注册后一定时间内是不能发贴的. * * @access public * @param int $uid 用户 ID. * @param int $type 类型, 可用的类型: TYPE_CLASSIFIED/TYPE_SQ; 默认 TYPE_CLASSIFIED. * @return bool 可以发贴返回 true; 否则返回 false. */ public function checkNewUserPost($uid, $type = self::TYPE_CLASSIFIED) { return checkNewUserPost($uid, $type); }