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: minimum height/width  (Read 4808 times)

0 Members and 1 Guest are viewing this topic.

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
minimum height/width
« on: November 23, 2005, 08:48:50 pm »

I don't want pictures that are too small in my gallery so I modified the hard code to check pic for a minimum width and height. I'm only an amateur php programmer....this code doesn't seem to work, small pictures are still getting uploaded without any error. Its too late in the night for me to spot any sill errors....hopefully someone can help  ???

Code: [Select]
        // Check that picture file size is lower than the maximum allowed
        if (filesize($uploaded_pic) > ($CONFIG['max_upl_size'] << 10)) {
            @unlink($uploaded_pic);
            cpg_die(ERROR, sprintf($lang_db_input_php['err_imgsize_too_large'], $CONFIG['max_upl_size']), __FILE__, __LINE__);
        } elseif (is_image($picture_name)) {
            $imginfo = getimagesize($uploaded_pic);
            // getimagesize does not recognize the file as a picture
            if ($imginfo == null) {
                @unlink($uploaded_pic);
                cpg_die(ERROR, $lang_db_input_php['err_invalid_img'], __FILE__, __LINE__, true);

            // JPEG and PNG only are allowed with GD
            } elseif ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($CONFIG['thumb_method'] == 'gd1' || $CONFIG['thumb_method'] == 'gd2')) {
                @unlink($uploaded_pic);
                cpg_die(ERROR, $lang_errors['gd_file_type_err'], __FILE__, __LINE__, true);

            // *** NOT NEEDED CHECK DONE BY 'is_image'
            // Check image type is among those allowed for ImageMagick
            //} elseif (!stristr($CONFIG['allowed_img_types'], $IMG_TYPES[$imginfo[2]]) && $CONFIG['thumb_method'] == 'im') {
                //@unlink($uploaded_pic);
                //cpg_die(ERROR, sprintf($lang_db_input_php['allowed_img_types'], $CONFIG['allowed_img_types']), __FILE__, __LINE__);

            // Check that picture size (in pixels) is very low.
            }  elseif ($imginfo[0] < '150') {
                @unlink($uploaded_pic);
                cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_small_width']), __FILE__, __LINE__);
    } elseif ($imginfo[1] < '200') {
                @unlink($uploaded_pic);
                cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_small_height']), __FILE__, __LINE__);


            // Check that picture size (in pixels) is lower than the maximum allowed
            } elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
                @unlink($uploaded_pic);
                cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_large'], $CONFIG['max_upl_width_height'], $CONFIG['max_upl_width_height']), __FILE__, __LINE__);
            }


« Last Edit: November 25, 2005, 05:05:15 pm by Nibbler »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: minimum height/width
« Reply #1 on: November 23, 2005, 09:56:46 pm »

Try searching the forums - I believe I coded a minimum requirement and posted it quite a while ago.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: minimum height/width
« Reply #2 on: November 24, 2005, 09:50:07 am »

hi,

the topic dealing with this is at:
http://forum.coppermine-gallery.net/index.php?topic=18556.0

i got the idea for the code from that topic only. i found some mistakes in my previous code...i simplified it further...but its still not working....it just uploads the (small) pic with no problems!!

its as though it doesn't even check for the condition

added in db_input.php

Code: [Select]
            } // Image is ok
        }

    // check to see if width or height is small than 200 pixels.
    if (min($imginfo[0], $imginfo[1]) < 200) {
                @unlink($uploaded_pic);
                cpg_die(ERROR, sprintf($lang_db_input_php['err_fsize_too_small']), __FILE__, __LINE__);
            }
« Last Edit: November 25, 2005, 07:06:41 am by ganeshcp »
Logged

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: minimum height/width
« Reply #3 on: November 25, 2005, 07:05:25 am »

gosh can someone help with this? it is important for my gallery  ???
Logged

Nibbler

  • Guest
Re: minimum height/width
« Reply #4 on: November 25, 2005, 03:41:35 pm »

Please post a link and test user account for help with upload issues. Note that the file db_input.php is used only for 'single file upload' type uploads. If you are using some other uploading method then the relevent code would be elsewhere.
Logged

ganeshcp

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: minimum height/width
« Reply #5 on: November 25, 2005, 05:04:02 pm »


i solved the problem  ;D
yes that was the problem. today when i was relooking the issue i realized that multi file uploads are handled by upload.php. Here is the code for those who want help with this issue (note: this is a hard code and values cannot be modified from admin)

add after
Code: [Select]
                } 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.
                    $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;
                }

Code: [Select]
       // check for minimum width
                elseif ($imginfo[0] < 150) {
                @unlink($uploaded_pic);
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['pixel_small_width']);

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


                // check for minimum height
                elseif ($imginfo[1] < 200) {
                @unlink($uploaded_pic);
                    $file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'=>$lang_upload_php['pixel_small_height']);

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

the above code should also be added for url uploads after

Code: [Select]
                    // 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;

                }

further the variables pixel_small_height and pixel_small_width should be added to ur language file under upload.php.

:)
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 15 queries.