Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -30,7 +30,7 @@
</span>
</li>
<li class="input-container-li clearfix">
<input type="hidden" name="code" value="159bI6arxsuaPBxG2iV9OE9BrgDnAPiTecUqYh2iUC3ntt6S0eOtxXpVu+jWIlveXx9NRuwS9zdrXzcUyOd+d3ikzYBAo0k">
<input type="hidden" name="code" value="{{code}}">
<input id="reset-pwd-btn" class="btn reset-pwd-btn" type="submit" value="提交" disabled="">
</li>
</ul>
... ...
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="g7ce">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/simple-header}}
<div class="verification-page back-page passport-page yoho-page clearfix">
{{# verification}}
{{> passport/cover}}
<div class="content">
<form id="verification-form" class="verification-form" method="POST" action="/passport/back/backmobile">
<ul>
<li class="head-title">验证身份</li>
<li class="po-re">
<label class="pn-label">手机号码</label>
<span class="country-code">+{{area}}</span>
<span class="phone-num">{{phoneNum}}</span>
</li>
<li class="po-re">
<input id="captcha" class="input va captcha" type="text" name="captcha">
<input id="send-captcha" class="btn send-captcha" type="button" value="发送验证码" disabled="">
<div id="captcha-tip" class="captcha-tips"><i class="iconfont">&#xe61f;</i>验证码已发送至您的手机,请查收</div>
<span id="err-tip" class="err-tip hide">
<i></i>
<em>请输入验证码</em>
</span>
</li>
<li>
<input name="area" id="area" type="hidden" value="{{area}}">
<input name="mobile" id="mobile" type="hidden" value="{{phoneNum}}">
<input name="captchaPic" id="captchaPic" type="hidden" value="{{captcha}}">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
</li>
</ul>
</form>
</div>
{{/ verification}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@
<li class="clearfix">
<select id="region" class="region" name="region">
{{#each region}}
<option {{#if selected}}selected="selected"{{/if}} value="{{id}}">{{name}}</option>
<option {{#if selected}}selected="selected"{{/if}} value="{{areaCode}}">{{name}}</option>
{{/each}}
</select>
</li>
... ...
... ... @@ -73,7 +73,7 @@ class Bootstrap extends Bootstrap_Abstract
$action = 'Index';
// 二级域名
if (3 === $level) {
if (2 === $level) {
$subDomain = strval($hostParts[0]);
switch (strtolower($subDomain)) {
case 'www': // 主站
... ... @@ -90,6 +90,10 @@ class Bootstrap extends Bootstrap_Abstract
case 'list': // 商品列表
$module = 'Product';
break;
case 'sale'://促销
$module = 'Product';
$controller = 'sale';
default: // 其它(识别为品牌)
$module = 'Product';
$action = 'Brand';
... ...
... ... @@ -24,6 +24,7 @@ class PassportModel
const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
const BACK_FIND_SECRET_KEY = '_+@#$%^';
//简单头部
public static function getSimpleHeader($isLogin, $username = '')
... ... @@ -75,6 +76,11 @@ class PassportModel
$ret['img'] = Images::getImageUrl($val['src'], 252, 190);
$ret['url'] = $val['url'];
}
else
{
$ret['img'] = 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190';
$ret['url'] = '';
}
return $ret;
}
... ...
... ... @@ -56,6 +56,7 @@ class BackController extends WebAction
$data = BackData::sendCodeToMobile($mobile);
$this->setSession('phoneNum', $phoneNum);
$this->setSession('area', $area);
$this->setSession('captcha', $captcha);
if($data['code'] == 200) {
$this->redirect('verification');
}
... ... @@ -66,7 +67,7 @@ class BackController extends WebAction
}
/**
* 发送邮件
* 发送邮件页面
*/
public function sendemailAction() {
$phoneNum = $this->getSession('phoneNum');
... ... @@ -96,14 +97,14 @@ class BackController extends WebAction
'sendEmail' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
)
);
$this->_view->display('send-email', $data);
}
/**
* 重置密码
* 重置密码页面
*/
public function backcodeAction() {
$code = $this->get('code');
... ... @@ -118,14 +119,15 @@ class BackController extends WebAction
'resetPwd' => array(
'coverHref' => $banner['url'],
'coverImg' => $banner['img'],
'countrys' => array()
'countrys' => array(),
'code' => $code,
)
);
$this->_view->display('reset-pwd', $data);
}
/**
* 更新密码
* 更新密码接口
*
*/
public function updateAction()
... ... @@ -134,10 +136,22 @@ class BackController extends WebAction
$password = $this->post('pwd');
$info = $this->checkCode($code);
if(Helpers::verifyPassword($password) && !empty($info)) {
$uid = $info['uid'];
//修改密码
if(isset($info['mobile'])) {//手机号修改密码
$mobile = $info['mobile'];
$token = $info['token'];
$area = $info['area'];
$data = BackData::modifyPasswordByMobile($mobile, $token, $password, $area);
if($data['code']) {
$this->redirect('resetSuccess');
}
} else if(isset($info['uid'])) {//其他方式修改密码
$uid = $info['uid'];
$this->redirect('resetSuccess');
}
}
//跳转错误页面
$this->redirect('/error/index');
}
/**
... ... @@ -157,14 +171,15 @@ class BackController extends WebAction
}
/**
* 手机验证
* 手机验证页面
*/
public function verificationAction() {
$phoneNum = $this->getSession('phoneNum');
$area = $this->getSession('area');
// if(empty($phoneNum)) {
// $this->redirect('index');
// }
$captcha = $this->getSession('captcha');
if(empty($phoneNum)) {
$this->redirect('index');
}
$banner = PassportModel::getLeftBanner(PassportModel::BACK_LFFT_BANNER_CODE);
$data = array(
'simpleHeader' => PassportModel::getSimpleHeader(false),
... ... @@ -174,6 +189,7 @@ class BackController extends WebAction
'coverImg' => $banner['img'],
'phoneNum' => $phoneNum,
'area' => $area,
'captcha'=> $captcha,
'countrys' => array()
)
);
... ... @@ -181,6 +197,32 @@ class BackController extends WebAction
}
/**
* 手机找回密码验证
*/
public function backmobileAction()
{
$mobile = $this->post('mobile');//phoneNum
$area = $this->post('area');
//$captcha = $this->post('captcha');
$code = $this->post('captcha');//code
if($this->getSession('phoneNum') == $mobile && $this->getSession('area') == $area)
{
$result = BackData::validateMobileCode($mobile, $code, $area);
if($result['code'] == 200) {
$str = json_encode(array(
'mobile'=> $mobile,
'area' => $area,
'token'=> $result['data']['token'],
'create_time' => time()
));
$code = AuthCode::encode($str, PassportModel::BACK_FIND_SECRET_KEY);
$url = '/passport/back/backcode?code='.base64_encode($code);
$this->redirect(SITE_MAIN.$url);
}
}
}
/**
* 检查code
*
* @param string $code
... ... @@ -188,9 +230,8 @@ class BackController extends WebAction
*/
private function checkCode($code)
{
$key = '_+@#$%^';
$code = base64_decode($code);
$info = json_decode(AuthCode::decode($code, $key), true);
$info = json_decode(AuthCode::decode($code, PassportModel::BACK_FIND_SECRET_KEY), true);
if ($info['create_time'] < 1 || (time() - $info['create_time']) > 86400) {
return array();
}
... ...
<?php
use Action\AbstractAction;
use Action\WebAction;
use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
class LoginController extends AbstractAction
class LoginController extends WebAction
{
/**
... ... @@ -23,7 +22,7 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', '');
//登录后跳转页面
$refer = empty($_SERVER["HTTP_REFERER"])?'':$_SERVER["HTTP_REFERER"];
$refer = empty($_SERVER["HTTP_REFERER"]) ? '' : $_SERVER["HTTP_REFERER"];
if (!empty($refer)) {
$this->setCookie('refer', $refer);
}
... ... @@ -40,13 +39,21 @@ class LoginController extends AbstractAction
$simpleHeader = PassportModel::getSimpleHeader($isLogin, $username);
//获取登陆页左侧资源
$cover = PassportModel::getLeftBanner(PassportModel::SIGNIN_LEFT_BANNER_CODE);
//是否记住密码
$isRemember = $this->getCookie('isRemember', FALSE);
$account = '';
$password = '';
if ($isRemember) {
$account = $this->decrypt($this->getCookie('account', ''));
$password = $this->decrypt($this->getCookie('userInfo', ''));
}
//整合
$data = array(
'loginPage' => true,
'simpleHeader' => $simpleHeader,
'passport' => array(
'coverHref' => $cover['url'],
'coverImg' => !empty($cover['img'])?$cover['img']:'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'coverImg' => !empty($cover['img']) ? $cover['img'] : 'http://img12.static.yhbimg.com/yhb-img01/2015/12/01/07/020a0b6e7ff908d0c2bc4045b4fef42b9f.png?imageView/2/w/252/h/190',
'countryCode' => '+86',
'countryName' => '中国',
'countryList' => RegData::getAreasData(),
... ... @@ -58,6 +65,9 @@ class LoginController extends AbstractAction
'alipayLogin' => Helpers::url('/passport/autosign/alipay'),
'doubanLogin' => Helpers::url('/passport/autosign/douban'),
'renrenLogin' => Helpers::url('/passport/autosign/renren'),
'isRemember' => $isRemember,
'password' => $password,
'account' => $account
),
);
... ... @@ -84,15 +94,17 @@ class LoginController extends AbstractAction
/* 判断参数是否传递 */
$area = trim($this->post('areaCode', '86'));
$profile = trim($this->post('account'));
$account = trim($this->post('account'));
$password = trim($this->post('password'));
if (!is_numeric($area) || empty($profile) || empty($password)) {
$isRemember = trim($this->post('isRemember'));
$isRemember = false;
if (!is_numeric($area) || empty($account) || empty($password)) {
break;
}
/* 判断参数是否有效 */
$verifyEmail = Helpers::verifyEmail($profile);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($profile) : Helpers::verifyAreaMobile($profile, $area);
$verifyEmail = Helpers::verifyEmail($account);
$verifyMobile = ($area === '86') ? Helpers::verifyMobile($account) : Helpers::verifyAreaMobile($account, $area);
if (!$verifyEmail && !$verifyMobile) {
break;
}
... ... @@ -106,10 +118,21 @@ class LoginController extends AbstractAction
/* 调用登录接口进行登录 */
// 获取未登录时的唯一识别码
$shoppingKey = Helpers::getShoppingKeyByCookie();
$data = LoginData::signin($area, $profile, $password, $shoppingKey);
$data = LoginData::signin($area, $account, $password, $shoppingKey);
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
break;
}
//登录成功记录账户信息
if ($isRemember) {
$this->setCookie('account', $this->encrypt($account), time() + 3600 * 24 * 7, '/');
$this->setCookie('userInfo', $this->encrypt($password), time() + 3600 * 24 * 7, '/');
$this->setCookie('isRemember', $isRemember, time() + 3600 * 24 * 7);
}
else {
$this->setCookie('account', '', -1, '/');
$this->setCookie('userInfo', '', -1, '/');
$this->setCookie('isRemember', '', -1, '/');
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
... ... @@ -152,4 +175,60 @@ class LoginController extends AbstractAction
$this->go($refer);
}
/*
* 加密算法
*/
private function encrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= $key{$x};
$x++;
}
for ($i = 0; $i < $len; $i++) {
$str .= chr(ord($data{$i}) + (ord($char{$i})) % 256);
}
return base64_encode($str);
}
/*
* 解密算法
*/
private function decrypt($data, $key='yohobuy')
{
$key = md5($key);
$x = 0;
$str='';
$char='';
$data = base64_decode($data);
$len = strlen($data);
$l = strlen($key);
for ($i = 0; $i < $len; $i++) {
if ($x == $l) {
$x = 0;
}
$char .= substr($key, $x, 1);
$x++;
}
for ($i = 0; $i < $len; $i++) {
if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
$str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
}
else {
$str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
}
}
return $str;
}
}
... ...