コード例 #1
0
ファイル: FilesAction.class.php プロジェクト: 8yong8/vshop
 public function files_user_update()
 {
     //$_POST['fid'] = 2;
     //$_POST['msg'] = '很好';
     //$_POST['user_id'] = '26,27';
     $model = M('files_user');
     //修改自己批复信息
     $data['fid'] = $_POST['fid'];
     $data['user_id'] = $this->user['id'];
     $vo = $model->where($data)->find();
     $s_data['status'] = 2;
     $s_data['msg'] = $_POST['msg'];
     if ($_POST['user_id']) {
         $uids = explode(',', $_POST['user_id']);
     }
     if ($_POST['user_id']) {
         $uids = explode(',', $_POST['user_id']);
         $umodel = M('user');
         foreach ($uids as $uid) {
             //判断是否已存在
             $cdata['fid'] = $_POST['fid'];
             $cdata['user_id'] = $uid;
             $count = $model->where($cdata)->count();
             //echo $model->getlastsql();exit;
             if ($count > 0) {
                 continue;
             }
             $udata['id'] = $uid;
             $user = $umodel->where($udata)->find();
             $add_data['fid'] = $vo['fid'];
             $add_data['title'] = $vo['title'];
             $add_data['user_id'] = $uid;
             $add_data['user_name'] = $user['nickname'];
             $add_data['bm_name'] = $user['bm_name'];
             $add_data['from_id'] = $this->user['id'];
             $add_data['from_name'] = $this->user['nickname'];
             $add_data['from_time'] = time();
             if ($_POST['call_time']) {
                 $add_data['call_time'] = strtotime($_POST['call_time']);
             }
             $result = $model->add($add_data);
             //推送
             if ($result && $user['baiduUserId']) {
                 $sent_array['module'] = MODULE_NAME;
                 $sent_array['action'] = 'show';
                 $sent_array['id'] = $_POST['fid'];
                 $custom_content = json_encode($sent_array);
                 $result = push_msg($user['baiduUserId'], $user['mb_system'], $vo['title'], $custom_content);
             }
             if ($user['position'] != '普通员工') {
                 $s_data['remark'] = '请' . $user['nickname'] . '批阅';
             } else {
                 if ($this->user['position'] == '书记') {
                     $s_data['remark'] = mb_substr($this->user['position'], 0, 1, 'utf-8') . $user['position'] . '分发';
                 } else {
                     $pos = strpos($user['position'], '主任');
                     if ($pos !== false) {
                         $notice = '分拣';
                     }
                     $s_data['remark'] = '请' . mb_substr($user['nickname'], 0, 1, 'utf-8') . $user['position'] . $notice;
                 }
             }
         }
         $this->update_file_users($_POST['fid']);
     } else {
         /*unset($data['user_id']);
           $data['status'] = array('lt',2);
           $count = $model->where($data)->count();
           */
         if ($this->user['position'] == '书记') {
             $s_data['remark'] = '批阅完毕';
         } else {
             $s_data['remark'] = mb_substr($this->user['nickname'], 0, 1, 'utf-8') . $this->user['position'] . '办结';
         }
         //echo $model->getlastsql();exit;
         //$s_data['remark'] = '文书归档';
     }
     $s_data['update_time'] = time();
     $result = $model->where($data)->save($s_data);
     if ($result) {
         $msg['status'] = 1;
         $msg['notice'] = '提交成功';
         $msg['error_code'] = 1000;
         echo json_encode($msg);
         exit;
     } else {
         $msg['status'] = 0;
         $msg['notice'] = '修改失败';
         $msg['error_code'] = 8002;
         echo json_encode($msg);
         exit;
     }
 }
コード例 #2
0
ファイル: PublicAction.class.php プロジェクト: 8yong8/vshop
 public function checkLogin()
 {
     if ($_SESSION['verify'] != md5($_POST['verify'])) {
         //$this->error('验证码错误!');
     }
     $model = M('Member');
     $data['mobile'] = $_POST['mobile'];
     $vo = $model->field('id,mobile,salt,password')->where($data)->find();
     if (!$_POST['baiduUserId'] || $_POST['baiduUserId'] == '(null)') {
         $msg['error_code'] = 1001;
         $msg['notice'] = '百度ID不存在';
         echo json_encode($msg);
         exit;
     }
     if (!$vo) {
         $msg['error_code'] = 1001;
         $msg['notice'] = '用户不存在';
         echo json_encode($msg);
         exit;
     }
     if ($vo['password'] != md5($_POST['password'] . $vo['salt'] . $vo['salt'][1])) {
         $msg['notice'] = '密码错误';
         $msg['error_code'] = 8002;
         echo json_encode($msg);
         exit;
     }
     //清除其他百度id
     if ($vo['baiduUserId'] != $_POST['baiduUserId'] && $vo['baiduUserId']) {
         //file_put_contents('./1.txt',$vo['baiduUserId'].'/'.$_POST['baiduUserId']);
         //踢出
         $sent_array['module'] = 'Public';
         $sent_array['action'] = 'logout';
         $sent_array['id'] = 0;
         $custom_content = json_encode($sent_array);
         $MsgContent = '在其他地方登陆';
         push_msg($vo['baiduUserId'], $vo['mb_system'], $MsgContent, $custom_content);
     }
     $_data['id'] = $vo['id'];
     $_sdata['last_login_ip'] = _get_ip();
     $_sdata['login_count'] = $vo['login_count'] + 1;
     $_sdata['last_login_time'] = time();
     $_sdata['baiduUserId'] = $_POST['baiduUserId'];
     $_sdata['mb_system'] = $_POST['mb_system'] ? $_POST['mb_system'] : 2;
     $model->where($_data)->save($_sdata);
     //list($usec, $sec) = explode(' ', microtime());
     //echo ceil($usec*1000000);exit;
     //重新生成token
     $token = create_token($vo['id'], $vo['salt']);
     //存储token
     set_token($vo, $token);
     $vo['error_code'] = 0;
     $vo['token'] = $token;
     $vo['baiduUserId'] = $_POST['baiduUserId'];
     unset($vo['password']);
     echo json_encode($vo);
     exit;
 }