[ PHPXref.com ] [ Generated: Sun Jul 20 19:30:10 2008 ] [ Photo Organizer 2.30 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/src/ -> bulk.update.php (source)

   1  <?php
   2  
   3  //  Copyright (C) 2002, 2003, 2004, 2005, 2006 Balint Kis (balint@k-i-s.net)
   4  
   5  //  This program is free software; you can redistribute it and/or modify
   6  //  it under the terms of the GNU General Public License as published by
   7  //  the Free Software Foundation; either version 2 of the License, or
   8  //  (at your option) any later version.
   9  
  10  //  This program is distributed in the hope that it will be useful,
  11  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  //  GNU General Public License for more details.
  14  
  15  //  You should have received a copy of the GNU General Public License
  16  //  along with this program; if not, write to the Free Software
  17  //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  18  
  19  include_once  "include/vars.php";
  20  include_once  "include/config.php";
  21  include_once  "include/tools.php";
  22  include_once  "include/mime.php";
  23  include_once "$theme/theme.php";
  24  
  25  $session_id = $_COOKIE[$po_cookie];
  26  if ($session_id == "") {
  27    header("location: login.php");
  28    exit();
  29  }
  30  
  31  $operator        = $_REQUEST['operator'];
  32  $rule_identifier = $_REQUEST['rule'];
  33  $select_folder   = $_REQUEST['select_folder'];
  34  
  35  if (!$select_folder) {
  36    /* return if no search criteria exists */
  37    header("location: my.tools.php?selector=1&rule=$rule_identifier");
  38  }
  39  
  40  include_once  "include/common.php";
  41  include_once  "include/site.php";
  42  include_once  "include/import.php";
  43  include_once  "include/database.php";
  44  
  45  $database = po_dbconnect();
  46  $my_user_id = pg_fetch_row(pg_query($database, "select identifier, type from users where session_id='$session_id'"));
  47  if ($my_user_id[1] < $user_type['user']) {
  48    pg_close($database);
  49    header("location: login.php");
  50    exit();
  51  }
  52  
  53  $set_rule_name              = $_REQUEST['set_rule_name'];
  54  $set_generate_thumbnail     = $_REQUEST['set_generate_thumbnail'];
  55  $set_generate_preview       = $_REQUEST['set_generate_preview'];
  56  
  57  $set_title                  = $_REQUEST['set_title'];
  58  $set_author                 = $_REQUEST['set_author'];
  59  $set_keyword                = $_REQUEST['set_keyword'];
  60  $set_headline               = $_REQUEST['set_headline'];
  61  $set_caption_writer         = $_REQUEST['set_caption_writer'];
  62  $set_caption                = $_REQUEST['set_caption'];
  63  $set_category               = $_REQUEST['set_category'];
  64  $set_supplemental_category  = $_REQUEST['set_supplemental_category'];
  65  $set_credit                 = $_REQUEST['set_credit'];
  66  $set_copyright              = $_REQUEST['set_copyright'];
  67  $set_web_statement          = $_REQUEST['set_web_statement'];
  68  $set_instructions           = $_REQUEST['set_instructions'];
  69  $set_source                 = $_REQUEST['set_source'];
  70  $set_transmission_reference = $_REQUEST['set_transmission_reference'];
  71  
  72  $set_date_of_exposure       = check_date_validity($_REQUEST['set_date_of_exposure']);
  73  $set_location               = $_REQUEST['set_location'];
  74  $set_access_rights          = $_REQUEST['set_access_rights'];
  75  $set_hide_original          = $_REQUEST['set_hide_original'];
  76  $set_camera                 = $_REQUEST['set_camera'];
  77  $set_camera_metering        = $_REQUEST['set_camera_metering'];
  78  $set_camera_program         = $_REQUEST['set_camera_program'];
  79  $set_lens                   = $_REQUEST['set_lens'];
  80  $set_focal_length           = $_REQUEST['set_focal_length'];
  81  $set_filter                 = $_REQUEST['set_filter'];
  82  $set_film                   = $_REQUEST['set_film'];
  83  $set_iso_override           = $_REQUEST['set_iso_override'];
  84  $set_aperture               = $_REQUEST['set_aperture'];
  85  $set_shutter                = $_REQUEST['set_shutter'];
  86  $set_exp_comp               = $_REQUEST['set_exp_comp'];
  87  $set_exp_diff               = $_REQUEST['set_exp_diff'];
  88  $set_flash                  = $_REQUEST['set_flash'];
  89  $set_flash_mode             = $_REQUEST['set_flash_mode'];
  90  $set_flash_comp             = $_REQUEST['set_flash_comp'];
  91  $set_scanner                = $_REQUEST['set_scanner'];
  92  $set_scan_resolution        = $_REQUEST['set_scan_resolution'];
  93  $set_scan_bitdepth          = $_REQUEST['set_scan_bitdepth'];
  94  $set_scan_multiscan         = $_REQUEST['set_scan_multiscan'];
  95  $set_support                = $_REQUEST['set_support'];
  96  
  97  if ($rule_identifier) {
  98    if ($operator == "save") {
  99      /* update exisiting new rule */
 100      $result = pg_query($database, "
 101       update bulk_update_rule set
 102         rule_name              = '$set_rule_name',
 103         regenerate_thumbnail   = '$set_generate_thumbnail',
 104         regenerate_preview     = '$set_generate_preview',
 105         title                  = '$set_title',
 106         author                 = '$set_author',
 107         keyword                = '$set_keyword',
 108         headline               = '$set_headline',
 109         caption_writer         = '$set_caption_writer',
 110         caption                = '$set_caption',
 111         category               = '$set_category',
 112         supplemental_category  = '$set_supplemental_category',
 113         credit                 = '$set_credit',
 114         copyright_statement    = '$set_copyright',
 115         web_statement          = '$set_web_statement',
 116         instructions           = '$set_instructions',
 117         source                 = '$set_source',
 118         transmission_reference = '$set_transmission_reference',
 119         date_of_exposure       = $set_date_of_exposure,
 120         access_rights          = $set_access_rights,
 121         hide_original          = '$set_hide_original',
 122         location               = $set_location,
 123         camera                 = $set_camera,
 124         camera_metering        = $set_camera_metering,
 125         camera_program         = $set_camera_program,
 126         lens                   = $set_lens,
 127         focal_length           = $set_focal_length,
 128         filter                 = $set_filter,
 129         film                   = $set_film,
 130         iso_override           = $set_iso_override,
 131         aperture               = $set_aperture,
 132         shutter                = $set_shutter,
 133         exposure_comp          = $set_exp_comp,
 134         ev_difference          = $set_exp_diff,
 135         flash                  = $set_flash,
 136         flash_mode             = $set_flash_mode,
 137         flash_comp             = $set_flash_comp,
 138         scanner                = $set_scanner,
 139         scan_resolution        = $set_scan_resolution,
 140         scan_bitdepth          = $set_scan_bitdepth,
 141         scan_multiscan         = $set_scan_multiscan,
 142         support                = $set_support
 143       where identifier = $rule_identifier");
 144    }
 145    else if ($operator == "delete") {
 146      $result = pg_query($database, " delete from bulk_update_rule where identifier = $rule_identifier");
 147    }
 148  }
 149  else {
 150    /* create a new rule */
 151    if ($operator == "save") {
 152      $new_rule_identifier = pg_fetch_row(pg_query($database, "select nextval('bulk_update_rule_id_sequence')"));
 153      $rule_identifier = $new_rule_identifier[0];
 154      $result = pg_query($database, "
 155       insert into bulk_update_rule (identifier, users, rule_name, regenerate_thumbnail, regenerate_preview, title, author, keyword, headline,
 156         caption_writer, caption, category, supplemental_category, credit, copyright_statement,
 157         web_statement, instructions, source, transmission_reference, date_of_exposure, access_rights,
 158         hide_original, location, camera, camera_metering, camera_program, lens, focal_length,
 159         filter, film, iso_override, aperture, shutter, exposure_comp, ev_difference, flash,
 160         flash_mode, flash_comp, scanner, scan_resolution, scan_bitdepth, scan_multiscan, support)
 161       values ($rule_identifier, $my_user_id[0], '$set_rule_name', '$set_generate_thumbnail', '$set_generate_preview', '$set_title', '$set_author', '$set_keyword', '$set_headline',
 162         '$set_caption_writer', '$set_caption', '$set_category', '$set_supplemental_category', '$set_credit', '$set_copyright',
 163         '$set_web_statement', '$set_instructions', '$set_source', '$set_transmission_reference', $set_date_of_exposure, $set_access_rights,
 164         '$set_hide_original', $set_location, $set_camera, $set_camera_metering, $set_camera_program, $set_lens, $set_focal_length,
 165         $set_filter, $set_film, $set_iso_override, $set_aperture, $set_shutter, $set_exp_comp, $set_exp_diff, $set_flash,
 166         $set_flash_mode, $set_flash_comp, $set_scanner, $set_scan_resolution, $set_scan_bitdepth, $set_scan_multiscan, $set_support)");
 167    }
 168  }
 169  
 170  if ($operator != "submit") {
 171    /* return if a rule operation was performed */
 172    pg_close($database);
 173    header("location: my.tools.php?selector=1&rule=$rule_identifier");
 174  }
 175  
 176  site_header($page_width, "Display Tools");
 177  site_navigator(10, $my_user_id[1]);
 178  site_navigator_staus("<a href=\"user.php\">Users</a> : My Tools", "");
 179  
 180  print "&nbsp;<br/>";
 181  display_navigator_box_top($tools_data['bulkupdate']['idx'], $tools_data, "100%");
 182  
 183  $update_photo = false;
 184  $update_photo_tech = false;
 185  
 186  if ($set_title                     ) { $update_photo = true; $sql_title                  = " title = '$set_title', "; }
 187  if ($set_author                    ) { $update_photo = true; $sql_author                 = " author = '$set_author', "; }
 188  if ($set_keyword                   ) { $update_photo = true; $sql_keyword                = " keyword = '$set_keyword', "; }
 189  if ($set_headline                  ) { $update_photo = true; $sql_headline               = " headline = '$set_headline', "; }
 190  if ($set_caption_writer            ) { $update_photo = true; $sql_caption_writer         = " caption_writer = '$set_caption_writer', "; }
 191  if ($set_caption                   ) { $update_photo = true; $sql_caption                = " caption = '$set_caption', "; }
 192  if ($set_category                  ) { $update_photo = true; $sql_category               = " category = '$set_category', "; }
 193  if ($set_supplemental_category     ) { $update_photo = true; $sql_supplemental_category  = " supplemental_category = '$set_supplemental_category', "; }
 194  if ($set_credit                    ) { $update_photo = true; $sql_credit                 = " credit = '$set_credit', "; }
 195  if ($set_copyright                 ) { $update_photo = true; $sql_copyright              = " copyright_statement = '$set_copyright', "; }
 196  if ($set_web_statement             ) { $update_photo = true; $sql_web_statement          = " web_statement = '$set_web_statement', "; }
 197  if ($set_instructions              ) { $update_photo = true; $sql_instructions           = " instructions = '$set_instructions', "; }
 198  if ($set_source                    ) { $update_photo = true; $sql_source                 = " source = '$set_source', "; }
 199  if ($set_transmission_reference    ) { $update_photo = true; $sql_transmission_reference = " transmission_reference = '$set_transmission_reference', "; }
 200  if ($set_date_of_exposure != "null") { $update_photo = true; $sql_date_of_exposure       = " date_of_exposure = $set_date_of_exposure, "; }
 201  if ($set_location != "null"        ) { $update_photo = true; $sql_location               = " location = $set_location, "; }
 202  if ($set_access_rights != "null"   ) { $update_photo = true; $sql_access_rights          = " access_rights = $set_access_rights, "; }
 203  if ($set_hide_original != "null"   ) { $update_photo = true; $sql_hide_original          = " hide_original = '$set_hide_original', "; }
 204  
 205  
 206  if ($set_camera != "null"          ) { $update_photo_tech = true; $sql_camera           = " camera = $set_camera, "; }
 207  if ($set_camera_metering != "null" ) { $update_photo_tech = true; $sql_camera_metering  = " camera_metering = $set_camera_metering, "; }
 208  if ($set_camera_program != "null"  ) { $update_photo_tech = true; $sql_camera_program   = " camera_program = $set_camera_program, "; }
 209  if ($set_lens != "null"            ) { $update_photo_tech = true; $sql_lens             = " lens = $set_lens, "; }
 210  if ($set_focal_length != "null"    ) { $update_photo_tech = true; $sql_focal_length     = " focal_length = $set_focal_length, "; }
 211  if ($set_filter != "null"          ) { $update_photo_tech = true; $sql_filter           = " filter = $set_filter, "; }
 212  if ($set_film != "null"            ) { $update_photo_tech = true; $sql_film             = " film = $set_film, "; }
 213  if ($set_iso_override != "null"    ) { $update_photo_tech = true; $sql_iso_override     = " iso_override = $set_iso_override, "; }
 214  if ($set_aperture != "null"        ) { $update_photo_tech = true; $sql_aperture         = " aperture = $set_aperture, "; }
 215  if ($set_shutter != "null"         ) { $update_photo_tech = true; $sql_shutter          = " shutter = $set_shutter, "; }
 216  if ($set_exp_comp != "null"        ) { $update_photo_tech = true; $sql_exp_comp         = " exposure_comp = $set_exp_comp, "; }
 217  if ($set_exp_diff != "null"        ) { $update_photo_tech = true; $sql_exp_diff         = " ev_difference = $set_exp_diff, "; }
 218  if ($set_flash != "null"           ) { $update_photo_tech = true; $sql_flash            = " flash = $set_flash, "; }
 219  if ($set_flash_mode != "null"      ) { $update_photo_tech = true; $sql_flash_mode       = " flash_mode = $set_flash_mode, "; }
 220  if ($set_flash_comp != "null"      ) { $update_photo_tech = true; $sql_flash_comp       = " flash_comp = $set_flash_comp, "; }
 221  if ($set_scanner != "null"         ) { $update_photo_tech = true; $sql_scanner          = " scanner = $set_scanner, "; }
 222  if ($set_scan_resolution != "null" ) { $update_photo_tech = true; $sql_scan_resolution  = " scan_resolution = $set_scan_resolution, "; }
 223  if ($set_scan_bitdepth != "null"   ) { $update_photo_tech = true; $sql_scan_bitdepth    = " scan_bitdepth = $set_scan_bitdepth, "; }
 224  if ($set_scan_multiscan != "null"  ) { $update_photo_tech = true; $sql_scan_multiscan   = " scan_multiscan = $set_scan_multiscan, "; }
 225  if ($set_support != "null"         ) { $update_photo_tech = true; $sql_support          = " support = $set_support, "; }
 226  
 227  if ($select_folder == "all") {
 228    $sql_selector = " users = $my_user_id[0] ";
 229  }
 230  else {
 231    $sql_selector = " folder = $select_folder ";
 232  }
 233  
 234  $num_of_updates = pg_fetch_row(pg_query($database, "
 235    select count(identifier) from photo
 236     where $sql_selector"));
 237  
 238  if ($update_photo) {
 239    /* append all strings */
 240    $sql_appended = $sql_title.$sql_author.$sql_keyword.$sql_headline.$sql_caption_writer.$sql_caption.$sql_category.$sql_supplemental_category.$sql_credit.$sql_copyright.$sql_web_statement.$sql_instructions.$sql_source.$sql_transmission_reference.$sql_date_of_exposure.$sql_location.$sql_access_rights.$sql_hide_original;
 241    /* remove last coma */
 242    $sql_appended = substr($sql_appended, 0, strlen($sql_appended) - 2);
 243  
 244  /*   print "$sql_appended"; */
 245  
 246    $result = pg_query($database, "
 247    update photo set
 248       $sql_appended
 249     where $sql_selector");
 250  }
 251  
 252  if ($update_photo_tech) {
 253    /* append all strings */
 254    $sql_appended = $sql_camera.$sql_camera_metering.$sql_camera_program.$sql_lens.$sql_focal_length.$sql_filter.$sql_film.$sql_iso_override.$sql_aperture.$sql_shutter.$sql_exp_comp.$sql_exp_diff.$sql_flash.$sql_flash_mode.$sql_flash_comp.$sql_scanner.$sql_scan_resolution.$sql_scan_bitdepth.$sql_scan_multiscan.$sql_support;
 255    /* remove last coma */
 256    $sql_appended = substr($sql_appended, 0, strlen($sql_appended) - 2);
 257  
 258  /*   print "$sql_appended"; */
 259  
 260    $result = pg_query($database, "
 261    update photo_tech set
 262       $sql_appended
 263     where photo in (select identifier from photo where $sql_selector)");
 264  }
 265  
 266  print "<p align=\"left\">Updated $num_of_updates[0] photos.</p>";
 267  
 268  if (($set_generate_thumbnail == 't') || ($set_generate_preview == 't')) {
 269    $im_options = get_im_options($database, $my_user_id[0]);
 270    $my_im_composite_options = get_im_composite_options($database, $my_user_id[0]);
 271    $dcraw_options = get_dcraw_options($database, $my_user_id[0]);
 272  
 273    print "<div align=\"left\">";
 274  
 275    $limit = 20;
 276    $offset = 0;
 277    while (1) {
 278      $photo = pg_query($database, "
 279        select small_image_path, medium_image_path, large_image_path, title, photo.identifier, colorspace, orientation
 280          from photo, photo_version
 281         where photo.identifier = photo_version.photo
 282           and $sql_selector
 283         limit $limit
 284        offset $offset");
 285  
 286      $num_of_photos = pg_num_rows($photo);
 287  
 288      if ($num_of_photos == 0)
 289        break;
 290  
 291      for ($counter = 0; $counter < $num_of_photos; $counter++) {
 292        $photo_data = pg_fetch_row($photo, $counter);
 293  
 294        $thumb_name    = $image_repository_path ."/". $photo_data[0];
 295        $image_name    = $image_repository_path ."/". $photo_data[1];
 296        $original_name = $image_repository_path ."/". $photo_data[2];
 297        $orientation = orientation_to_xform($database, $photo_data[6]);
 298  
 299        $original_file_type   = strtolower(substr($original_name, strrpos($original_name, ".") + 1));
 300        $multi_page_parameter = $mime_type[$original_file_type]['page'];
 301        $decoder              = $mime_type[$original_file_type]['decoder'];
 302        $postprocessor        = $mime_type[$original_file_type]['postprocessor'];
 303  
 304        print "Regenerating thumbnail and preview for <a href=\"photo.php?photo=$photo_data[4]\">$photo_data[3]</a>.<ul>";
 305  
 306        $temporary_ppm_file = import_raw_decode($original_name, $dcraw_options, $decoder, $postprocessor);
 307        if ($temporary_ppm_file) {
 308          $original_name = $temporary_ppm_file;
 309        }
 310  
 311        if ($set_generate_preview == 't') {
 312          import_generate_preview($original_name, $image_name, TRUE, $im_options, $my_im_composite_options, $multi_page_parameter, $orientation, $photo_data[5]);
 313        }
 314  
 315        if ($set_generate_thumbnail == 't') {
 316          import_generate_thumbnail($original_name, $thumb_name, TRUE, $im_options, $multi_page_parameter, $orientation, $photo_data[5]);
 317        }
 318        print "</ul>";
 319      }
 320  
 321      $offset += $limit;
 322    }
 323    print "</div>";
 324  }
 325  
 326  print "<p>";
 327  print "<a class=\"nodecor\" href=\"my.tools.php?selector=1&rule=$rule_identifier\"><img src=\"$theme/button.back.gif\" border=\"0\"></a>";
 328  print "</p>";
 329  
 330  
 331  display_navigator_box_bottom("100%");
 332  print "&nbsp;<br/>";
 333  
 334  site_footer($database);
 335  pg_close($database);
 336  
 337  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]