joomla1.6 - 如何保护 joomla 管理员文件夹?

标签 joomla1.6

index.php

$admin_cookie_code="1234567890";
setcookie("JoomlaAdminSession",$admin_cookie_code,0,"/");
header("Location: /administrator/index.php");

.htaccess 文件

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/administrator
RewriteCond %{HTTP_COOKIE} !JoomlaAdminSession=1234567890
RewriteRule .* - [L,F]

我使用了此代码,但它不起作用... 页面将被重定向到管理员,但 www.domain.com/administrator 也可以访问

最佳答案

我厌倦了为这个问题寻找答案,只是制作了一个 PHP 代码,如果访问者没有安全 key 或作为注册用户进入/administration 文件夹,它将重定向:

只需将此代码放在管理文件夹 (/administration/index.php) 中 index.php 文件末尾的“echo”指令之前:

/* Block access to administrator
 --------------------------------------------- */
$user =& JFactory::getUser();
$secretkey = 'mysecretkey';
$redirectto = 'location: yourdomainurlhere';
$usertype = 'Registered';

//Check if the user is not logged in or if is not a super user:
if ($user->guest || (!$user->guest && $user->usertype != $usertype) ) {
 //Check if the secret key is present on the url:
 if (@$_GET['access'] != $secretkey) { header($redirectto); }
}
/* --------------------------------------------- */

之后您将只能使用以下方式访问您的网站: mysite.com/administrator/?access=mysecretkey

在 Joomla 1.5 和 Jooma 2.5 上测试,两者都运行良好。

我在我的页面上稍微解释一下: https://www.infoeplus.com/protect-your-joomla-administrator-folder/

关于joomla1.6 - 如何保护 joomla 管理员文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9031961/

相关文章:

php - 在 Joomla 中构建查询的不同方式?

joomla - 如何从 joomla 1.6 中的文章 ID 获取菜单项的 url?

joomla1.6 - ajax无法在joomla的微风形式组件中工作

php - 乔姆拉 | PHP : Have a category blog listing/latest articles within the menu structure

joomla - 自定义模块/组件无法保存 HTML

php - Joomla 1.6 JCategories::get() 方法在自定义 MVC 组件中生成 'PHP Fatal error: Allowed memory exhausted'

php - 多页注册系统 : How to maintain state along the way?

php - fatal error : Allowed memory size of 25165824 bytes exhausted (tried to allocate 31436096 bytes)