我已经创建了一个PHP文件,并将其放在我的服务器中的joomla中,但有一段时间,这个页面没有任何保护。
我想使用"管理登录"让用户使用这些凭据访问我的新页面。
如果用户没有登录管理,我的页面不允许用户访问和重定向到另一个页面。
我想我需要使用会话,但我不知道如何使用。
有人能帮我吗?
对不起我的英语,非常感谢
只需使用基本的joomla用户对象检查登录用户的类型。
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
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();
if($user->usertype == "deprecated"){
/*deprecated means super admin also you can check and allow user group level from
[groups] => Array
(
[8] => 8
)
admin user logged in do what ever you want here
*/
}
else{
$mainframe = JFactory::getApplcation();
$mainframe->redirect('url','message ','message type'); //last param like error,warning success , info etc
}
希望它能有所帮助。。
如果我理解你想正确地做什么,你可以做这样的事情https://github.com/Buddhima/Joomla-HttpLogin-plugin