我正在学习如何管理登录过程和会话的基本概念。我试图找出joomla 3.4如何处理“注销”操作以验证我是否正确理解了我所学到的知识。但我很难找到哪个PHP文件实际上正在处理“注销”逻辑。这是我的工作:
首先,我认为无论Joomla使用什么样的(对我而言)库或框架,从头到尾,应该有一个接收“$ _POST”数据的文件,所以我在所有PHP文件中搜索$_POST
在我的网站上,我用这个函数找到了这个文件“libraries / legacy / request / request.php”
Class JRequest{
.....
public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0)
{
// Ensure hash and type are uppercase
$hash = strtoupper($hash);
if ($hash === 'METHOD')
{
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}
$type = strtoupper($type);
$sig = $hash . $type . $mask;
// Get the input hash
switch ($hash)
{
case 'GET':
$input = &$_GET;
break;
case 'POST':
$input = &$_POST;
break;
case 'FILES':
$input = &$_FILES;
break;
case 'COOKIE':
$input = &$_COOKIE;
break;
case 'ENV':
$input = &$_ENV;
break;
case 'SERVER':
$input = &$_SERVER;
break;
default:
$input = &$_REQUEST;
$hash = 'REQUEST';
break;
}
.....
在我看来,Joomla已将“$ _POST”数据处理集成到此函数中,因此每当Joomla想要处理用户输入时,它都会调用此函数。所以我继续在所有PHP文件中搜索JRequest::getVar
,我发现只有1个出现,在components/com_meida/views/medialist/view.html.php
第64行
$dirname = JRequest::getVar('folder', '', '', 'string');
这看起来与登录/注销处理无关。所以我将搜索范围扩大到getVar
,虽然有很多情况,但它们都没有相关性,这就是我被卡住的地方。
请问您不仅要指出我要查找的PHP文件,还要告诉我我的方法有什么问题?先感谢您。
答案 0 :(得分:0)
您应首先指定Joomla版本的含义。
对于Joomla! 3:
对于后端:
/administrator/components/com_login/controller.php
第85行启动功能注销
前端:
plugins/system/logout/logout.php
第65行函数onUserLogout
此处处理用户注销
第98行components/com_users/controllers/user.php
在components/com_users/views/login/tmpl/default_logout.php
你可以看到它是如何完成的......尤其是那部分代码:
<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.logout'); ?>" method="post" class="form-horizontal well">
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary"><span class="icon-arrow-left icon-white"></span> <?php echo JText::_('JLOGOUT'); ?></button>
</div>
</div>
<input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('logout_redirect_url', $this->form->getValue('return'))); ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
至于你的方法: JRequest处理所有请求变量(POST,GET,REQUEST),以便它们可以通过输入过滤器传递以进行清理。
有关更多信息,请访问https://docs.joomla.org/以了解Joomla的工作方式......对于特定的Joomla问题,最好使用论坛 - http://forum.joomla.org/ ....还...有一个网站仅针对joomla问题称为https://joomla.stackexchange.com/的堆栈交换:)