Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Redirecting from Admin page if not logged in...  (Read 2204 times)

0 Members and 1 Guest are viewing this topic.

fatmcgav

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Redirecting from Admin page if not logged in...
« on: March 15, 2007, 03:41:28 pm »

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
« Last Edit: March 17, 2007, 10:36:22 am by GauGau »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Redirecting from Admin page if not logged in...
« Reply #1 on: March 16, 2007, 08:33:02 am »

You can edit admin.php :

go to line 45 and change this:

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

with this

Code: [Select]
//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 ;)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

fatmcgav

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Redirecting from Admin page if not logged in...
« Reply #2 on: March 16, 2007, 01:46:50 pm »

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
You can edit admin.php :

go to line 45 and change this:

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

with this

Code: [Select]
//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 ;)
Logged
Pages: [1]   Go Up
 

Page created in 0.015 seconds with 15 queries.