write to file on adding photo

pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Mon, 2003-10-20 15:16

Hi,
using zman hack, i can have /classes/albums.php add a line to a .txt file which can then later be retrieved by the random photo script.
this is the code:

list($w, $h) = $item->getThumbDimensions($i); 
          if ($w <= 150 && $h <= 125) { 
             $random_file = fopen("/home/www/extreme-z.com/htdocs/appearance/my_photos.txt","a"); 
             $newline = $gallery->app->photoAlbumURL . "/" . $gallery->session->albumName . "/$name" . "|0|1|" . $gallery->app->albumDirURL . "/" . $gallery->session->albumName . "/$name.thumb.$tag" . "|$caption\r\n"; 
             fwrite($random_file,"$newline"); 
             fclose($random_file); 
          }

I am trying to have this line added too when i add a photo with gallery_remote2.php, however, i couldn t find where the code should be added...
can anyone help?

 
joel558
joel558's picture

Joined: 2003-04-10
Posts: 93
Posted: Mon, 2003-10-20 20:16

I changed a couple things to make it work for the gallery_remote2.php and variables it has. heres the version to add:

list($w, $h) = $photo->getThumbDimensions();
if ($w <= 150 && $h <= 125) {
  $random_file = fopen("/home/www/extreme-z.com/htdocs/appearance/my_photos.txt","a");
  $newline = $gallery->app->photoAlbumURL . "/" . $gallery->session->albumName . "/$name" . "|0|1|" . $gallery->app->albumDirURL . "/" . $gallery->session->albumName . "/$name.thumb.$tag" . "|$caption\r\n";
  fwrite($random_file,"$newline");
  fclose($random_file);
}

add that as indicated here(taken starting at line 501):

          $err = $gallery->album->addPhoto($file, $tag, $mangledFilename, $caption, "", $myExtraFields, $gallery->user->getUid());
          if (!$err) {
              /* resize the photo if needed */
              if ($gallery->album->fields["resize_size"] > 0 && isImage($tag)) {
                  $index = $gallery->album->numPhotos(1);
                  $photo = $gallery->album->getPhoto($index);
                  list($w, $h) = $photo->image->getRawDimensions();
                  if ($w > $gallery->album->fields["resize_size"] ||
                      $h > $gallery->album->fields["resize_size"]) {
                      $gallery->album->resizePhoto($index, $gallery->album->fields["resize_size"]);
                  }
              }
               //*********ADD CODE HERE****************
          } else {

this should work...

joel

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Thu, 2003-10-23 13:14

all right... thanks to you it works!
BUT! my remote_gallery2.php is in a different folder than my gallery installation.
my installation is in /ad
remote_gallery is in another (non-embedded / back up installtion) in /ad/gallery.
Therefore, $gallery->app->photoAlbumURL has /gallery at the end of its URL but it shouldn t...
what is my problem? is it due to gallery_basedir? should i change smth in the gallery_remote file or what?

also, $name is not the correct name of the file as it includes $tag... so, in gallery_remote2.php, in the little bit of code we add, we have to replace $name by $originalFilename. Also i noticed that gallery_remote has no code to clean $name in case it is a duplicate... at least, it is missing some code we find in /classes/albums.php... is it smth to change in future releases?

thanks for your help and time. :)
Paul

 
joel558
joel558's picture

Joined: 2003-04-10
Posts: 93
Posted: Sat, 2003-11-08 06:40

have you gotten this working?