forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: Αndré on May 04, 2012, 03:05:40 pm

Title: Fullsize access plugin for cpg1.5.x
Post by: Αndré on May 04, 2012, 03:05:40 pm
This is the cpg1.5.x port of the fullsize_access plugin by Klaus Schwarzburg (http://forum.coppermine-gallery.net/index.php?action=profile;u=8075). The port has been created as a freelance job (link (http://forum.coppermine-gallery.net/index.php/topic,74851.0.html)), so there's just limited support.

From the original announcement thread:
this plugin controls access for downloading fullsize images and adds several features:

- restrict access to fullsize pics to registered users
- adds a download link to the image information section
- adds a fullsize download history (datetime,username,ip) table and a statistics page
- sending email to admin and/or customer for each download
- zip download link to download all pics in an album and in favorites
- clicking on medium sized pic to show fullsize pic is disabled
- Secure image files on the file system level via chmod

Most settings can be controlled by a configuration page added to the admin menu. Plugin language is english only, but some settings are in german. This may be improved in a future version... At the moment all registered users are allowed to download fullsize images. You can change this behavior by editing the file fullsize_check.php.

The zip download feature bypasses cpg's build-in favorites zip download. I recommend to switch off the cpg favorites-zip download in the cpg-config page if you want to use this plugin.


The optional file security feature will prevent users to download pics by entering the pics url directly and it works like this:
- if a fullsize pic is requested, the plugin first changes the file attributes from 660 (safe) to 666 (unsafe) and then sends the file to the user. After the download the attribute is set back to 660.
- The fullsize access conig panel has  buttons to secure and unsecure all files
- The file attribute is changed via ftp

If you want to use this feature you have to edit the file 'fullsize_secure.php'. At the beginning of the file there is a section where you must specify your ftp login and the path for the ftp client to the coppermine root.  New pics that are added to the cpg gallery are not automatically secured. You must use the secure button in the plugins config page. So this feature is only useful for galleries were only 1 or a few people are uploading pics.
I'm not an unix/apache expert and the security feature is open for discussion. On my present webserver the file attribute change from 660 to 666 is not needed to download the file via the script. However this was different on my old system.... Any suggestions are welcome!

The album ZIP download feature has been disabled, as it doesn't work (missing library).
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Mimer on June 26, 2012, 03:29:48 pm
Hi

I would like to change the plugin, so a specific user group can access fullsize and not all registred users.
For a test I changed fullsize_check.php:
Code: [Select]
<?php
function fullsize_check_user(){
if( USER_GROUP=='Testing' ){
return(true);
} else{
return(false);
}
}
?>
This doesn't do the trick.
Do I have to change something in the codebase.php as well?

Best regards
Mimer  8)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on June 27, 2012, 10:52:34 am
Try
Code: [Select]
<?php
function fullsize_check_user(){
global $USER_DATA;
if($USER_DATA['group_name'] == 'Testing'){
return(true);
} else{
return(false);
}
}
?>
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Mimer on June 28, 2012, 11:37:03 am
Tnx - works fine now.

Mimer  8)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: paquets on August 27, 2012, 09:57:32 pm
Hi,

Great plugin! Do you know if it would be possible to move the download link from the file info section and position it right under the image itself in displayimage.php?

Thank you!
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on August 29, 2012, 10:53:31 am
That's possible by using the file_data (http://documentation.coppermine-gallery.net/en/dev_plugin_hooks.htm#plugin_hooks_filename_file_data) plugin hook.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: paquets on August 29, 2012, 11:06:17 am
Thank you André.

Would it be simply a case of replacing "file_info" by "file_data" in fullsize_access/codebase.php? I'm not familiar how plugin hooks work.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on August 29, 2012, 12:55:34 pm
I doubt that this will work. But as I hadn't looked at the code, I don't know.

I'm not familiar how plugin hooks work.
Have a look at the docs and maybe some other plugins, that use that plugin hook to add something below the picture.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: paquets on August 31, 2012, 09:39:06 pm
I will have a look and if I figure it out, I'll report it back here.
Thank you.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Phill Luckhurst on November 27, 2012, 11:10:39 am
Interesting idea changing perms that way. For users with root access it might be easier to have a specific group (chown) setup on the server so images in the albums folder could only be called up by a script belonging to that group and not a general user guessing the URL. The problem as ever with this kind of script it how an individuals server is setup.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: taucher0815 on December 24, 2012, 06:55:31 pm
Hi all!

