forum.coppermine-gallery.net

Support => cpg1.4 plugins => cpg1.4.x Support => Older/other versions => cpg1.4 plugin contributions => Topic started by: Nibbler on August 26, 2005, 04:55:09 pm

Title: File replacement plugin
Post by: Nibbler on August 26, 2005, 04:55:09 pm
This plugin will allow you and your users to replace files in your gallery with new ones. Installation is via the plugin manager, and will present a new button under the file in the intermediate/displayimage.php view.
Title: No access after replacing file with plugin
Post by: flashi on February 11, 2006, 04:50:50 pm
Hi all  :)

I love coppermine and wanted to say thx to all the developers out there, really great work.

I have a big problem with access rights at the moment...

I installed the File Replacement-Plugin a few days ago because I decided to change the quality of all my pictures without losing the number of views of each photo. Everything worked really fine, but today I realized a strange thing:

When I upload a completely new file / photo to the gallery, coppermine chmods it with 666, everything fine so far.
But if I replace a file with the File Replacement-Plugin, coppermine sets chmod to 600, so I can't change anything via ftp after it   :o

Cause I make backups regularly via ftp-download of the whole site, that isn't possible any longer. I don't have the rights to download the replaced files via ftp, and I can't change the rights via ftp to 666 to correct this, I get a "Operation not permitted"  :(

Could someone please help me to correct this? I don't know PHP very well, is there a possibility to set chmod to 666 when I replace a file with the plugin as coppermine do as default when uploading a new file?

Thanks to all out there for help, keep up your great work.

flashi
Title: Re: File replacement plugin
Post by: Nibbler on February 11, 2006, 05:03:19 pm
Look in the plugin's codebase.php for

Code: [Select]
move_uploaded_file($_FILES['fileupload']['tmp_name'], $image);
and add after it

Code: [Select]
chmod($image, octdec($CONFIG['default_file_mode']));
Title: Re: File replacement plugin
Post by: flashi on February 11, 2006, 05:09:55 pm
Wow, that was a fast solution  :o

I thank you very much, everything works fine now  ;D
Title: Re: File replacement plugin
Post by: LilAngel on February 19, 2006, 03:55:19 pm
Great plugin!
I used to manually replace the files on the FTP and then rebuild thumbs and resized pictures, but this is by far more easier.
Title: Re: File replacement plugin
Post by: Beyond_Doubt on February 27, 2006, 12:55:55 am
This is a plugin that fits my needs 100% :)

Tha problem is that I am using the mod'ed CPG to suit PragmaMX.
I realise this isn't an issue for this board, but just to keep things all above board I thought it courteous to let you know I was asking for help on the PragmaMX forum to adapt your work to suit.

I trust that this is not a problem for you. :)

Quote
Appologies, but this is an English only post; I know no German.

I have a PragmaMX installation with MX-CPG 1.4.3.
In that installation I have added a few Plugins from the CPG site.
Some of these Plugins required small modifications to the codebase.php before they would work.
Usually this modification was just to change...
Code: [Select]
require ('plugins/control_fullsize/include/init.inc.php');to
Code: [Select]
require (dirname(__FILE__).'/include/init.inc.php');

However I am very eager to use the 'File Replacer' Plugin that can be found here. (http://forum.coppermine-gallery.net/index.php?topic=21193.0)

But when I use that Plugin, and then click on the 'Replace File' button I get the following error message...
Quote
Sorry, you can't access this file directly, parameter 'name' is required...



So, I am asking for some help here.
Are there any modifications that need to be made to basic CPG code to convert it to MX-CPG that I have missed?
Or, more to the point, can someone get this plugin working in MX-CPG for me?

:D

Thanks in advance!
Title: Re: File replacement plugin
Post by: Andi on February 27, 2006, 10:54:40 am
Hello Beyond_Doubt,

I answered you in pragmaMx the forum and the solution described.
http://www.pragmamx.org/forum-topic-15705.0.html

At Nibbler: you should also regard the solution, only few things are to be considered, that Plugins also runs in pragmaMx.
Title: Re: File replacement plugin
Post by: Beyond_Doubt on February 27, 2006, 02:14:44 pm
Thank You to Nibbler for the very usefull plugin, and Thank You to Andi for helping me to use it!

Great Work Fellas. :)
Title: Re: File replacement plugin
Post by: Andi on March 01, 2006, 10:00:24 am
Hi :)

