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: Login before entering gallery?  (Read 7199 times)

0 Members and 1 Guest are viewing this topic.

med20

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Login before entering gallery?
« on: November 07, 2004, 03:59:19 pm »

Any suggestions of how to have users register/login from a web page before entering the gallery?

Mark
« Last Edit: November 10, 2004, 01:10:43 pm by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Login before entering gallery?
« Reply #1 on: November 08, 2004, 07:51:15 am »

there's a hack on the mods board that will accomplish this, and there's a section in the faq that tells you how to only let users view the thumbnails, but require login/registration to see the actual pics.
Please do a search.

Joachim
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #2 on: November 08, 2004, 08:20:14 am »

Thanks, I'm off to look for it.
-dave
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #3 on: November 09, 2004, 05:28:02 am »

Joachim,
Per the FAQ, I added the following code to displayimage.php:

Code: [Select]

if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);
  */

before the existing line:
 * Local functions definition */

But it does nothing, all pic's and zip files open to the max.

Any ideas whats wrong?
-desert dave
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Login before entering gallery?
« Reply #4 on: November 09, 2004, 07:58:18 am »

please post the line of displayimage.php you modified with the code surrounding it (10 lines of code before and after it will do).

Joachim
Logged

Nibbler

  • Guest
Re: Login before entering gallery?
« Reply #5 on: November 09, 2004, 12:24:14 pm »

Looks like you posted the line inside a comment, try placing it after the */
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #6 on: November 09, 2004, 04:06:05 pm »

Here you go:

Code: [Select]
require('include/init.inc.php');

if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");

$breadcrumb = '';
$breadcrumb_text = '';
$cat_data = array();

if($CONFIG['read_exif_data'] ){
        include("include/exif_php.inc.php");
}
if($CONFIG['read_iptc_data'] ){
        include("include/iptc.inc.php");
}


/**
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);

 * Local functions definition
 */

function html_picture_menu($id)
{
    global $lang_display_image_php;

    return <<<EOT
     <a href="#" onClick="return MM_openBrWindow('picEditor.php?id=$id','Crop_Picture','scrollbars=yes,toolbar=no,status=yes,resizable=yes')" class="admin_menu" >{$lang_display_image_php['crop_pic']}</a> <a href="editOnePic.php?id=$id&what=picture"  class="admin_menu">{$lang_display_image_php['edit_pic']}</a> <a href="delete.php?id=$id&what=picture"  class="admin_menu" onclick="return confirm('{$lang_display_image_php['confirm_del']}'); return false; ">{$lang_display_image_php['del_pic']}</a>

EOT;
}
// Prints the image-navigation menu
function html_img_nav_menu()
{
    global $CONFIG, $HTTP_SERVER_VARS, $HTTP_GET_VARS, $CURRENT_PIC_DATA, $PHP_SELF;
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;

    $cat_link = is_numeric($album) ? '' : '&cat=' . $cat;

    $human_pos = $pos + 1;
    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
 
Logged

Nibbler

  • Guest
Re: Login before entering gallery?
« Reply #7 on: November 09, 2004, 04:19:29 pm »

Yup.
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Login before entering gallery?
« Reply #8 on: November 09, 2004, 05:37:37 pm »

@desert_dave. This is when basic php knowledge helps. This is what a code block looks like in PHP.
/*
commented out = ignored text
*/

Thus, the following is a code block. Anything between /* and */ are ignored:
/*
* Local functions definition
*/
By putting your code after /*, it was treated as a comment and ignored.
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #9 on: November 09, 2004, 06:36:39 pm »

Well...getting better.
First off, the manual should be changed because it says to insert it before not after.
Ok, now we have a  lock out for the unclean, which gives them this message when tring to view more than a thumb;

Error
You need to register to access this page

File: /home/creating/public_html/coppermine/cpg132/displayimage.php - Line: 45


But this is pretty tacky with the error and all. How about just showing: "You need to register to access this page"
and have the register box show up under it. Or even just a link to it.
 8)
desert dave
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Login before entering gallery?
« Reply #10 on: November 09, 2004, 06:49:05 pm »

This is what it says:
Quote
How can I prevent unregistered user from viewing the gallery?

edit
displayimage.php
and search for

/**************************************************************************
* Local functions definition
**************************************************************************/


and add before it
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #11 on: November 09, 2004, 06:58:32 pm »

I know and the key phrase being; "and add before it"
That tells me to insert before * Local functions definition not after.
Of course if I knew php it would be a mute point.

How about my suggestion on the error message being changed to the register box, I think that would be nice for everyone.

Cheers,
desert dave
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Login before entering gallery?
« Reply #12 on: November 09, 2004, 07:26:02 pm »

It doesn't really matter if it's before or after the comment block because the php parser will ignore the block anyway. The problem you had was you had the code within the block. I had thought in your post that the instructions weren't clear and that's why you put the code within the comment block.
Based on what you had done, I had thought you saw the instructions said to place the code before
Code: [Select]
* Local functions definition
However, the instructions are clear on placing the code before
Code: [Select]
/**************************************************************************
* Local functions definition
which is a big difference.
« Last Edit: November 09, 2004, 07:34:00 pm by TranzNDance »
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #13 on: November 09, 2004, 08:04:08 pm »

Your right,
I guess the part that threw me not knowing php about the blocks and all the ****************
that aren't actually in the code and I just figured it went in before local functions.

Now that that is laid to rest, how about adding the register box to the message to make it easy for the unclean to register. I tried to change the code but without knowing php I can't get it right. 

Cheers,
dave
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Login before entering gallery?
« Reply #14 on: November 10, 2004, 08:55:23 am »

disable debug mode and the line that tells people where in the code the message comes from will disappear. If you need more beauty in the message, you're free to come up with nicer wording. Replace
Code: [Select]
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);with
Code: [Select]
if (!USER_ID) {
cpg_die('Oops, we\'re sorry', 'You need to be logged in to access this page. Either <a href="register">register</a> for an account, or <a href="login.php">log in</a> if you already have one.', __FILE__, __LINE__);
}

Joachim
« Last Edit: November 10, 2004, 09:40:40 am by GauGau »
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #15 on: November 10, 2004, 09:36:04 am »

Thanks Joachim!
What additional code do I need to add to have the register box show up under the notice?
Cheers,
dave

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Login before entering gallery?
« Reply #16 on: November 10, 2004, 09:42:54 am »

there's a hack that will show a login screen when a user is not logged in (search the mods board for it). Afaik nobody has posted a hack yet that displays the registration screen for unlogged users, and I don't think it's a good idea, as you will probably end up with many double and triple registrations (yes, users can be stupid sometimes).

Joachim
Logged

desert_dave

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 54
Re: Login before entering gallery?
« Reply #17 on: November 10, 2004, 10:18:16 am »

Ah So.....I see what you mean. Login will do it fine.
Thanks again!

SOLVED
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 19 queries.