File replacement plugin File replacement plugin
 

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

File replacement plugin

Started by Nibbler, August 26, 2005, 04:55:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nibbler

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.

flashi

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

Nibbler

Look in the plugin's codebase.php for

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

and add after it

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

flashi

Wow, that was a fast solution  :o

I thank you very much, everything works fine now  ;D

LilAngel

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.

Beyond_Doubt

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...
require ('plugins/control_fullsize/include/init.inc.php');
to
require (dirname(__FILE__).'/include/init.inc.php');


However I am very eager to use the 'File Replacer' Plugin that can be found here.

But when I use that Plugin, and then click on the 'Replace File' button I get the following error message...
QuoteSorry, 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!

Andi

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.
hope, I could help you... :)

Beyond_Doubt

Thank You to Nibbler for the very usefull plugin, and Thank You to Andi for helping me to use it!

Great Work Fellas. :)

Andi

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:
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:
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...
hope, I could help you... :)

Paver

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):
include("include/exif_php.inc.php");

Visiluna

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

Paver

#11
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.

Visiluna

Thank you, thank you, thank you.

Did I mention that you guys are awesome?

Thank you again,
PJ

Eugene Merzlyakov

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?

Paver

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.

midnightshowx0

im a little confused here, where do i put this at??

Paver


Eddy Newell

Thanks, guys for a terrific plugin, this is just what I needed. This should be part of the core!
Eddy|eddynewell.com
Coppermine 1.4.9 bridged with SMF 1.1RC3

Bazzah

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?

wirewolf

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
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:
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