STBLOG里面_check_referrer()的作用?
private function _check_referrer()
{
$ref = $this->input->get('ref', TRUE);
$this->referrer = (!empty($ref)) ? $ref : '/admin/dashboard';
}
这段代码在BLOG中起到的作用是干什么用的?为什么要如此麻烦的获取. 本帖最后由 tugh 于 2011-2-16 17:07 编辑
就是用户之前的位置或者用户输入的位置。比如说用户直接输入http://www.example.com/stblog/index.php/admin/posts/manage
如果用户还没登陆的话这个地址就会转换成
http://www.example.com/stblog/index.php/admin/login?ref=/admin/posts/manage
private function _check_referrer()
{
$ref = $this->input->get('ref', TRUE); // $ref = /admin/posts/manage
$this->referrer = (!empty($ref)) ? $ref : '/admin/dashboard'; // $this->referrer = /admin/posts/manage
}
/**
* 默认执行函数
*
* @access public
* @return void
*/
public function index()
{
if($this->auth->hasLogin())
{
redirect($this->referrer); //redirect 到 /admin/posts/manage
}
.....
当用户登陆时,直接就到这个页面而不是 dashboard 呵呵。这个函数名字可能让楼主困惑了,其实名字叫_get_referrer是不是更直观点
页:
[1]