Permanant watermark with undo possibility (GD2+IM working!) + better admin tools - Page 10 Permanant watermark with undo possibility (GD2+IM working!) + better admin tools - Page 10
 

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

Permanant watermark with undo possibility (GD2+IM working!) + better admin tools

Started by Stramm, March 31, 2006, 03:33:15 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

MastiMasti

Dear Stramm
work pretty nice I just INSTALL IT NOW
I did tried yesterday but I think I were missing something today backup and tried again
now it's work fine

10+ great work

cong

hello

i have problem

i do all steps as you said in mod but after i applied the mod i can't access the admin tools page and i get this message
"There was an error while processing a database query "

and when i active image watermarking in config and click yes and after that when i go to config i found that  image watermarking is not active and mark "no" instead of yes

thank you stramm

cong

i did steps again and now config page is ok and the mod work nice
i am beginner in php so i can't understand this step ( what exact code that i remove it and put this code )





replace the entire function update_thumbs() with


Code:
function update_thumbs()
{
        global $CONFIG, $lang_util_php;

        $albumid = (isset($_REQUEST['albumid'])) ? $_REQUEST['albumid'] : 0;
        $albstr = ($albumid) ? "WHERE aid = $albumid" : '';
        $autorefresh = $_REQUEST['autorefresh'];
        $updatetype = $_REQUEST['updatetype'];
        $numpics = $_REQUEST['numpics'];
        $startpic = (isset($_REQUEST['startpic'])) ? $_REQUEST['startpic'] : 0;

        echo "<h2>{$lang_util_php['thumbs_wait']}</h2>";

        $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} $albstr LIMIT $startpic, $numpics");
        $count = mysql_num_rows($result);

        while ($row = mysql_fetch_assoc($result)){

                $image = $CONFIG['fullpath'] . $row['filepath'] . $row['filename'];
                $normal = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['normal_pfx'] . $row['filename'];
                $thumb = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['thumb_pfx'] . $row['filename'];
                $mini = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['mini_pfx'] . $row['filename'];
            $orig=$CONFIG['fullpath'] . $row['filepath'] . $CONFIG['orig_pfx'] . $row['filename'];
            
            if (file_exists($orig)) {
               $work_image=$orig;
               $orig_true='true';
            } else {
               $work_image=$image;
               $orig_true='false';
            }
            
        $imagesize = getimagesize($work_image);
        if ($updatetype == 0 || $updatetype == 2 || $updatetype == 5)  {
            if (resize_image($work_image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], "false", 1)) {
                echo $thumb .' '. $lang_util_php['updated_succesfully'] . '!<br />';
                my_flush();
            } else {
                echo $lang_util_php['error_create'] . ':$thumb<br />';
                my_flush();
            }
           if ($CONFIG['enable_mini_thumbs'] == '1') {
               if (resize_image($work_image, $mini, $CONFIG['mini_thumb_width'], $CONFIG['thumb_method'], "mini", "false", 1)) {
                   echo $mini .' '. $lang_util_php['updated_succesfully'] . '!<br />';
                   my_flush();
               } else {
                   echo $lang_util_php['error_create'] . ':$mini<br />';
                   my_flush();
               }
         }
      }

        if ($updatetype == 1 || $updatetype == 2 || $updatetype == 3 || $updatetype == 5)
         {
            ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'resized') ? $watermark="true" : $watermark="false";
            if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'])
            {
                if (resize_image($work_image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'], $watermark))
               {
                    echo $normal . " " . $lang_util_php['updated_succesfully'] . '!<br />';
                    my_flush();
               }
                else
               {
                    echo $lang_util_php['error_create'] . ':$normal<br />';
                    my_flush();
                   }
               }
         }
        if ($updatetype == 3 || $updatetype == 4 || $updatetype == 5) 
         {
         ($CONFIG['thumb_use'] == "ex") ? $resize_method = "any" : $resize_method = $CONFIG['thumb_use'];

           if (((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1) || (!USER_IS_ADMIN && $CONFIG['auto_resize'] > 0)) && max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']){ //$CONFIG['auto_resize']==1
            $max_size_size = $CONFIG['max_upl_width_height'];
         }
         else {
            $resize_method = "orig";
            $max_size_size = max($imagesize[0], $imagesize[1]);
         }
         if ($orig_true == 'false')
            {
            if (copy($image, $orig))
               {             
                    if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')
                     {
                        if (resize_image($work_image, $image, $max_size_size, $CONFIG['thumb_method'], $resize_method, 'true'))
                           {
                               echo $image . " " . $lang_util_php['updated_succesfully'] . '!<br />';
                               my_flush();
                           }
                            else
                           {
                                echo $lang_util_php['error_create'] . ':$image<br />';
                                my_flush();
                               }
                     }
               }
            } else {
                 if ($CONFIG['enable_watermark'] == '1' && $CONFIG['which_files_to_watermark'] == 'both' || $CONFIG['which_files_to_watermark'] == 'original')
                  {
                     if (resize_image($work_image, $image, $max_size_size, $CONFIG['thumb_method'], $resize_method, 'true'))
                        {
                            echo $image . " " . $lang_util_php['updated_succesfully'] . '!<br />';
                            my_flush();
                        }
                         else
                        {
                             echo $lang_util_php['error_create'] . ':$image<br />';
                             my_flush();
                            }
               } else {
                    if (((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1) || (!USER_IS_ADMIN && $CONFIG['auto_resize'] > 0)) && max($imagesize[0], $imagesize[1]) > $CONFIG['max_upl_width_height']){
                     if (resize_image($work_image, $image, $max_size_size, $CONFIG['thumb_method'], $resize_method, 'false'))
                        {
                            echo $image . " " . $lang_util_php['updated_succesfully'] . '!<br />';
                            my_flush();
                        }
                         else
                        {
                             echo $lang_util_php['error_create'] . ':$image<br />';
                             my_flush();
                            }
                  } elseif (copy($orig, $image))
                     {
                          echo $orig . " " . $lang_util_php['updated_succesfully'] . '!<br />';
                          my_flush();
                     }
                      else
                     {
                          echo $lang_util_php['error_create'] . ':$image<br />';
                          my_flush();
                         }
                  }
               }
            }
          $imagesize = getimagesize($image);
      $query_up = "UPDATE {$CONFIG['TABLE_PICTURES']} SET pwidth='$imagesize[0]' , pheight='$imagesize[1]' WHERE pid='".$row['pid']."' ";
      cpg_db_query($query_up);
      }

        if ($count == $numpics){

                $startpic += $numpics;
            if($autorefresh) {
               echo <<< EOT
               <meta http-equiv="refresh" content="1; URL=util.php?numpics={$numpics}&startpic={$startpic}&albumid={$albumid}&autorefresh={$autorefresh}&action=update_thumbs&updatetype={$updatetype}">
EOT;
            }
            else
            {
                 echo <<< EOT
                   <form action="util.php" method="post">
                                   <input type="hidden" name="action" value="update_thumbs" />
                                   <input type="hidden" name="numpics" value="$numpics" />
                                   <input type="hidden" name="startpic" value="$startpic" />
                                   <input type="hidden" name="updatetype" value="$updatetype" />
                                   <input type="hidden" name="albumid" value="$albumid" />
                                   <input type="hidden" name="autorefresh" value="$autorefresh" />
                                   <input type="submit" value="{$lang_util_php['continue']}" class="button" />
                   </form>
EOT;
            }
        }
      else echo $lang_util_php['finished'];
}

