|
Posted by Oli Filth on 11/13/05 02:00
Greg Scharlemann said the following on 12/11/2005 23:01:
> I thought I had a workable approach to specifing which pages required a
> redirect in a config file, but it appears the way I'm attempting to do
> it is not going to work.
>
> The idea is that I can specify in the config file all of the pages that
> require a user to login otherwise the page will redirect if the user is
> not logged in.
>
> config.php looks like this:
> ----------------------
> // This allows you to set which pages require a login. If the
> // user tries to access a page specified below, they are
> // redirected to the specified page (usually the
> // registration page).
>
> // The # of pages that require user login
> $_CONF['required_login_pages'] = 1;
> $_CONF['required_login_0'] = '/myaccount.php'; //(slash required)
> ----------------------
Urrgghh, nasty!
Use nested arrays instead, i.e.:
$_CONF['required_login'][0] = '/myaccount.php';
$_CONF['required_login'][1] = '/other.php';
$_CONF['required_login'][2] = '/another.php';
....
That way, you don't even need $_CONF['required_login_pages'], as
count($_CONF['required_login']) will give the same effect.
You could then reduce your test logic to:
if (array_search($_SERVER['PHP_SELF'], $_CONF['required_login']))
{
header("Location: ...");
exit();
}
(Not tested)
--
Oli
Navigation:
[Reply to this message]
|