forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 permissions => Topic started by: oboi on June 19, 2009, 11:22:59 pm

Title: Secure a directory, not a part of CM, possible?
Post by: oboi on June 19, 2009, 11:22:59 pm
My client (and oh what a client) has a request I cannot fig how to work into Coppermine. As is, the gallery is secure with access only to registered users. My client has had me insert a section, not a part of CM, that can, of course, be accessed by anyone. These are HTML pages. Is it possible to only allow access to these pages by registered CM users? So basically, I have a folder, within the CM structure, that needs to be secured for CM users only.

Is there a way to do this?
Title: Re: Secure a directory, not a part of CM, possible?
Post by: Joachim Müller on June 21, 2009, 09:02:23 am
The files need to be PHP-driven and they need to reside in coppermine's folder. You can then create custom pages that respect coppermine's logic - just create a file named test.php that contains this:
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
?>

Your custom stuff here
If the file is meant to have the same look that your coppermine-driven pages have, use this:
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
pageheader('Your page title here');
?>

Your custom stuff here
<?php
pagefooter
();
?>
Finally: to make above mentioned code only accessible for registered users, change to this:
Code: [Select]
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
if (!
USER_ID) {
    
cpg_die(ERROR'You need to register to access this page'__FILE____LINE__);
}
pageheader('Your page title here');
?>

Your custom stuff here
<?php
pagefooter
();
?>
There is however no secret protection available on folder level - coppermine's logic doesn't apply to folders on file system level.
This has been asked and answered often - especially since you claim to be a pro and get paid for your work (you said that you need this for a client) we could expect that you do your homework first and perform a thorough search.