Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fusionadmin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林洽文
fusionadmin
Commits
88ad1ddc
Commit
88ad1ddc
authored
2 years ago
by
zazaname
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聚合服务端后台V1.0
parent
5842053e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
common.php
app/common.php
+26
-24
No files found.
app/common.php
View file @
88ad1ddc
...
...
@@ -9,25 +9,25 @@ use think\facade\Cache;
* @param $message
* @return array|bool|string
*/
if
(
!
function_exists
(
'dingdingLog'
))
{
function
dingdingLog
(
$message
)
{
if
(
is_array
(
$message
))
{
$message
=
"该参数是数组:"
.
var_export
(
$message
,
true
);
if
(
!
function_exists
(
'dingdingLog'
))
{
function
dingdingLog
(
$message
)
{
if
(
is_array
(
$message
))
{
$message
=
"该参数是数组:"
.
var_export
(
$message
,
true
);
}
$data
=
array
(
'msgtype'
=>
'text'
,
'text'
=>
array
(
'content'
=>
'[ '
.
date
(
"Y-m-d H:i:s"
)
.
' ] - 日志:'
.
$message
));
$data
=
array
(
'msgtype'
=>
'text'
,
'text'
=>
array
(
'content'
=>
'[ '
.
date
(
"Y-m-d H:i:s"
)
.
' ] - 日志:'
.
$message
));
$post_string
=
json_encode
(
$data
);
$ch
=
curl_init
();
$access_token
=
'b74a7e686873baaed443c4d4bf6c68e3f58debc79324c4d3ea14549dc43586f2'
;
curl_setopt
(
$ch
,
CURLOPT_URL
,
'https://oapi.dingtalk.com/robot/send?access_token='
.
$access_token
);
curl_setopt
(
$ch
,
CURLOPT_URL
,
'https://oapi.dingtalk.com/robot/send?access_token='
.
$access_token
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
5
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: application/json;charset=utf-8'
));
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: application/json;charset=utf-8'
));
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$post_string
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
// 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
0
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
0
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
0
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
0
);
$data
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$data
;
...
...
@@ -40,27 +40,28 @@ if (!function_exists('dingdingLog'))
* @param array $headers
* @return bool|mixed
*/
if
(
!
function_exists
(
'curl_get'
)){
function
curl_get
(
$url
=
''
,
$headers
=
[]){
if
(
!
function_exists
(
'curl_get'
))
{
function
curl_get
(
$url
=
''
,
$headers
=
[])
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
//是否在展示header信息
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
// curl_setopt($curl,CURLOPT_PROXY,'127.0.0.1:8888');
if
(
preg_match
(
"/^https(.*)?/i"
,
$url
))
{
if
(
preg_match
(
"/^https(.*)?/i"
,
$url
))
{
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
//规避ssl的证书检查
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
}
curl_setopt
(
$curl
,
CURLOPT_CONNECTTIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_ENCODING
,
'gzip'
);
count
(
$headers
)
&&
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
$headers
);
$result
=
curl_exec
(
$curl
);
$result_no
=
curl_errno
(
$curl
);
curl_close
(
$curl
);
if
(
$result_no
!=
0
)
{
// 请求异常,写日志
if
(
$result_no
!=
0
)
{
// 请求异常,写日志
return
false
;
}
else
{
}
else
{
return
$result
;
}
}
...
...
@@ -73,18 +74,19 @@ if(!function_exists('curl_get')){
* @param string $post
* @return bool|mixed
*/
if
(
!
function_exists
(
'curl_post'
)){
function
curl_post
(
$url
=
''
,
$headers
=
[],
$post
=
''
){
if
(
!
function_exists
(
'curl_post'
))
{
function
curl_post
(
$url
=
''
,
$headers
=
[],
$post
=
''
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
//是否在展示header信息
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
if
(
preg_match
(
"/^https(.*)?/i"
,
$url
))
{
if
(
preg_match
(
"/^https(.*)?/i"
,
$url
))
{
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
//规避ssl的证书检查
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
}
curl_setopt
(
$curl
,
CURLOPT_CONNECTTIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
5
);
curl_setopt
(
$curl
,
CURLOPT_ENCODING
,
"gzip"
);
count
(
$headers
)
&&
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
$headers
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
...
...
@@ -92,9 +94,9 @@ if(!function_exists('curl_post')){
$result
=
curl_exec
(
$curl
);
$result_no
=
curl_errno
(
$curl
);
curl_close
(
$curl
);
if
(
$result_no
!=
0
)
{
// 请求异常,写日志
if
(
$result_no
!=
0
)
{
// 请求异常,写日志
return
false
;
}
else
{
}
else
{
return
$result
;
}
}
...
...
@@ -136,12 +138,12 @@ if (!function_exists('xdebug')) {
/**
* debug调试
* @deprecated 不建议使用,建议直接使用框架自带的log组件
* @param string|array $data 打印信息
* @param string $type 类型
* @param string $suffix 文件后缀名
* @param bool $force
* @param null $file
* @deprecated 不建议使用,建议直接使用框架自带的log组件
*/
function
xdebug
(
$data
,
$type
=
'xdebug'
,
$suffix
=
null
,
$force
=
false
,
$file
=
null
)
{
...
...
@@ -150,7 +152,7 @@ if (!function_exists('xdebug')) {
$file
=
is_null
(
$suffix
)
?
runtime_path
()
.
'xdebug/'
.
date
(
'Ymd'
)
.
'.txt'
:
runtime_path
()
.
'xdebug/'
.
date
(
'Ymd'
)
.
"_
{
$suffix
}
"
.
'.txt'
;
}
file_put_contents
(
$file
,
"["
.
date
(
'Y-m-d H:i:s'
)
.
"] "
.
"=========================
{
$type
}
==========================="
.
PHP_EOL
,
FILE_APPEND
);
$str
=
(
is_string
(
$data
)
?
$data
:
(
is_array
(
$data
)
||
is_object
(
$data
))
?
print_r
(
$data
,
true
)
:
var_export
(
$data
,
true
))
.
PHP_EOL
;
$str
=
(
is_string
(
$data
)
?
$data
:
(
(
is_array
(
$data
)
||
is_object
(
$data
))
?
print_r
(
$data
,
true
)
:
var_export
(
$data
,
true
))
.
PHP_EOL
)
;
$force
?
file_put_contents
(
$file
,
$str
)
:
file_put_contents
(
$file
,
$str
,
FILE_APPEND
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment