| Re: how to protect single custom page ? |
| by mjoel on 2016/7/5 0:23:52 i put this code inside my root and named it as test.php and it works if i dont want to use any module is this acceptable/ok ? |
| Re: how to protect single custom page ? |
| by mjoel on 2016/7/5 0:08:03 Thank you for all the replies i found the code below from this old topic le="color: #000000"><?php // group $groups = 0; if (is_object($xoopsUser)) { $groups = $xoopsUser->getGroups(); } else { $groups = array(XOOPS_GROUP_ANONYMOUS); } switch($groups) { case (in_array(1, $groups)): //admin echo "admin group"; break 1; case (in_array(2, $groups)): //registered echo "registered group"; break 1; case (in_array(3, $groups)): //anonymous echo "guest group"; break 1; case (in_array(4, $groups)): //customized echo "custom group"; break 1; }
|
| Re: how to protect single custom page ? |
| by zyspec on 2016/7/4 17:04:51 @mjoel, Since you've included ./mainfile.php you should be able to just add: le="color: #000000"><?php (($xoopsUser instanceof XoopsUser) && ($xoopsUser->isAdmin(0))) || exit(_NOPERM); after: le="color: #000000"><?php include("../../mainfile.php"); include(XOOPS_ROOT_PATH."/header.php"); although I would change the include("../../mainfile.php") to require_once dirname(dirname(dirname(__DIR__))) . "/mainfile.php"; - but that's not required to make it work. You can do something similar (although a little more complex) for other groups... |
| Re: how to protect single custom page ? |
| by vamptrix on 2016/7/4 5:56:54 Quote:
And I can understand that :). However, we should really make a module for things like this. Once I'll get the hang of it, I'll try to look into this. |
| Re: how to protect single custom page ? |
| by Mamba on 2016/7/1 14:52:59 Quote: I think that's a bit overkill (in terms of resource usage) for 1 page, but yeah, that does work. One way or the other, you need a module, in order to take advantage of the Permissions (even when using XMF that you've linked to). You can create a new "dummy" module and add the page there, which probably would take you at least 30 minutes, or you can clone an existing module, which would take only 5 minutes, and be done with it. To be honest, I am less concerned about the resources than about effective use of my own time
|