function deletbackup_img()
{
        global $CONFIG, $lang_util_php;

        $albumid = (isset($_POST['albumid'])) ? $_POST['albumid'] : 0;
        $albstr = ($albumid) ? "WHERE aid = $albumid" : '';

        $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} $albstr");
        $num = mysql_num_rows($result);
    $i = 0;
    while ($i < $num) {
        $pid = mysql_result($result, $i, "pid");
        $back = $CONFIG['fullpath'] . mysql_result($result, $i, "filepath") . $CONFIG['orig_pfx'] . mysql_result($result, $i, "filename");

        if (file_exists($back)) {
         if(unlink($back)){
                printf("Success".$lang_util_php['main_success'], $back);
                print '!<br>';
            }
            } else {
                printf("Error".$lang_util_php['error_rename'], $back);
            }
        ++$i;
    }
}


cong

i solved all problems   8)
and the mod is very very very very gooooood
and you stramm is very very very goooood  ;D ;D

JJRuhle

He says: "now just replace include/picmgmnt.inc.php with the attached one"

But there is no such file attached to his post. Where do I get it?

JJRuhle

Nevermind... just found it attached to the first post, instead of the one it is mentioned in.

rajraj

hi, i am new - just got the gallery and wondering how would i add watermaking mod to my cofig?

i notice in your instructions on 1st post to edit a code ...where is this code found, which i am supposed to edit to get watermark?

i got this gallery function on my website by installing it from my control panel from my hosting website - so its offered as standard you can say.

therefore i have no access - or i think i have no access to the code of my gallery.

please help me find this place where i am suppose to edit this code to make all my images secure with watermark as its vital for me.

also is this the latest and best solution we have so far - as it seems there have been soo many mods.

thanks


Stramm

None of the supporters here know your server. What OS, what directory layout etc. Therefore we can't give you advice. Ask your webhost to find out. Sometimes it's enough to use a ftp client and to browse your server to find out.

This solution with some changes will be part of the next coppermine version. The latest version of that mod is always part of the modpack (found on the mods board also). The picmgmnt.inc.php file you can download in this thread isn't the latest version. You can use the one from the modpack.

LWAA

could you please tell me where to download the latest version of this?

thanks.
<i>"I understand everything, except what you're telling me"</i>

Stramm


jw0ollard

Can't you somehow put a chmod() command into one of the PHP files to automatically set the image permissions to 666?

I keep forgetting to chmod the files when using Batch Upload, and it's getting very annoying.

I've been trying this myself,  but I can't find where exactly to put the chmod() code.  ???

Stramm

coppermine already does that (see config), however batch uploading is FTP, and the files you upload do not go through a php file. Just when you want to watermark them it's necessary. But without the necessary permission php only can read the files but not save them. You only can do that with your ftp client.

jw0ollard

You didn't understand what I was asking.  I'm aware of all that,  but what I'm asking is wouldn't it be more simple to actually write a chmod command into the PHP file that handles batch uploaded images?

http://www.php.net/chmod

That way it would be automated and wouldn't require any chmodding through FTP.

Esp. read this comment: http://www.php.net/manual/en/function.chmod.php#73147

I'm not skilled enough with PHP to do this,  but surely if you were smart enough to write all the watermarking code, you'd know how to add a CHMOD command right into the PHP file?

Having to change file permissions every time I batch upload images is just NOT an option for me.

Stramm

No, I guess you didn't understand me. If you upload by FTP and don't set the necessray permissions for php (GD2) or ImageMagick to edit a pic, then of course php (GD2) and ImageMagick won't have the permission to change permissions. Otherwise the entire permission system is useless.
If a user doesn't have the permission to edit, then he (it) can't edit. Doesn't matter if it's the file itself or its permissions.

You could change your setup, let php run under your account. Or upload as http or php or whatever account php's running under.

jw0ollard

Yeah,  I guess you are still not understanding me.   ???

If you actually followed the links I showed you in the last post,  you'd see that you're able to use PHP code to connect ****VIA FTP**** and change the file permissions on the fly. So this would in a sense "automate" the Batch Uploading process as it was originally intended,  instead of uploading, changing permissions, and then finally batch uploading in Coppermine.  No extra steps,  no extra hassle,  no constantly forgetting to change the damn file permissions after you upload.

So tell me again why this can't be done through PHP?  :)

Like I said before,  I'm not an advanced coder,  but I don't see any problem in running the CHMOD via FTP code in the PHP file directly before GD2 works its watermarking magic??  I assume that even using batch upload,  the "picmgmt.inc.php" file is still loaded for the watermarking, but I have no idea where to add the code.

If you could actually take the time and read the words I'm typing this time, instead of just brushing me off and telling me I'm wrong,  I'd appreciate it. Thank you.

jw0ollard

I guess there is no edit button??

Edit:

