Redirecting from Admin page if not logged in... Redirecting from Admin page if not logged in...
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Redirecting from Admin page if not logged in...

Started by fatmcgav, March 15, 2007, 03:41:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fatmcgav

Hi there,

This is prob simple to do, but i cant for the life of me work it out.
What i want to be able to do is have the admin page redirect anybody who isnt logged in to the login page.
This is because i've removed the login.php link as the site's locked down, and i want admins to still be able to login to the site easily.

Any info appreicated.

Cheers
Fatmcgav

Sami

You can edit admin.php :

go to line 45 and change this:


if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);


with this


//if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__); // Comment for redirecting
if (!GALLERY_ADMIN_MODE) header("Location: http://" . $_SERVER['HTTP_HOST']. dirname($ORIGINAL_PHP_SELF). "/login.php") ;


It should work ;)
‍I don't answer to PM with support question
Please post your issue to related board

fatmcgav

Sweet, that worked a treat.
Made one slight tweak to it, to add a referer onto the login.php link so that it will automatically go back through to the admin page once logged in.

Many thanks.

Cheers
Quote from: Sami on March 16, 2007, 08:33:02 AM
You can edit admin.php :

go to line 45 and change this:


if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);


with this


//if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__); // Comment for redirecting
if (!GALLERY_ADMIN_MODE) header("Location: http://" . $_SERVER['HTTP_HOST']. dirname($ORIGINAL_PHP_SELF). "/login.php") ;


It should work ;)