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
-
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).
-
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:
<?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)
-
Try
<?php
function fullsize_check_user(){
global $USER_DATA;
if($USER_DATA['group_name'] == 'Testing'){
return(true);
} else{
return(false);
}
}
?>
-
Tnx - works fine now.
Mimer 8)
-
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!
-
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.
-
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.
-
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.
-
I will have a look and if I figure it out, I'll report it back here.
Thank you.
-
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.
-
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)
-
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)
-
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:
$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.
-
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:
$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
-
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
-
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:
////////////////////// 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)
-
ftp.myhost.de is changed to my file zilla host too
-
http://stackoverflow.com/questions/18467876/ftp-connect-fatal-error-call-undefined-function
-
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.
-
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)
-
Independent from the functionality of the plugin, with "download" you mean access to the full-sized picture, right?
-
Yes André
-
Will have a closer look as soon as possible. Has no priority for me, sorry.
-
Thanx André
Will wait in anticipation ... ;D
-
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
-
Open fullsize_check.php, find
if( USER_ID && $superCage->cookie->getInt($CONFIG['cookie_name'].'_agb') === 1){
and replace with
global $USER_DATA;
if(in_array(4, $USER_DATA['groups'])) {
(where "4" is the group ID of your VIP group).
Open codebase.php, find
?>
and above, add
$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).
-
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...
-
That was no requirement in his post in this thread (yet) and should be discussed in the other thread.
-
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
-
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
if(in_array(4, $USER_DATA['groups'])) {
with
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
return $pic_html.$download;
with
return $download."<br />\n".$pic_html;
-
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
-
will it be complecated to add the actual category as well ?
Open fullsize_hist.php, find
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
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>";
-
André
Thanx. Your an absolute star !!!
It works perfectly.
Thanx again.
-
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.
-
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.
-
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 ?
-
Open fullsize_hist.php, find
pagefooter();
and above, add
echo '<br /><a href="'.$CPG_PHP_SELF.'?file=fullsize_access/fullsize_hist&clearlog" class="admin_menu">Clear logs</a>';
find
if( !USER_IS_ADMIN ) {
echo '<br><br><b>access to this page is restricted to administrators</b>';
exit;
}
and below, add
if($superCage->get->keyExists('clearlog')) {
cpg_db_query("DELETE FROM $htab");
}
-
André
Thank you so much. Works wonderfull.
Your a star !
-
André
Mmm, hope you dont mind.
Adding the Category in from of the album in "most viewed albums" on history page ?
Please. And thanx.
-
Open fullsize_hist.php, find
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
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
-
Try
<?php
function fullsize_check_user(){
global $USER_DATA;
if($USER_DATA['group_name'] == 'Testing'){
return(true);
} else{
return(false);
}
}
?>
Hi Αndré,
This code works fine, but only for one group. Is it possible to change this option for several groups?
I would like to add full access to 12 different groups.
All the best
Mat
-
Try
<?php
function fullsize_check_user(){
global $USER_DATA;
if (in_array($USER_DATA['group_name'], array('Testing', 'Group 2', 'Group 3', 'Group 4'))){
return(true);
} else{
return(false);
}
}
?>
-
Thank you for the quick reply.
I have this error:
Parse error: syntax error, unexpected '{' in /home/admin/domains/domain/public_html/resources/plugins/fullsize_access/fullsize_check.php on line 4
<?php
function fullsize_check_user(){
global $USER_DATA;
if (in_array($USER_DATA['group_name'], array('Boss', 'Global Mod', 'Mod', 'Cover Legend')){
return(true);
} else{
return(false);
}
}
?>
-
Sorry, missing bracket. This should work:
<?php
function fullsize_check_user(){
global $USER_DATA;
if (in_array($USER_DATA['group_name'], array('Boss', 'Global Mod', 'Mod', 'Cover Legend'))){
return(true);
} else{
return(false);
}
}
?>
I'll update my above code accordingly.
-
Now it works perfectly, thank you very much Αndré
-
Hello Andre
Hope you are doing well.
Will it possible to adopt this plugin for cpg v1.6.05 and php 7 as I use this on a daily basis ?
Regards
Johann
-
I'm quite sure this is possible. I'll have a look as soon as possible.
-
Please try this version and report if it works as expected, as I hadn't much time to test: https://github.com/coppermine-gallery/cpg1.6.x-plugins/blob/master/cpg1.6.x_plugin_fullsize_access_v1.1.zip