Changeset 1523


Ignore:
Timestamp:
Aug 2, 2006, 8:14:53 PM (18 years ago)
Author:
laurent_duretz
Message:

Bugs 122 and 475 : Crash on big remote site update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_6/tools/create_listing_file.php

    r1485 r1523  
    252252
    253253  $thumbnails = array();
    254   if ($opendir = @opendir($dir.'/thumbnail'))
    255   {
    256     while ($file = readdir($opendir))
    257     {
    258       if (in_array(get_extension($file), $conf['picture_ext'])
    259           and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'])
    260       {
    261         array_push($thumbnails, $file);
     254  if (is_dir($dir.'/thumbnail'))
     255  {
     256    if ($opendir = opendir($dir.'/thumbnail'))
     257    {
     258      while ($file = readdir($opendir))
     259      {
     260        if (in_array(get_extension($file), $conf['picture_ext'])
     261            and substr($file,0,$prefix_length) == $conf['prefix_thumbnail'])
     262        {
     263          array_push($thumbnails, $file);
     264        }
    262265      }
    263266    }
     
    278281
    279282  $pictures = array();
    280   if ($opendir = @opendir($dir.'/pwg_representative'))
    281   {
    282     while ($file = readdir($opendir))
    283     {
    284       if (in_array(get_extension($file), $conf['picture_ext']))
    285       {
    286         array_push($pictures, $file);
     283  if (is_dir($dir.'/pwg_representative'))
     284  {
     285    if ($opendir = opendir($dir.'/pwg_representative'))
     286    {
     287      while ($file = readdir($opendir))
     288      {
     289        if (in_array(get_extension($file), $conf['picture_ext']))
     290        {
     291          array_push($pictures, $file);
     292        }
    287293      }
    288294    }
     
    303309
    304310  $pictures = array();
    305   if ($opendir = @opendir($dir.'/pwg_high'))
    306   {
    307     while ($file = readdir($opendir))
    308     {
    309       if (in_array(get_extension($file), $conf['picture_ext']))
    310       {
    311         array_push($pictures, $file);
     311  if (is_dir($dir.'/pwg_high'))
     312  {
     313    if ($opendir = opendir($dir.'/pwg_high'))
     314    {
     315      while ($file = readdir($opendir))
     316      {
     317        if (in_array(get_extension($file), $conf['picture_ext']))
     318        {
     319          array_push($pictures, $file);
     320        }
    312321      }
    313322    }
     
    325334  $fs_dirs = array();
    326335  $dirs = "";
     336  global $conf_safe_mode;
     337
     338  // Refresh the max_execution_time to avoid timout error
     339  // By default time to scan a directory (without subdirs) is fixed to 30 seconds
     340  if (!$conf_safe_mode)
     341  {
     342    set_time_limit(30);
     343  }
    327344
    328345  if ($opendir = opendir($basedir))
     
    436453        if ($conf['use_exif'])
    437454        {
    438           if ($exif = @read_exif_data($dir.'/'.$fs_file))
     455          // Verify activation of exif module
     456          if (extension_loaded('exif'))
    439457          {
    440             foreach ($conf['use_exif_mapping'] as $pwg_key => $exif_key )
     458            if ($exif = read_exif_data($dir.'/'.$fs_file))
    441459            {
    442               if (isset($exif[$exif_key]))
     460              foreach ($conf['use_exif_mapping'] as $pwg_key => $exif_key )
    443461              {
    444                 if ( in_array($pwg_key, array('date_creation','date_available') ) )
     462                if (isset($exif[$exif_key]))
    445463                {
    446                    if (preg_match('/^(\d{4}):(\d{2}):(\d{2})/'
    447                          ,$exif[$exif_key]
    448                          ,$matches))
    449                    {
    450                      $element[$pwg_key] =
    451                         $matches[1].'-'.$matches[2].'-'.$matches[3];
    452                    }
    453                 }
    454                 else
    455                 {
    456                   $element[$pwg_key] = $exif[$exif_key];
     464                  if ( in_array($pwg_key, array('date_creation','date_available') ) )
     465                  {
     466                     if (preg_match('/^(\d{4}):(\d{2}):(\d{2})/'
     467                           ,$exif[$exif_key]
     468                           ,$matches))
     469                     {
     470                       $element[$pwg_key] =
     471                          $matches[1].'-'.$matches[2].'-'.$matches[3];
     472                     }
     473                  }
     474                  else
     475                  {
     476                    $element[$pwg_key] = $exif[$exif_key];
     477                  }
    457478                }
    458479              }
     
    539560}
    540561
     562// Looking at the safe_mode configuration for execution time
     563$conf_safe_mode = TRUE;
     564if (ini_get('safe_mode') == 0)
     565{
     566  $conf_safe_mode = FALSE;
     567}
     568
    541569echo '<pre>';
    542570switch ($page['action'])
Note: See TracChangeset for help on using the changeset viewer.