...
|
...
|
@@ -34,6 +34,7 @@ class AbstractAction extends Controller_Abstract |
|
|
protected $_uid = 0;
|
|
|
protected $_uname = '';
|
|
|
protected $_vip;
|
|
|
protected $_useSession = true;
|
|
|
|
|
|
/**
|
|
|
* 存放模板数据
|
...
|
...
|
@@ -53,16 +54,20 @@ class AbstractAction extends Controller_Abstract |
|
|
switch (APPLICATION_ENV) {
|
|
|
case 'production': // 生产
|
|
|
$this->_view->assign('rlsEnv', true);
|
|
|
$this->_useSession = true;
|
|
|
break;
|
|
|
case 'preview': // 预览
|
|
|
$this->_view->assign('preEnv', true);
|
|
|
$this->_useSession = true;
|
|
|
break;
|
|
|
case 'testing': // 测试
|
|
|
$this->_view->assign('testEnv', true);
|
|
|
$this->_useSession = true;
|
|
|
break;
|
|
|
case 'develop': // 开发
|
|
|
default:
|
|
|
$this->_view->assign('devEnv', true);
|
|
|
$this->_useSession = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -261,8 +266,10 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
public function setSession($name, $value)
|
|
|
{
|
|
|
if ($this->_useSession) {
|
|
|
Session::start('yohobuy_session', null, 'yohobuy.com')->__set($name, $value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取Session
|
...
|
...
|
@@ -272,7 +279,11 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
public function getSession($name)
|
|
|
{
|
|
|
if ($this->_useSession) {
|
|
|
return Session::start('yohobuy_session', null, 'yohobuy.com')->__get($name);
|
|
|
} else {
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -283,25 +294,26 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
protected function getUid($useSession = false)
|
|
|
{
|
|
|
// @todo
|
|
|
// $useSession = false;
|
|
|
// 控制是否启用SESSION
|
|
|
if (!$this->_useSession) {
|
|
|
$useSession = false;
|
|
|
}
|
|
|
|
|
|
if (!$this->_uid) {
|
|
|
$cookie = $this->getCookie('_UID');
|
|
|
if (!empty($cookie)) {
|
|
|
$uid = 0;
|
|
|
$cookieList = explode('::', $cookie);
|
|
|
if (isset($cookieList[1]) && is_numeric($cookieList[1])) {
|
|
|
$uid = $cookieList[1];
|
|
|
$this->_uname = $cookieList[0];
|
|
|
$this->_vip = $cookieList[2];
|
|
|
}
|
|
|
// 服务端比较
|
|
|
if ($useSession && $uid) {
|
|
|
if ($useSession) {
|
|
|
$token = $this->getSession('_TOKEN');
|
|
|
if ($token === Helpers::makeToken($uid)) {
|
|
|
$this->_uid = $uid;
|
|
|
if ($token === Helpers::makeToken($cookieList[1])) {
|
|
|
$this->_uid = $cookieList[1];
|
|
|
}
|
|
|
} else {
|
|
|
$this->_uid = $cookieList[1];
|
|
|
}
|
|
|
$this->_uname = $cookieList[0];
|
|
|
$this->_vip = $cookieList[2];
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|