First of all: Merry Christmas!

I really like the plugin but I have a little issue.
It is running on CPG 1.5.20 with no ability to use the php internal mail sending.
I set up my mail-providers details in the general cpg setup und all works well.

Any chance to get this enabled here, too?

Many thanks
Sven

(http://www.sportfotos-oberbayern.de)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: taucher0815 on December 27, 2012, 11:47:18 am
Hi all!

OK, the above topic can be ignored.

A few more questions:
a) Is it possible to add more text to the mail a user gets after downloading an image?
b) Is there a way to insert the Album-Name and the user name as a variable?
c) For the access rights of the full sized image: The "secured" images are getting the rights 660. In the settings of coppermine there is an option to set the default access rights of files. When setting 660 there, does this save the step from securing images via the plug in?

Many thanks
Sven

(http://www.sportfotos-oberbayern.de)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on December 28, 2012, 11:12:36 am
no ability to use the php internal mail sending.
It seems that the plugin doesn't use the cpg mail function, but the PHP function mail.

OK, the above topic can be ignored.
Please post your solution.


a) Is it possible to add more text to the mail a user gets after downloading an image?
Have a look at the file fullsize_secure.php and check the mail functions. I guess you either have to adjust that line:
Code: [Select]
$txt = $CONFIG['plugin_ks_fullsize_message_for_customer'] . "\n";or adjust the corresponding config value.


b) Is there a way to insert the Album-Name and the user name as a variable?
Should be possible by adjusting the some code near the code you found in a).


c) For the access rights of the full sized image: The "secured" images are getting the rights 660. In the settings of coppermine there is an option to set the default access rights of files. When setting 660 there, does this save the step from securing images via the plug in?
If Coppermine has sufficient permissions to change that, I guess you won't be able to access any generated files (thumbnails, intermediate-sized versions). I haven't checked that nor looked at the code. I suggest to test this on your gallery.
Title: Re: Re: Fullsize access plugin for cpg1.5.x
Post by: taucher0815 on December 28, 2012, 08:34:53 pm
Hi André!

It seems that the plugin doesn't use the cpg mail function, but the PHP function mail.
Please post your solution.
Initially I wanted to host the large gallery on my own server at home via dyndns... Due to bandwidth reasons and a good offer from my webhoster I upgraded my plan there.

Have a look at the file fullsize_secure.php and check the mail functions. I guess you either have to adjust that line:
Code: [Select]
$txt = $CONFIG['plugin_ks_fullsize_message_for_customer'] . "\n";or adjust the corresponding config value.

OK, I will have a look.

Thanks so far!
Sven
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: taucher0815 on December 28, 2012, 08:51:35 pm
Hi Andrč!

The message text is stored in the config-table where the values are defined as varchar(255)...

That's the reason for the limited message size.

Sven
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: allvip on September 14, 2013, 11:51:26 pm
Fatal error: Call to undefined function ftp_connect() in /gallery/plugins/fullsize_access/fullsize_secure.php on line 177 error when I clik secure all files.

I edited the fullsize_secure.php:

Code: [Select]


////////////////////// section to edit

// edit ftp user/host data here:
$ftp_server = "ftp.myhost.de";
$ftp_user_name = "my filezilla usename";
$ftp_user_pass = "file zilla pass";
$ftppath_to_cpg = '/gallery/'; // this is the path to your cpg dir starting from your home page root (what the ftp sees by default)

////////////////////// end section to edit


my gallery:

http://allvip.us/gallery/index.php (http://allvip.us/gallery/index.php)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: allvip on September 14, 2013, 11:53:08 pm
ftp.myhost.de is changed to my file zilla host too
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on September 16, 2013, 02:18:22 pm
http://stackoverflow.com/questions/18467876/ftp-connect-fatal-error-call-undefined-function
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: allvip on September 16, 2013, 03:58:21 pm
done.ftp suport not showing.

anyway I'm moving my gallery to another host and I will use .htaccess for hotlinking.

yahoo host does not allows many many things.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on January 09, 2016, 05:39:46 pm
Hi there

I disabled "image information" completely since I do not want to have my website visitors or registered users to see it.

Question: Is there a way to configure this:

1. To enable only my group "VIP" to be able to download
2. Display a simple button "DOWNLOAD" just below or above the intermediate picture based on my usergroup "VIP" ?

Thank you in advance.

JohannM
( www.youth-sport-fotos.com)
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on January 09, 2016, 09:55:14 pm
Independent from the functionality of the plugin, with "download" you mean access to the full-sized picture, right?
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on January 09, 2016, 10:16:39 pm
Yes André
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on January 09, 2016, 10:18:50 pm
Will have a closer look as soon as possible. Has no priority for me, sorry.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on January 09, 2016, 10:25:09 pm
Thanx André

Will wait in anticipation ...  ;D
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 20, 2016, 10:07:47 am
Hi André

Had any chance to look at this already. I tried to find the "hooks" for the info part, to try to change it to current pic data, but with no luck.

Basicly what I want to do as said, is to have this button displayed in top/bottom of the intermediate pic, in spite of the file_info section.

At ehe moment, when I grant certain users VIP status (access to the bigger photo), they basicly have access to all albums with bigger photos. I want to be able to grant access for certain users for bigger pictures just for certain albums. Surely there must be a easier way to do this.

Regards

Johann
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 21, 2016, 10:16:36 am
Open fullsize_check.php, find
Code: [Select]
if( USER_ID && $superCage->cookie->getInt($CONFIG['cookie_name'].'_agb') === 1){and replace with
Code: [Select]
    global $USER_DATA;
    if(in_array(4, $USER_DATA['groups'])) {
(where "4" is the group ID of your VIP group).


Open codebase.php, find
Code: [Select]
?>and above, add
Code: [Select]
$thisplugin->add_filter('html_image_reduced','download_link_img');
$thisplugin->add_filter('html_image_reduced_overlay','download_link_img');

function  download_link_img($pic_html)
{
global $CURRENT_PIC_DATA,$CONFIG;

if( fullsize_check_user() ){
$download = '<a href="plugins/fullsize_access/jpgdownload.php?pid=' . $CURRENT_PIC_DATA['pid'] . '" >Download Original File</a>';
} else {
$download = 'Fullsize download for registered users only! Please, <a href="register.php" >Register</a> or <a href="login.php" >login</a>';
}
return $pic_html.$download;
}
(you probably either want to edit or remove the text for users that have no fullsize access).
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: gmc on March 21, 2016, 12:07:30 pm
Quote
 
Code: [Select]
global $USER_DATA;
  if(in_array(4, $USER_DATA['groups'])) {
(where "4" is the group ID of your VIP group).
As I understand from JohannM's other thread - he will have a VIP group PER ALBUM... so he will need to determine what group to look for based on the album being viewed...
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 21, 2016, 01:18:12 pm
That was no requirement in his post in this thread (yet) and should be discussed in the other thread.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 21, 2016, 08:12:54 pm
André

Thanx so much for your help. I managed to get it working.

Two questions if you dont mind:

1. If I want to add e.g. two user groups (e.g. VIP wich is 4, and Admin which is 1), how would I code the line ?
2. If I want to put the link ontop of the intermediate pic, where should I change what ?

I haven't tested the zip function there, do you perhaps know if it works ?

Thanx a lot for your help.

Regards

JohannM
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 22, 2016, 02:34:03 pm
1. If I want to add e.g. two user groups (e.g. VIP wich is 4, and Admin which is 1), how would I code the line ?

Replace
Code: [Select]
if(in_array(4, $USER_DATA['groups'])) {with
Code: [Select]
if(in_array(4, $USER_DATA['groups']) || in_array(1, $USER_DATA['groups'])) {

2. If I want to put the link ontop of the intermediate pic, where should I change what ?

Replace
Code: [Select]
return $pic_html.$download;with
Code: [Select]
return $download."<br />\n".$pic_html;
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 22, 2016, 03:15:49 pm
André

Thanx a million.

If I look at the script changes, it's actually very simple. I'm getting stupid with php.

Thanx in anyway.

By the way, in the plugins admin section where you can view the downloads ( "show downloads history" ) and then you get a section "downloaded fullsize images sorted by download date ( with user    date    filename    album    ip-address), will it be complecated to add the actual category as well ?

Thanx a lot for your input.

Regards

JohannM
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 22, 2016, 03:39:21 pm
will it be complecated to add the actual category as well ?

Open fullsize_hist.php, find
Code: [Select]
starttable('100%','downloaded fullsize images sorted by download date');

$query = "SELECT  user.user_name,hist.tstamp,hist.picname,pic.pid,alb.title,hist.ip FROM $utab As user,$htab As hist,$ptab AS pic,$atab AS alb  WHERE " .
         "hist.uid=user.user_id AND alb.aid=pic.aid AND hist.picname LIKE pic.filename ORDER BY hist.tstamp DESC " .
"LIMIT 100";
$res = cpg_db_query( $query );         

echo "<tr><td><table CELLPADDING=\"5\">\n";
echo "<b><tr class=\"tableb\">\n";
    echo "<td>\n";
    echo "<b>user</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>date</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>filename</b>";
    echo "</td>\n"; 
    echo "<td>\n";
    echo "<b>album</b>";
    echo "</td>\n"; 
        echo "<td>\n";
    echo "<b>ip-address</b>";
    echo "</td>\n";   

    echo "</tr></b>\n";

 while($row = mysql_fetch_row($res))
  {
    echo "<tr class=\"tableb\">\n";
    echo "<td>\n";
    echo $row[0];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[1];
    echo "</td>\n";
    echo "<td>\n";
    echo "<A HREF=\"displayimage.php?pos=-$row[3]\">$row[2]</A>";
    echo "</td>\n";
    echo "<td>\n";
    echo $row[4];
    echo "</td>\n";   
    echo "<td>\n";
    echo $row[5];
    echo "</td>\n";
    echo "</tr>\n";
  }
 
echo "</table></td></tr>\n";
 
mysql_free_result($res);
endtable(); 
echo "<br><br>";
and replace with
Code: [Select]
starttable('100%','downloaded fullsize images sorted by download date');

$query = "SELECT  user.user_name,hist.tstamp,hist.picname,pic.pid,alb.title,hist.ip,cat.name
            FROM {$CONFIG['TABLE_USERS']} AS user
            INNER JOIN {$CONFIG['TABLE_PREFIX']}fullsize_hist AS hist
            ON hist.uid=user.user_id
            INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pic
            ON hist.picname = pic.filename
            INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS alb
            ON alb.aid=pic.aid
            LEFT JOIN {$CONFIG['TABLE_CATEGORIES']} AS cat
            ON cat.cid=alb.category
            ORDER BY hist.tstamp DESC
            LIMIT 100";
$res = cpg_db_query( $query );         

echo "<tr><td><table CELLPADDING=\"5\">\n";
echo "<b><tr class=\"tableb\">\n";
    echo "<td>\n";
    echo "<b>user</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>date</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>filename</b>";
    echo "</td>\n"; 
    echo "<td>\n";
    echo "<b>album</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>category</b>";
    echo "</td>\n"; 
        echo "<td>\n";
    echo "<b>ip-address</b>";
    echo "</td>\n";   

    echo "</tr></b>\n";

 while($row = mysql_fetch_row($res))
  {
    echo "<tr class=\"tableb\">\n";
    echo "<td>\n";
    echo $row[0];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[1];
    echo "</td>\n";
    echo "<td>\n";
    echo "<A HREF=\"displayimage.php?pos=-$row[3]\">$row[2]</A>";
    echo "</td>\n";
    echo "<td>\n";
    echo $row[4];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[6];
    echo "</td>\n";   
    echo "<td>\n";
    echo $row[5];
    echo "</td>\n";
    echo "</tr>\n";
  }
 
echo "</table></td></tr>\n";
 
mysql_free_result($res);
endtable(); 
echo "<br><br>";
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 22, 2016, 04:17:01 pm
André

Thanx. Your an absolute star !!!

It works perfectly.

Thanx again.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 22, 2016, 04:22:07 pm
Just a small note: if the album resides in the root category (* no category*) or in the user galleries, the script won't display a category name. This would need an additional check, which I haven't added, as I haven't found such albums in your gallery at first glance.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 22, 2016, 06:08:06 pm
André

Its all fine for the moment. I do not have any albums in my root. And I do not have any users with their own albums. All albums and uploads is created by me and me only.

Thanx anyway.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 22, 2016, 06:10:23 pm
André

I just thought of something else that might be usefull to this "admin" side. A button to clear the current "logs". Is it a mission to code this and add a button ?

Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on March 23, 2016, 09:08:58 am
Open fullsize_hist.php, find
Code: [Select]
pagefooter();and above, add
Code: [Select]
echo '<br /><a href="'.$CPG_PHP_SELF.'?file=fullsize_access/fullsize_hist&amp;clearlog" class="admin_menu">Clear logs</a>';
find
Code: [Select]
if( !USER_IS_ADMIN ) {
 echo '<br><br><b>access to this page is restricted to administrators</b>';
 exit;
}
and below, add
Code: [Select]
if($superCage->get->keyExists('clearlog')) {
    cpg_db_query("DELETE FROM $htab");
}
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 23, 2016, 06:02:35 pm
André

Thank you so much. Works wonderfull.

Your a star !
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: JohannM on March 23, 2016, 06:08:23 pm
André

Mmm, hope you dont mind.

Adding the Category in from of the album in "most viewed albums" on history page ?

Please. And thanx.
Title: Re: Fullsize access plugin for cpg1.5.x
Post by: Αndré on April 13, 2016, 11:46:44 am
Open fullsize_hist.php, find
Code: [Select]
starttable('100%','most viewed albums');
$query = "SELECT alb.title,SUM(pic.hits) AS ahits, COUNT(*) FROM $atab AS alb, $ptab AS pic WHERE pic.aid=alb.aid GROUP BY alb.aid ORDER BY ahits DESC";
$res = cpg_db_query( $query );         

echo "<tr><td><table CELLPADDING=\"5\">\n";

    echo "<b><tr class=\"tableb\">\n";
    echo "<td>\n";
    echo "<b>album name</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>images in album</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>total hits in album</b>";
    echo "</td>\n";   
    echo "</tr></b>\n";


 while($row = mysql_fetch_row($res))
  {
    echo "<tr class=\"tableb\">\n";
    echo "<td>\n";
    echo $row[0];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[2];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[1];
    echo "</td>\n";   
    echo "</tr>\n";
  }
echo "</table></td></tr>\n";
 
mysql_free_result($res);
endtable();  // album statistics
and replace with
Code: [Select]
starttable('100%','most viewed albums');
$query = "SELECT alb.title,SUM(pic.hits) AS ahits, COUNT(*), cat.name
            FROM {$CONFIG['TABLE_ALBUMS']} AS alb
            INNER JOIN {$CONFIG['TABLE_PICTURES']} AS pic
            ON pic.aid=alb.aid
            LEFT JOIN {$CONFIG['TABLE_CATEGORIES']} AS cat
            ON cat.cid=alb.category
            GROUP BY alb.aid
            ORDER BY ahits DESC";
$res = cpg_db_query( $query );

echo "<tr><td><table CELLPADDING=\"5\">\n";

    echo "<b><tr class=\"tableb\">\n";
    echo "<td>\n";
    echo "<b>category</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>album name</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>images in album</b>";
    echo "</td>\n";
    echo "<td>\n";
    echo "<b>total hits in album</b>";
    echo "</td>\n";   
    echo "</tr></b>\n";


 while($row = mysql_fetch_row($res))
  {
    echo "<tr class=\"tableb\">\n";
    echo "<td>\n";
    echo $row[3];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[0];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[2];
    echo "</td>\n";
    echo "<td>\n";
    echo $row[1];
    echo "</td>\n";   
    echo "</tr>\n";
  }
echo "</table></td></tr>\n";
 
mysql_free_result($res);
endtable();  // album statistics