Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: MarkoKg - tammikuu 28, 2014, 01:48:41 IP

Otsikko: Using ssi to allow only admins access some php file?
Kirjoitti: MarkoKg - tammikuu 28, 2014, 01:48:41 IP
Hello there,

I have a php file on my server and I would like only logged in admins from forum to be able to access that file. Can I somehow do it using ssi or something?

Thanks! :)
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: Arantor - tammikuu 28, 2014, 04:16:29 IP
Load SSI.php, then after that line add:
isAllowedTo('admin_forum');

Do that before anything else on the page.
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: kat - tammikuu 28, 2014, 04:53:29 IP
Q: Could you do that using file permissions? If it was readable only by the owner, would that work?

This assumes, of course, that there's one admin and they're the site owner.
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: Arantor - tammikuu 28, 2014, 04:58:20 IP
Not really, no.
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: kat - tammikuu 28, 2014, 05:08:09 IP
Poodles. :)
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: Deprecated - tammikuu 28, 2014, 05:09:18 IP
Cumber's suggestion looks like the perfect and super simple suggestion. I'm not aware of any SSI use other than by admins, might even be worth making that change to SSI permanent.

For my education, if non-admins ever use SSI could you give me an example?
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: Arantor - tammikuu 28, 2014, 05:12:29 IP
Apart from, say, the entire purpose for which the file was designed. SSI = Simple Site Integration. (The 'original' meaning of Server Side Includes primarily relates to SHTML and not PHP)

Like, for example, providing a login form to external sites. Or pulling board news on to a front page outside the forum. Or indeed any kind of integration without using a portal.
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: Deprecated - tammikuu 28, 2014, 07:11:51 IP
Thank you for the info. My chief use of SSI has been in its application to mod packages. I've never been a portal kind of person.
Otsikko: Re: Using ssi to allow only admins access some php file?
Kirjoitti: MarkoKg - tammikuu 29, 2014, 02:36:09 IP
Thank you, works like a charm! :)