Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
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
hujun
tl_estate
Commits
8eedf62a
Commit
8eedf62a
authored
Nov 21, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推广手机号码记录
parent
625d9696
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
SpreadUser.php
application/api_broker/controller/SpreadUser.php
+19
-24
No files found.
application/api_broker/controller/SpreadUser.php
View file @
8eedf62a
...
...
@@ -29,47 +29,41 @@ class SpreadUser extends Basic
* User: 朱伟
* Date: 2018-11-21
* Time: 10:43:58
*http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=686
*/
public
function
addSpreadUser
(){
$params
=
$this
->
params
;
$
user_ip
=
$this
->
i
p
();
$
params
[
"ip"
]
=
$this
->
getUserI
p
();
$params
=
array
(
/*$params = array(
"type" => 1,
"phone"
=>
1811234715
1
,
"ip"
=>
$
user_ip
);
"phone" => 1811234715
2
,
"ip" => $
params["ip"]
);
*/
if
(
!
isset
(
$params
[
"phone"
])
or
!
isset
(
$params
[
"ip"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
//先判断是否已经存在数据
$field
=
'phone,ip,create_time'
;
$where
[
'ip'
]
=
$params
[
"ip"
];
$where_or
[
'phone'
]
=
$params
[
"phone"
];
$res
=
$this
->
uSpreadUser
->
getSpreadUser
(
$field
,
$where
,
$where_or
);
if
(
$res
){
//如果存在
dump
(
$res
);
if
(
$res
){
}
else
{
if
(
$res
[
0
][
'phone'
]
==
$params
[
"phone"
]){
return
$this
->
response
(
"101"
,
"手机号已存在"
);
}
elseif
((
$res
[
0
][
'ip'
]
==
$params
[
"ip"
])
and
((
time
()
-
strtotime
(
$res
[
0
][
'create_time'
]))
<
(
60
*
30
))){
return
$this
->
response
(
"101"
,
"30分钟内不允许重复提交"
);
}
return
$this
->
response
(
"101"
,
"30分钟内不允许重复提交"
);
}
else
{
//不存在则新增数据
$insert
[
"phone"
]
=
$params
[
'phone'
];
$insert
[
"ip"
]
=
$params
[
'ip'
];
$insert
[
"type"
]
=
$params
[
'type'
];
$res
=
$this
->
uSpreadUser
->
saveSpreadUser
(
$insert
);
//int(1)
}
$insert
[
"phone"
]
=
$params
[
'phone'
];
$insert
[
"ip"
]
=
$params
[
'ip'
];
$insert
[
"type"
]
=
$params
[
'type'
];
$res
=
$this
->
uSpreadUser
->
saveSpreadUser
(
$insert
);
//int(1)
if
(
$res
)
{
return
$this
->
response
(
"200"
,
"成功"
);
}
else
{
...
...
@@ -79,8 +73,11 @@ class SpreadUser extends Basic
}
public
function
ip
()
{
/**
* 获取用户提交IP
* @return string
*/
public
function
getUserIp
()
{
//strcasecmp 比较两个字符,不区分大小写。返回0,>0,<0。
if
(
getenv
(
'HTTP_CLIENT_IP'
)
&&
strcasecmp
(
getenv
(
'HTTP_CLIENT_IP'
),
'unknown'
))
{
$ip
=
getenv
(
'HTTP_CLIENT_IP'
);
...
...
@@ -93,7 +90,6 @@ class SpreadUser extends Basic
}
$res
=
preg_match
(
'/[\d\.]{7,15}/'
,
$ip
,
$matches
)
?
$matches
[
0
]
:
''
;
return
$res
;
//dump(phpinfo());//所有PHP配置信息
}
}
\ 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