...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
|
|
|
/**
|
|
|
* 所有Controller控制器的基类
|
|
|
*
|
|
|
*
|
|
|
* @name AbstractAction
|
|
|
* @package library
|
|
|
* @copyright yoho.inc
|
...
|
...
|
@@ -25,8 +25,8 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* HTTP请求对象
|
|
|
*
|
|
|
* @var object
|
|
|
*
|
|
|
* @var object
|
|
|
*/
|
|
|
protected $_request;
|
|
|
|
...
|
...
|
@@ -41,8 +41,8 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 存放模板数据
|
|
|
*
|
|
|
* @var array
|
|
|
*
|
|
|
* @var array
|
|
|
*/
|
|
|
protected $_data;
|
|
|
|
...
|
...
|
@@ -51,9 +51,9 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
public function init()
|
|
|
{
|
|
|
$this->_request = $this->getRequest();
|
|
|
|
|
|
$this->_view->assign('isWechat', stripos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false);
|
|
|
$this->_request = $this->getRequest();
|
|
|
|
|
|
$this->_view->assign('isWechat', stripos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false);
|
|
|
|
|
|
// 设置环境变量
|
|
|
switch (APPLICATION_ENV) {
|
...
|
...
|
@@ -72,14 +72,14 @@ class AbstractAction extends Controller_Abstract |
|
|
case 'develop': // 开发
|
|
|
default:
|
|
|
$this->_view->assign('devEnv', true);
|
|
|
$this->_useSession = false;
|
|
|
$this->_useSession = false;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 封装一下获取get参数
|
|
|
*
|
|
|
*
|
|
|
* @param String $key
|
|
|
* @param mixed $default
|
|
|
* @return mixed
|
...
|
...
|
@@ -94,7 +94,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 封装一下获取post参数
|
|
|
*
|
|
|
*
|
|
|
* @param String $key
|
|
|
* @param mixed $default
|
|
|
* @return mixed
|
...
|
...
|
@@ -109,7 +109,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 封装一下获取YAF内部的参数
|
|
|
*
|
|
|
*
|
|
|
* @param String $key
|
|
|
* @param mixed $default
|
|
|
* @return mixed
|
...
|
...
|
@@ -121,7 +121,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 封装一下获取服务器的参数
|
|
|
*
|
|
|
*
|
|
|
* @param String $key
|
|
|
* @param mixed $default
|
|
|
* @return mixed
|
...
|
...
|
@@ -133,7 +133,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 关闭模板自动渲染
|
|
|
*
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function disableView()
|
...
|
...
|
@@ -143,7 +143,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 输出JSON数据到浏览器
|
|
|
*
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function echoJson($json)
|
...
|
...
|
@@ -158,7 +158,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 返回JSON数据
|
|
|
*
|
|
|
*
|
|
|
* @param int $code 状态编码
|
|
|
* @param string $message 提示信息
|
|
|
* @param mixed $data 数据内容
|
...
|
...
|
@@ -173,7 +173,7 @@ class AbstractAction extends Controller_Abstract |
|
|
'data' => $data,
|
|
|
));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* JSON输出
|
|
|
* @param $code
|
...
|
...
|
@@ -186,7 +186,7 @@ class AbstractAction extends Controller_Abstract |
|
|
echo json_encode(array('code' => $code, 'message' => $message, 'data' => $data));
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* JSONP Callback输出,用于远程调用
|
|
|
* @param $callbackString
|
...
|
...
|
@@ -202,11 +202,11 @@ class AbstractAction extends Controller_Abstract |
|
|
echo ")";
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 判断是不是AJAX请求
|
|
|
*
|
|
|
*
|
|
|
* @return bool
|
|
|
*/
|
|
|
protected function isAjax()
|
...
|
...
|
@@ -226,7 +226,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 跳转到指定的URL
|
|
|
*
|
|
|
*
|
|
|
* @param string $url 链接地址
|
|
|
* @return void
|
|
|
*/
|
...
|
...
|
@@ -239,7 +239,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置Cookie
|
|
|
*
|
|
|
*
|
|
|
* @param string $name cookie的名字
|
|
|
* @param string $value cookie的值
|
|
|
* @param integer $expire cookie过期时间
|
...
|
...
|
@@ -253,7 +253,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 返回Cookie变量
|
|
|
*
|
|
|
*
|
|
|
* @param string $name cookie名称
|
|
|
* @param string $default 未获取到返回的默认值
|
|
|
* @return string 获取到的cookie值
|
...
|
...
|
@@ -265,7 +265,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置缓存
|
|
|
*
|
|
|
*
|
|
|
* @param string $key 键名
|
|
|
* @param mixed $value 需要缓存的数据
|
|
|
* @param int $expire 缓存有效期(单位秒, 0表示永久)
|
...
|
...
|
@@ -278,7 +278,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 获取缓存
|
|
|
*
|
|
|
*
|
|
|
* @param string $key 键名
|
|
|
* @param bool $isMaster 控制是到主服务器取,还是到从服务器取缓存
|
|
|
* @return mixed
|
...
|
...
|
@@ -294,7 +294,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置Session
|
|
|
*
|
|
|
*
|
|
|
* @param string $name 名称
|
|
|
* @param mixed $value 值
|
|
|
* @return void
|
...
|
...
|
@@ -308,7 +308,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 获取Session
|
|
|
*
|
|
|
*
|
|
|
* @param string $name 名称
|
|
|
* @return mixed
|
|
|
*/
|
...
|
...
|
@@ -330,17 +330,17 @@ class AbstractAction extends Controller_Abstract |
|
|
$token = Helpers::makeToken($uid);
|
|
|
if (isset($userInfo['data']) && $userInfo['data']) {
|
|
|
$uidCookie = $userInfo['data']['profile_name'] . '::' . $userInfo['data']['uid'] . '::' . $userInfo['data']['vip_info']['title'] . '::' . $token;
|
|
|
$this->setCookie('_UID', $uidCookie);
|
|
|
$this->setCookie('_UID', $uidCookie, time() + 3600 * 24 * 30);
|
|
|
UdpLog::info('【登录】同步登陆cookie生成',$uidCookie);
|
|
|
}
|
|
|
$this->setSession('_TOKEN', $token);
|
|
|
$this->setSession('_LOGIN_UID', $uid);
|
|
|
$this->setCookie('_TOKEN', $token);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取当前登录的用户ID
|
|
|
*
|
|
|
*
|
|
|
* @param bool $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
|
|
|
* @return int
|
|
|
*/
|
...
|
...
|
@@ -373,7 +373,7 @@ class AbstractAction extends Controller_Abstract |
|
|
$this->_usession = $cookieList[3];
|
|
|
$this->_vip = $cookieList[2];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 新的, 如果老站没有同步成功,再尝试从SESSION获取
|
|
|
elseif ($useSession) {
|
|
|
$uid = $this->getSession('_LOGIN_UID');
|
...
|
...
|
@@ -384,10 +384,10 @@ class AbstractAction extends Controller_Abstract |
|
|
}
|
|
|
return $this->_uid;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取客户端唯一标识
|
|
|
*
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
protected function getUdid()
|
...
|
...
|
@@ -404,10 +404,10 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
return $udid;
|
|
|
}
|
|
|
|
|
|
|
|
|
/*
|
|
|
* 设置网站SEO的标题
|
|
|
*
|
|
|
*
|
|
|
* @param string $title 标题
|
|
|
* @param string $sign 连接的字符串
|
|
|
* @param bool $showMore 是否显示更多内容
|
...
|
...
|
@@ -422,7 +422,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置网站SEO的关键词
|
|
|
*
|
|
|
*
|
|
|
* @param string $keywords 关键词,多个之间用","逗号分隔
|
|
|
* @return void
|
|
|
*/
|
...
|
...
|
@@ -433,7 +433,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置网站SEO的描述内容
|
|
|
*
|
|
|
*
|
|
|
* @param string $description 描述内容
|
|
|
* @param bool $showMore 是否显示更多内容
|
|
|
* @param string $sign 连接的字符串
|
...
|
...
|
@@ -447,7 +447,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置网站导航头部信息
|
|
|
*
|
|
|
*
|
|
|
* @param string $title 头部标题
|
|
|
* @param mixed $backUrl 返回的链接
|
|
|
* @param boolean $navBtn 是否显示右上角导航
|
...
|
...
|
@@ -506,13 +506,13 @@ class AbstractAction extends Controller_Abstract |
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->_view->assign('pageHeader', $header);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置网站导航底部信息
|
|
|
*
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function setNavFooterTab()
|
...
|
...
|
@@ -528,7 +528,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置侧边栏信息
|
|
|
*
|
|
|
*
|
|
|
* @param string $guangChoosed 逛默认选中项 "all"表示全部,"boys":只看男生,"girls":只看女生
|
|
|
* @return void
|
|
|
*/
|
...
|
...
|
@@ -539,7 +539,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置最后修改时间
|
|
|
*
|
|
|
*
|
|
|
* @param string $modifiedTime 修改时间戳
|
|
|
* @param type $notModifiedExit 是否在没有修改时返回304状态
|
|
|
* @return void
|
...
|
...
|
@@ -556,7 +556,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
/**
|
|
|
* 设置浏览器的缓存
|
|
|
*
|
|
|
*
|
|
|
* @param int $seconds 单位是秒
|
|
|
* @return void
|
|
|
*/
|
...
|
...
|
@@ -566,7 +566,7 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
header('Expires: ' . $time);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* JS 跳转并提示
|
|
|
*
|
...
|
...
|
@@ -577,7 +577,7 @@ class AbstractAction extends Controller_Abstract |
|
|
protected function helpJsRedirect($message = '', $expression = "history.back()")
|
|
|
{
|
|
|
header("content-type: text/html; charset=utf-8");
|
|
|
|
|
|
|
|
|
if ($message != '') {
|
|
|
$message = strtr(addslashes($message), array('\n' => '\\n'));
|
|
|
echo "<script language=\"javascript\">";
|
...
|
...
|
|