Advanced search  

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]

Pages: [1]   Go Down

Author Topic: set a minimim upload resolution  (Read 12980 times)

0 Members and 1 Guest are viewing this topic.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
set a minimim upload resolution
« on: March 15, 2007, 06:30:23 pm »

I have searched and looked but can't seem to find anything.

Is there a way, or a mod that allows admin to set a minimum upload size for images?
« Last Edit: March 17, 2007, 07:47:37 pm by GauGau »
Logged

Nibbler

  • Guest
Re: set a minimim upload resolution
« Reply #1 on: March 15, 2007, 06:31:56 pm »

I don't know of any mod, just look through upload.php for the maximum dimensions check and add a corresponding minimum dimensions check.
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: set a minimim upload resolution
« Reply #2 on: March 16, 2007, 05:51:14 pm »

ok I have figured this out...of course you were exactly right Nibbler

ok if anyone else wants to have the option to set a minimum resolution of images this is how you do it:

first open you database and insert a new row like so:       (alter your db prefix accordingly)
Code: [Select]
INSERT INTO `cpg_config` (`name`, `value`) VALUES ('min_upl_width_height', '200');
now open your language file (I'm going to assume it's english.php)

open english.php

find:
Code: [Select]
  array('Max width or height for uploaded pictures/videos (pixels)', 'max_upl_width_height', 0, 'f=index.htm&as=admin_picture_thumbnail_max_upload_dimension&ae=admin_picture_thumbnail_max_upload_dimension_end'), //cpg1.4after add:
Code: [Select]
  //mod for MIN UPLOAD START
   array('Min width or height for uploaded pictures/videos (pixels)', 'min_upl_width_height', 0, 'f=index.htm&as=admin_picture_thumbnail_min_upload_dimension&ae=admin_picture_thumbnail_min_upload_dimension_end'), //cpg1.4
   //MOD from MIN UPLOAD END
find:
Code: [Select]
  'pixel_allowance' => 'The height and or width of the uploaded picture is more than that allowed by the gallery config.', //cpg1.4after add:
Code: [Select]
  'min_pixel_allowance' => 'The height and or width of the uploaded picture is less than that allowed by the gallery config.',
open upload.php
find:
Code: [Select]
// Check that picture size (in pixels) is lower than the maximum allowed. If not, delete it.
                } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                  if ((USER_IS_ADMIN && $CONFIG['auto_resize'] == 1) || (!USER_IS_ADMIN && $CONFIG['auto_resize'] > 0)) //($CONFIG['auto_resize']==1)
                  {
                    //resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $imginfo[0] > $CONFIG['max_upl_width_height'] ? 'wd' : 'ht');
                    resize_image($uploaded_pic, $uploaded_pic, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
                  }
                  else
                  {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                  }
                }
after ad:
Code: [Select]
//mod to set min resolution //reversed
elseif (max($imginfo[0], $imginfo[1]) < $CONFIG['min_upl_width_height']) {

                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions are smaller than the allowed size.
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['min_pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
}
//end of mod to set min resolution

find:
Code: [Select]
                // Check that picture size (in pixels) is lower than the maximum allowed. If not, delete it.
                } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $URI_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'URI_name'=> $_POST['URI_array'][$counter], 'error_code'=>$lang_upload_php['pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                }
after add:
Code: [Select]
// MIN PIXEL MOD HERE //reversed
elseif (max($imginfo[0], $imginfo[1]) < $CONFIG['min_upl_width_height']) {
                    @unlink($path_to_image);

                    // The file upload has failed -- the image dimensions exceed the allowed amount.
                    $URI_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'URI_name'=> $_POST['URI_array'][$counter], 'error_code'=>$lang_upload_php['min_pixel_allowance']);

                    // There is no need for further tests or action, so skip the remainder of the iteration.
                    continue;
                }
// END OF MIN PIXEL MOD

If you go into config you will see a new option below max resolution called min resolution.  It is set to 200 by default.

That should do it, I have tested this with a admin and member account and also with too large, too small and correct midrange images and have found no errors.
Logged

Nibbler

  • Guest
Re: set a minimim upload resolution
« Reply #3 on: March 16, 2007, 06:56:18 pm »

Great, thanks for contributing your changes.
Logged

christian1980nrw

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: set a minimim upload resolution
« Reply #4 on: January 16, 2008, 09:12:27 am »

 ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.387 seconds with 19 queries.