Authored by yangyang

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

... ... @@ -160,4 +160,67 @@ class CommonController extends WebAction
}
}
/*
* 简单头部
*/
public function getSimpleHeaderAction()
{
$result = array();
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取用户
$uid = $this->getUid(true);
if (!$uid) {
$isLogin = false;
$username = '';
}
else {
$isLogin = true;
$username = $this->_uname;
}
//拼接简单头部
$tool = array(
'favorite' => Helpers::url('/home/favorite?t=' . time()), //我的收藏链接
'coupon' => Helpers::url('/home/coupons?t=' . time()), //我的优惠券链接
'order' => Helpers::url('/home/orders?t=' . time()), //订单中心连接
'help' => Helpers::url('/help'),
);
if ($isLogin) {
$tool+=array(
'user' => $username,
'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接
'logout' => Helpers::url('/logout.html?t=' . time()), //退出
);
}
else {
$tool+=array(
'login' => Helpers::url('/signin.html'), //登录链接,已登录不传
'register' => Helpers::url('/reg.html'), //注册链接,已登录不传
);
}
$simpleHeader = array(
'user' => $username,
'href' => $tool,
'logo' => array(
'img' => 'http://static.yohobuy.com/newheader/img/logo_e.png',
'url' => SITE_MAIN
),
);
$result = array(
'code' => 200,
'data' => $simpleHeader
);
}
while (false);
$this->echoJson($result);
}
}
\ No newline at end of file
... ...
... ... @@ -20,26 +20,27 @@ use Plugin\Captcha;
class PassportModel
{
const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064';//注册左边的banner
const BACK_LFFT_BANNER_CODE = '3bbaf502c447a2ddad60879042e286d8';//找回密码左边的banner
const SIGNIN_LEFT_BANNER_CODE ='db350894e01e90eac55cd3a13ad77331';//登录页左边的banner
const AUTOUSERINFO_LEFT_BANNER_CODE ='c62d5da06d843b6ed78d8d27e87fa143';//完善信息页左边的banner
const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; //注册左边的banner
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 = '')
{
//拼接简单头部
$tool = array(
'favoriteHref' => Helpers::url('/home/favorite/index'), //我的收藏链接
'couponHref' => Helpers::url('/home/coupons/index'), //我的优惠券链接
'orderHref' => Helpers::url('/home/orders/index'), //订单中心连接
'favoriteHref' => Helpers::url('/home/favorite?t=' . time()), //我的收藏链接
'couponHref' => Helpers::url('/home/coupons?t=' . time()), //我的优惠券链接
'orderHref' => Helpers::url('/home/orders?t=' . time()), //订单中心连接
'helpHref' => Helpers::url('/help'),
);
if ($isLogin) {
$tool+=array(
'user' => $username,
'userCenter' => Helpers::url('/home/index'), //用户中心链接
'logoutHref' => Helpers::url('/passport/signout/index'), //退出
'userCenter' => Helpers::url('/home?t=' . time()), //用户中心链接
'logoutHref' => Helpers::url('/logout.html?t=' . time()), //退出
);
}
else {
... ... @@ -68,13 +69,13 @@ class PassportModel
*/
public static function getLeftBanner($code)
{
$ret = array('img'=>'','url'=>'');
$ret = array('img' => '', 'url' => '');
$resource = IndexData::getResourceData($code);
if(isset($resource['data'][0]))
{
if($resource['data'][0]['template_name'] == 'single_image') {
if (isset($resource['data'][0])) {
if ($resource['data'][0]['template_name'] == 'single_image') {
$val = current($resource['data'][0]['data']);
} else if($resource['data'][0]['template_name'] == 'single_name_image') {
}
else if ($resource['data'][0]['template_name'] == 'single_name_image') {
$val = $resource['data'][0]['data'];
}
$ret['img'] = Images::getImageUrl($val['src'], 252, 190);
... ... @@ -98,7 +99,7 @@ class PassportModel
$verifyCode = strtolower($verifyCode);
$ret = true;
//检测验证码不正确
if($verifyCode != strtolower(Captcha::getFromSession('passport_istration'))) {
if ($verifyCode != strtolower(Captcha::getFromSession('passport_istration'))) {
$ret = false;
}
return $ret;
... ... @@ -111,11 +112,12 @@ class PassportModel
* @param string $mobile
* @return array
*/
public static function getUserInfoByMobile($area, $mobile) {
public static function getUserInfoByMobile($area, $mobile)
{
$ret = array();
$data = UserData::getUserInfoByMobile($area, $mobile);
if($data['code'] == 200) {
if(!empty($data['data'])) {
if ($data['code'] == 200) {
if (!empty($data['data'])) {
$ret = current($data['data']);
}
}
... ... @@ -128,14 +130,16 @@ class PassportModel
* @param string $email
* @return array
*/
public static function getUserInfoByEmail($email) {
public static function getUserInfoByEmail($email)
{
$ret = array();
$data = UserData::getUserInfoByEmail($email);
if($data['code'] == 200) {
if(!empty($data['data'])) {
if ($data['code'] == 200) {
if (!empty($data['data'])) {
$ret = current($data['data']);
}
}
return $ret;
}
}
... ...
... ... @@ -5,6 +5,7 @@ use LibModels\Web\Passport\RegData;
use LibModels\Web\Passport\LoginData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
class LoginController extends WebAction
{
... ... @@ -93,7 +94,6 @@ class LoginController extends WebAction
$account = trim($this->post('account'));
$password = trim($this->post('password'));
$isRemember = trim($this->post('isRemember'));
$isRemember = false;
if (!is_numeric($area) || empty($account) || empty($password)) {
break;
}
... ... @@ -119,17 +119,6 @@ class LoginController extends WebAction
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) || strstr($refer, 'signin.html') || strstr($refer, 'passport/login/index')) {
... ... @@ -138,7 +127,7 @@ class LoginController extends WebAction
else {
$refer = rawurldecode($refer);
}
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid'],$refer);
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid'], $refer);
$data['data']['href'] = $refer;
$token = Helpers::makeToken($data['data']['uid']);
... ... @@ -172,59 +161,4 @@ class LoginController extends WebAction
$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;
}
}
... ...
... ... @@ -21,7 +21,7 @@ routes.login.route.action = Index
; 登录退出页
routes.logout.type = "rewrite"
routes.logout.match = "/passport/signout/index"
routes.logout.match = "/logout.html"
routes.logout.route.module = Passport
routes.logout.route.controller = Login
routes.logout.route.action = Out
... ...