1
zippylad
Adding Group Verification to a static file
  • 2010/5/18 15:04

  • zippylad

  • Just popping in

  • Posts: 14

  • Since: 2005/10/16


First off, I apologize if this is answered somewhere else. I spent 2 hours searching and haven't found what I am looking for.

From time to time, I generate static php pages and create a link inside a news block for people to go check the info. The concern is that the static page does not include any security features. If someone knows the direct link, they could access it without logging into the website.

Is there an easy way to integrate XOOPS security into a static file so users who are not logged in cannot see the file?

I am hoping it is just some repeatable code I can put at the top of every php file I generate.

Thanks in advance!
cHris

2
ghia
Re: Adding Group Verification to a static file
  • 2010/5/18 18:06

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


You can try something like this for a static test with predifined groups inside the file
include_once '../../mainfile.php';
if (
is_object($xoopsUser)) {
    
$groups $xoopsUser->getGroups();
} else {
    
$groups = array(XOOPS_GROUP_ANONYMOUS);
}
if (!
in_array(XOOPS_GROUP_USERS,$groups)) {
    
redirect_header(XOOPS_URL.'/'3_NOPERM);
    exit();
}
Note: Path to mainfile depend on location.
$groups contain all groups the user belong to.
XOOPS_GROUP_USERS is number 2. Exchange with other allowed group eg 5 (= eg editors) or make logical combines of in_array tests.


3
zippylad
Re: Adding Group Verification to a static file
  • 2010/5/18 19:00

  • zippylad

  • Just popping in

  • Posts: 14

  • Since: 2005/10/16


That did the trick.

Thanks so much for your help!
cHris

Login

Who's Online

154 user(s) are online (88 user(s) are browsing Support Forums)


Members: 0


Guests: 154


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits