[Solved]: guests can view thumbnails only, but full acces to certain category? [Solved]: guests can view thumbnails only, but full acces to certain category?
 

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

[Solved]: guests can view thumbnails only, but full acces to certain category?

Started by jerx, July 25, 2007, 07:42:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jerx

The FAQ tells you how to restrict access to full size images:
http://coppermine-gallery.net/demo/cpg14x/docs/faq.htm#viewThumbnailsOnly

Here you learn how to do this for certain albums only:
http://forum.coppermine-gallery.net/index.php?topic=43152.0

But I want to restrict access on a whole category only. I tried to use $_GET['category'] or $_GET['cid'] instead of $_GET['album'], but it does not work. Can anyone help me, please?

Joachim Müller

Quote from: jerx on July 25, 2007, 07:42:01 AM
But I want to restrict access on a whole category only. I tried to use $_GET['category'] or $_GET['cid'] instead of $_GET['album'], but it does not work.
Sounds like wishfull thinking. Try $_GET['cat'] (not tested). Observer the browser's address bar - if a variable/parameter doesn't show there, it is not passed in the $_GET array. $_GET['category'] is never being used, you must have made this up.

jerx

It doesn' t work. If I look at the browser' s address bar, I only see cat in the URL, if I am at the root of a category. If I am inside one album, at gallery root or looking at a full size image, no category is displayed in URL. Is it possible to add the category variable to the $_GET array? Or is there a better solution?

Joachim Müller

Try using $cat. Make it global first when being used within a function.

jerx

Unfortunately I wasn' t able to follow your suggestion.

It looked like this (restriction on one album only)

if (!USER_ID) {
    if ($_GET['album'] != 90) {
        cpg_die(ERROR, 'Only registered user have access to this page.', __FILE__, __LINE__);
    }
}


Then I changed it to this:

global $cat;
if (!USER_ID) {
    if ($cat != 10)) {
        cpg_die(ERROR, 'Only registered user have access to this page.', __FILE__, __LINE__);
    }
}

But this opens every album.

Since I seem to be too stupid to solve it by using the cat variable, I tried to restrict by albums. This is not as good as using the category, because I always would need to edit displayimage and add every single album, but until I find out using the category, it would have been ok.

So I modified the code as follows:

if (!USER_ID) {
    if (($_GET['album'] != 90) || ($_GET['album']!=95)) {
        cpg_die(ERROR, 'Only registered user have access to this page.', __FILE__, __LINE__);
    }
}

But this restricts every album, not only album 90 or 95.

If I use "xor" instead of "||" it restricts every gallery but albums 90 and 95. This is the opposite of what I am trying to do. So I tried to use "!", but it did not work either.

Can anyone please tell me why those changes failed?

Joachim Müller

if (!USER_ID) {
    if (($_GET['album'] == 90) || ($_GET['album'] ==95)) {
        cpg_die(ERROR, 'Only registered user have access to this page.', __FILE__, __LINE__);
    }
}

jerx

This is the opposite of what I try to do. Albums 90 and 95 should be restricted. That is why I used "!=", but somehow I cannot get it to work if there are more restricted albums.

Sorry for bothering you with this all the time! I really appreciate your help!

Joachim Müller

Well, the above mentioned code does what you're up to: if a visitor is a guest (i.e. not legged in) and tries to access album 90 or album 95 he will not be able to access it by see an error message that tells him he can't access. Not sure though why you don't use Coppermine's built-in mechanisms to accomplish this.

jerx

Quote from: GauGau on August 01, 2007, 07:17:05 AM
Well, the above mentioned code does what you're up to: if a visitor is a guest (i.e. not legged in) and tries to access album 90 or album 95 he will not be able to access it by see an error message that tells him he can't access. Not sure though why you don't use Coppermine's built-in mechanisms to accomplish this.

Yes, but that is not what we need. If guests access albums 90 or 95, they should not see the error message. They should be able to view all pictures without beeing registered on those two albums.

The problem with Coppermine' s built-in permission is that you can only lock the entire album. We think it is better to only lock the full size images, because the user only needs to register if there are pictures, which he is interested in.

Joachim Müller

Then don't use the cpg_die function, but remove the link to the full-size pictures in theme.php for visitors who are not meant to see it using an if...else construct. Take a look at the function theme_html_picture() to see how the fullsize pop-up link is being composed.

jerx

Finally I found a solution. I have only lifted the restriction on the most recent album of that category over the last months. But I was sick and tired of updating my displayimage.php file each week and did some further testing today.

First, ignore my third post in this thread. I asked for help on restricting one album, but I wanted to do the opposite - lifting the restriction on that album. Sorry, Joachim!

The following code will restrict access to full-size pictures for guests, but all albums in category 10 will not be restricted at all:

Open displayimage.php and find (in last line):
?>

Before, add:
if (!USER_ID) {
    if (($CURRENT_ALBUM_DATA['category'] != 10)) {
       cpg_die(ERROR, 'Only registered user have access to this page.', __FILE__, __LINE__);
    }
}


I am not sure, if this is correct. Use at your own risk. All I know is that it works for me. The position is different than on restricting the whole gallery, because the $CURRENT_ALBUM_DATA array is processed much later.

I have not tried Joachim' s last suggestion (modifying theme.php). Although removing the link looks more elegant than displaying an error message, it would not be sufficient for me. Guests should be made aware that registered users will be able to see the full-size picture. Maybe I will try to remove the (full-size) link and to display the registration hint on the thumbnail page one day.

@Joachim, the reason I cannot use cpg' s permission system is that I do not want to lock out guests completely. They should be able to browse the gallery, so that they can see what they get by registering. Moreover guests might think that the gallery is empty, since cpg hides albums completely if you do not have permission to view.

Joachim Müller