You are here: Re: Suggestion for handling pages requiring redirect using Config File « PHP Programming Language « IT news, forums, messages
Re: Suggestion for handling pages requiring redirect using Config File

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация