Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
weixiuhui
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
蒋林
weixiuhui
Commits
78ff7dbb
Commit
78ff7dbb
authored
Jan 19, 2017
by
蒋林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
苏宁-邮箱获取短信验证码规则修改
parent
f7573b59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
12 deletions
+89
-12
Suning.php
application/controllers/test/Suning.php
+11
-1
base_helper.php
application/helpers/base_helper.php
+50
-3
SourceSuning.php
application/libraries/Source/SourceSuning.php
+28
-8
No files found.
application/controllers/test/Suning.php
View file @
78ff7dbb
...
@@ -27,7 +27,7 @@ class Suning extends BaseController
...
@@ -27,7 +27,7 @@ class Suning extends BaseController
self
::
$apiUrl
=
"http://
{
$_SERVER
[
'HTTP_HOST'
]
}
/"
;
self
::
$apiUrl
=
"http://
{
$_SERVER
[
'HTTP_HOST'
]
}
/"
;
$account
=
[
$account
=
[
0
=>
[
'u'
=>
'
深圳唯修汇科技有限公司
'
,
'p'
=>
'weixiuhui123456'
],
0
=>
[
'u'
=>
'
451592674@qq.com
'
,
'p'
=>
'weixiuhui123456'
],
1
=>
[
'u'
=>
'18771093166@163.com'
,
'p'
=>
'wgw19771230'
],
1
=>
[
'u'
=>
'18771093166@163.com'
,
'p'
=>
'wgw19771230'
],
];
];
...
@@ -56,6 +56,16 @@ class Suning extends BaseController
...
@@ -56,6 +56,16 @@ class Suning extends BaseController
var_dump
(
$result
);
var_dump
(
$result
);
}
}
public
function
mail
()
{
$mail
=
'weixiuhui1688@163.com'
;
$pwd
=
'wxh16888'
;
$result
=
receive_mails
(
$mail
,
$pwd
);
$this
->
show
(
$result
);
}
public
function
selectServiceOrderCondition
()
public
function
selectServiceOrderCondition
()
{
{
$obj
=
$this
->
receiveObj
();
$obj
=
$this
->
receiveObj
();
...
...
application/helpers/base_helper.php
View file @
78ff7dbb
...
@@ -181,7 +181,7 @@ function phone_code($mail, $pwd)
...
@@ -181,7 +181,7 @@ function phone_code($mail, $pwd)
$result
=
[];
$result
=
[];
if
(
$num
)
{
if
(
$num
)
{
$body
=
imap_base64
(
imap_fetchbody
(
$mbox
,
imap_num_msg
(
$mbox
)
,
1
));
$body
=
imap_base64
(
imap_fetchbody
(
$mbox
,
$num
,
1
));
preg_match
(
'/验证码[\s\S]+?(\d{6,8})/'
,
$body
,
$code
);
preg_match
(
'/验证码[\s\S]+?(\d{6,8})/'
,
$body
,
$code
);
preg_match
(
'/2\d{3}-[\s\S]{14}/'
,
$body
,
$date
);
preg_match
(
'/2\d{3}-[\s\S]{14}/'
,
$body
,
$date
);
...
@@ -191,10 +191,57 @@ function phone_code($mail, $pwd)
...
@@ -191,10 +191,57 @@ function phone_code($mail, $pwd)
$result
[
'date'
]
=
$date
[
0
];
$result
[
'date'
]
=
$date
[
0
];
$result
[
'st'
]
=
time
()
-
strtotime
(
$result
[
'date'
]);
$result
[
'st'
]
=
time
()
-
strtotime
(
$result
[
'date'
]);
}
}
}
//关闭资源
imap_close
(
$mbox
);
//关闭资源
return
$result
;
imap_close
(
$mbox
);
}
function
receive_mails
(
$mail
,
$pwd
,
$max
=
10
)
{
$mbox
=
imap_open
(
"
{
pop.163.com:995/pop3/ssl
}
INBOX"
,
$mail
,
$pwd
);
if
(
!
$mbox
)
{
return_msg
(
false
,
'登陆邮箱失败'
);
}
}
$num
=
imap_num_msg
(
$mbox
);
$receive_num
=
0
;
//接收条数
$receive_max
=
$max
;
//接收最大的条数
$nowtime
=
time
();
$result
=
[];
if
(
$num
)
{
if
(
$num
<
$receive_max
)
{
$receive_max
=
$num
;
}
while
(
$receive_num
<
$receive_max
)
{
$body
=
imap_base64
(
imap_fetchbody
(
$mbox
,
$num
-
$receive_num
,
1
));
preg_match
(
'/用户([^,]+),/'
,
$body
,
$username
);
preg_match
(
'/验证码[\s\S]+?(\d{6,8})/'
,
$body
,
$code
);
preg_match
(
'/2\d{3}-[\s\S]{14}/'
,
$body
,
$date
);
if
(
!
isset
(
$code
[
1
])
||
!
isset
(
$date
[
0
])
||
!
isset
(
$username
[
1
]))
{
return_msg
(
false
,
'请检查邮箱中手机验证码内容'
);
}
$result
[]
=
[
'username'
=>
$username
[
1
],
'code'
=>
$code
[
1
],
'date'
=>
$date
[
0
],
'st'
=>
$nowtime
-
strtotime
(
$date
[
0
])
];
$receive_num
++
;
}
}
//关闭资源
imap_close
(
$mbox
);
return
$result
;
return
$result
;
}
}
application/libraries/Source/SourceSuning.php
View file @
78ff7dbb
...
@@ -20,7 +20,7 @@ class SourceSuning extends Source
...
@@ -20,7 +20,7 @@ class SourceSuning extends Source
self
::
$captchaFilePath
=
PUBDIR
.
"captcha/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".gif"
;
self
::
$captchaFilePath
=
PUBDIR
.
"captcha/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".gif"
;
//debug
//debug
self
::
$debug
=
fals
e
;
self
::
$debug
=
tru
e
;
//登陆检查
//登陆检查
login_check
(
self
::
$app
,
self
::
$account
[
'username'
],
self
::
$account
[
'pwd'
],
3
);
login_check
(
self
::
$app
,
self
::
$account
[
'username'
],
self
::
$account
[
'pwd'
],
3
);
...
@@ -326,7 +326,7 @@ class SourceSuning extends Source
...
@@ -326,7 +326,7 @@ class SourceSuning extends Source
if
(
$phoneCode
===
false
)
{
if
(
$phoneCode
===
false
)
{
login_fail
(
self
::
$app
,
self
::
$account
[
'username'
],
self
::
$account
[
'pwd'
]);
login_fail
(
self
::
$app
,
self
::
$account
[
'username'
],
self
::
$account
[
'pwd'
]);
return_msg
(
false
,
'获取手机验证码失败'
);
return_msg
(
false
,
'
通过邮箱
获取手机验证码失败'
);
}
}
//检验验证码
//检验验证码
...
@@ -553,19 +553,39 @@ class SourceSuning extends Source
...
@@ -553,19 +553,39 @@ class SourceSuning extends Source
// $mail = 'wxh__8888@163.com';
// $mail = 'wxh__8888@163.com';
// $pwd = 'WXH888888';
// $pwd = 'WXH888888';
$result
=
phone_code
(
$mail
,
$pwd
);
// $result = phone_code($mail, $pwd);
//
// if ($num > 20) {
// return false;
// }
//
// if (empty($result) || $result['st'] > 45) {
// $num++;
// sleep(5);
// return $this->GetPhoneCode($num);
// }
//
// return $result;
if
(
$num
>
20
)
{
if
(
$num
>
20
)
{
return
false
;
return
false
;
}
}
if
(
empty
(
$result
)
||
$result
[
'st'
]
>
45
)
{
$mails
=
receive_mails
(
$mail
,
$pwd
);
$num
++
;
sleep
(
5
);
if
(
$mails
)
{
return
$this
->
GetPhoneCode
(
$num
);
foreach
(
$mails
as
$k
=>
$v
)
{
if
(
$v
[
'username'
]
==
self
::
$account
[
'username'
]
&&
$v
[
'st'
]
<
45
)
{
return
$mails
[
$k
];
}
}
}
}
return
$result
;
$num
++
;
sleep
(
5
);
return
$this
->
GetPhoneCode
(
$num
);
}
}
/**
/**
...
...
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