Ignore:
Timestamp:
Jun 29, 2010, 8:42:11 PM (14 years ago)
Author:
plg
Message:

merge r6624 from branch 2.1 to trunk

bug 1747 fixed: some checks were added to verify the upload will fail for a
too big size or if the upload has failed for a too big size (test on
upload_max_filesize and post_max_size)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/photos_add_direct.php

    r6622 r6625  
    6363// +-----------------------------------------------------------------------+
    6464
    65 if (isset($_POST['submit_upload']))
     65if (isset($_GET['processed']))
    6666{
    6767//   echo '<pre>POST'."\n"; print_r($_POST); echo '</pre>';
     
    6969//   echo '<pre>SESSION'."\n"; print_r($_SESSION); echo '</pre>';
    7070//   exit();
     71
     72  // sometimes, you have submitted the form but you have nothing in $_POST
     73  // and $_FILES. This may happen when you have an HTML upload and you
     74  // exceeded the post_max_size (but not the upload_max_size)
     75  if (!isset($_POST['submit_upload']))
     76  {
     77    array_push(
     78      $page['errors'],
     79      sprintf(
     80        l10n('The uploaded files exceed the post_max_size directive in php.ini: %sB'),
     81        ini_get('post_max_size')
     82        )
     83      );
     84  }
    7185 
    7286  $category_id = null;
    73   if ('existing' == $_POST['category_type'])
     87  if (!isset($_POST['category_type']))
     88  {
     89    // nothing to do, we certainly have the post_max_size issue
     90  }
     91  elseif ('existing' == $_POST['category_type'])
    7492  {
    7593    $category_id = $_POST['category'];
     
    194212      }
    195213    }
     214    else
     215    {
     216      $error_message = file_upload_error_message($error);
     217     
     218      array_push(
     219        $page['errors'],
     220        sprintf(
     221          l10n('Error on file "%s" : %s'),
     222          $_FILES['image_upload']['name'][$idx],
     223          $error_message
     224          )
     225        );
     226    }
    196227  }
    197228 
     
    205236  {
    206237    // we're on a multiple upload, with uploadify and so on
    207     $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ];
    208 
    209     associate_images_to_categories(
    210       $image_ids,
    211       array($category_id)
    212       );
    213 
    214     $query = '
     238    if (isset($_SESSION['uploads_error'][ $_POST['upload_id'] ]))
     239    {
     240      foreach ($_SESSION['uploads_error'][ $_POST['upload_id'] ] as $error)
     241      {
     242        array_push($page['errors'], $error);
     243      }
     244    }
     245
     246    if (isset($_SESSION['uploads'][ $_POST['upload_id'] ]))
     247    {
     248      $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ];
     249
     250      associate_images_to_categories(
     251        $image_ids,
     252        array($category_id)
     253        );
     254
     255      $query = '
    215256UPDATE '.IMAGES_TABLE.'
    216257  SET level = '.$_POST['level'].'
    217258  WHERE id IN ('.implode(', ', $image_ids).')
    218259;';
    219     pwg_query($query);
     260      pwg_query($query);
    220261   
    221     invalidate_user_cache();
     262      invalidate_user_cache();
     263    }
    222264  }
    223265 
     
    326368      'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL,
    327369      'uploadify_path' => $uploadify_path,
     370      'upload_max_filesize' => min(
     371        get_ini_size('upload_max_filesize'),
     372        get_ini_size('post_max_size')
     373        ),
    328374    )
    329375  );
     
    346392    array(
    347393      'upload_mode' => $upload_mode,
     394      'form_action' => PHOTOS_ADD_BASE_URL.'&amp;upload_mode='.$upload_mode.'&amp;processed=1',
    348395      'switch_url' => PHOTOS_ADD_BASE_URL.'&amp;upload_mode='.$upload_switch,
    349396      'upload_id' => md5(rand()),
    350397      'session_id' => session_id(),
    351398      'pwg_token' => get_pwg_token(),
     399      'another_upload_link' => PHOTOS_ADD_BASE_URL.'&amp;upload_mode='.$upload_mode,
    352400    )
    353401  );
     
    465513}
    466514
     515if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size'))
     516{
     517  array_push(
     518    $setup_warnings,
     519    sprintf(
     520      l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'),
     521      get_ini_size('upload_max_filesize', false),
     522      get_ini_size('post_max_size', false)
     523      )
     524    );
     525}
     526
    467527$template->assign(
    468528    array(
Note: See TracChangeset for help on using the changeset viewer.