Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
ticker_config
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallets
ticker_config
Commits
bcc0f446
Commit
bcc0f446
authored
Dec 09, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数配置
parent
a27f96e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
11 deletions
+114
-11
index.php
api/index.php
+18
-11
main-local.php
common/config/main-local.php
+7
-0
params-local.php
common/config/params-local.php
+12
-0
Curl.php
common/helper/Curl.php
+77
-0
No files found.
api/index.php
View file @
bcc0f446
...
...
@@ -12,18 +12,25 @@ define('WALLET_PROJECT_PATH', '/data_wallet/token'); //定义框架代码的目
define
(
'WALLET_RUNTIME_PATH'
,
dirname
(
__DIR__
));
//定义程序运行的目录
if
(
isset
(
$_GET
[
'env'
])
&&
'test'
==
$_GET
[
'env'
])
{
require_once
__DIR__
.
'/../common/helper/Curl.php'
;
require_once
__DIR__
.
'/../common/helper/InitAppHelper.php'
;
$realip
=
InitAppHelper
::
getUserIp
();
$ip_list
=
file_get_contents
(
'http://47.100.212.109/api_ip_limit.txt'
);
$ip_arr
=
explode
(
"
\n
"
,
$ip_list
);
foreach
(
$ip_arr
as
$key
=>
$ip
)
{
if
(
$ip
==
$realip
)
{
$data
=
[
'code'
=>
403
,
'message'
=>
'请求次数过多!'
];
echo
json_encode
(
$data
);
exit
;
if
(
strpos
(
$_SERVER
[
'REQUEST_URI'
],
'black-list'
)
==
false
)
{
$realip
=
InitAppHelper
::
getUserIp
();
$url
=
'http://127.0.0.1:8082/interface/validate/black-list'
;
Curl
::
prepare
(
$url
);
Curl
::
exec_get
();
$ip_list
=
Curl
::
get_response_assoc
();
if
(
isset
(
$ip_list
[
'data'
])
&&
count
(
$ip_list
>
0
))
{
foreach
(
$ip_list
[
'data'
]
as
$key
=>
$ip
)
{
if
(
$ip
==
$realip
)
{
$data
=
[
'code'
=>
403
,
'message'
=>
'请求次数过多!'
];
echo
json_encode
(
$data
);
exit
;
}
}
}
}
}
...
...
common/config/main-local.php
View file @
bcc0f446
...
...
@@ -92,6 +92,13 @@ return [
'password'
=>
'fuzamei47100222198'
,
'database'
=>
6
,
],
'redis_es'
=>
[
'class'
=>
'yii\redis\Connection'
,
'hostname'
=>
'47.100.226.15'
,
'port'
=>
6379
,
'password'
=>
'fuzamei47100222198'
,
'database'
=>
7
,
],
'queue'
=>
[
'class'
=>
\yii\queue\redis\Queue
::
class
,
'redis'
=>
'redis-queue'
,
// Redis connection component or its config
...
...
common/config/params-local.php
View file @
bcc0f446
...
...
@@ -151,5 +151,17 @@ return [
3
=>
'文章'
,
4
=>
'邀请有礼Banner'
,
5
=>
'邀请有礼海报'
],
'api_ip_limit'
=>
[
'limit'
=>
200
,
'white_list'
=>
[
'127.0.0.1'
,
'47.103.119.244'
,
//lsb 1
'47.100.212.109'
,
//lsb 2
'183.129.134.34'
,
//公司
'129.226.132.153'
,
//公司VPN
'161.117.33.70'
//比特元
]
]
];
common/helper/Curl.php
0 → 100644
View file @
bcc0f446
<?php
/**
* Class curl
* @package simple_curl
*/
class
Curl
{
protected
static
$url
;
protected
static
$headers
;
protected
static
$query
;
protected
static
$responses
;
/**
* @param $url
* @param $headers
* @param $query
*/
public
static
function
prepare
(
$url
,
$query
=
array
(),
$headers
=
array
())
{
self
::
$url
=
$url
;
self
::
$headers
=
$headers
;
self
::
$query
=
http_build_query
(
$query
);
}
/**
* Execute post method curl request
*/
public
static
function
exec_post
()
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
self
::
$url
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
self
::
$headers
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
self
::
$query
);
self
::
$responses
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
}
/**
* Execute get method curl request
*/
public
static
function
exec_get
()
{
$full_url
=
self
::
$url
.
'?'
.
self
::
$query
;
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$full_url
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
self
::
$headers
);
self
::
$responses
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
}
/**
* @return mixed
*/
public
static
function
get_response
()
{
return
self
::
$responses
;
}
/**
* @return mixed
*/
public
static
function
get_response_assoc
()
{
return
json_decode
(
self
::
$responses
,
true
);
}
}
\ No newline at end of file
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