A small problem still exists with the Plugin.

If the option, to read the EXIF-data is switched on, these informations are not updated when we replace the picture.
I extended the Plugin as follows.

find this line:
Code: [Select]
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filesize = '$image_filesize', total_filesize = '$total_filesize', pwidth = '$width', pheight = '$height' WHERE pid = '$pid' LIMIT 1");
add after:
Code: [Select]
if ($CONFIG['read_exif_data']) {
    include("includes/exif_php.inc.php");
    exif_parse_file($image);
}

@ Beyond_Doubt
the updated pragmaMx file is available in the thread...
Title: Re: File replacement plugin
Post by: Paver on March 31, 2006, 06:34:03 pm
I'm not sure if this is a typo or a renamed include directory for PragmaMX, but in the core Coppermine, the include line in your mod should be the following (no 's' in the directory name):
Code: [Select]
include("include/exif_php.inc.php");
Title: Re: File replacement plugin
Post by: Visiluna on May 04, 2006, 11:33:31 pm
It appears that when you upload a replacement file, the new file takes on the filename of the original file. Would it be possible for the record to reflect the filename of the newly uploaded replacement file instead?

Thanks,
PJ
Title: Re: File replacement plugin
Post by: Paver on May 05, 2006, 01:00:08 am
So you want the new file to be placed in the same folder as the old file but have it retain its filename?  (with the old file being deleted of course)

If so, try out the attached new plugin version.  I incorporated all the mods in this thread to this point (Nibbler's chmod, Andi's EXIF), then added in a configuration option to set whether you want the replaced file to have the original filename or keep its own.  The option is set in codebase.php.  You must manually change the option in the file; there is *no* web-based admin panel.  Look for the CONFIGURATION OPTIONS block and change the option to true or false, depending upon what you want.
Title: Re: File replacement plugin
Post by: Visiluna on May 05, 2006, 05:30:28 pm
Thank you, thank you, thank you.

Did I mention that you guys are awesome?

Thank you again,
PJ
Title: Re: File replacement plugin
Post by: Eugene Merzlyakov on May 14, 2006, 07:21:56 pm
I've install this plug-in, below pict appeared button "replace file", but if i'm click on it - doesnt changed!
What i'm doing wrong?
Title: Re: File replacement plugin
Post by: Paver on May 14, 2006, 10:11:07 pm
When you click on the "Replace File" button, it should show a new page with a single box labelled "Upload Replacement File" and a "Browse" button to select the file.

If you don't see this, you should start a new thread on the main Plugins board for support with this plugin.  Support is not available on this thread.
Title: Re: File replacement plugin
Post by: midnightshowx0 on May 25, 2006, 06:13:11 pm
im a little confused here, where do i put this at??
Title: Re: File replacement plugin
Post by: Paver on May 25, 2006, 06:20:55 pm
http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#plugin (http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#plugin)
Title: Re: File replacement plugin
Post by: Eddy Newell on September 02, 2006, 10:24:26 am
Thanks, guys for a terrific plugin, this is just what I needed. This should be part of the core!
Title: Re: File replacement plugin
Post by: Bazzah on November 18, 2006, 11:21:10 am
Great plug in - just what I wanted.

However, I am using this with 'Permanant watermark with undo possibility (GD2+IM working!) + better admin tools' mod. If you use this replace file mod, it does not redraw the watermark. Is this something I have done wrong, or is there possibly a fix for it?
Title: Re: File replacement plugin
Post by: wirewolf on December 01, 2006, 02:58:46 am
Paver and all, great plugin. Very handy. I was playing around with the codebase file and added this bit of user friendliness (for those with short term memory). See the screenshot.
Near the end of codebase.php
Code: [Select]
echo <<< EOT
<tr>
<td class="tableb" valign="top">
Browse:
</td>
<td class="tableb" valign="top">
<input type="file" name="fileupload" size="40" class="listbox" />
</td>
</tr>
<tr>
<td align="center" colspan="2" class="tablef">
<input type="submit" name="commit" class="button" value="Upload"/>
</td>
</tr>

