예제 #1
0
function getCurrentUser()
{
    $_cookie_user = cookie('LOGGED_USER');
    $_session_user_id = intval($_SESSION['mid']);
    // 验证本地系统登录
    if ($_session_user_id) {
        return $_session_user_id;
    } elseif ($_cookie_user) {
        $cookieId = explode('.', jiemi($_cookie_user));
        if ($cookieId[0] !== 'thinksns') {
            return false;
        }
        $db_prefix = getDbPrefix();
        $userInfo = doQuery("SELECT * FROM {$db_prefix}user WHERE `uid` = '{$cookieId[1]}'");
        $user = doQuery("SELECT * FROM {$db_prefix}user WHERE `email` = '{$userInfo[0]['email']}'");
        if ($user) {
            $_SESSION['mid'] = $user[0]['uid'];
            return $_SESSION['mid'];
        } else {
            return false;
        }
    } else {
        return false;
    }
}
예제 #2
0
 public function ajaxUpload()
 {
     //执行附件上传操作
     $d['type_name'] = 11;
     D('feedback_type')->add($d);
     $attach_type = t($_REQUEST['type']);
     $options['uid'] = $this->mid;
     //加密传输这个字段,防止客户端乱设置.
     $options['allow_exts'] = t(jiemi($_REQUEST['exts']));
     $options['allow_size'] = t(jiemi($_REQUEST['size']));
     $jiamiData = jiemi(t($_REQUEST['token']));
     list($options['allow_exts'], $options['need_review'], $fid) = explode("||", $jiamiData);
     $options['limit'] = intval(jiemi($_REQUEST['limit']));
     $options['now_pageCount'] = intval($_REQUEST['now_pageCount']);
     $data['upload_type'] = $attach_type;
     $info = model('Attach')->upload($data, $options);
     //上传成功
     echo json_encode($info);
 }
예제 #3
0
 public function checkVersion()
 {
     $version = t($_GET['version']);
     $version = jiemi($version);
     $version = explode('|', $version);
     $path = DATA_PATH . '/update';
     $versionArr = F('versions', '', $path);
     $keyArr = array_keys($versionArr);
     $diff = array_diff($keyArr, $version);
     if (empty($diff)) {
         echo json_encode(0);
         exit;
     }
     foreach ($diff as $d) {
         $result[$d] = $versionArr[$d];
     }
     echo json_encode($result);
 }
 public function ajaxUpload()
 {
     //执行附件上传操作
     $attach_type = t($_REQUEST['type']);
     $options['uid'] = $this->mid;
     //加密传输这个字段,防止客户端乱设置.
     $options['allow_exts'] = t(jiemi($_REQUEST['exts']));
     $options['allow_size'] = t(jiemi($_REQUEST['size']));
     $options['limit'] = intval(jiemi($_REQUEST['limit']));
     $options['now_pageCount'] = intval($_REQUEST['now_pageCount']);
     $info = X('Xattach')->upload($attach_type, $options);
     if ($info['status'] == true) {
         unset($info['info'][0]['savename']);
         unset($info['info'][0]['savepath']);
         unset($info['info'][0]['hash']);
     }
     $info['debug'] = $options;
     //上传成功
     echo json_encode($info);
 }
예제 #5
0
 public function ajaxUpload()
 {
     //执行附件上传操作
     $attach_type = t($_REQUEST['type']);
     $options['uid'] = $this->mid;
     //加密了这个字段
     $options['allow_exts'] = jiemi(t($_REQUEST['token']));
     $options['limit'] = intval($_REQUEST['limit']);
     $options['now_pageCount'] = intval($_REQUEST['now_pageCount']);
     $info = X('Xattach')->upload($attach_type, $options);
     if ($info['status'] == true) {
         unset($info['info']['savename']);
         unset($info['info']['savepath']);
         unset($info['info']['hash']);
         unset($info['info']['attach_type']);
     }
     //上传成功
     echo json_encode($info);
 }
 /**
  * 获取cookie中记录的用户ID
  */
 public function getCookieUid()
 {
     static $cookie_uid = null;
     if (isset($cookie_uid)) {
         return $cookie_uid;
     }
     $cookie = t(cookie('LOGGED_USER'));
     $cookie = explode('.', jiemi($cookie));
     $cookie_uid = $cookie[0] !== 'thinksns' ? false : $cookie[1];
     return $cookie_uid;
 }
