Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jcy2004x
ShopXO
提交
aa0e11e6
ShopXO
项目概览
jcy2004x
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa0e11e6
编写于
11月 20, 2018
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
user
上级
58cbeffa
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
354 addition
and
214 deletion
+354
-214
alipay/pages/goods-category/goods-category.acss
alipay/pages/goods-category/goods-category.acss
+2
-1
service/Application/Admin/View/Default/AppMiniAlipayConfig/Index.html
...ication/Admin/View/Default/AppMiniAlipayConfig/Index.html
+23
-6
service/Application/Api/Controller/UserController.class.php
service/Application/Api/Controller/UserController.class.php
+191
-166
service/Application/Common/Conf/config.php
service/Application/Common/Conf/config.php
+0
-3
service/Application/Library/Alipay.class.php
service/Application/Library/Alipay.class.php
+43
-38
service/Application/Library/BaiduAuth.class.php
service/Application/Library/BaiduAuth.class.php
+95
-0
未找到文件。
alipay/pages/goods-category/goods-category.acss
浏览文件 @
aa0e11e6
...
...
@@ -3,6 +3,7 @@
box-sizing: border-box;
overflow: hidden;
padding-bottom: 120rpx;
min-height: 100vh;
}
.content-items {
float: left;
...
...
@@ -15,6 +16,6 @@
line-height: 46rpx;
}
.content-items .icon {
width: 1
20rpx
;
width: 1
00%
;
height: 120rpx;
}
\ No newline at end of file
service/Application/Admin/View/Default/AppMiniAlipayConfig/Index.html
浏览文件 @
aa0e11e6
...
...
@@ -6,16 +6,33 @@
<!-- form start -->
<form
class=
"am-form form-validation view-save"
action=
"{{:U('Admin/AppMiniAlipayConfig/Save')}}"
method=
"POST"
request-type=
"ajax-url"
request-value=
"{{:U('Admin/AppMiniAlipayConfig/Index')}}"
>
<div
class=
"am-form-group"
>
<label>
{{$data.
home_app_mini_alipay_title
.name}}
</label>
<input
type=
"text"
name=
"{{$data.
home_app_mini_alipay_title.only_tag}}"
placeholder=
"{{$data.home_app_mini_alipay_title.name}}"
data-validation-message=
"{{$data.home_app_mini_alipay_title.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.home_app_mini_alipay_title
.value}}"
</present>
required />
<label>
{{$data.
common_app_mini_alipay_appid
.name}}
</label>
<input
type=
"text"
name=
"{{$data.
common_app_mini_alipay_appid.only_tag}}"
placeholder=
"{{$data.common_app_mini_alipay_appid.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_appid.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.common_app_mini_alipay_appid
.value}}"
</present>
required />
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.
home_app_mini_alipay_describe
.name}}
</label>
<
input
type=
"text"
name=
"{{$data.home_app_mini_alipay_describe.only_tag}}"
placeholder=
"{{$data.home_app_mini_alipay_describe.name}}"
data-validation-message=
"{{$data.home_app_mini_alipay_describe.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.home_app_mini_alipay_describe.value}}"
</present>
required /
>
<label>
{{$data.
common_app_mini_alipay_rsa_public
.name}}
</label>
<
textarea
rows=
"3"
name=
"{{$data.common_app_mini_alipay_rsa_public.only_tag}}"
class=
"am-radius"
placeholder=
"{{$data.common_app_mini_alipay_rsa_public.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_rsa_public.error_tips}}"
><present
name=
"data"
>
{{$data.common_app_mini_alipay_rsa_public.value}}
</present></textarea
>
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.home_app_mini_alipay_customer_service_tel.name}}
</label>
<input
type=
"text"
name=
"{{$data.home_app_mini_alipay_customer_service_tel.only_tag}}"
placeholder=
"{{$data.home_app_mini_alipay_customer_service_tel.name}}"
data-validation-message=
"{{$data.home_app_mini_alipay_customer_service_tel.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.home_app_mini_alipay_customer_service_tel.value}}"
</present>
/>
<label>
{{$data.common_app_mini_alipay_rsa_private.name}}
</label>
<textarea
rows=
"3"
name=
"{{$data.common_app_mini_alipay_rsa_private.only_tag}}"
class=
"am-radius"
placeholder=
"{{$data.common_app_mini_alipay_rsa_private.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_rsa_private.error_tips}}"
><present
name=
"data"
>
{{$data.common_app_mini_alipay_rsa_private.value}}
</present></textarea>
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.common_app_mini_alipay_out_rsa_public.name}}
</label>
<textarea
rows=
"3"
name=
"{{$data.common_app_mini_alipay_out_rsa_public.only_tag}}"
class=
"am-radius"
placeholder=
"{{$data.common_app_mini_alipay_out_rsa_public.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_out_rsa_public.error_tips}}"
><present
name=
"data"
>
{{$data.common_app_mini_alipay_out_rsa_public.value}}
</present></textarea>
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.common_app_mini_alipay_title.name}}
</label>
<input
type=
"text"
name=
"{{$data.common_app_mini_alipay_title.only_tag}}"
placeholder=
"{{$data.common_app_mini_alipay_title.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_title.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.common_app_mini_alipay_title.value}}"
</present>
required />
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.common_app_mini_alipay_describe.name}}
</label>
<input
type=
"text"
name=
"{{$data.common_app_mini_alipay_describe.only_tag}}"
placeholder=
"{{$data.common_app_mini_alipay_describe.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_describe.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.common_app_mini_alipay_describe.value}}"
</present>
required />
</div>
<div
class=
"am-form-group"
>
<label>
{{$data.common_app_mini_alipay_customer_service_tel.name}}
</label>
<input
type=
"text"
name=
"{{$data.common_app_mini_alipay_customer_service_tel.only_tag}}"
placeholder=
"{{$data.common_app_mini_alipay_customer_service_tel.name}}"
data-validation-message=
"{{$data.common_app_mini_alipay_customer_service_tel.error_tips}}"
class=
"am-radius"
<
present
name=
"data"
>
value="{{$data.common_app_mini_alipay_customer_service_tel.value}}"
</present>
/>
</div>
<div
class=
"am-form-group"
>
<button
type=
"submit"
class=
"am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100"
data-am-loading=
"{loadingText:'{{:L('common_form_loading_tips')}}'}"
>
{{:L('common_operation_save')}}
</button>
...
...
service/Application/Api/Controller/UserController.class.php
浏览文件 @
aa0e11e6
...
...
@@ -11,70 +11,70 @@ namespace Api\Controller;
*/
class
UserController
extends
CommonController
{
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-02T22:48:35+0800
*/
public
function
_initialize
()
{
// 调用父类前置方法
parent
::
_initialize
();
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-02T22:48:35+0800
*/
public
function
_initialize
()
{
// 调用父类前置方法
parent
::
_initialize
();
// 是否ajax请求
if
(
!
IS_AJAX
)
{
$this
->
error
(
L
(
'common_unauthorized_access'
));
}
}
/**
* [Reg 用户注册-数据添加]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-07T00:08:36+0800
*/
public
function
Reg
()
{
// 账户校验
$this
->
UserRegAccountsCheck
();
// 验证码校验
$verify_param
=
array
(
'key_prefix'
=>
'reg'
,
'expire_time'
=>
MyC
(
'common_verify_expire_time'
)
);
$obj
=
new
\
Library\Sms
(
$verify_param
);
// 是否已过期
if
(
!
$obj
->
CheckExpire
())
{
$this
->
ajaxReturn
(
L
(
'common_verify_expire'
),
-
10
);
}
// 是否正确
if
(
!
$obj
->
CheckCorrect
(
I
(
'verify'
)))
{
$this
->
ajaxReturn
(
L
(
'common_verify_error'
),
-
11
);
}
// 绑定
$m
=
M
(
'User'
);
}
/**
* [Reg 用户注册-数据添加]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-07T00:08:36+0800
*/
public
function
Reg
()
{
// 账户校验
$this
->
UserRegAccountsCheck
();
// 验证码校验
$verify_param
=
array
(
'key_prefix'
=>
'reg'
,
'expire_time'
=>
MyC
(
'common_verify_expire_time'
)
);
$obj
=
new
\
Library\Sms
(
$verify_param
);
// 是否已过期
if
(
!
$obj
->
CheckExpire
())
{
$this
->
ajaxReturn
(
L
(
'common_verify_expire'
),
-
10
);
}
// 是否正确
if
(
!
$obj
->
CheckCorrect
(
I
(
'verify'
)))
{
$this
->
ajaxReturn
(
L
(
'common_verify_error'
),
-
11
);
}
// 绑定
$m
=
M
(
'User'
);
$type_field
=
I
(
'app_type'
,
'alipay'
)
.
'_openid'
;
$data
=
array
(
$type_field
=>
I
(
'alipay_openid'
),
'mobile'
=>
I
(
'mobile'
),
$data
=
array
(
$type_field
=>
I
(
$type_field
),
'mobile'
=>
I
(
'mobile'
),
'referrer'
=>
intval
(
I
(
'referrer'
,
0
)),
'nickname'
=>
I
(
'nickname'
),
'avatar'
=>
I
(
'avatar'
),
'province'
=>
I
(
'province'
),
'city'
=>
I
(
'city'
),
'gender'
=>
intval
(
I
(
'gender'
,
0
)),
);
);
$where
=
[
$type_field
=>
I
(
'alipay_openid'
)
,
'is_delete_time'
=>
0
];
$where
=
[
'mobile'
=>
$data
[
'mobile'
]
,
'is_delete_time'
=>
0
];
$temp
=
$m
->
where
(
$where
)
->
find
();
if
(
empty
(
$temp
))
{
...
...
@@ -87,97 +87,91 @@ class UserController extends CommonController
$user_id
=
$temp
[
'id'
];
}
}
if
(
isset
(
$user_id
)
&&
$user_id
>
0
)
{
// 清除验证码
$obj
->
Remove
();
$this
->
ajaxReturn
(
L
(
'common_bind_success'
),
0
,
$m
->
find
(
$user_id
));
}
else
{
$this
->
ajaxReturn
(
L
(
'common_bind_error'
),
-
100
);
}
}
/**
* [RegVerifySend 用户注册-验证码发送]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-05T19:17:10+0800
*/
public
function
RegVerifySend
()
{
// 账户校验
$this
->
UserRegAccountsCheck
();
// 验证码公共基础参数
$verify_param
=
array
(
'key_prefix'
=>
'reg'
,
'expire_time'
=>
MyC
(
'common_verify_expire_time'
),
'time_interval'
=>
MyC
(
'common_verify_time_interval'
),
);
// 发送验证码
$obj
=
new
\
Library\Sms
(
$verify_param
);
$code
=
GetNumberCode
(
6
);
$status
=
$obj
->
SendCode
(
I
(
'mobile'
),
$code
,
MyC
(
'home_sms_user_reg'
));
// 状态
if
(
$status
)
{
$this
->
ajaxReturn
(
L
(
'common_send_success'
),
0
);
}
else
{
$this
->
ajaxReturn
(
L
(
'common_send_error'
)
.
'['
.
$obj
->
error
.
']'
,
-
100
);
}
}
/**
* [UserRegAccountsCheck 用户注册账户校验]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-10T10:06:29+0800
*/
private
function
UserRegAccountsCheck
()
{
// 参数
$accounts
=
I
(
'mobile'
);
if
(
empty
(
$accounts
))
{
$this
->
ajaxReturn
(
L
(
'common_param_error'
),
-
1
);
}
// 手机号码格式
if
(
!
CheckMobile
(
$accounts
))
{
$this
->
ajaxReturn
(
L
(
'common_mobile_format_error'
),
-
2
);
}
// 手机号码是否已存在
if
(
$this
->
IsExistAccounts
(
$accounts
,
'mobile'
))
{
$this
->
ajaxReturn
(
L
(
'common_mobile_exist_error'
),
-
3
);
}
}
/**
* [IsExistAccounts 账户是否存在]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-08T10:27:14+0800
* @param [string] $accounts [账户名称]
* @param [string] $field [字段名称]
* @return [boolean] [存在true, 不存在false]
*/
private
function
IsExistAccounts
(
$accounts
,
$field
=
'mobile'
)
{
$id
=
M
(
'User'
)
->
where
(
array
(
'is_delete_time'
=>
0
,
$field
=>
$accounts
))
->
getField
(
'id'
);
return
!
empty
(
$id
);
}
/**
if
(
isset
(
$user_id
)
&&
$user_id
>
0
)
{
// 清除验证码
$obj
->
Remove
();
$this
->
ajaxReturn
(
L
(
'common_bind_success'
),
0
,
$m
->
find
(
$user_id
));
}
else
{
$this
->
ajaxReturn
(
L
(
'common_bind_error'
),
-
100
);
}
}
/**
* [RegVerifySend 用户注册-验证码发送]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-05T19:17:10+0800
*/
public
function
RegVerifySend
()
{
// 账户校验
$this
->
UserRegAccountsCheck
();
// 验证码公共基础参数
$verify_param
=
array
(
'key_prefix'
=>
'reg'
,
'expire_time'
=>
MyC
(
'common_verify_expire_time'
),
'time_interval'
=>
MyC
(
'common_verify_time_interval'
),
);
// 发送验证码
$obj
=
new
\
Library\Sms
(
$verify_param
);
$code
=
GetNumberCode
(
6
);
$status
=
$obj
->
SendCode
(
I
(
'mobile'
),
$code
,
MyC
(
'home_sms_user_reg'
));
// 状态
if
(
$status
)
{
$this
->
ajaxReturn
(
L
(
'common_send_success'
),
0
);
}
else
{
$this
->
ajaxReturn
(
L
(
'common_send_error'
)
.
'['
.
$obj
->
error
.
']'
,
-
100
);
}
}
/**
* [UserRegAccountsCheck 用户注册账户校验]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-10T10:06:29+0800
*/
private
function
UserRegAccountsCheck
()
{
// 参数
$accounts
=
I
(
'mobile'
);
if
(
empty
(
$accounts
))
{
$this
->
ajaxReturn
(
L
(
'common_param_error'
),
-
1
);
}
// 手机号码格式
if
(
!
CheckMobile
(
$accounts
))
{
$this
->
ajaxReturn
(
L
(
'common_mobile_format_error'
),
-
2
);
}
}
/**
* [IsExistAccounts 账户是否存在]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-08T10:27:14+0800
* @param [string] $accounts [账户名称]
* @param [string] $field [字段名称]
* @return [boolean] [存在true, 不存在false]
*/
private
function
IsExistAccounts
(
$accounts
,
$field
=
'mobile'
)
{
$id
=
M
(
'User'
)
->
where
(
array
(
'is_delete_time'
=>
0
,
$field
=>
$accounts
))
->
getField
(
'id'
);
return
!
empty
(
$id
);
}
/**
* [GetAlipayUserInfo 获取支付宝用户信息]
* @author Devil
* @blog http://gong.gg/
...
...
@@ -186,38 +180,49 @@ class UserController extends CommonController
*/
public
function
GetAlipayUserInfo
()
{
$result
=
(
new
\
Library\Alipay
())
->
GetAlipayUserInfo
(
I
(
'authcode'
),
C
(
'alipay_mini
_appid'
));
$result
=
(
new
\
Library\Alipay
())
->
GetAlipayUserInfo
(
I
(
'authcode'
),
MyC
(
'common_app_mini_alipay
_appid'
));
if
(
$result
===
false
)
{
$this
->
ajaxReturn
(
'获取授权信息失败'
);
}
else
{
$data
=
[
'alipay_openid'
=>
$result
[
'user_id'
],
'nickname'
=>
empty
(
$result
[
'nick_name'
])
?
''
:
$result
[
'nick_name'
],
'avatar'
=>
empty
(
$result
[
'avatar'
])
?
''
:
$result
[
'avatar'
],
'gender'
=>
empty
(
$result
[
'gender'
])
?
0
:
(
$result
[
'gender'
]
==
'm'
)
?
2
:
1
,
'province'
=>
empty
(
$result
[
'province'
])
?
''
:
$result
[
'province'
],
'city'
=>
empty
(
$result
[
'city'
])
?
''
:
$result
[
'city'
],
'referrer'
=>
intval
(
I
(
'referrer'
,
0
)),
];
$m
=
M
(
'User'
);
$where
=
[
'alipay_openid'
=>
$result
[
'user_id'
],
'is_delete_time'
=>
0
];
$user
=
$m
->
where
(
$where
)
->
find
();
if
(
!
empty
(
$user
))
{
$data
[
'upd_time'
]
=
time
();
if
(
$m
->
where
(
$where
)
->
save
(
$data
)
===
false
)
{
$this
->
ajaxReturn
(
'用户更新失败'
);
}
$data
=
$user
;
}
// 返回成功
$this
->
ajaxReturn
(
'授权成功'
,
0
,
$data
);
$result
[
'openid'
]
=
$result
[
'user_id'
];
$this
->
AuthUserProgram
(
$result
,
'alipay_openid'
);
}
}
/**
* 用户授权保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-06
* @desc description
* @param [array] $params [用户数据]
* @param [string] $field [平台字段名称]
*/
private
function
AuthUserProgram
(
$params
,
$field
)
{
$data
=
[
$field
=>
$params
[
'openid'
],
'nickname'
=>
empty
(
$params
[
'nick_name'
])
?
''
:
$params
[
'nick_name'
],
'avatar'
=>
empty
(
$params
[
'avatar'
])
?
''
:
$params
[
'avatar'
],
'gender'
=>
empty
(
$params
[
'gender'
])
?
0
:
(
$params
[
'gender'
]
==
'm'
)
?
2
:
1
,
'province'
=>
empty
(
$params
[
'province'
])
?
''
:
$params
[
'province'
],
'city'
=>
empty
(
$params
[
'city'
])
?
''
:
$params
[
'city'
],
'referrer'
=>
intval
(
I
(
'referrer'
,
0
)),
];
$m
=
M
(
'User'
);
$where
=
[
$field
=>
$params
[
'openid'
],
'is_delete_time'
=>
0
];
$user
=
$m
->
where
(
$where
)
->
find
();
if
(
!
empty
(
$user
))
{
$data
=
$user
;
}
// 返回成功
$this
->
ajaxReturn
(
'授权成功'
,
0
,
$data
);
}
/**
* [ClientCenter 用户中心]
* @author Devil
...
...
@@ -243,5 +248,25 @@ class UserController extends CommonController
// 返回数据
$this
->
ajaxReturn
(
L
(
'common_operation_success'
),
0
,
$result
);
}
/**
* 百度小程序获取用户信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-06
* @desc description
*/
public
function
GetBaiduUserInfo
()
{
$_POST
[
'config'
]
=
C
(
'baidu_mini_program_config'
);
$result
=
(
new
\
Library\BaiduAuth
())
->
GetAuthUserInfo
(
$_POST
);
if
(
$result
[
'status'
]
==
0
)
{
$this
->
AuthUserProgram
(
$result
[
'data'
],
'baidu_openid'
);
}
else
{
$this
->
ajaxReturn
(
$result
[
'msg'
]);
}
}
}
?>
\ No newline at end of file
service/Application/Common/Conf/config.php
浏览文件 @
aa0e11e6
...
...
@@ -124,9 +124,6 @@ return array(
// 开启U带域名
'url_domain_deploy'
=>
true
,
// 支付宝appid
'alipay_mini_appid'
=>
'2018071160553916'
,
// 支付业务类型,支付插件根据业务类型自动生成支付入口文件
'payment_business_type_all'
=>
[
...
...
service/Application/Library/Alipay.class.php
浏览文件 @
aa0e11e6
...
...
@@ -47,7 +47,7 @@ class Alipay
private
function
SoonPayApp
(
$data
,
$config
)
{
$parameter
=
array
(
'app_id'
=>
C
(
'alipay_mini
_appid'
),
'app_id'
=>
MyC
(
'common_app_mini_alipay
_appid'
),
'method'
=>
'alipay.trade.app.pay'
,
'format'
=>
'JSON'
,
'charset'
=>
'utf-8'
,
...
...
@@ -446,38 +446,51 @@ class Alipay
}
/**
* [
SyncRsaVerify 同步返回签名验证
]
* [
MyRsaSign 签名字符串
]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2017-09-2
5T13:13:39
+0800
* @param [
array] $data [返回数据
]
* @
param [boolean] $key [数据key
]
* @datetime 2017-09-2
4T08:38:28
+0800
* @param [
string] $prestr [需要签名的字符串
]
* @
return [string] [签名结果
]
*/
private
function
SyncRsaVerify
(
$data
,
$key
)
private
function
MyRsaSign
(
$prestr
)
{
$string
=
json_encode
(
$data
[
$key
],
JSON_UNESCAPED_UNICODE
);
return
$this
->
AlipayRsaVerify
(
$string
,
$data
[
'sign'
]);
$res
=
"-----BEGIN RSA PRIVATE KEY-----
\n
"
;
$res
.
=
wordwrap
(
MyC
(
'common_app_mini_alipay_rsa_private'
),
64
,
"
\n
"
,
true
);
$res
.
=
"
\n
-----END RSA PRIVATE KEY-----"
;
return
openssl_sign
(
$prestr
,
$sign
,
$res
,
OPENSSL_ALGO_SHA256
)
?
base64_encode
(
$sign
)
:
null
;
}
/**
* [MyRsa
Sign 签名字符串
]
* [MyRsa
Decrypt RSA解密
]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2017-09-24T0
8:38:28
+0800
* @param [string] $
prestr [需要签名的字符串
]
* @return [string]
[签名结果
]
* @datetime 2017-09-24T0
9:12:06
+0800
* @param [string] $
content [需要解密的内容,密文
]
* @return [string]
[解密后内容,明文
]
*/
private
function
MyRsa
Sign
(
$prestr
)
private
function
MyRsa
Decrypt
(
$content
)
{
$public_key
=
file_get_contents
(
ROOT_PATH
.
'Rsakeys/rsa_mini_private_key_pkcs8.pem'
);
$pkeyid
=
openssl_pkey_get_private
(
$public_key
);
return
openssl_sign
(
$prestr
,
$sign
,
$pkeyid
,
OPENSSL_ALGO_SHA256
)
?
base64_encode
(
$sign
)
:
null
;
$res
=
"-----BEGIN PUBLIC KEY-----
\n
"
;
$res
.
=
wordwrap
(
MyC
(
'common_app_mini_alipay_rsa_public'
),
64
,
"
\n
"
,
true
);
$res
.
=
"
\n
-----END PUBLIC KEY-----"
;
$res
=
openssl_get_privatekey
(
$res
);
$content
=
base64_decode
(
$content
);
$result
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$content
)
/
128
;
$i
++
)
{
$data
=
substr
(
$content
,
$i
*
128
,
128
);
openssl_private_decrypt
(
$data
,
$decrypt
,
$res
,
OPENSSL_ALGO_SHA256
);
$result
.
=
$decrypt
;
}
openssl_free_key
(
$res
);
return
$result
;
}
/**
* [
Alipay
RsaVerify 支付宝验证签名]
* [
Out
RsaVerify 支付宝验证签名]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
...
...
@@ -486,11 +499,13 @@ class Alipay
* @param [string] $sign [签名结果]
* @return [boolean] [正确true, 错误false]
*/
private
function
Alipay
RsaVerify
(
$prestr
,
$sign
)
private
function
Out
RsaVerify
(
$prestr
,
$sign
)
{
$res
=
"-----BEGIN PUBLIC KEY-----
\n
"
;
$res
.
=
wordwrap
(
MyC
(
'common_app_mini_alipay_out_rsa_public'
),
64
,
"
\n
"
,
true
);
$res
.
=
"
\n
-----END PUBLIC KEY-----"
;
$pkeyid
=
openssl_pkey_get_public
(
$res
);
$sign
=
base64_decode
(
$sign
);
$public_key
=
file_get_contents
(
ROOT_PATH
.
'Rsakeys/rsa_alipay_mini_public_key.pem'
);
$pkeyid
=
openssl_pkey_get_public
(
$public_key
);
if
(
$pkeyid
)
{
$verify
=
openssl_verify
(
$prestr
,
$sign
,
$pkeyid
,
OPENSSL_ALGO_SHA256
);
...
...
@@ -500,28 +515,18 @@ class Alipay
}
/**
* [
MyRsaDecrypt RSA解密
]
* [
SyncRsaVerify 同步返回签名验证
]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2017-09-2
4T09:12:06
+0800
* @param [
string] $content [需要解密的内容,密文
]
* @
return [string] [解密后内容,明文
]
* @datetime 2017-09-2
5T13:13:39
+0800
* @param [
array] $data [返回数据
]
* @
param [boolean] $key [数据key
]
*/
private
function
MyRsaDecrypt
(
$content
)
private
function
SyncRsaVerify
(
$data
,
$key
)
{
$priKey
=
file_get_contents
(
ROOT_PATH
.
'Rsakeys/mini_private_key.pem'
);
$res
=
openssl_get_privatekey
(
$priKey
);
$content
=
base64_decode
(
$content
);
$result
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$content
)
/
128
;
$i
++
)
{
$data
=
substr
(
$content
,
$i
*
128
,
128
);
openssl_private_decrypt
(
$data
,
$decrypt
,
$res
,
OPENSSL_ALGO_SHA256
);
$result
.
=
$decrypt
;
}
openssl_free_key
(
$res
);
return
$result
;
$string
=
json_encode
(
$data
[
$key
],
JSON_UNESCAPED_UNICODE
);
return
$this
->
OutRsaVerify
(
$string
,
$data
[
'sign'
]);
}
/**
...
...
@@ -582,7 +587,7 @@ class Alipay
{
// 请求参数
$params
=
[
'app_id'
=>
C
(
'alipay_mini
_appid'
),
'app_id'
=>
MyC
(
'common_app_mini_alipay
_appid'
),
'method'
=>
'alipay.open.app.qrcode.create'
,
'charset'
=>
'utf-8'
,
'format'
=>
'JSON'
,
...
...
service/Application/Library/BaiduAuth.class.php
0 → 100644
浏览文件 @
aa0e11e6
<?php
namespace
Library
;
/**
* 百度用户授权驱动
* @author Devil
* @version V_1.0.0
*/
class
BaiduAuth
{
/**
* [__construct 构造方法]
*/
public
function
__construct
(){}
/**
* 用户授权
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-11-06
* @desc description
* @param [array] $params [输入参数]
*/
public
function
GetAuthUserInfo
(
$params
=
[])
{
if
(
empty
(
$params
[
'authcode'
]))
{
return
[
'status'
=>-
1
,
'msg'
=>
'授权码有误'
];
}
if
(
empty
(
$params
[
'config'
]))
{
return
[
'status'
=>-
1
,
'msg'
=>
'配置有误'
];
}
$data
=
[
'code'
=>
$params
[
'authcode'
],
'client_id'
=>
$params
[
'config'
][
'key'
],
'sk'
=>
$params
[
'config'
][
'secret'
],
];
$result
=
$this
->
HttpRequest
(
'https://openapi.baidu.com/nalogin/getSessionKeyByCode'
,
$data
);
if
(
empty
(
$result
[
'openid'
]))
{
return
[
'status'
=>-
1
,
'msg'
=>
$result
[
'error_description'
]];
}
return
[
'status'
=>
0
,
'msg'
=>
'授权成功'
,
'data'
=>
$result
];
}
/**
* [HttpRequest 网络请求]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2017-09-25T09:10:46+0800
* @param [string] $url [请求url]
* @param [array] $data [发送数据]
* @return [mixed] [请求返回数据]
*/
private
function
HttpRequest
(
$url
,
$data
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_FAILONERROR
,
false
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
$body_string
=
''
;
if
(
is_array
(
$data
)
&&
0
<
count
(
$data
))
{
foreach
(
$data
as
$k
=>
$v
)
{
$body_string
.
=
$k
.
'='
.
urlencode
(
$v
)
.
'&'
;
}
curl_setopt
(
$ch
,
CURLOPT_POST
,
true
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$body_string
);
}
$headers
=
array
(
'content-type: application/x-www-form-urlencoded;charset=UTF-8'
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
$reponse
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$ch
))
{
return
false
;
}
else
{
$httpStatusCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
200
!==
$httpStatusCode
)
{
return
false
;
}
}
curl_close
(
$ch
);
return
json_decode
(
$reponse
,
true
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录