EOT;
Replaced with:
Code: [Select]
echo <<< EOT
<tr>
    <td class="tableb" valign="top">
      <input type="file" name="fileupload" size="70" class="listbox" /><br /><br />
      <input type="submit" name="commit" class="button" value="Upload" /><br /><br />File you wish to replace - $row[filename]</td>
    <td class="tableb" valign="top">
    <img src="albums/$row[filepath]thumb_$row[filename]" class="image" border="0" title="$row[filename]" alt="$row[filename]" /></a>
    </td>
</tr>
EOT;

wirewolf
Title: Re: File replacement plugin
Post by: majay on December 11, 2006, 09:04:08 pm
This is exactly what I needed, thanks!
Title: Re: File replacement plugin
Post by: MarkP on January 14, 2007, 05:22:56 pm
I have a little problem with the plugin...whenever a photo gets replaced the watermark goes away.
Title: Re: File replacement plugin
Post by: Stramm on January 14, 2007, 07:44:22 pm
If you use my watermarking mod or the modpack then try the attached, modded file replacer plugin. It's enhanced to also replace the mini thumb and the original backup file (if set in the config and/ or watermarking is enabled). Also (if set in the config) it'll crop the thumbs and sharpen them.

btw., sweet plugin, Nibbler

edit: I've nearly forgotten to say... I haven't tested that much... just replaced one image. So there may be glitches.
Title: Re: File replacement plugin
Post by: MarkP on January 16, 2007, 06:02:00 am
Works great! I have your mod pack installed. Thanks!
Title: Re: File replacement plugin
Post by: July3 on February 28, 2007, 11:54:19 pm
Hello, my English is very bad. But i hope you understand my Problem with the Replacer-Plugin. Does it work only with Pictures or also with Videos? Because i would like to replace a video in my Gallery but i will not loose the comments and the number of views.
Title: Re: File replacement plugin
Post by: Nibbler on March 01, 2007, 12:02:45 am
Should do. Try it and see.
Title: Re: File replacement plugin
Post by: July3 on March 01, 2007, 12:08:32 am
I try it, but everytime a error comes. It said he can not Load the file to the server  ???
Title: Re: File replacement plugin
Post by: midnightshowx0 on October 11, 2007, 03:30:12 pm
Where do I upload the files? Is it the plugin folder? Cause I just tried that, and the button didn't show up.
Title: Re: File replacement plugin
Post by: François Keller on October 11, 2007, 04:29:13 pm
have you read the doc  ? http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#plugin_manager_install (http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#plugin_manager_install)
i think you will find the answer here  ;)
Title: Re: File replacement plugin
Post by: taiofmine on February 09, 2008, 10:46:56 pm
For some reason, it made the replaced image all pixel-y...
[Edit GauGau] Replaced hotlinked image with attachment [/Edit]
...like that.

Is there something I missed that will make the new image display properly?
Title: Re: File replacement plugin
Post by: Joachim Müller on February 10, 2008, 12:10:34 am
If the replacement file has a different resolution to the original pic you should use the admin tools to resize.
Title: Re: File replacement plugin
Post by: Trev98 on March 27, 2008, 01:50:43 am
Excellent plugin! Works perfectly. Thanks very much, and to wirewolf for the nifty little mod, too. ;D
Title: Re: File replacement plugin
Post by: dwo on August 16, 2008, 08:42:30 pm
Seems to be a very good plugin.

Unfortunately, I deleted all buttons under the intermediate pic, so there is no button appearing for me.

Is it possible to get the link/button under "edit files" in the thumbnail overview?

Must be line 34/35, or ?

Thank you very much, regards Dietmar
Title: Re: File replacement plugin
Post by: dwo on August 17, 2008, 09:27:21 am
solved.

Its just the {ADMIN_MENU}  in theme.php which decides where the button gets.

thank you very much for the plugin.
Title: Re: File replacement plugin - BUG
Post by: dwo on August 17, 2008, 11:11:46 pm
Hello.

There is one serious bug if you use 1.1 version which uses the new filename.

example:
the picture to be replaced is named pic1

the new picture is named pic2

(!) if there is already a pic named pic 2 in the folder, this makes great problems with thumbnails etc. At least with me right now.

regards, dietmar



