public function token()
 {
     $token = \Libs\Util\Encrypt::authcode($_POST['token'], 'DECODE', C('CLOUD_USERNAME'));
     if (!empty($token)) {
         S($this->Cloud->getTokenKey(), $token, 3600);
         $this->success('验证通过');
         exit;
     }
     $this->error('验证失败');
 }
示例#2
0
 /**
  * 注册用户的登陆状态 (即: 注册cookie + 注册session + 记录登陆信息)
  * @param array $user 用户相关信息 uid , username
  * @param type $is_remeber_me 有效期
  * @return type 成功返回布尔值
  */
 public function registerLogin(array $user, $is_remeber_me = 604800)
 {
     $key = \Libs\Util\Encrypt::authcode((int) $user['userid'], '');
     cookie(self::userUidKey, $key, (int) $is_remeber_me);
     return true;
 }
示例#3
0
    /**
     * 获取上传头像FLASH代码
     * @param type $uid 用户ID
     * @param type $type 类型
     * @param type $returnhtml
     * @return string 头像代码
     */
    public function getUploadPhotosHtml($uid, $type = 'virtual', $returnhtml = 1)
    {
        //验证
        $auth_data = urlencode(\Libs\Util\Encrypt::authcode($uid, ''));
        $upurl = CONFIG_SITEURL_MODEL . 'index.php?g=Member&m=Index&a=uploadavatar&auth_data=' . $auth_data;
        $html = '<script type="text/javascript">
swfobject.addDomLoadEvent(function () {
    var swfFullAvatar = new fullAvatarEditor("myContent", {
        id: \'swf\',
        upload_url: \'' . $upurl . '\',
        avatar_sizes:"90*90|45*45|22*22|15*15",
        avatar_scale:2,
        avatar_sizes_desc:"180*180像素|90*90像素|45*45像素|30*30像素",
        src_upload: 1
    }, fullAvatarCallback);
});
</script>';
        return $html;
    }
