forum.coppermine-gallery.net
Support => cpg1.3.x Support => Older/other versions => cpg1.3 Permissions & Access Rights => Topic started by: med20 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
-
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
-
Thanks, I'm off to look for it.
-dave
-
Joachim,
Per the FAQ, I added the following code to displayimage.php:
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
-
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
-
Looks like you posted the line inside a comment, try placing it after the */
-
Here you go:
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']));
-
Yup.
-
@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.
-
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
-
This is what it says:
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__);
-
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
-
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
* Local functions definition
However, the instructions are clear on placing the code before
/**************************************************************************
* Local functions definition
which is a big difference.
-
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
-
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
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);
withif (!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
-
Thanks Joachim!
What additional code do I need to add to have the register box show up under the notice?
Cheers,
dave
-
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
-
Ah So.....I see what you mean. Login will do it fine.
Thanks again!
SOLVED