我有一个脚本,用于检查用户是否是(超级)管理员,然后授予对该页面的访问权限。
它工作了几年但现在它停止了工作。我收到错误的响应文本错误消息。当我注释掉脚本时,事情就可以了。
以下是代码:
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
$user = JFactory::getUser();
$userGroups = $user->getAuthorisedGroups();
if(in_array(7,$userGroups) or in_array(8,$userGroups)){
}else{
header( 'Location: /beheer-niet-toegestaan.html' ) ;
}
?>
我不知所措。希望有人可以帮助我。
//编辑//
对不完整的问题感到抱歉。经过一个多小时尝试在线的各种代码示例后,我通过编辑它来解决它:
<?php
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
$user = JFactory::getUser();
$isAdmin = $user->get('isRoot');
if ($isAdmin == false) {
header( 'Location: /beheer-niet-toegestaan.html' ) ;
}
?>