[TIP] "original" image file delete prevention [TIP] "original" image file delete prevention
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[TIP] "original" image file delete prevention

Started by wooff, May 25, 2006, 09:31:20 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

wooff

Hi,
I change the code to prevent deleting of "original" images files. Now, when you want to delete albums or files. It will delete only: thumbnails, reduce size, comments, (album). The original file will stay untoched.

Edit file /cpg/delete.php

$files = array($dir . $file, $dir . $CONFIG['normal_pfx'] . $file, $dir . $CONFIG['thumb_pfx'] . $file);
    foreach ($files as $currFile) {
        echo "<td class=\"tableb\" align=\"center\">";
        if (is_file($currFile)) {
            if (@unlink($currFile))
                echo $green;
            else
                echo $red;
        } else
            echo "&nbsp;";
        echo "</td>";

replace with

$files = array($dir . nodelete, $dir . $CONFIG['normal_pfx'] . $file, $dir . $CONFIG['thumb_pfx'] . $file);
    foreach ($files as $currFile) {
        echo "<td class=\"tableb\" align=\"center\">";
        if (is_file($currFile)) {
            if (@unlink($currFile))
                echo $green;
            else
                echo $red;
        } else
            if ($currFile == $dir . nodelete) {
            echo $red;
            } else
              echo "&nbsp;";
        echo "</td>";


Result will look like on the attached picture.
Base of this I found on this forum. I thought that "Nibbler" post it, but Iam not sure. Thank to him or anybody else ((-:
Have a nice day ((-:
W

cgc0202

#1
Quote from: wooff on May 25, 2006, 09:31:20 PM
I change the code to prevent deleting of "original" images files. Now, when you want to delete albums or files. It will delete only: thumbnails, reduce size, comments, (album). The original file will stay untoched. ...
W


Hi wooff,

Paver directed me to your post, based from an inquiry I had:

http://forum.coppermine-gallery.net/index.php?topic=32316.msg150195

Is there a way so that your script may be revised further so that not only is the original photo, but also the thumbnails, intermediate photos, as well as other stuff associated with the photo (comments, caption, etc.) are retained?   The only thing that must be achieved is that the photo (i.e., thumbnail) link is deleted from a specific album.

If this could be done, the revised script may be used for a number of existing features of Coppermine.  For example, allowing "users" who post in public albums to edit their posted photos, without the ability to delete the original and derivative photo itself.  It may be useful also for those who would want to allow  Moderator mod of Abbas, but not allow a Moderator to have delete permissions.

cgc0202


wooff

hi, Iam not sure what do you want exactly.
This my very easy and small code isnt really plugin. Its just change of code whitch prevent the original file to be deleted.
I mean, prevent to be deleted by all ways. Because I removed pard of code which did it. And rerplace id with one who will show the red icon.
Thats all.
All other files are normally deleted. But Iam not sure about captions and thinks like this (strings variables). Iam not really sure where are they stored.
W

cgc0202

Thanks for the response.

Quote from: wooff on June 07, 2006, 07:13:37 AM
hi, Iam not sure what do you want exactly.
This my very easy and small code isnt really plugin. Its just change of code whitch prevent the original file to be deleted.
I mean, prevent to be deleted by all ways. Because I removed pard of code which did it. And rerplace id with one who will show the red icon.
Thats all.

For starters, I wonder if the thumbnails and intermediate photos may not be deleted also.

Quote from: wooff on June 07, 2006, 07:13:37 AM
All other files are normally deleted. But Iam not sure about captions and thinks like this (strings variables). Iam not really sure where are they stored.
W

The original and derivative photos themselves are stored normally in the Albums and its subdirectories.  As far as I know, all the rest are stored in specific tables in the database.

cgc0202

Joachim Müller

Coppermine doesn't store files in the db, neither thumbnails nor intermediate-sized files. All those files are stored in the same folder as the original pics. Inside the db, only relative paths are being stored, that's all.

cgc0202

Quote from: GauGau on June 07, 2006, 09:16:30 AM
Coppermine doesn't store files in the db, neither thumbnails nor intermediate-sized files. All those files are stored in the same folder as the original pics. Inside the db, only relative paths are being stored, that's all.

You are correct Gaugau, and that is what I stated in my previous post.  The photos for example are stored usually in the "albums" directory and its subdirectories "userpics" and another for those entered by the Admin using FTP.  In my case, I opted to place them in a separate directory and subdirectories -- independent of the CPG directory because I opted for multigalleries.

I have been analysing the DB tables of CPG because there are features that I wish to understand more.  I have not analyzed it fully and extensively yet, but in a specific table, the characteristics of the individual photos (size, width, length, etc), as well as other user inputs associated with each photo, are stored in that table.  I will post a separate thread in regard this issue, about photo-related stored info -- to further clarify the implications of editing the original photos.

cgc0202