Access to Full Size images for certain users - Page 2 Access to Full Size images for certain users - Page 2
 

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]

Main Menu

Access to Full Size images for certain users

Started by JohannM, December 30, 2015, 02:23:54 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

JohannM

André

O .... yes, sure. not a problem. I do have my moments ... sorry.

Yes, tahnx, I can do that.

Αndré

Create a file "access.php" in plugins/fullsize_access. Each line needs to contain the following data:
<USER_ID> <ALBUM_ID>
(USER_ID and ALBUM_ID are separated by space). Example:
1 1
2 1
1 2
1 3
2 6
3 8



Now, replace the content of fullsize_check.php with this:
<?php
function fullsize_check_user() {
    if (
GALLERY_ADMIN_MODE) {
        return 
true;
    }
    if (!
USER_ID) {
        return 
false;
    }
    global 
$CONFIG;
    
$superCage Inspekt::makeSuperCage();
    
$pid $superCage->get->getInt('pid');
    
$aid mysql_result(cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = $pid"), 0);
    
$access file_get_contents('plugins/fullsize_access/access.php');
    
$access str_replace("\r""\n"$access);
    
$access str_replace("\n\n""\n"$access);
    
$lines explode("\n"$access);
    foreach (
$lines as $line) {
        
$user_id NULL;
        
$album_id NULL;
        list(
$user_id$album_id) = explode(" "trim($line));
        if (
USER_ID == $user_id && $aid == $album_id) {
            return 
true;
        }
    }
    return 
false;
}
?>


As you can see, I already added general access for the admin user and denied for unregistered users. If you don't like that, change it to your needs. Additionally, I removed the check for
$superCage->cookie->getInt($CONFIG['cookie_name'].'_agb')
as I wasn't asked to accept anything while testing. Of course it's possible to re-add this check, if needed. Just let me know.

JohannM

Thanx André

Got it to work fine. Thanx a lot for your input. Much appreciate it.

Hope this plugin can be changed sometime to make it a bit easier. But for now, I am 100% happy.


JohannM

Hi André

Just two more things.

1. If someone download a photo, I get a text "Fullsize image <051-MB1-0004.jpg> has been downloaded by user <User1234>
Users email address is : User1234@whatever.com"

Q: Can we add the users IP address to this ?

2. Can I add a domain name (e.g. boy-dols.com_051-MB1-0004.jpg  with "boy-dols.com_" prefixed before the filename) to the filename that is downloaded ?

Thanx in advance.

Best

JohannM

Αndré

Quote from: JohannM on April 22, 2016, 09:27:46 AM
1. If someone download a photo, I get a text "Fullsize image <051-MB1-0004.jpg> has been downloaded by user <User1234>
Users email address is : User1234@whatever.com"

Q: Can we add the users IP address to this ?

Open fullsize_secure, find
function download_mail($filename,$uid) {

global $CONFIG;

and replace with
function download_mail($filename,$uid) {

global $CONFIG, $raw_ip;


find
"\nUsers email address is : " . $row[1];
and replace with
"\nUser's email address is : " . $row[1] . "\nUser's IP address is : " . $raw_ip;


Quote from: JohannM on April 22, 2016, 09:27:46 AM
2. Can I add a domain name (e.g. boy-dols.com_051-MB1-0004.jpg  with "boy-dols.com_" prefixed before the filename) to the filename that is downloaded ?

Open jpgdownload.php, find
header('Content-Disposition: attachment; filename=' . basename($file));
and replace with
header('Content-Disposition: attachment; filename=boy-dols.com_' . basename($file));

JohannM

André

Wow, that was fast ... I will do changes and report back.

Thanx a million.

Btw, the zip download of entire album is disabled due to library shorting ... will it be a mission to change that ?

Best

JohannM

Αndré

Quote from: JohannM on April 22, 2016, 10:03:03 AM
the zip download of entire album is disabled due to library shorting

Is this related to the fullsize_access plugin?

JohannM

Yes.

In codebase.php line 9 :

// ZIP download feature disabled (doesn't work because of missing library)
//$thisplugin->add_action('post_breadcrumb','ziplink');

Would be nice to have this working though.

Αndré

Open codebase.php, find
//$thisplugin->add_action('post_breadcrumb','ziplink');
and replace with
$thisplugin->add_action('post_breadcrumb','ziplink');


Open zipdownload_extended.php, find
$zip = new zipfile($cwd,$flags);

$zip->addfiles($files);

$zip->filedownload('pictures.zip');

and replace with
$options = array(
    'inmemory'   => 1,
);
$zip = new archive($cwd,$flags);
$zip->set_options($options);
$zip->add_files($files);
$zip->download_file('pictures.zip');


This adds the link and opens a download dialog for me. Unfortunately, the file name is wrong and the file doesn't contain anything. I've currently no time to have a closer look at this, so I posted what I got.


By the way, I don't think that this request is related to your initial question. Additionally, you also posted an issue in the plugin announcement thread of the Download complete album as ZIP plugin. If you want to use that plugin, I suggest to fix the other plugin and drop the idea of fixing that functionality of the fullsize_access plugin.

JohannM

André

I made the changes on the zip section, but I do not get a link and does not open a dialog for me. Where does this open a link for you and what does this dialogue looks like ?

Should I enable zip downloads in main config or just in the config of the plugin ?

Regards

JohannM

Αndré

First of all: sorry, it wasn't you who posted the issue in the other thread: http://forum.coppermine-gallery.net/index.php/topic,74257.msg381466.html#msg381466

The plugin checks if you're allowed to download pictures. Maybe we need to adjust your custom mod to display the download link. I'll check that later.

JohannM

Hi Αndré

Sorry to bother again. I need to ask you another big favour.

The mods for full access works fine, but I still have a group "VIP" which is uder group "4".

In the file "fullsize_check.php" there's a part

"
function fullsize_check_user() {
   if (GALLERY_ADMIN_MODE) {
        return true;
    }
    if (!USER_ID) {
        return false;
    }
  etc . "

How can I script it to allow also allow full access to the usergroup "4" as it does with the part " if (GALLERY_ADMIN_MODE) {
        return true; "

Im not sure how to add it.

Also, have you managed to check the plugin yet to allow the zip download function yet ?

Thanx in advance

Regards

JohannM

Αndré

Quote from: JohannM on June 14, 2016, 08:25:49 PM
How can I script it to allow also allow full access to the usergroup "4" as it does with the part " if (GALLERY_ADMIN_MODE) {
        return true; "

Add,
    global $USER_DATA;
    if (in_array(4, $USER_DATA['groups'])) {
        return true;
    }

below
    if (GALLERY_ADMIN_MODE) {
        return true;
    }



Quote from: JohannM on June 14, 2016, 08:25:49 PM
have you managed to check the plugin yet to allow the zip download function yet ?

No, sorry.

JohannM


Αndré

I just had a look at your other issue. In codebase.php we find this code:
function ziplink(){
global $CONFIG;
$superCage = Inspekt::makeSuperCage();

if ($CONFIG['plugin_ks_fullsize_zip'] != 0 ){

if( $superCage->get->testInt('album') and !$superCage->get->keyExists('pid') and fullsize_check_user()){
echo '<div class="tableh1"><b>';
echo '<a style="color:white; text-align:right;" href="plugins/fullsize_access/zipdownload_extended.php?album=' . $superCage->get->getInt('album') . '" >Download aller Bilder dieses Albums als ZIP Datei</a>';
echo '</b></div>';
}
if( strstr($superCage->get->getAlpha('album'),'favpics') != false  and !$superCage->get->keyExists('pid') and fullsize_check_user()){
echo '<div class="tableh1"><b>';
echo '<a style="color:white" href="plugins/fullsize_access/zipdownload_extended.php?fav' . '" >Download aller Favoriten als ZIP Datei</a>';
echo '</b></div>';
}

}
}


First of all, please check if $CONFIG['plugin_ks_fullsize_zip'] is "1" (have a look at the config table in your Coppermine MySQL database). If so, with your last modification, the download button should be displayed for all admins and users of your VIP group.

JohannM

Hi André

I have checked "if ($CONFIG['plugin_ks_fullsize_zip'] != 0" and change it to "if ($CONFIG['plugin_ks_fullsize_zip'] != 1", and also checked that the "plugin_ks_fullsize_zip" is set to 1, but I did not managed to get a link to "Download aller Favoriten als ZIP Datei" ....

Where is this link suppose to show ?

Regards

JohannM

JohannM

André

Sorry, got the link now. I will just make it a bit more visable. Thanx.

I will test it and report.

Thanx so far.

JohannM

André

Im testing and get this error.

"Fatal error: Class 'zipfile' not found in /home/boyidols/public_html/plugins/fullsize_access/zipdownload_extended.php on line 125"


Αndré

Quote from: JohannM on June 17, 2016, 11:55:57 AM
"Fatal error: Class 'zipfile' not found in /home/boyidols/public_html/plugins/fullsize_access/zipdownload_extended.php on line 125"

Please have a look at my instructions in this post: http://forum.coppermine-gallery.net/index.php/topic,78547.msg381485.html#msg381485

As it probably also won't work for you, I suggest to use the "download all albums as zip file" plugin and add a check for fullsize_check_user() at some places to restrict access.

JohannM

Hi André

First of all, a very happy and prosperous 2017 for you.

Question: The cript is working fine for me now. My customers asked me now if it is possible to download a zip file contaning all the photos. Not to use other scripts, I compressed the files into a zip. Now, (as I coded it with your help ), the "DOWNLOAD FULL SIZE IMAGE" button is above the intermediate photo, but does not appear above the "zip" file. Anyway to fix this that it shows on top of zip file also ? I have VIP usergroup that allows HR downloads only.

Thanx, and hoping for a reply soon.

Best Regards

JohannM