Also,  if you'd very closely read the link I'm referring to (http://www.php.net/manual/en/function.chmod.php#73147), you'll notice this person is using this CHMOD via PHP method for image watermarking :

QuoteHere's a version that works with PHP 5.x - I use this to watermark images on a shared server.

Stramm

And you still didn't understand what I said. Coppermine chmods uploads (http) already (as mentioned above).
What you do is requesting a new feature (one that's neither implemented in Coppermine nor in this mod cause of possible php timeouts).

So what do you want me to tell you???
I won't implement something like that cause I consider it not practical?
No feature request in the mods board, there's already one dedicated to feature requests (board rules)?
Or should I say:
If you need it then code it. Not related to this mod.

I already toold you a possibility to get around that restriction (change your server setup).

Joachim Müller

[ot]
@Stramm:
Hehe, that's funny - Stramm (one of the Coppermine dev team's most skilled PHP coders) being sent to the PHP documentation page by someone who appears not to have understood the permissions concept behind Lunix *giggle*.
Sorry, Thomas - simply couldn't resist ;D.

@jw0ollard: as Stramm suggested: you can't assign/edit permissions on something that you don't already have permissions on. The whole point of permissions is that users who don't have them can't get them. Someone who has the permissions already needs to grant the unprivileged user the permissions he needs. Subsequently: if the script doesn't have permissions to CHMOD, then there's no use to issue PHP's chmod() command. This is in no way related to this mod, but a matter of server setup. Ranting on this thread about possible unrelated mods is not a bright idea. Telling skilled PHP developers to read up the PHP documentation and even insisting on being right even though Stramm has explained things in detail is not a bright idea neither.

Now let's close this unrelated discussion and return to the subject of this thread itself: the watermarking mod.

[/ot]

jw0ollard

Dear GauGau,

Hehe, I'M NOT talking about the PHP CHMOD() COMMAND!  Jesus!

Could you please do your job, GauGau, instead of writing 185 words making fun of me? You obviously haven't read my posts.

Since you won't visit the freaking links I've posted here,  here's what I was referring to.

<?php
// Connect to the FTP to chmod the file via FTP

$ftpUserName 'username';
$ftpUserPass 'userpass';
$ftpServer 'ftp.example.com';

  
$ftpConn ftp_connect($ftpServer);
 
  if (!
$ftpConn) {
    die(
"Unable to connect to $ftpServer");
  }

if (@
ftp_login($conn_id$ftpUserName$ftpUserPass)) {
   echo 
"Connected as $ftpUserName @ $ftpServer";
}
else {
   echo 
"Couldn't connect as $ftpUserName";
   
ftp_close($ftpConn);
   die(
"Closed connection to $ftpServer");
}

//Now change permissions to 666 or whatever you need

echo ftp_chmod($ftpConn0666$ftpFilename) ? "CHMOD successful!" 'Error';

// do what you need here

//Now change permissions back to 644 or whatever
echo ftp_chmod($ftpConn0644$ftpFilename) ? "CHMOD successful!" 'Error';

// Close the connection
ftp_close($conn_id);
?>


Does that look like a chmod() command GauGau?? NO.  So, again,  please read the discussion again.

Just because you're both developers does NOT make you right on this.  Quit disregarding everything everyone ever says on this board just because you automatically think you're right.

Now,  I'm not saying that I was in fact right,  but I was TRYING to suggest that the FTP_CHMOD() commands could be used to make sure the images were set to 0666 during the Batch Upload process.  OK??

I appreciate Stramm for his input, and I understand why he thinks that such a thing could not be implemented,  but you,  GauGau,  can you please apologize to me for wasting 185 words on making fun of me for absolutely no reason? I did not once insist I was right about anything, but it was also painfully clear that Stramm had not followed the link because the first TWO of his posts are all referring to the chmod() command when I was in fact asking about the ftp_chmod() command.  OK?

It's not my fault that I had to reiterate what I was saying a dozen times. 

Anyway,  I'm certainly never suggesting things on this board again, and I don't feel like I could possibly get any help from a developer who acts like a child.

P.S. I fully understand the permissions concept behind "Lunix," GauGau.  *giggle*
----------------------------------------

Now, back on topic.  I've just noticed that changing the Transparency value in the Config doesn't actually do anything for me.  I installed it and then installed the upgrade for resizing watermarks, both correctly.  There is a 0.0001% chance that I followed the directions wrong, unless I'm a complete idiot like GauGau was implying.  :)

Tata! 

Stramm

Quote from: jw0ollard on June 06, 2007, 11:19:52 PM
Now, back on topic.  I've just noticed that changing the Transparency value in the Config doesn't actually do anything for me.  I installed it and then installed the upgrade for resizing watermarks, both correctly.  There is a 0.0001% chance that I followed the directions wrong, unless I'm a complete idiot like GauGau was implying.  :)

Tata! 

Just read the first post of this thread. It answers your question.