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
f0c864f5
Commit
f0c864f5
authored
Oct 20, 2016
by
蒋林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
苏宁后台登陆
parent
946d056d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4338 additions
and
0 deletions
+4338
-0
cacert.pem
application/config/cacert.pem
+3920
-0
ReceiveGalanz.php
application/libraries/Receive/ReceiveGalanz.php
+20
-0
SourceSuning.php
application/libraries/Source/SourceSuning.php
+398
-0
No files found.
application/config/cacert.pem
0 → 100644
View file @
f0c864f5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
application/libraries/Receive/ReceiveGalanz.php
View file @
f0c864f5
...
@@ -314,6 +314,11 @@ class ReceiveGalanz extends Receive
...
@@ -314,6 +314,11 @@ class ReceiveGalanz extends Receive
$dfields
=
[
$dfields
=
[
'cardno'
,
//安装卡号
'cardno'
,
//安装卡号
'engineeringmachine'
,
//是否工程机
'isreplacesettle'
,
//是否代结算
'replace_site'
,
//被代结算单位
'ismissingparts'
,
//是否开箱缺件
'missingpartsremarks'
,
//缺件备注
'contactname'
,
//姓名
'contactname'
,
//姓名
'mobile'
,
//手机
'mobile'
,
//手机
'telephone'
,
//电话
'telephone'
,
//电话
...
@@ -338,6 +343,21 @@ class ReceiveGalanz extends Receive
...
@@ -338,6 +343,21 @@ class ReceiveGalanz extends Receive
if
(
$values
[
'cardno'
]
!==
false
)
{
if
(
$values
[
'cardno'
]
!==
false
)
{
$order
[
'new_name'
]
=
trim
(
$values
[
'cardno'
]);
$order
[
'new_name'
]
=
trim
(
$values
[
'cardno'
]);
}
}
if
(
$values
[
'engineeringmachine'
]
!==
false
)
{
$order
[
'ddlengineeringmachine'
]
=
intval
(
$values
[
'engineeringmachine'
]);
}
if
(
$values
[
'isreplacesettle'
]
!==
false
)
{
$order
[
'ddlisreplacesettle'
]
=
intval
(
$values
[
'isreplacesettle'
]);
}
if
(
$values
[
'replace_site'
]
!==
false
)
{
$order
[
'new_replace_site'
]
=
trim
(
$values
[
'replace_site'
]);
}
if
(
$values
[
'ismissingparts'
]
!==
false
)
{
$order
[
'ddlismissingparts'
]
=
intval
(
$values
[
'ismissingparts'
]);
}
if
(
$values
[
'missingpartsremarks'
]
!==
false
)
{
$order
[
'new_missingpartsremarks'
]
=
trim
(
$values
[
'missingpartsremarks'
]);
}
if
(
$values
[
'contactname'
])
{
if
(
$values
[
'contactname'
])
{
$order
[
'new_contactname'
]
=
trim
(
$values
[
'contactname'
]);
$order
[
'new_contactname'
]
=
trim
(
$values
[
'contactname'
]);
}
}
...
...
application/libraries/Source/SourceSuning.php
0 → 100644
View file @
f0c864f5
<?php
/**
* Created by PhpStorm.
* User: LinJiangL
* Date: 16/10/17
* Time: 下午1:35
*/
require
'Source.php'
;
class
SourceSuning
extends
Source
{
private
static
$account
=
[];
private
static
$app
=
'suning'
;
private
static
$debug
=
true
;
public
function
__construct
(
$account
)
{
self
::
$account
=
$account
;
self
::
$cookieFilePath
=
PUBDIR
.
"cookie/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".cookie"
;
self
::
$captchaFilePath
=
PUBDIR
.
"captcha/"
.
self
::
$app
.
"_"
.
md5
(
self
::
$account
[
'username'
])
.
".gif"
;
//判断是否登陆
$isLogin
=
$this
->
IsLogin
();
if
(
$isLogin
==
false
)
{
return_msg
(
false
,
'登陆失败'
);
}
}
public
function
IsLogin
()
{
$isLogin
=
$this
->
IsLoginHtml
();
if
(
$isLogin
)
{
return
$isLogin
;
}
//密码登陆
$result
=
$this
->
Login
();
//登陆需要手机验证
if
(
isset
(
$result
[
'errorCode'
])
&&
$result
[
'errorCode'
]
==
'sopSuspiciousLogin'
)
{
//手机验证页面,需要获取参数
$checkPhone
=
$this
->
CheckPhone
(
$result
[
'checkPhoneUrl'
]);
//发送验证码
$this
->
SendPhoneCode
(
$checkPhone
,
$result
[
'checkPhoneUrl'
]);
//获取验证码
$phoneCode
=
$this
->
GetPhoneCode
();
if
(
$phoneCode
===
false
)
{
return_msg
(
false
,
'获取手机验证码失败'
);
}
//检验验证码
$checkPhone
[
'phoneCode'
]
=
$phoneCode
[
'code'
];
$checkResult
=
$this
->
CheckPhoneCode
(
$checkPhone
,
$result
[
'checkPhoneUrl'
]);
//自动登陆
if
(
stripos
(
$checkResult
[
'data'
],
'OK'
)
!==
false
)
{
$this
->
ToAutoLogin
(
$checkPhone
,
$result
[
'checkPhoneUrl'
]);
return
$this
->
IsLoginHtml
();
}
else
{
return_msg
(
false
,
'登陆失败,手机验证码错误'
);
}
}
return
$this
->
IsLoginHtml
();
}
public
function
IsLoginHtml
()
{
$url
=
"https://asvp.suning.com/asvp/portal/jumpToportal.action"
;
$result
=
$this
->
GetUrlContents
(
$url
,
false
);
$result
=
$this
->
HandelHtmlScript
(
$result
);
//调试
if
(
self
::
$debug
)
{
$this
->
Debug
(
'IsLoginHtml'
,
$result
);
}
$islogin
=
false
;
if
(
stripos
(
$result
,
'showIndex.action'
)
!==
false
)
{
$islogin
=
true
;
}
return
$islogin
;
}
public
function
Login
()
{
$loginUrl
=
"https://mpassport.suning.com/ids/login?service=https%3A%2F%2Fasvp.suning.com%2Fasvp%2Fportal%2Flogon.do&loginTheme=asvp"
;
$post
=
[
'username'
=>
self
::
$account
[
'username'
],
'password'
=>
self
::
$account
[
'pwd'
],
'verifyCode'
=>
''
,
'service'
=>
''
,
'uuid'
=>
''
,
'loginTheme'
=>
'asvp'
,
'secPassword'
=>
''
];
$content
=
$this
->
SetUrlCookie
(
$loginUrl
);
$formData
=
$this
->
GetFormData
(
$content
);
if
(
empty
(
$formData
))
{
return_msg
(
false
,
'登陆参数错误'
);
}
$post
[
'service'
]
=
$formData
[
'service'
];
$post
[
'uuid'
]
=
$formData
[
'uuid'
];
$headers
=
$this
->
Header
(
$loginUrl
);
$result
=
$this
->
CurlHttpsPost
(
$loginUrl
,
$post
,
$headers
);
$result
[
'data'
]
=
$this
->
HandelHtmlScript
(
$result
[
'data'
]);
//登陆返回处理
preg_match
(
'/errorCode = "([^"]+)"/'
,
$result
[
'data'
],
$errorCode
);
//登陆返回参数
if
(
isset
(
$errorCode
[
1
])
&&
$errorCode
[
1
])
{
//需要图片验证码
if
(
$errorCode
[
1
]
==
'needVerifyCode'
)
{
$verifyCodeUrl
=
"https://vcs.suning.com/vcs/imageCode.htm?uuid=
{
$post
[
'uuid'
]
}
"
;
$this
->
SaveUrlCaptcha
(
$verifyCodeUrl
);
$post
[
'verifyCode'
]
=
get_uuapi
(
self
::
$captchaFilePath
);
$vcresult
=
$this
->
CurlHttpsPost
(
$loginUrl
,
$post
,
$headers
);
$vcresult
[
'data'
]
=
$this
->
HandelHtmlScript
(
$vcresult
[
'data'
]);
preg_match
(
'/errorCode = "([^"]+)"/'
,
$vcresult
[
'data'
],
$vcErrorCode
);
$vcHandelResult
=
$this
->
HandelLoginReturnMsg
(
$vcErrorCode
[
1
],
$vcresult
[
'data'
],
$post
);
$result
=
array_merge
(
$vcresult
,
$vcHandelResult
);
}
else
{
$handelResult
=
$this
->
HandelLoginReturnMsg
(
$errorCode
[
1
],
$result
[
'data'
],
$post
);
$result
=
array_merge
(
$result
,
$handelResult
);
}
}
if
(
self
::
$debug
)
{
$this
->
Debug
(
'Login'
,
[
$post
,
$result
]);
}
return
$result
;
}
private
function
HandelLoginReturnMsg
(
$errorCode
,
$loginHtml
,
$loginFormData
)
{
$result
=
[];
switch
(
$errorCode
)
{
//手机验证码验证
case
'sopSuspiciousLogin'
:
preg_match
(
"/snapshotId = '([^']*)'/"
,
$loginHtml
,
$snapshotId
);
preg_match
(
'/city = encodeURIComponent\("([^"]*)"\)/'
,
$loginHtml
,
$city
);
$snapshotId
=
$snapshotId
[
1
];
$targetUrl
=
$loginFormData
[
'service'
];
$city
=
$city
[
1
];
$checkPhoneUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toDealSuspiciousPlace.htm?ticket=
{
$snapshotId
}
&targetUrl=
{
$targetUrl
}
&city="
.
urlencode
(
$city
);
$result
[
'errorCode'
]
=
$errorCode
;
$result
[
'city'
]
=
$city
;
$result
[
'checkPhoneUrl'
]
=
$checkPhoneUrl
;
break
;
//图形验证码验证
case
'needVerifyCode'
:
return_msg
(
false
,
"需要输入的验证码!"
);
break
;
case
"serviceNotAvailable"
:
return_msg
(
false
,
"当前服务不可用,请稍后再试。"
);
break
;
case
"badCredentials"
:
return_msg
(
false
,
"账号数据异常,请更换账号再试。"
);
break
;
case
"badPassword.msg1"
:
return_msg
(
false
,
"您输入的账户名与密码不匹配,请重新输入!"
);
break
;
case
"badPassword.msg2"
:
return_msg
(
false
,
"您输入的账户名与密码不匹配,请重新输入!重试次数过多,账号将会被锁定。"
);
break
;
case
"badVerifyCode"
:
return_msg
(
false
,
"输入的验证码错误,请重新输入!"
);
break
;
case
"lockedByManual"
:
return_msg
(
false
,
"您的账号已经被锁定,请联系客服4008-198-198进行解锁。"
);
break
;
case
"lockedBySystem"
:
return_msg
(
false
,
"您的账号已经被锁定,请联系客服4008-198-198进行解锁。"
);
break
;
case
"unsupportedCredentials"
:
return_msg
(
false
,
"当前服务不可用,请稍后再试。"
);
break
;
case
"uncategorized"
:
return_msg
(
false
,
"验证失败,请稍后再试。"
);
break
;
case
"highRiskAccount"
:
return_msg
(
false
,
"该账号密码存在风险,请您点击忘记密码重置密码后再登录"
);
break
;
}
return
$result
;
}
public
function
CheckPhone
(
$checkPhoneUrl
)
{
$result
=
$this
->
GetUrlContents
(
$checkPhoneUrl
);
$formData
=
$this
->
GetFormData
(
$result
);
if
(
self
::
$debug
)
{
$this
->
Debug
(
'CheckPhone'
,
$formData
);
}
if
(
empty
(
$formData
))
{
return_msg
(
false
,
'手机短信验证表单参数错误'
);
}
return
$formData
;
}
public
function
GetPhoneCode
(
$num
=
0
)
{
$result
=
parent
::
GetPhoneCode
();
if
(
$num
>
45
)
{
return
false
;
}
if
(
$result
[
'st'
]
>
60
)
{
$num
++
;
sleep
(
1
);
return
$this
->
GetPhoneCode
(
$num
);
}
return
$result
;
}
public
function
SendPhoneCode
(
$data
,
$checkPhoneUrl
)
{
$sendData
=
[
'custNum'
=>
$data
[
'custNum'
],
'phoneNum'
=>
$data
[
'phoneNum'
],
'userName'
=>
$data
[
'userName'
],
];
$headers
=
$this
->
Header
(
$checkPhoneUrl
);
$sendPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toSendValCodeSuspiciousLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$sendPhoneCodeUrl
,
$sendData
,
$headers
);
if
(
self
::
$debug
)
{
$this
->
Debug
(
'SendPhoneCode'
,
$sendData
);
}
if
(
$result
[
'data'
]
==
6
)
{
return_msg
(
false
,
'您当前累计获取验证码已达到5次,请您1小时后重新获取验证码'
);
}
return
$result
;
}
public
function
CheckPhoneCode
(
$data
,
$checkPhoneUrl
)
{
$checkData
=
[
'custNum'
=>
$data
[
'custNum'
],
'phoneNum'
=>
$data
[
'phoneNum'
],
'validateCode'
=>
$data
[
'phoneCode'
],
];
$headers
=
$this
->
Header
(
$checkPhoneUrl
);
$checkPhoneCodeUrl
=
"https://masc.suning.com/masc/suspiciousOpt/validateCodeSuspiciousLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$checkPhoneCodeUrl
,
$checkData
,
$headers
);
if
(
self
::
$debug
)
{
$this
->
Debug
(
'CheckPhoneCode'
,
$checkData
);
}
return
$result
;
}
public
function
ToAutoLogin
(
$data
,
$checkPhoneUrl
)
{
$post
=
[
'phoneNum'
=>
$data
[
'phoneNum'
],
'userName'
=>
$data
[
'userName'
],
'custNum'
=>
$data
[
'custNum'
],
'targetUrl'
=>
$data
[
'targetUrl'
],
'loginCity'
=>
$data
[
'loginCity'
],
'deviceID'
=>
$data
[
'deviceID'
],
'validateCode'
=>
$data
[
'phoneCode'
]
];
$headers
=
$this
->
Header
(
$checkPhoneUrl
);
$loginUrl
=
"https://masc.suning.com/masc/suspiciousOpt/toAutoLogin.htm"
;
$result
=
$this
->
CurlHttpsPost
(
$loginUrl
,
$post
,
$headers
);
return
$result
;
}
public
function
OrderList
()
{
$url
=
'https://asvp.suning.com/asvp/serviceOrder/serviceOrderTab1.action'
;
$post
=
[
'choosedFlag'
=>
0
,
'siteBp'
=>
904102
,
'objectIds'
=>
''
,
'applyStartTime'
=>
''
,
'applyEndTime'
=>
''
,
'choosedtabNow'
=>
0
,
'processTypeName'
=>
''
,
'processType'
=>
''
];
$headers
=
$this
->
Header
(
$url
);
$result
=
$this
->
CurlHttpsPost
(
$url
,
$post
,
$headers
);
return
$result
;
}
/**
* 请求头信息
* @param $referer
* @return array
*/
public
function
Header
(
$referer
)
{
$parseUrl
=
parse_url
(
$referer
);
$header
=
[
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
,
'Accept-Encoding: gzip, deflate'
,
'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3'
,
'Cache-Control: max-age=0'
,
'Connection: keep-alive'
,
'Content-Type: application/x-www-form-urlencoded'
,
'Host: '
.
$parseUrl
[
'host'
],
'Origin: '
.
$parseUrl
[
'scheme'
]
.
'//'
.
$parseUrl
[
'host'
],
'Referer: '
.
$referer
,
'Upgrade-Insecure-Requests: 1'
,
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36'
,
];
return
$header
;
}
private
function
Debug
(
$function
,
$data
)
{
echo
"
{
$function
}
<br/>"
;
echo
"<pre>"
;
print_r
(
$data
);
}
private
function
CurlHttpsPost
(
$url
,
$post
,
$headers
)
{
$result
=
parent
::
CurlPostHttps
(
$url
,
$post
,
$headers
);
if
(
$result
[
'data'
])
{
$result
[
'data'
]
=
gzdecode
(
$result
[
'data'
]);
}
return
$result
;
}
private
function
GetFormData
(
$formHtml
)
{
preg_match_all
(
'/<input[^>]+name="([^"]+)"[^>]+value="([^"]*)"/'
,
$formHtml
,
$arr
);
$formData
=
[];
if
(
isset
(
$arr
[
1
])
&&
$arr
[
1
])
{
foreach
(
$arr
[
1
]
as
$k
=>
$v
)
{
$formData
[
$v
]
=
$arr
[
2
][
$k
];
}
}
return
$formData
;
}
}
\ 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