예제 #7
0
 function doChangePassword()
 {
     $email = jiemi($_POST['code'], 'thinksns');
     $map['email'] = $email;
     $dao = D('User');
     //验证密码位数
     if (strlen($_POST['newpassword']) < 6) {
         $this->error("密码不得少于6位!");
         exit;
     }
     //验证两次输入
     if ($_POST['newpassword'] != $_POST['newpassword2']) {
         $this->error("两次输入的密码不一致!");
         exit;
     }
     //修改密码
     $map['password'] = md5($_POST['newpassword']);
     if ($dao->save($map, "email='{$email}'")) {
         $this->success("密码修改成功,请下一次使用新密码登陆!");
     } else {
         $this->error("密码修改失败!");
     }
 }
 function relation($code, $uid)
 {
     $Group = D('Group');
     $Friend = D('Friend');
     $User = D('User');
     D("LoginRecord")->record($user["id"]);
     $code = jiemi($code);
     $code = json_decode($code);
     $fuid = 0;
     $gid = 0;
     if ($code) {
         $fuid = $code[0];
         $fusername = $code[1];
         $fgid = $code[2];
         $gid = $code[3];
         D("Friend")->makeFriend($fuid, $fusername, $fgid, $uid, getUserName($uid), 1);
         //添加动态
         $title['fuid'] = $fuid;
         $title['fuser'] = getUserName($fuid);
         $title['uid'] = $uid;
         $title['user'] = getUserName($uid);
         $title['site_name'] = $this->opts['site_name'];
         $this->api->feed_publish('invite_reg', $title, $body = '');
         //添加积分
         setScore($fuid, 'invite_reg');
         if ($gid > 0) {
             D('Group')->joingroup($uid, $gid, 3, $incMemberCount = true);
         }
     }
     $relationFriend = explode(',', $this->opts['reg_relation_friend']);
     //朋友关联
     $relationGroup = explode(',', $this->opts['reg_relation_group']);
     //群众默认关联
     if (!empty($relationFriend) && is_array($relationFriend)) {
         foreach ($relationFriend as $v) {
             $v = intval($v);
             if ($User->where('id=' . $v)->count()) {
                 if ($fuid != $v) {
                     $Friend->makeFriend($v, getUserName($v), 1, $uid, getUserName($uid), 1);
                 }
             }
         }
     }
     if (!empty($relationGroup) && is_array($relationGroup)) {
         foreach ($relationGroup as $v) {
             $v = intval($v);
             if ($Group->where('id=' . $v . ' AND is_del=0')->count()) {
                 if ($gid != $v) {
                     $Group->joingroup($uid, $v, 3, $incMemberCount = true);
                 }
             }
         }
     }
 }
예제 #9
0
 public function checkJsToken()
 {
     $type = C('OTHER_TOKEN');
     $old = Session::get($type);
     $this->setJsToken();
     if (empty($old)) {
         return true;
     }
     $jiemi_token = jiemi($old);
     $time = microtime(TRUE) - $jiemi_token;
     if ($time < 1) {
         echo 'error';
         exit;
     } elseif ($time < 3) {
         $count = intval(Cookie::get('count_' . $this->appId));
         $result = !empty($count) ? $count + 1 : 0;
         if ($result == 3) {
             echo 'fail';
             Cookie::set('count_' . $this->appId, 0);
             exit;
         } else {
             Cookie::set('count_' . $this->appId, $result);
         }
     }
 }