Example #1
0
 /**
  * @Author: 段涛
  * @判断用户当天发帖是否已经超过5天
  * @function name checkPostTimes
  * @param int $times
  * @return int
  */
 private function checkPostTimes()
 {
     $status = checkTimes(session('userID'), 0);
     if (!$status) {
         $result['status'] = FALSE;
         $result['msg'] = '每个帐号每天只能操作' . C('POST_NUM') . '个帖子!';
     } else {
         $result['status'] = true;
     }
     return $result;
 }
     }
 } else {
     echo "Could not read from DB\n";
 }
 //check for fault events in DB
 if ($data2 = $_db->get('Fault_Event', array('Id', '>', $last_fault_id))) {
     $message = "The following fault event occured on:\n";
     if ($data2->counts() > 0) {
         $last_fault_id = $data->last()->Id;
         //echo "Id 2 = $last_fault_id\n";
         foreach ($data2->results() as $key) {
             if ($email = getEmailAddress($_db, $key->Unit_Id)) {
                 $user = $email[0];
                 $alarm = getValue(2, $key->Fault_Type);
                 $message = $message . "RTU: {$email['1']}\nFault Type: {$alarm['0']}\nFault Value: {$key->Fault_Value} {$alarm['1']}\nTime: {$timenow}";
                 if (checkTimes($_db, $user)) {
                     //echo "do email stuff\n";
                     //var_dump($email);
                     for ($i = 2; $i < sizeof($email); $i++) {
                         //echo $email[$i];
                         mail($email[$i], $subject, $message, $headers);
                     }
                 } else {
                     echo "do nothing\n";
                 }
             }
         }
     } else {
         //echo "no data received from database\n";
     }
 } else {
Example #3
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');
 }
Example #4
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();
     }
 }