From 7f6ac7af08adba0cb96b35a47783949b13dafb2b Mon Sep 17 00:00:00 2001 From: tao Date: Wed, 12 Jan 2022 16:12:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Addons.php | 62 ++-- app/middleware/Auth.php | 2 +- composer.json | 3 +- composer.lock | 134 ++++++++- config/social.php | 85 ++++++ config/taoler.php | 2 +- public/static/admin/modules/addons.js | 2 + vendor/composer/autoload_psr4.php | 2 + vendor/composer/autoload_static.php | 13 + vendor/composer/installed.json | 138 +++++++++ vendor/composer/installed.php | 22 +- vendor/liliuwei/thinkphp-social/.gitignore | 0 vendor/liliuwei/thinkphp-social/LICENSE | 201 +++++++++++++ vendor/liliuwei/thinkphp-social/README.md | 99 +++++++ vendor/liliuwei/thinkphp-social/composer.json | 33 +++ .../liliuwei/thinkphp-social/src/GetInfo.php | 280 ++++++++++++++++++ vendor/liliuwei/thinkphp-social/src/Oauth.php | 267 +++++++++++++++++ .../thinkphp-social/src/config/config.php | 85 ++++++ .../thinkphp-social/src/sdk/Baidu.php | 74 +++++ .../thinkphp-social/src/sdk/Dingtalk.php | 170 +++++++++++ .../thinkphp-social/src/sdk/Douyin.php | 141 +++++++++ .../thinkphp-social/src/sdk/Facebook.php | 83 ++++++ .../thinkphp-social/src/sdk/Gitee.php | 79 +++++ .../thinkphp-social/src/sdk/Github.php | 73 +++++ .../thinkphp-social/src/sdk/Google.php | 80 +++++ .../thinkphp-social/src/sdk/Oschina.php | 81 +++++ .../liliuwei/thinkphp-social/src/sdk/Qq.php | 111 +++++++ .../liliuwei/thinkphp-social/src/sdk/Sina.php | 74 +++++ .../thinkphp-social/src/sdk/Taobao.php | 106 +++++++ .../thinkphp-social/src/sdk/Weixin.php | 137 +++++++++ .../thinkphp-social/src/sdk/Xiaomi.php | 104 +++++++ vendor/services.php | 2 +- vendor/topthink/think-installer/.gitignore | 3 + vendor/topthink/think-installer/composer.json | 25 ++ .../think-installer/src/LibraryInstaller.php | 28 ++ .../topthink/think-installer/src/Plugin.php | 34 +++ .../topthink/think-installer/src/Promise.php | 11 + .../think-installer/src/ThinkExtend.php | 72 +++++ .../think-installer/src/ThinkFramework.php | 66 +++++ .../think-installer/src/ThinkTesting.php | 66 +++++ view/taoler/index/article/edit.html | 1 + 41 files changed, 3006 insertions(+), 45 deletions(-) create mode 100644 config/social.php create mode 100644 vendor/liliuwei/thinkphp-social/.gitignore create mode 100644 vendor/liliuwei/thinkphp-social/LICENSE create mode 100644 vendor/liliuwei/thinkphp-social/README.md create mode 100644 vendor/liliuwei/thinkphp-social/composer.json create mode 100644 vendor/liliuwei/thinkphp-social/src/GetInfo.php create mode 100644 vendor/liliuwei/thinkphp-social/src/Oauth.php create mode 100644 vendor/liliuwei/thinkphp-social/src/config/config.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Github.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Google.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Qq.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Sina.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php create mode 100644 vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php create mode 100644 vendor/topthink/think-installer/.gitignore create mode 100644 vendor/topthink/think-installer/composer.json create mode 100644 vendor/topthink/think-installer/src/LibraryInstaller.php create mode 100644 vendor/topthink/think-installer/src/Plugin.php create mode 100644 vendor/topthink/think-installer/src/Promise.php create mode 100644 vendor/topthink/think-installer/src/ThinkExtend.php create mode 100644 vendor/topthink/think-installer/src/ThinkFramework.php create mode 100644 vendor/topthink/think-installer/src/ThinkTesting.php diff --git a/app/admin/controller/Addons.php b/app/admin/controller/Addons.php index 72fa9b2..8f193e1 100644 --- a/app/admin/controller/Addons.php +++ b/app/admin/controller/Addons.php @@ -207,57 +207,43 @@ class Addons extends AdminController Files::mkdirs($addons_dir); $package_file = $addons_dir . $data['name'] .'.zip'; //升级的压缩包文件 -// halt($package_file); $cpfile = copy($file_url,$package_file); - if(!$cpfile) - { - return json(['code'=>-1,'msg'=>'下载升级文件失败']); - } + if(!$cpfile) return json(['code'=>-1,'msg'=>'下载升级文件失败']); $uzip = new Zip(); $zipDir = strstr($package_file, '.zip',true); //返回文件名后缀前的字符串 $zipPath = Files::getDirPath($zipDir); //转换为带/的路径 压缩文件解压到的路径 $unzip_res = $uzip->unzip($package_file,$zipPath,true); + if(!$unzip_res) return json(['code'=>-1,'msg'=>'解压失败']); - if(!$unzip_res) - { - return json(['code'=>-1,'msg'=>'解压失败']); - } //升级插件 - if(is_dir($zipPath)) - { - //升级前的写入文件权限检查 - $allUpdateFiles = Files::getAllFile($zipPath); - if (empty($allUpdateFiles)) return json(['code' => -1, 'msg' => '无可更新文件。']); - $checkString = ''; - foreach ($allUpdateFiles as $updateFile) { - $coverFile = ltrim(str_replace($zipPath, '', $updateFile), DIRECTORY_SEPARATOR); - $dirPath = dirname('../'.$coverFile); - if (file_exists('../'.$coverFile)) { - if (!is_writable('../'.$coverFile)) $checkString .= $coverFile . ' [' . '无写入权限' . ']
'; - } else { - if (!is_dir($dirPath)) @mkdir($dirPath, 0777, true); - if (!is_writable($dirPath)) $checkString .= $dirPath . ' [' . '无写入权限' . ']
'; - } - } + //升级前的写入文件权限检查 + $allUpdateFiles = Files::getAllFile($zipPath); - if (!empty($checkString)) return json(['code' => -1, 'msg' => $checkString]); - $addonsPath = '../'; - $cpRes = Files::copyDirs($zipPath,$addonsPath); - $cpData = $cpRes->getData(); - //更新失败 - if($cpData['code'] == -1) - { - return json(['code'=>-1,'msg'=>$cpData['msg']]); - } + if (empty($allUpdateFiles)) return json(['code' => -1, 'msg' => '无可更新文件。']); + $checkString = ''; + foreach ($allUpdateFiles as $updateFile) { + $coverFile = ltrim(str_replace($zipPath, '', $updateFile), DIRECTORY_SEPARATOR); + $dirPath = dirname('../'.$coverFile); + if (file_exists('../'.$coverFile)) { + if (!is_writable('../'.$coverFile)) $checkString .= $coverFile . ' [' . '无写入权限' . ']
'; + } else { + if (!is_dir($dirPath)) @mkdir($dirPath, 0777, true); + if (!is_writable($dirPath)) $checkString .= $dirPath . ' [' . '无写入权限' . ']
'; + } + } - //清除 - Files::delDirAndFile('../runtime/addons/'); + if (!empty($checkString)) return json(['code' => -1, 'msg' => $checkString]); + $addonsPath = '../'; + $cpRes = Files::copyDirs($zipPath,$addonsPath); + $cpData = $cpRes->getData(); + //更新失败 + if($cpData['code'] == -1) return json(['code'=>-1,'msg'=>$cpData['msg']]); + Files::delDirAndFile('../runtime/addons/'); - } - return json(['code'=>0,'msg'=>'插件安装成功!']); + return json(['code'=>0,'msg'=>'插件安装成功!']); } /** diff --git a/app/middleware/Auth.php b/app/middleware/Auth.php index 87a841c..54ddd04 100644 --- a/app/middleware/Auth.php +++ b/app/middleware/Auth.php @@ -43,7 +43,7 @@ class Auth } //没有登录及当前非登录页重定向登录页 - if(!Session::has('admin_id') && $path !== 'admin/login/index' && !stristr($request->pathinfo(),"captcha.html") ) + if(!Session::has('admin_id') && $path !== 'admin/login/index' && !(stristr($request->pathinfo(),"captcha.html") || stristr($request->pathinfo(),"addons")) ) { return redirect((string) url('admin/login/index')); } diff --git a/composer.json b/composer.json index fde31a5..0c8e704 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "firebase/php-jwt": "^5.2", "lotofbadcode/phpspirit_databackup": "^1.1", "wamkj/thinkphp6.0-databackup": "^1.0", - "taoser/think-addons": "^1.0" + "taoser/think-addons": "^1.0", + "liliuwei/thinkphp-social": "^1.3" }, "require-dev": { "symfony/var-dumper": "^4.2", diff --git a/composer.lock b/composer.lock index 30bc6ac..4f69eb6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3ef61427e5d1c98f5ca1e197d25ef688", + "content-hash": "9a2defc1ce427f4ab5f63c13400425c3", "packages": [ { "name": "firebase/php-jwt", @@ -288,6 +288,87 @@ ], "time": "2021-11-21T11:48:40+00:00" }, + { + "name": "liliuwei/thinkphp-social", + "version": "v1.3", + "source": { + "type": "git", + "url": "https://github.com/liliuwei/thinkphp-social.git", + "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/liliuwei/thinkphp-social/zipball/2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", + "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.6.0", + "topthink/framework": "^5.1 || ^6.0", + "topthink/think-installer": "^2.0" + }, + "type": "think-extend", + "extra": { + "think-config": { + "social": "src/config/config.php" + }, + "think": { + "config": { + "social": "src/config/config.php" + } + } + }, + "autoload": { + "psr-4": { + "liliuwei\\social\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liliuwei", + "email": "974829947@qq.com" + } + ], + "description": "适用于thinkphp5.1和6.0的社会化登录扩展", + "keywords": [ + "Facebook登录", + "Gitee登录", + "Github登录", + "Google登录", + "Oschina登录", + "QQ登录", + "oauth", + "think-social", + "thinkphp", + "thinkphp-social", + "thinkphp5.1", + "thinkphp6.0", + "小米登录", + "微信登录", + "抖音登录", + "新浪登录", + "淘宝登录", + "百度登录", + "第三方授权登录", + "谷歌登录", + "钉钉登录" + ], + "support": { + "issues": "https://github.com/liliuwei/thinkphp-social/issues", + "source": "https://github.com/liliuwei/thinkphp-social/tree/v1.3" + }, + "time": "2021-01-13T05:11:12+00:00" + }, { "name": "lotofbadcode/phpspirit_databackup", "version": "v1.1", @@ -1008,6 +1089,57 @@ }, "time": "2021-12-15T04:27:55+00:00" }, + { + "name": "topthink/think-installer", + "version": "v2.0.5", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-installer.git", + "reference": "38ba647706e35d6704b5d370c06f8a160b635f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-installer/zipball/38ba647706e35d6704b5d370c06f8a160b635f88", + "reference": "38ba647706e35d6704b5d370c06f8a160b635f88", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer-plugin-api": "^1.0||^2.0" + }, + "require-dev": { + "composer/composer": "^1.0||^2.0" + }, + "type": "composer-plugin", + "extra": { + "class": "think\\composer\\Plugin" + }, + "autoload": { + "psr-4": { + "think\\composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "support": { + "issues": "https://github.com/top-think/think-installer/issues", + "source": "https://github.com/top-think/think-installer/tree/v2.0.5" + }, + "time": "2021-01-14T12:12:14+00:00" + }, { "name": "topthink/think-multi-app", "version": "v1.0.14", diff --git a/config/social.php b/config/social.php new file mode 100644 index 0000000..4f1cc58 --- /dev/null +++ b/config/social.php @@ -0,0 +1,85 @@ + [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //微信扫码登录配置 + 'weixin' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //新浪登录配置 + 'sina' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Baidu登录配置 + 'baidu' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Gitee登录配置 + 'gitee' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Github登录配置 + 'github' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Google登录配置 + 'google' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Facebook登录配置 + 'facebook' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Oschina登录配置 + 'oschina' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Taobao登录配置 + 'taobao' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Douyin登录配置 + 'douyin' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Xiaomi登录配置 + 'xiaomi' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Dingtalk登录配置 + 'dingtalk' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ] +]; diff --git a/config/taoler.php b/config/taoler.php index 7d76a08..51b838e 100644 --- a/config/taoler.php +++ b/config/taoler.php @@ -7,7 +7,7 @@ return [ //应用名,此项不可更改 'appname' => 'TaoLer', //版本配置 - 'version' => '1.8.21', + 'version' => '1.8.22', //加盐 'salt' => 'taoler', //数据库备份目录 diff --git a/public/static/admin/modules/addons.js b/public/static/admin/modules/addons.js index d581029..7cd7675 100644 --- a/public/static/admin/modules/addons.js +++ b/public/static/admin/modules/addons.js @@ -168,6 +168,7 @@ layui.define(["table", "form", "upload"], function (exports) { }, }); } else if (obj.event === "install") { + var index = layer.load(1); //安装插件 $.post( addonsInstall, @@ -183,6 +184,7 @@ layui.define(["table", "form", "upload"], function (exports) { anim: 6, }); } + layer.close(index); } ); } else if (obj.event === "config") { diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index af4330b..2c640e2 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -9,12 +9,14 @@ return array( 'wamkj\\thinkphp\\' => array($vendorDir . '/wamkj/thinkphp6.0-databackup/src'), 'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'), 'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'), + 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'), 'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'), 'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'), 'taoser\\' => array($vendorDir . '/taoser/think-addons/src'), 'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'), + 'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'), 'app\\' => array($baseDir . '/app'), 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), 'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 1f22873..accea89 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -27,6 +27,7 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 'think\\view\\driver\\' => 18, 'think\\trace\\' => 12, + 'think\\composer\\' => 15, 'think\\captcha\\' => 14, 'think\\app\\' => 10, 'think\\' => 6, @@ -37,6 +38,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 'phpspirit\\databackup\\' => 21, ), + 'l' => + array ( + 'liliuwei\\social\\' => 16, + ), 'a' => array ( 'app\\' => 4, @@ -82,6 +87,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 0 => __DIR__ . '/..' . '/topthink/think-trace/src', ), + 'think\\composer\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-installer/src', + ), 'think\\captcha\\' => array ( 0 => __DIR__ . '/..' . '/topthink/think-captcha/src', @@ -109,6 +118,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 0 => __DIR__ . '/..' . '/lotofbadcode/phpspirit_databackup/src', ), + 'liliuwei\\social\\' => + array ( + 0 => __DIR__ . '/..' . '/liliuwei/thinkphp-social/src', + ), 'app\\' => array ( 0 => __DIR__ . '/../..' . '/app', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d54dfde..9dbbb00 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -290,6 +290,90 @@ ], "install-path": "../league/mime-type-detection" }, + { + "name": "liliuwei/thinkphp-social", + "version": "v1.3", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/liliuwei/thinkphp-social.git", + "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/liliuwei/thinkphp-social/zipball/2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", + "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.6.0", + "topthink/framework": "^5.1 || ^6.0", + "topthink/think-installer": "^2.0" + }, + "time": "2021-01-13T05:11:12+00:00", + "type": "think-extend", + "extra": { + "think-config": { + "social": "src/config/config.php" + }, + "think": { + "config": { + "social": "src/config/config.php" + } + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "liliuwei\\social\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liliuwei", + "email": "974829947@qq.com" + } + ], + "description": "适用于thinkphp5.1和6.0的社会化登录扩展", + "keywords": [ + "Facebook登录", + "Gitee登录", + "Github登录", + "Google登录", + "Oschina登录", + "QQ登录", + "oauth", + "think-social", + "thinkphp", + "thinkphp-social", + "thinkphp5.1", + "thinkphp6.0", + "小米登录", + "微信登录", + "抖音登录", + "新浪登录", + "淘宝登录", + "百度登录", + "第三方授权登录", + "谷歌登录", + "钉钉登录" + ], + "support": { + "issues": "https://github.com/liliuwei/thinkphp-social/issues", + "source": "https://github.com/liliuwei/thinkphp-social/tree/v1.3" + }, + "install-path": "../liliuwei/thinkphp-social" + }, { "name": "lotofbadcode/phpspirit_databackup", "version": "v1.1", @@ -1399,6 +1483,60 @@ }, "install-path": "../topthink/think-helper" }, + { + "name": "topthink/think-installer", + "version": "v2.0.5", + "version_normalized": "2.0.5.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-installer.git", + "reference": "38ba647706e35d6704b5d370c06f8a160b635f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-installer/zipball/38ba647706e35d6704b5d370c06f8a160b635f88", + "reference": "38ba647706e35d6704b5d370c06f8a160b635f88", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer-plugin-api": "^1.0||^2.0" + }, + "require-dev": { + "composer/composer": "^1.0||^2.0" + }, + "time": "2021-01-14T12:12:14+00:00", + "type": "composer-plugin", + "extra": { + "class": "think\\composer\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "support": { + "issues": "https://github.com/top-think/think-installer/issues", + "source": "https://github.com/top-think/think-installer/tree/v2.0.5" + }, + "install-path": "../topthink/think-installer" + }, { "name": "topthink/think-multi-app", "version": "v1.0.14", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 690ab75..3280fa3 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '3e8741aae6a9a6de29bf9a55d5c22e9cf86f922c', + 'reference' => '260604abd3f6eb2b7f43706b8dd2b7cc35acc93c', 'name' => 'taoser/taoler', 'dev' => true, ), @@ -46,6 +46,15 @@ 'reference' => 'aa70e813a6ad3d1558fc927863d47309b4c23e69', 'dev_requirement' => false, ), + 'liliuwei/thinkphp-social' => array( + 'pretty_version' => 'v1.3', + 'version' => '1.3.0.0', + 'type' => 'think-extend', + 'install_path' => __DIR__ . '/../liliuwei/thinkphp-social', + 'aliases' => array(), + 'reference' => '2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970', + 'dev_requirement' => false, + ), 'lotofbadcode/phpspirit_databackup' => array( 'pretty_version' => 'v1.1', 'version' => '1.1.0.0', @@ -151,7 +160,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '3e8741aae6a9a6de29bf9a55d5c22e9cf86f922c', + 'reference' => '260604abd3f6eb2b7f43706b8dd2b7cc35acc93c', 'dev_requirement' => false, ), 'taoser/think-addons' => array( @@ -199,6 +208,15 @@ 'reference' => '769acbe50a4274327162f9c68ec2e89a38eb2aff', 'dev_requirement' => false, ), + 'topthink/think-installer' => array( + 'pretty_version' => 'v2.0.5', + 'version' => '2.0.5.0', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../topthink/think-installer', + 'aliases' => array(), + 'reference' => '38ba647706e35d6704b5d370c06f8a160b635f88', + 'dev_requirement' => false, + ), 'topthink/think-multi-app' => array( 'pretty_version' => 'v1.0.14', 'version' => '1.0.14.0', diff --git a/vendor/liliuwei/thinkphp-social/.gitignore b/vendor/liliuwei/thinkphp-social/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/vendor/liliuwei/thinkphp-social/LICENSE b/vendor/liliuwei/thinkphp-social/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/liliuwei/thinkphp-social/README.md b/vendor/liliuwei/thinkphp-social/README.md new file mode 100644 index 0000000..304f0bc --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/README.md @@ -0,0 +1,99 @@ +## thinkphp-social +适用于thinkphp5.1 thinkphp6.0的社会化登录扩展 + +目前已支持:QQ、微信、新浪、百度、Gitee、Github、Oschina、Google、Facebook、淘宝、抖音、小米、钉钉 + +欢迎提交pr或者建议! + +有问题可以联系邮箱:974829947@qq.com + +## 安装(扩展包) +```php +composer require liliuwei/thinkphp-social +``` + +# 配置Config信息 +```php +// 安装之后会在config目录里自动生成social.php配置文件 + [ + 'app_key' => '*******', //应用注册成功后分配的 APP ID + 'app_secret' => '*******', //应用注册成功后分配的KEY + 'callback' => 'http://www.youquanya.com/oauth/callback/type/qq', // 应用回调地址 + ], + //微信扫码登录配置 + 'weixin' => [ + 'app_key' => '*******', //应用注册成功后分配的 APP ID + 'app_secret' => '*******', //应用注册成功后分配的KEY + 'callback' => 'http://www.youquanya.com/oauth/callback/type/weixin', // 应用回调地址 + ], +]; + +``` + +## 用法示例 +```` +QQ登录 +新浪微博登录 +微信登录 +百度登录 +gitee登录 +github登录 +oschaina登录 +google登录 +facebook登录 +淘宝登录 +抖音登录 +小米登录 +钉钉登录 + ```` +```php +//设置路由 +Route::get('oauth/callback','index/oauth/callback'); +``` + +```php +error('参数错误'); + } + // 获取对象实例 + $sns = \liliuwei\social\Oauth::getInstance($type); + //跳转到授权页面 + $this->redirect($sns->getRequestCodeURL()); + } + + //授权回调地址 + public function callback($type = null, $code = null) + { + if ($type == null || $code == null) { + $this->error('参数错误'); + } + $sns = \liliuwei\social\Oauth::getInstance($type); + // 获取TOKEN + $token = $sns->getAccessToken($code); + //获取当前第三方登录用户信息 + if (is_array($token)) { + $user_info = \liliuwei\social\GetInfo::getInstance($type, $token); + dump($user_info);// 获取第三方用户资料 + $sns->openid();//统一使用$sns->openid()获取openid + //$sns->unionid();//QQ和微信、淘宝可以获取unionid + dump($sns->openid()); + echo '登录成功!!'; + echo '正在持续开发中,敬请期待!!'; + } else { + echo "获取第三方用户的基本信息失败"; + } + } +} +``` diff --git a/vendor/liliuwei/thinkphp-social/composer.json b/vendor/liliuwei/thinkphp-social/composer.json new file mode 100644 index 0000000..b9673f3 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/composer.json @@ -0,0 +1,33 @@ +{ + "name": "liliuwei/thinkphp-social", + "description": "适用于thinkphp5.1和6.0的社会化登录扩展", + "keywords": ["第三方授权登录","QQ登录","微信登录","新浪登录","百度登录","谷歌登录","Google登录","Facebook登录","Gitee登录","Github登录","Oschina登录","淘宝登录","抖音登录","小米登录","钉钉登录","think-social","thinkphp-social","oauth", "thinkphp","thinkphp5.1","thinkphp6.0"], + "license": "Apache-2.0", + "type": "think-extend", + "require": { + "php": ">=5.6.0", + "topthink/think-installer": "^2.0", + "topthink/framework": "^5.1 || ^6.0" + }, + "authors": [ + { + "name": "liliuwei", + "email": "974829947@qq.com" + } + ], + "autoload" : { + "psr-4" : { + "liliuwei\\social\\" : "src/" + } + }, + "extra": { + "think-config": { + "social": "src/config/config.php" + }, + "think": { + "config": { + "social": "src/config/config.php" + } + } + } +} diff --git a/vendor/liliuwei/thinkphp-social/src/GetInfo.php b/vendor/liliuwei/thinkphp-social/src/GetInfo.php new file mode 100644 index 0000000..46823c1 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/GetInfo.php @@ -0,0 +1,280 @@ +call('user/get_user_info'); + if ($data['ret'] == 0) { + $userInfo['type'] = 'qq'; + $userInfo['name'] = $data['nickname']; + $userInfo['nickname'] = $data['nickname']; + $userInfo['avatar'] = $data['figureurl_2']; + $userInfo['gender'] = $data['gender']; + return $userInfo; + } else { + throw new \Exception("获取腾讯QQ用户信息失败:{$data['msg']}"); + } + } + + //微信用户信息 + public static function weixin($token) + { + $weixin = Oauth::getInstance('weixin', $token); + $data = $weixin->call('sns/userinfo'); + if (isset($data['errcode'])) { + throw new \Exception("获取微信用户信息失败:errcode:{$data['errcode']} errmsg: {$data['errmsg']}"); + } + if ($data['openid']) { + $userInfo['type'] = 'weixin'; + $userInfo['name'] = $data['nickname']; + $userInfo['nickname'] = $data['nickname']; + $userInfo['avatar'] = $data['headimgurl']; + $userInfo['openid'] = $data['openid']; + $userInfo['unionid'] = $data['unionid']; + $userInfo['province'] = $data['province']; + $userInfo['city'] = $data['city']; + $userInfo['country'] = $data['country']; + $userInfo['sex'] = $data['sex']==1?'男':'女'; + return $userInfo; + } else { + throw new \Exception("获取微信用户信息失败"); + } + } + + //新浪微博用户信息 + public static function sina($token) + { + $sina = Oauth::getInstance('sina', $token); + $data = $sina->call('users/show',"uid={$sina->openid()}"); + if ($data['id']) { + $userInfo['type'] = 'sina'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['screen_name']; + $userInfo['avatar'] = $data['avatar_large']; + $userInfo['openid'] = $data['id']; + $userInfo['idstr'] = $data['idstr']; + $userInfo['province'] = $data['province']; + $userInfo['city'] = $data['city']; + $userInfo['location'] = $data['location']; + $userInfo['created_at'] = $data['created_at']; + $userInfo['gender'] = $data['gender']=='m'?'男':($data['gender']=='f'?'女':'未知'); + $userInfo['followers_count'] = $data['followers_count']; + $userInfo['friends_count'] = $data['friends_count']; + $userInfo['statuses_count'] = $data['statuses_count']; + $userInfo['favourites_count'] = $data['favourites_count']; + $userInfo['description'] = $data['description']; + $userInfo['url'] = $data['url']; + $userInfo['profile_url'] = $data['profile_url']; + return $userInfo; + } else { + throw new \Exception("获取新浪微博用户信息失败:{$data['error']}"); + } + } + + //Baidu用户信息 + public static function baidu($token) + { + $baidu = Oauth::getInstance('baidu', $token); + $data = $baidu->call('passport/users/getInfo'); + if (isset($data['userid'])) { + $userInfo['type'] = 'baidu'; + $userInfo['name'] = $data['username']; + $userInfo['nickname'] = isset($data['realname'])?$data['realname']:''; + $userInfo['avatar'] = 'http://tb.himg.baidu.com/sys/portrait/item/'.$data['portrait']; + $userInfo['openid'] = $data['userid']; + $userInfo['sex'] = $data['sex']==1?'男':'女'; + return $userInfo; + } else { + throw new \Exception("获取Baidu用户信息失败"); + } + } + + //Gitee用户信息 + public static function gitee($token) + { + $google = Oauth::getInstance('gitee', $token); + $data = $google->call('user'); + if (isset($data['id'])) { + $userInfo['type'] = 'gitee'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['login']; + $userInfo['avatar'] = $data['avatar_url']; + $userInfo['openid'] = $data['id']; + $userInfo['html_url'] = $data['html_url']; + $userInfo['blog'] = $data['blog']; + $userInfo['email'] = $data['email']; + return $userInfo; + } else { + throw new \Exception("获取Gitee用户信息失败"); + } + } + + //Github用户信息 + public static function github($token) + { + $google = Oauth::getInstance('github', $token); + $data = $google->call('user'); + if (isset($data['id'])) { + $userInfo['type'] = 'github'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['login']; + $userInfo['avatar'] = $data['avatar_url']; + $userInfo['openid'] = $data['id']; + $userInfo['html_url'] = $data['html_url']; + $userInfo['blog'] = $data['blog']; + $userInfo['email'] = $data['email']; + return $userInfo; + } else { + throw new \Exception("获取Gitee用户信息失败"); + } + } + + //Google用户信息 + public static function google($token) + { + $google = Oauth::getInstance('google', $token); + $data = $google->call('userinfo'); + if (isset($data['id'])) { + $userInfo['type'] = 'google'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['name']; + $userInfo['avatar'] = $data['picture']; + $userInfo['openid'] = $data['id']; + $userInfo['given_name'] = $data['given_name']; + $userInfo['family_name'] = $data['family_name']; + $userInfo['locale'] = $data['locale']; + $userInfo['email'] = $data['email']; + return $userInfo; + } else { + throw new \Exception("获取Google用户信息失败"); + } + } + + //Facebook用户信息 + public static function facebook($token) + { + $facebook = Oauth::getInstance('facebook', $token); + $data = $facebook->call('me', 'fields=name,picture,first_name,last_name,short_name,email'); + if (isset($data['id'])) { + $userInfo['type'] = 'facebook'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['name']; + $userInfo['avatar'] = $data['picture']['data']['url']; + $userInfo['openid'] = $data['id']; + $userInfo['first_name'] = $data['first_name']; + $userInfo['last_name'] = $data['last_name']; + $userInfo['short_name'] = $data['short_name']; + $userInfo['email'] = $data['email']; + return $userInfo; + } else { + throw new \Exception("获取Facebook用户信息失败"); + } + } + + //Oschina用户信息 + public static function oschina($token) + { + $oschina = Oauth::getInstance('oschina', $token); + $data = $oschina->call('action/openapi/user'); + if (isset($data['id'])) { + $userInfo['type'] = 'gitee'; + $userInfo['name'] = $data['name']; + $userInfo['nickname'] = $data['name']; + $userInfo['avatar'] = $data['avatar']; + $userInfo['openid'] = $data['id']; + $userInfo['email'] = $data['email']; + $userInfo['location'] = $data['location']; + return $userInfo; + } else { + throw new \Exception("获取Gitee用户信息失败"); + } + } + + //Taobao用户信息 + public static function taobao($token) + { + $data = $token; + if (isset($data['taobao_user_id'])) { + $userInfo['type'] = 'taobao'; + $userInfo['name'] = urldecode($data['taobao_user_nick']); + $userInfo['nickname'] = urldecode($data['taobao_user_nick']); + $userInfo['avatar'] = ''; + $userInfo['openid'] = $data['taobao_user_id']; + $userInfo['taobao_open_uid'] = $data['taobao_open_uid']; + return $userInfo; + } else { + throw new \Exception("获取淘宝用户信息失败"); + } + } + + //Douyin用户信息 + public static function douyin($token) + { + $douyin = Oauth::getInstance('douyin', $token); + $data = $douyin->call('oauth/userinfo'); + $data = $data['data']; + if (isset($data['open_id'])) { + $userInfo['type'] = 'douyin'; + $userInfo['name'] = $data['nickname']; + $userInfo['nickname'] = $data['nickname']; + $userInfo['avatar'] = $data['avatar']; + $userInfo['openid'] = $data['open_id']; + $userInfo['unionid'] = $data['union_id']; + $userInfo['gender'] = $data['sex']==1?'男':'女'; + $userInfo['city'] = $data['city']; + $userInfo['province'] = $data['province']; + $userInfo['country'] = $data['country']; + return $userInfo; + } else { + throw new \Exception("获取抖音用户信息失败"); + } + } + + //Xiaomi用户信息 + public static function xiaomi($token) + { + $xiaomi = Oauth::getInstance('xiaomi', $token); + $data = $xiaomi->call('user/profile'); + $data = $data['data']; + if (isset($data['unionId'])) { + $userInfo['type'] = 'xiaomi'; + $userInfo['name'] = $data['miliaoNick']; + $userInfo['nickname'] = $data['miliaoNick']; + $userInfo['avatar'] = $data['miliaoIcon']; + $userInfo['openid'] = array_key_exists('userId',$data)?$data['userId']:$data['unionId']; + $userInfo['unionid'] = $data['unionId']; + return $userInfo; + } else { + throw new \Exception("获取小米用户信息失败"); + } + } + + //Dingtalk用户信息 + public static function dingtalk($token) + { + $data = $token; + if ($data['openid']) { + $userInfo['type'] = 'dingtalk'; + $userInfo['name'] = $data['nick']; + $userInfo['nickname'] = $data['nick']; + $userInfo['avatar'] = ''; + $userInfo['openid'] = $data['openid']; + $userInfo['unionid'] = $data['unionid']; + return $userInfo; + } else { + throw new \Exception("获取钉钉用户信息失败"); + } + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/Oauth.php b/vendor/liliuwei/thinkphp-social/src/Oauth.php new file mode 100644 index 0000000..7c251d1 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/Oauth.php @@ -0,0 +1,267 @@ +Type = strtolower($re_str); + + //获取应用配置 + $config = config("social.{$this->Type}"); + if (empty($config['app_key']) || empty($config['app_secret'])) { + throw new \Exception('请配置您申请的app_key和app_secret'); + } else { + $this->AppKey = $config['app_key']; + $this->AppSecret = $config['app_secret']; + $this->Token = $token; //设置获取到的TOKEN + } + } + + /** + * 取得Oauth实例 + * @static + * @return mixed 返回Oauth + */ + public static function getInstance($type, $token = null) + { + $sdk = [ + 'Qq', 'Weixin', 'Sina', 'Baidu', 'Gitee', 'Github', 'Google', 'Facebook', 'Taobao', 'Oschina', 'Douyin', 'Xiaomi', 'Dingtalk' + ]; + $name = ucfirst(strtolower($type)); + if (in_array($name, $sdk)) { + $class = '\\liliuwei\\social\\sdk\\' . $name; + return new $class($token); + } else { + header('content-type:text/html;charset=utf-8'); + throw new \Exception('暂时还不支持该' . $name . '的扩展'); + } + } + + /** + * 初始化配置 + */ + protected function config() + { + $config = config("social.{$this->Type}"); + if (!empty($config['authorize'])) + $this->Authorize = $config['authorize']; + if (!empty($config['callback'])) + $this->Callback = $config['callback']; + else + throw new \Exception('请配置回调页面地址'); + } + + /** + * 请求code + */ + public function getRequestCodeURL() + { + $this->config(); + //Oauth 标准参数 + $params = array( + 'client_id' => $this->AppKey, + 'redirect_uri' => $this->Callback, + 'response_type' => $this->ResponseType, + ); + + //获取额外参数 + if ($this->Authorize) { + parse_str($this->Authorize, $_param); + if (is_array($_param)) { + $params = array_merge($params, $_param); + } else { + throw new \Exception('AUTHORIZE配置不正确!'); + } + } + return $this->GetRequestCodeURL . '?' . http_build_query($params); + } + + /** + * 获取access_token + * @param string $code 上一步请求到的code + */ + public function getAccessToken($code, $extend = null) + { + $this->config(); + $params = array( + 'client_id' => $this->AppKey, + 'client_secret' => $this->AppSecret, + 'grant_type' => $this->GrantType, + 'code' => $code, + 'redirect_uri' => $this->Callback, + ); + + $data = $this->http($this->GetAccessTokenURL, $params, 'POST'); + $this->Token = $this->parseToken($data, $extend); + return $this->Token; + } + + /** + * 合并默认参数和额外参数 + * @param array $params 默认参数 + * @param array/string $param 额外参数 + * @return array: + */ + protected function param($params, $param) + { + if (is_string($param)) + parse_str($param, $param); + return array_merge($params, $param); + } + + /** + * 获取指定API请求的URL + * @param string $api API名称 + * @param string $fix api后缀 + * @return string 请求的完整URL + */ + protected function url($api = '', $fix = '') + { + return $this->ApiBase . $api . $fix; + } + + /** + * 发送HTTP请求方法,目前只支持CURL发送请求 + * @param string $url 请求URL + * @param array $params 请求参数 + * @param string $method 请求方法GET/POST + * @return array $data 响应数据 + */ + protected function http($url, $params, $method = 'GET', $header = array(), $multi = false) + { + $opts = array( + CURLOPT_TIMEOUT => 30, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYHOST => false, + CURLOPT_HTTPHEADER => $header + ); + + /* 根据请求类型设置特定参数 */ + switch (strtoupper($method)) { + case 'GET': + $opts[CURLOPT_URL] = $url . '?' . http_build_query($params); + break; + case 'POST': + //判断是否传输文件 + $params = $multi ? $params : http_build_query($params); + $opts[CURLOPT_URL] = $url; + $opts[CURLOPT_POST] = 1; + $opts[CURLOPT_POSTFIELDS] = $params; + break; + default: + throw new \Exception('不支持的请求方式!'); + } + + /* 初始化并执行curl请求 */ + $ch = curl_init(); + curl_setopt_array($ch, $opts); + $data = curl_exec($ch); + $error = curl_error($ch); + curl_close($ch); + if ($error) throw new \Exception('请求发生错误:' . $error); + return $data; + } + + /** + * 抽象方法,在SNSSDK中实现 + * 组装接口调用参数 并调用接口 + */ + abstract protected function call($api, $param = '', $method = 'GET', $multi = false); + + /** + * 抽象方法,在SNSSDK中实现 + * 解析access_token方法请求后的返回值 + */ + abstract protected function parseToken($result, $extend); + + /** + * 抽象方法,在SNSSDK中实现 + * 获取当前授权用户的SNS标识 + */ + abstract public function openid(); +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/config/config.php b/vendor/liliuwei/thinkphp-social/src/config/config.php new file mode 100644 index 0000000..4f1cc58 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/config/config.php @@ -0,0 +1,85 @@ + [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //微信扫码登录配置 + 'weixin' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //新浪登录配置 + 'sina' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Baidu登录配置 + 'baidu' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Gitee登录配置 + 'gitee' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Github登录配置 + 'github' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Google登录配置 + 'google' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Facebook登录配置 + 'facebook' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Oschina登录配置 + 'oschina' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Taobao登录配置 + 'taobao' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Douyin登录配置 + 'douyin' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Xiaomi登录配置 + 'xiaomi' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ], + //Dingtalk登录配置 + 'dingtalk' => [ + 'app_key' => '', //应用注册成功后分配的 APP ID + 'app_secret' => '', //应用注册成功后分配的KEY + 'callback' => '', // 应用回调地址 + ] +]; diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php b/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php new file mode 100644 index 0000000..8e9e86a --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php @@ -0,0 +1,74 @@ + $this->Token['access_token'], + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['expires_in'] && $data['refresh_token']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取百度ACCESS_TOKEN出错:{$data['error']}"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('passport/users/getInfo'); + if (isset($data['userid'])) + return $data['userid']; + else + throw new \Exception('没有获取到百度用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php b/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php new file mode 100644 index 0000000..c2bda4b --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php @@ -0,0 +1,170 @@ +getMicrotime(); + // 根据timestamp, appSecret计算签名值 + $s = hash_hmac('sha256', $time, $this->AppSecret, true); + $signature = base64_encode($s); + $urlencode_signature = urlencode($signature); + /* Dingtalk 调用公共参数 */ + $params = array( + 'tmp_auth_code'=>$param['code'], + ); + $data = $this->http($this->url($api.'?signature='.$urlencode_signature.'×tamp='.$time.'&accessKey='.$this->AppKey), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 发送HTTP请求方法,目前只支持CURL发送请求 + * @param string $url 请求URL + * @param array $params 请求参数 + * @param string $method 请求方法GET/POST + * @return array $data 响应数据 + */ + public function http($url, $params, $method = 'POST', $header = array(), $multi = false) + { + $data_string = json_encode($params); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + + $result = curl_exec($ch); + return $result; + } + + /** + * 时间戳 - 精确到毫秒 + * @return float + */ + public function getMicrotime() + { + list($t1, $t2) = explode(' ', microtime()); + return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000); + } + + /** + * 请求code + */ + public function getRequestCodeURL() + { + $this->config(); + //Oauth 标准参数 + $params = array( + 'appid' => $this->AppKey, + 'redirect_uri' => $this->Callback, + 'response_type' => $this->ResponseType, + ); + + //获取额外参数 + if ($this->Authorize) { + parse_str($this->Authorize, $_param); + if (is_array($_param)) { + $params = array_merge($params, $_param); + } else { + throw new \Exception('AUTHORIZE配置不正确!'); + } + } + return $this->GetRequestCodeURL . '?' . http_build_query($params); + } + + /** + * 获取access_token + * @param string $code 上一步请求到的code + */ + public function getAccessToken($code, $extend = null) + { + $result = $this->call('sns/getuserinfo_bycode',['code'=>$code]); + $data = $result['user_info']; + $this->Token = [ + 'nick'=>$data['nick'], + 'openid'=>$data['openid'], + 'unionid'=>$data['unionid'], + ]; + return $this->Token; + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend){} + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid($unionid=false) + { + if ($unionid){ + return $this->unionid(); + } + $data = $this->Token; + if (isset($data['openid'])){ + return $data['openid']; + }else{ + throw new \Exception('没有获取到 Dingtalk 用户openid!'); + } + } + + /** + * 获取当前授权应用的unionid + */ + public function unionid() + { + $data = $this->Token; + if (isset($data['unionid'])){ + return $data['unionid']; + }else{ + throw new \Exception('没有获取到 Dingtalk 用户unionid!'); + } + } + +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php b/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php new file mode 100644 index 0000000..834f609 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php @@ -0,0 +1,141 @@ +config(); + $params = array( + 'client_key ' => $this->AppKey, + 'redirect_uri' => $this->Callback, + 'response_type' => $this->ResponseType, + ); + + //获取额外参数 + if ($this->Authorize) { + parse_str($this->Authorize, $_param); + if (is_array($_param)) { + $params = array_merge($params, $_param); + } else { + throw new \Exception('AUTHORIZE配置不正确!'); + } + } + return $this->GetRequestCodeURL . '?' . http_build_query($params); + } + + /** + * 获取access_token + * @param string $code 上一步请求到的code + */ + public function getAccessToken($code, $extend = null) + { + $this->config(); + $params = array( + 'client_key' => $this->AppKey, + 'client_secret ' => $this->AppSecret, + 'grant_type' => $this->GrantType, + 'code' => $code, + ); + $data = $this->http($this->GetAccessTokenURL, $params, 'GET'); + $this->Token = $this->parseToken($data, $extend); + return $this->Token; + } + + /** + * 组装接口调用参数 并调用接口 + * @param string $api Douyin API + * @param string $param 调用API的额外参数 + * @param string $method HTTP请求方法 默认为GET + * @return json + */ + public function call($api, $param = '', $method = 'GET', $multi = false) + { + /* Douyin 调用公共参数 */ + $params = array( + 'access_token' => $this->Token['access_token'], + 'open_id' => $this->openid(), + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + $data = $data['data']; + if ($data['access_token'] && $data['expires_in']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取 抖音 ACCESS_TOKEN出错:未知错误"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid($unionid=false) + { + if ($unionid){ + return $this->unionid(); + } + $data = $this->call('oauth/userinfo'); + $data = $data['data']; + if (isset($data['open_id'])) + return $data['open_id']; + else + throw new \Exception('没有获取到 抖音 用户openid!'); + } + + /** + * 获取当前授权应用的unionid + */ + public function unionid() + { + $data = $this->call('oauth/userinfo'); + $data = $data['data']; + if (isset($data['union_id'])) + return $data['union_id']; + else + exit('没有获取到 抖音 用户unionid!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php b/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php new file mode 100644 index 0000000..58dd342 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php @@ -0,0 +1,83 @@ + $this->Token['access_token']); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + * @param mix $extend + * @return array + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if (is_array($data) && $data['access_token'] && $data['expires_in']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else { + throw new \Exception("获取 facebook ACCESS_TOKEN出错:未知错误"); + } + + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('me'); + if (isset($data['id'])) + return $data['id']; + else + throw new \Exception('没有获取到 facebook 用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php b/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php new file mode 100644 index 0000000..5fcd481 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php @@ -0,0 +1,79 @@ +Token['access_token']}"); + $data = $this->http($this->url($api), $this->param($params, $param), $method, $header); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['token_type']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取 Gitee ACCESS_TOKEN出错:未知错误"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('user'); + if (isset($data['id'])) + return $data['id']; + else + throw new \Exception('没有获取到 Gitee 用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Github.php b/vendor/liliuwei/thinkphp-social/src/sdk/Github.php new file mode 100644 index 0000000..d821e05 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Github.php @@ -0,0 +1,73 @@ +Token['access_token']}","User-Agent:thinkphp-social"); + $data = $this->http($this->url($api), $this->param($params, $param), $method, $header); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + parse_str($result, $data); + if ($data['access_token'] && $data['token_type']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取 Github ACCESS_TOKEN出错:未知错误"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('user'); + if (isset($data['id'])) + return $data['id']; + else + throw new \Exception('没有获取到 Github 用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Google.php b/vendor/liliuwei/thinkphp-social/src/sdk/Google.php new file mode 100644 index 0000000..4502807 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Google.php @@ -0,0 +1,80 @@ + $this->Token['access_token'], + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['expires_in']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取Google ACCESS_TOKEN 出错:{$result}"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('userinfo'); + if (isset($data['id'])) + return $data['id']; + else + throw new \Exception('没有获取到 Google 用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php b/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php new file mode 100644 index 0000000..feac8f1 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php @@ -0,0 +1,81 @@ + $this->Token['access_token'], + 'dataType' => 'json' + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['token_type']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取 Oschina ACCESS_TOKEN出错:未知错误"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->call('action/openapi/user'); + if (isset($data['id'])) + return $data['id']; + else + throw new \Exception('没有获取到 Oschina 用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php b/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php new file mode 100644 index 0000000..e81f00a --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php @@ -0,0 +1,111 @@ + $this->AppKey, + 'access_token' => $this->Token['access_token'], + 'openid' => $this->openid(), + 'format' => 'json' + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + parse_str($result, $data); + if ($data['access_token'] && $data['expires_in']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid($unionid=false) + { + if ($unionid){ + return $this->unionid(); + } + $data = $this->Token; + if ($data['access_token']) { + $data = $this->http($this->url('oauth2.0/me'), array('access_token' => $data['access_token'])); + $data = json_decode(trim(substr($data, 9), " );\n"), true); + if (isset($data['openid'])) + return $data['openid']; + else + throw new \Exception("获取用户openid出错:{$data['error_description']}"); + } else { + throw new \Exception('没有获取到openid!'); + } + } + + /** + * 获取当前授权应用的unionid + * @return string + */ + public function unionid() + { + $data = $this->Token; + if ($data['access_token']) { + $data = $this->http($this->url('oauth2.0/me'), array('access_token' => $data['access_token'],'unionid'=>1)); + $data = json_decode(trim(substr($data, 9), " );\n"), true); + if (isset($data['unionid'])) + return $data['unionid']; + else + throw new \Exception("获取用户unionid出错:{$data['error_description']}"); + } else { + throw new \Exception('没有获取到unionid!'); + } + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php b/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php new file mode 100644 index 0000000..d9ea774 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php @@ -0,0 +1,74 @@ + $this->Token['access_token'], + ); + $data = $this->http($this->url($api, '.json'), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['expires_in'] && $data['remind_in'] && $data['uid']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid() + { + $data = $this->Token; + if (isset($data['uid'])) + return $data['uid']; + else + throw new \Exception('没有获取到新浪微博用户ID!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php b/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php new file mode 100644 index 0000000..bb76551 --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php @@ -0,0 +1,106 @@ + $api, + 'access_token' => $this->Token['access_token'], + 'format' => 'json', + 'v' => '2.0', + ); + $paramsAll = $this->param($params, $param); + ksort($paramsAll); + $str = ''; + foreach ($paramsAll as $key => $value) { + $str .= $key . $value; + } + $sign = strtoupper(md5($this->AppSecret . $str . $this->AppSecret)); + $params_sign = array( + 'sign' => $sign, + ); + $data = $this->http($this->url(), array_merge($paramsAll, $params_sign), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['expires_in'] && $data['taobao_user_id']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else { + throw new \Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}"); + } + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid($unionid = false) + { + if ($unionid) { + return $this->unionid(); + } + $data = $this->Token; + if (isset($data['taobao_user_id'])) { + return $data['taobao_user_id']; + } else { + throw new \Exception('没有获取到淘宝网用户openid!'); + } + } + + /** + * 获取当前授权应用的unionid + * @return string + */ + public function unionid() + { + $data = $this->Token; + if (isset($data['taobao_open_uid'])) { + return $data['taobao_open_uid']; + } else { + throw new \Exception('没有获取到淘宝网用户unionid!'); + } + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php b/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php new file mode 100644 index 0000000..9582d2a --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php @@ -0,0 +1,137 @@ +config(); + $params = array( + 'appid' => $this->AppKey, + 'redirect_uri' => $this->Callback, + 'response_type' => $this->ResponseType, + ); + + //获取额外参数 + if ($this->Authorize) { + parse_str($this->Authorize, $_param); + if (is_array($_param)) { + $params = array_merge($params, $_param); + } else { + throw new \Exception('AUTHORIZE配置不正确!'); + } + } + return $this->GetRequestCodeURL . '?' . http_build_query($params) . "#wechat_redirect"; + } + + /** + * 获取access_token + * @param string $code 上一步请求到的code + */ + public function getAccessToken($code, $extend = null) + { + $this->config(); + $params = array( + 'appid' => $this->AppKey, + 'secret' => $this->AppSecret, + 'grant_type' => $this->GrantType, + 'code' => $code, + ); + $data = $this->http($this->GetAccessTokenURL, $params, 'POST'); + $this->Token = $this->parseToken($data, $extend); + return $this->Token; + } + + /** + * 组装接口调用参数 并调用接口 + * @param string $api 微信 API + * @param string $param 调用API的额外参数 + * @param string $method HTTP请求方法 默认为GET + * @return json + */ + public function call($api, $param = '', $method = 'GET', $multi = false) + { + /* 微信调用公共参数 */ + $params = array( + 'access_token' => $this->Token['access_token'], + 'openid' => $this->openid(), + 'lang' => 'zh_CN', + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['expires_in']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取微信 ACCESS_TOKEN 出错:{$result}"); + } + + /** + * 获取当前授权应用的openid + */ + public function openid($unionid=false) + { + if ($unionid){ + return $this->unionid(); + } + $data = $this->Token; + if (isset($data['openid'])) + return $data['openid']; + else + exit('没有获取到微信用户openid!'); + } + + /** + * 获取当前授权应用的unionid + */ + public function unionid() + { + $data = $this->Token; + if (isset($data['unionid'])) + return $data['unionid']; + else + exit('没有获取到微信用户unionid!'); + } +} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php b/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php new file mode 100644 index 0000000..f38366e --- /dev/null +++ b/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php @@ -0,0 +1,104 @@ + $this->Token['access_token'], + 'clientId' => $this->AppKey + ); + $data = $this->http($this->url($api), $this->param($params, $param), $method); + return json_decode($data, true); + } + + /** + * 解析access_token方法请求后的返回值 + * @param string $result 获取access_token的方法的返回值 + */ + protected function parseToken($result, $extend) + { + $data = json_decode($result, true); + if ($data['access_token'] && $data['token_type']) { + $this->Token = $data; + $data['openid'] = $this->openid(); + return $data; + } else + throw new \Exception("获取 Xiaomi ACCESS_TOKEN出错:未知错误"); + } + + /** + * 获取当前授权应用的openid + * @return string + */ + public function openid($unionid=false) + { + if ($unionid){ + return $this->unionid(); + } + $data = $this->call('user/profile'); + if ($data['result']=='ok'){ + $data = $data['data']; + if (isset($data['userId'])){ + return $data['userId']; + }else{ + return $this->unionid(); + } + }else{ + throw new \Exception('没有获取到 Xiaomi 用户openid!'); + } + } + + /** + * 获取当前授权应用的unionid + * @return string + */ + public function unionid() + { + $data = $this->call('user/profile'); + $data = $data['data']; + if (isset($data['unionId'])) + return $data['unionId']; + else + throw new \Exception('没有获取到 Xiaomi 用户unionid!'); + } +} \ No newline at end of file diff --git a/vendor/services.php b/vendor/services.php index bde30f9..ed7d0c1 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'taoser\\addons\\Service', diff --git a/vendor/topthink/think-installer/.gitignore b/vendor/topthink/think-installer/.gitignore new file mode 100644 index 0000000..8f4c02d --- /dev/null +++ b/vendor/topthink/think-installer/.gitignore @@ -0,0 +1,3 @@ +/.idea +composer.lock +/vendor \ No newline at end of file diff --git a/vendor/topthink/think-installer/composer.json b/vendor/topthink/think-installer/composer.json new file mode 100644 index 0000000..08bc72b --- /dev/null +++ b/vendor/topthink/think-installer/composer.json @@ -0,0 +1,25 @@ +{ + "name": "topthink/think-installer", + "type": "composer-plugin", + "require": { + "composer-plugin-api": "^1.0||^2.0" + }, + "require-dev": { + "composer/composer": "^1.0||^2.0" + }, + "license": "Apache-2.0", + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "autoload": { + "psr-4": { + "think\\composer\\": "src" + } + }, + "extra": { + "class": "think\\composer\\Plugin" + } +} diff --git a/vendor/topthink/think-installer/src/LibraryInstaller.php b/vendor/topthink/think-installer/src/LibraryInstaller.php new file mode 100644 index 0000000..45c05bc --- /dev/null +++ b/vendor/topthink/think-installer/src/LibraryInstaller.php @@ -0,0 +1,28 @@ +makePromise(parent::install($repo, $package)); + } + + public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) + { + return $this->makePromise(parent::update($repo, $initial, $target)); + } + + protected function makePromise($promise) + { + if ($promise instanceof PromiseInterface) { + return $promise; + } + return new Promise(); + } +} diff --git a/vendor/topthink/think-installer/src/Plugin.php b/vendor/topthink/think-installer/src/Plugin.php new file mode 100644 index 0000000..4415232 --- /dev/null +++ b/vendor/topthink/think-installer/src/Plugin.php @@ -0,0 +1,34 @@ +getInstallationManager(); + + //框架核心 + $manager->addInstaller(new ThinkFramework($io, $composer)); + + //单元测试 + $manager->addInstaller(new ThinkTesting($io, $composer)); + + //扩展 + $manager->addInstaller(new ThinkExtend($io, $composer)); + } + + public function deactivate(Composer $composer, IOInterface $io) + { + + } + + public function uninstall(Composer $composer, IOInterface $io) + { + + } +} diff --git a/vendor/topthink/think-installer/src/Promise.php b/vendor/topthink/think-installer/src/Promise.php new file mode 100644 index 0000000..6bfed5d --- /dev/null +++ b/vendor/topthink/think-installer/src/Promise.php @@ -0,0 +1,11 @@ + +// +---------------------------------------------------------------------- + +namespace think\composer; + +use Composer\Package\PackageInterface; +use Composer\Repository\InstalledRepositoryInterface; + +class ThinkExtend extends LibraryInstaller +{ + public function install(InstalledRepositoryInterface $repo, PackageInterface $package) + { + return parent::install($repo, $package) + ->then(function () use ($package) { + $this->copyExtraFiles($package); + }); + } + + public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) + { + return parent::update($repo, $initial, $target) + ->then(function () use ($target) { + $this->copyExtraFiles($target); + }); + } + + protected function copyExtraFiles(PackageInterface $package) + { + if ($this->composer->getPackage()->getType() == 'project') { + + $extra = $package->getExtra(); + + if (!empty($extra['think-config'])) { + + $configDir = 'config'; + + $this->filesystem->ensureDirectoryExists($configDir); + + //配置文件 + foreach ((array) $extra['think-config'] as $name => $config) { + $target = $configDir . DIRECTORY_SEPARATOR . $name . '.php'; + $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config; + + if (is_file($target)) { + $this->io->write("File {$target} exist!"); + continue; + } + + if (!is_file($source)) { + $this->io->write("File {$target} not exist!"); + continue; + } + + copy($source, $target); + } + } + } + } + + public function supports($packageType) + { + return 'think-extend' === $packageType; + } +} diff --git a/vendor/topthink/think-installer/src/ThinkFramework.php b/vendor/topthink/think-installer/src/ThinkFramework.php new file mode 100644 index 0000000..2a7cc03 --- /dev/null +++ b/vendor/topthink/think-installer/src/ThinkFramework.php @@ -0,0 +1,66 @@ +getPrettyName()) { + throw new InvalidArgumentException('Unable to install this library!'); + } + + if ($this->composer->getPackage()->getType() !== 'project') { + return parent::getInstallPath($package); + } + + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (!empty($extra['think-path'])) { + return $extra['think-path']; + } + } + + return 'thinkphp'; + } + + public function install(InstalledRepositoryInterface $repo, PackageInterface $package) + { + return parent::install($repo, $package) + ->then(function () use ($package) { + $this->removeTestDir($package); + }); + } + + public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) + { + return parent::update($repo, $initial, $target) + ->then(function () use ($target) { + $this->removeTestDir($target); + }); + } + + protected function removeTestDir(PackageInterface $target) + { + if ($this->composer->getPackage()->getType() == 'project' && $target->getInstallationSource() != 'source') { + //remove tests dir + $this->filesystem->removeDirectory($this->getInstallPath($target) . DIRECTORY_SEPARATOR . 'tests'); + } + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + return 'think-framework' === $packageType; + } +} diff --git a/vendor/topthink/think-installer/src/ThinkTesting.php b/vendor/topthink/think-installer/src/ThinkTesting.php new file mode 100644 index 0000000..af74d20 --- /dev/null +++ b/vendor/topthink/think-installer/src/ThinkTesting.php @@ -0,0 +1,66 @@ + +// +---------------------------------------------------------------------- + +namespace think\composer; + +use Composer\Package\PackageInterface; +use Composer\Repository\InstalledRepositoryInterface; +use InvalidArgumentException; + +class ThinkTesting extends LibraryInstaller +{ + /** + * {@inheritDoc} + */ + public function getInstallPath(PackageInterface $package) + { + if ('topthink/think-testing' !== $package->getPrettyName()) { + throw new InvalidArgumentException('Unable to install this library!'); + } + + return parent::getInstallPath($package); + } + + public function install(InstalledRepositoryInterface $repo, PackageInterface $package) + { + return parent::install($repo, $package) + ->then(function () use ($package) { + $this->copyTestDir($package); + }); + } + + public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) + { + return parent::update($repo, $initial, $target) + ->then(function () use ($target) { + $this->copyTestDir($target); + }); + } + + private function copyTestDir(PackageInterface $package) + { + $appDir = dirname($this->vendorDir); + $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'example'; + if (!is_file($appDir . DIRECTORY_SEPARATOR . 'phpunit.xml')) { + $this->filesystem->copyThenRemove($source, $appDir); + } else { + $this->filesystem->removeDirectoryPhp($source); + } + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + return 'think-testing' === $packageType; + } +} diff --git a/view/taoler/index/article/edit.html b/view/taoler/index/article/edit.html index facb69d..10ad592 100644 --- a/view/taoler/index/article/edit.html +++ b/view/taoler/index/article/edit.html @@ -167,6 +167,7 @@ upload.render({ elem: '#zip-button' ,url: "{:url('article/uploads')}" //改成您自己的上传接口 + ,data: {type:'zip'} ,accept: 'file' //普通文件 ,done: function(res){ if(res.status == 0){