Title: Re: File replacement plugin
Post by: jManuel on October 16, 2008, 10:21:04 pm
Hi,

For spanish users, spanish version "File replacement plugin Ver.1.1 in spanish".

(Added): "lang spanish interface" ,"Cancel button".

Great plugin
Title: Re: File replacement plugin
Post by: HollowMac on August 03, 2009, 01:37:02 am
Hello,

I am French.
I am interested by this plugin but it dit not rename and resize pictures according to regulations in admin panel. So, i have changed the code :

------

Salut,
Je suis français.
J'étais intéressé par ce plugin mais il ne renommait ni ne redimensionnait les images d'après les réglages indiqués dans le panneau d'administration. J'ai donc changé le code pour qu'il le fasse :

Code: [Select]

if (count($_FILES) && $row){



if ($_FILES['fileupload']['error']) die('Upload error ' . $_FILES['fileupload']['error']);


// If magic quotes is on, remove the slashes it added to the file name.
                    if (get_magic_quotes_gpc()) $_FILES['fileupload']['name'] = stripslashes($_FILES['fileupload']['name']);

                    // Create the holder $picture_name by translating the file name. Translate any forbidden character into an underscore.
                    $_FILES['fileupload']['name'] = replace_forbidden($_FILES['fileupload']['name']);


if (REPLACER_USE_NEW_FILENAME) {

$rfilename = $_FILES['fileupload']['name'];

cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filename ='$rfilename' WHERE pid = '$pid' LIMIT 1");

$old_filename = $row['filename'];

$old_image = $CONFIG['fullpath'] . $row['filepath'] . $old_filename;

$old_normal = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['normal_pfx'] . $old_filename;

$old_thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $old_filename;

unlink($old_image);

unlink($old_normal);

unlink($old_thumb);

} else {

$rfilename = $row['filename'];

}



$image = $CONFIG['fullpath'] . $row['filepath'] . $rfilename;

$normal = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['normal_pfx'] . $rfilename;

$thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $rfilename;



move_uploaded_file($_FILES['fileupload']['tmp_name'], $image);

chmod($image, octdec($CONFIG['default_file_mode']));



require('include/picmgmt.inc.php');


if (is_known_filetype($image)){



if (is_image($image)){


resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);

resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
resize_image($image, $image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);


list($width, $height) = getimagesize($image);



} else {

$width = 0;

$height = 0;

}



$image_filesize = filesize($image);

$total_filesize = $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb);



cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filesize = '$image_filesize', total_filesize = '$total_filesize', pwidth = '$width', pheight = '$height' WHERE pid = '$pid' LIMIT 1");



// addition by Andi to parse EXIF info of new file

if ($CONFIG['read_exif_data']) {

    include("include/exif_php.inc.php");

    exif_parse_file($image);

}

// end addition



$CONFIG['site_url'] = rtrim($CONFIG['site_url'], '/');

} else {

@unlink($image);

}

header("Location: {$CONFIG['site_url']}/displayimage.php?pos=-$pid");

die();





}


 ;)

Thank you for this plugin. :-*
Title: Re: File replacement plugin
Post by: ondynek on August 03, 2009, 09:31:56 pm
Hello,
thank You very much for plugin - it is awesome, but I would like to ask You one thing - EXIF reading doesn't work for me (I used  Paver version, I tried also Nibbler version with manual update of codebase.php file). Is there any change in Exif reading?
Thank You in advance
Title: Re: File replacement plugin
Post by: Joachim Müller on August 04, 2009, 09:17:13 am
Start a thread of your own on the support board for your individual issues, doing as suggested per board rules (http://forum.coppermine-gallery.net/index.php/topic,55415.0.html) (posting a link to your gallery in your thread etc.)
Title: Re: File replacement plugin
Post by: Bradster on October 15, 2009, 03:12:24 pm
Neat plugin, but the download link on the main Plugins page goes to 'file2albummover' (the plugin just above it), which gives a catastrophically different result when you're not paying attention.
Title: ffxiv
Post by: qxq_0o0 on October 20, 2010, 10:43:05 am
ok
Title: Re: File replacement plugin
Post by: mr.bena on April 06, 2011, 12:28:05 am
Hi when I click the "Replace File" it shows "The Selected Album/File does not exits!". What could be the problem?