Authored by hf

do merge develop to test cart feature

@@ -303,6 +303,7 @@ class AbstractAction extends Controller_Abstract @@ -303,6 +303,7 @@ class AbstractAction extends Controller_Abstract
303 303
304 if (!$this->_uid) { 304 if (!$this->_uid) {
305 $cookie = $this->getCookie('_UID'); 305 $cookie = $this->getCookie('_UID');
  306 + // 兼容老的
306 if (!empty($cookie)) { 307 if (!empty($cookie)) {
307 $cookieList = explode('::', $cookie); 308 $cookieList = explode('::', $cookie);
308 if (isset($cookieList[1]) && is_numeric($cookieList[1])) { 309 if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
@@ -322,6 +323,13 @@ class AbstractAction extends Controller_Abstract @@ -322,6 +323,13 @@ class AbstractAction extends Controller_Abstract
322 $this->_vip = $cookieList[2]; 323 $this->_vip = $cookieList[2];
323 } 324 }
324 } 325 }
  326 + // 新的, 如果老站没有同步成功,再尝试从SESSION获取
  327 + elseif ($useSession) {
  328 + $uid = $this->getSession('_LOGIN_UID');
  329 + if (!empty($uid)) {
  330 + $this->_uid = $uid;
  331 + }
  332 + }
325 } 333 }
326 return $this->_uid; 334 return $this->_uid;
327 } 335 }
@@ -746,7 +746,7 @@ class Helpers @@ -746,7 +746,7 @@ class Helpers
746 public static function syncUserSession($uid, $refer = '', $callback = 'call') 746 public static function syncUserSession($uid, $refer = '', $callback = 'call')
747 { 747 {
748 return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback 748 return 'http://mapi.yohobuy.com/Passport/session/index?callback=' . $callback
749 - . '&sign=' .md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer; 749 + . '&sign=' . md5(md5($uid . 'Js8Yn0!EwPM45-ws')) . '&uid=' . $uid . '&go=' . $refer;
750 } 750 }
751 751
752 /** 752 /**
1 { 1 {
2 "name": "yohobuy", 2 "name": "yohobuy",
3 - "version": "1.2.6", 3 + "version": "1.2.7",
4 "description": "yohobuy statics", 4 "description": "yohobuy statics",
5 "keywords": [], 5 "keywords": [],
6 "homepage": "", 6 "homepage": "",
@@ -44,6 +44,9 @@ class LoginController extends AbstractAction @@ -44,6 +44,9 @@ class LoginController extends AbstractAction
44 44
45 // 渲染模板 45 // 渲染模板
46 $this->_view->display('index', $data); 46 $this->_view->display('index', $data);
  47 +
  48 + // 设置登录有效时间30分钟, 防机器刷
  49 + $this->setSession('_LOGIN_EXPIRE', time() + 1800);
47 } 50 }
48 51
49 /** 52 /**
@@ -67,6 +70,9 @@ class LoginController extends AbstractAction @@ -67,6 +70,9 @@ class LoginController extends AbstractAction
67 $data['countrys'] = RegData::getAreasData(); // 地区信息列表 70 $data['countrys'] = RegData::getAreasData(); // 地区信息列表
68 // 渲染模板 71 // 渲染模板
69 $this->_view->display('international', $data); 72 $this->_view->display('international', $data);
  73 +
  74 + // 设置登录有效时间30分钟, 防机器刷
  75 + $this->setSession('_LOGIN_EXPIRE', time() + 1800);
70 } 76 }
71 77
72 /** 78 /**
@@ -80,6 +86,7 @@ class LoginController extends AbstractAction @@ -80,6 +86,7 @@ class LoginController extends AbstractAction
80 $this->setCookie('_SPK', ''); 86 $this->setCookie('_SPK', '');
81 // 清除服务端会话 87 // 清除服务端会话
82 $this->setSession('_TOKEN', ''); 88 $this->setSession('_TOKEN', '');
  89 + $this->setSession('_LOGIN_UID', '');
83 90
84 $refer = $this->server('HTTP_REFERER', SITE_MAIN); 91 $refer = $this->server('HTTP_REFERER', SITE_MAIN);
85 $token = $this->get('token'); 92 $token = $this->get('token');
@@ -123,6 +130,12 @@ class LoginController extends AbstractAction @@ -123,6 +130,12 @@ class LoginController extends AbstractAction
123 break; 130 break;
124 } 131 }
125 132
  133 + /* 设置登录有效时间30分钟, 防机器刷 */
  134 + $expire = $this->getSession('_LOGIN_EXPIRE');
  135 + if (empty($expire) || $expire < time()) {
  136 + break;
  137 + }
  138 +
126 /* 调用登录接口进行登录 */ 139 /* 调用登录接口进行登录 */
127 // 获取未登录时的唯一识别码 140 // 获取未登录时的唯一识别码
128 $shoppingKey = Helpers::getShoppingKeyByCookie(); 141 $shoppingKey = Helpers::getShoppingKeyByCookie();
@@ -143,6 +156,8 @@ class LoginController extends AbstractAction @@ -143,6 +156,8 @@ class LoginController extends AbstractAction
143 $token = Helpers::makeToken($data['data']['uid']); 156 $token = Helpers::makeToken($data['data']['uid']);
144 $this->setCookie('_TOKEN', $token); 157 $this->setCookie('_TOKEN', $token);
145 $this->setSession('_TOKEN', $token); 158 $this->setSession('_TOKEN', $token);
  159 + $this->setSession('_LOGIN_UID', $data['data']['uid']);
  160 +
146 } while (false); 161 } while (false);
147 162
148 $this->echoJson($data); 163 $this->echoJson($data);
@@ -213,6 +228,7 @@ class LoginController extends AbstractAction @@ -213,6 +228,7 @@ class LoginController extends AbstractAction
213 $token = Helpers::makeToken($result['data']['uid']); 228 $token = Helpers::makeToken($result['data']['uid']);
214 $this->setCookie('_TOKEN', $token); 229 $this->setCookie('_TOKEN', $token);
215 $this->setSession('_TOKEN', $token); 230 $this->setSession('_TOKEN', $token);
  231 + $this->setSession('_LOGIN_UID', $result['data']['uid']);
216 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 232 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
217 } else { 233 } else {
218 $this->go($refer); 234 $this->go($refer);
@@ -250,6 +266,7 @@ class LoginController extends AbstractAction @@ -250,6 +266,7 @@ class LoginController extends AbstractAction
250 $token = Helpers::makeToken($result['data']['uid']); 266 $token = Helpers::makeToken($result['data']['uid']);
251 $this->setCookie('_TOKEN', $token); 267 $this->setCookie('_TOKEN', $token);
252 $this->setSession('_TOKEN', $token); 268 $this->setSession('_TOKEN', $token);
  269 + $this->setSession('_LOGIN_UID', $result['data']['uid']);
253 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 270 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
254 } else { 271 } else {
255 $this->go($refer); 272 $this->go($refer);
@@ -287,6 +304,7 @@ class LoginController extends AbstractAction @@ -287,6 +304,7 @@ class LoginController extends AbstractAction
287 $token = Helpers::makeToken($result['data']['uid']); 304 $token = Helpers::makeToken($result['data']['uid']);
288 $this->setCookie('_TOKEN', $token); 305 $this->setCookie('_TOKEN', $token);
289 $this->setSession('_TOKEN', $token); 306 $this->setSession('_TOKEN', $token);
  307 + $this->setSession('_LOGIN_UID', $result['data']['uid']);
290 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 308 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
291 } else { 309 } else {
292 $this->go($refer); 310 $this->go($refer);