示例#4
0
 public function uphead()
 {
     $auth_data = \Libs\Util\Encrypt::authcode(str_replace(' ', '+', $_GET['authkey']), 'DECODE');
     if ($auth_data != $this->userid) {
         $this->error('身份验证失败!');
     }
     //实例化上传类
     $UploadFile = new \UploadFile(array('allowExts' => array('jpg', 'gif', 'png'), 'thumb' => true, 'dateFormat' => 'y/m/d', 'thumbRemoveOrigin' => true, 'thumbMaxWidth' => '180', 'thumbMaxHeight' => '180'));
     $savepath = D('Upload/Files')->getFilePath('user', $UploadFile->dateFormat, time());
     $dir = C("UPLOADFILEPATH") . service("Passport")->getAvatarPath($this->userid);
     $file = $UploadFile->uploadOne($_FILES['uavatar'], $savepath);
     if ($file === false) {
         $this->error($UploadFile->getErrorMsg());
         exit;
     } else {
         service('Attachment')->movingFiles($file['getExtpath'] . $file['savename'], $file['getExtpath'] . $file['savename']);
         $data['uavatar'] = $savepath . $file[0]['savename'];
         $result = M('User')->where(array('userid' => $this->userid))->save($data);
         if ($result) {
             $this->success('头像更新成功');
         } else {
             $this->error('头像更新失败');
         }
     }
 }
 public function d()
 {
     //当前客户端标识
     $aut = md5($this->userid . $this->groupid . substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
     //key
     $key = I('get.key', '', 'trim');
     if (!empty($key)) {
         $key = str_replace(array('+', '%23', '%2F', '%3F', '%26', '%3D', '%2B'), array(' ', '#', '/', '?', '&', '=', '+'), $key);
     }
     $key = \Libs\Util\Encrypt::authcode($key, "DECODE");
     if (empty($key)) {
         $this->error('下载地址非法!');
     }
     //格式:aut|栏目ID|信息id|下载编号|字段
     $key = explode("|", $key);
     //栏目ID
     $this->catid = $key[1];
     //信息ID
     $this->id = $key[2];
     //编号
     $k = $key[3];
     //字段名称
     $f = $key[4];
     //模型ID
     $modelid = getCategory($this->catid, 'modelid');
     $ModelField = cache('ModelField');
     $Model_field = $ModelField[$modelid];
     //判断字段类型
     if (!in_array($Model_field[$f]['formtype'], array('downfiles', 'downfile'))) {
         $this->error('下载地址错误!');
     }
     //主表名称
     if ((int) $Model_field[$f]['issystem'] == 1) {
         $tablename = ucwords(getModel($modelid, 'tablename'));
     } else {
         $tablename = ucwords(getModel($modelid, 'tablename')) . "_data";
     }
     //字段配置
     $setting = unserialize($Model_field[$f]['setting']);
     if ($aut == $key[0] && $setting) {
         //取得下载字段内容
         $downfiles = M($tablename)->where(array("id" => $this->id))->getField($f);
         $dowUnserialize = unserialize($downfiles);
         //判断是否可以反序列化
         if ($dowUnserialize) {
             $info = $dowUnserialize[$k];
             //判断会有组
             if ((int) $info['groupid'] > 0 || (int) $info['point'] > 0) {
                 if (!$this->userid) {
                     $this->error("请登陆后再下载!", U("Member/Index/login", "forward=" . urlencode(get_url())));
                 }
                 if ((int) $info['groupid'] > 0 && (int) $this->groupid != (int) $info['groupid']) {
                     $this->error("您所在的会有组不能下载该附件!");
                 }
                 if ((int) $info['point'] > 0) {
                     $point = 0 - $info['point'];
                     $status = service("Passport")->userIntegration($this->userid, $point);
                     if ($status !== true) {
                         $this->error(service("Passport")->getError() ?: '积分扣除失败!');
                     }
                     //下载记录
                     $content_download_log = array('id' => $this->id, 'catid' => $this->catid, 'field' => $f, 'userid' => $this->userid, 'groupid' => $this->groupid, 'info' => $info);
                     tag('content_download_log', $content_download_log);
                 }
             }
             //下载地址
             $fileurl = $info['fileurl'];
         } else {
             //下载地址
             $fileurl = $downfiles;
             $info = array();
             $info['filename'] = basename($fileurl);
             $info['filename'] = str_replace('.' . fileext($info['filename']), '', $info['filename']);
         }
         //下载统计+1
         if (!empty($setting['statistics'])) {
             $statistics = trim($setting['statistics']);
             M(ucwords(getModel($modelid, 'tablename')))->where(array("id" => $this->id))->setInc($statistics);
         }
         $urlDomain = urlDomain(self::$Cache['Cache']['siteurl']);
         if (!$urlDomain) {
             $urlDomain = urlDomain(get_url());
             //当前页面地址域名
         }
         //不管附件地址是远程地址,还是不带域名的地址,都进行替换
         $fileurl = str_replace($urlDomain, "", $fileurl);
         //远程文件
         if (strpos($fileurl, ':/')) {
             header("Location: {$fileurl}");
             exit;
         }
         //取得文件后缀
         $houz = "." . fileext(basename($fileurl));
         $fileurl = SITE_PATH . $fileurl;
         if (file_exists($fileurl)) {
             $this->downfiles($fileurl, urldecode($info['filename'] . $houz));
         } else {
             $this->error("需要下载的文件不存在!");
         }
     } else {
         $this->error("下载地址不正确!");
     }
 }
示例#6
0
 /**
  * 注册用户登录状态
  * @param array $userInfo 用户信息
  */
 private function registerLogin(array $userInfo)
 {
     //写入session
     session(self::userUidKey, \Libs\Util\Encrypt::authcode((int) $userInfo['id'], ''));
     //更新状态
     D('Admin/User')->loginStatus((int) $userInfo['id']);
     //注册权限
     \Libs\System\RBAC::saveAccessList((int) $userInfo['id']);
 }