1

Topic: Users can upload avatars over set pixels limit

All users in my forum are with avatars which are more than set (60x60) pixels. If the file is over 10 KB they can't upload, but it doesn't detect pixels. Where can't be the mistake ?

jUzt m3 ...

Re: Users can upload avatars over set pixels limit

Hmm, I think I remember this as a bug in an earlier version of PunBB. Which version are you running?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by blade 2004-03-18 12:08)

Re: Users can upload avatars over set pixels limit

I'm using the last version - 1.1.2 ... I don't know ... But I'll try to set different size and then turn it back. I don't know whether this will work but I'll just try

jUzt m3 ...

4

Re: Users can upload avatars over set pixels limit

I think that the error is in web server where the forum is hosted. When I tried to update my avatar I received this error message :

PHP Error

Warning: getimagesize() [function.getimagesize.html]: open_basedir restriction in effect. File(/tmp/phpsrPxsf) is not within the allowed path(s): ($PATH) in $PATH/forum/profile.php on line 357

jUzt m3 ...

Re: Users can upload avatars over set pixels limit

This is a known problem in PunBB 1.1.2. To fix it, do this. Open up profile.php and locate the following piece of code:

if (is_uploaded_file($uploaded_file['tmp_name']))
{
    $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');

    if (!in_array($uploaded_file['type'], $allowed_types))
        message($lang_profile['Bad type']);

    list($width, $height, ,) = getimagesize($uploaded_file['tmp_name']);

    if ($width > $pun_config['o_avatars_width'])
        message($lang_profile['Too wide'].' '.$pun_config['o_avatars_width'].' '.$lang_profile['pixels'].'.');
    if ($height > $pun_config['o_avatars_height'])
        message($lang_profile['Too high'].' '.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
    if ($uploaded_file['size'] > $pun_config['o_avatars_size'])
        message($lang_profile['Too large'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].'.');

    if ($uploaded_file['type'] == 'image/gif')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.gif', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
    }
    else if ($uploaded_file['type'] == 'image/jpeg' || $uploaded_file['type'] == 'image/pjpeg')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.jpg', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
    }
    else if ($uploaded_file['type'] == 'image/png' || $uploaded_file['type'] == 'image/x-png')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.png');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.png', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
    }

    if (!$temp)
        message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
}

and replace it with

if (is_uploaded_file($uploaded_file['tmp_name']))
{
    $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
    $width = $height = 0;

    if (!in_array($uploaded_file['type'], $allowed_types))
        message($lang_profile['Bad type']);

    if ($uploaded_file['type'] == 'image/gif')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.gif', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
        list($width, $height, ,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif');
    }
    else if ($uploaded_file['type'] == 'image/jpeg' || $uploaded_file['type'] == 'image/pjpeg')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.jpg', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
        list($width, $height, ,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
    }
    else if ($uploaded_file['type'] == 'image/png' || $uploaded_file['type'] == 'image/x-png')
    {
        $temp = @move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.png');
        @chmod($pun_config['o_avatars_dir'].'/'.$id.'.png', 0644);
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        list($width, $height, ,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png');
    }

    if ($width > $pun_config['o_avatars_width'])
    {
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
        message($lang_profile['Too wide'].' '.$pun_config['o_avatars_width'].' '.$lang_profile['pixels'].'.');
    }
    if ($height > $pun_config['o_avatars_height'])
    {
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
        message($lang_profile['Too high'].' '.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
    }
    if ($uploaded_file['size'] > $pun_config['o_avatars_size'])
    {
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
        @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
        message($lang_profile['Too large'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].'.');
    }

    if (!$temp)
        message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
}

That should do it.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

Parse error: parse error in /usr/local/psa/home/vhosts/benbigun.com/httpdocs/forum/profile.php on line 463

461         require $pun_root.'footer.php';
462    }
463    }
464  else if ($action == 'delete_avatar')
465  {

Re: Users can upload avatars over set pixels limit

Then you did something wrong. You probably missed a } at the end or something.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8 (edited by benbign.com 2004-06-13 00:31)

Re: Users can upload avatars over set pixels limit

ok i got the problem and no more Parse error.
but i still have the same problem :

when i try to change mt avatar picture in Profile menu the image does not change only the size changes. somehow i can sometimes change the image too but its just by luck i duno how it happens...

Re: Users can upload avatars over set pixels limit

It's not a browser cache problem then?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

In this forum theres not a problem but in my forum i have the problem. Seems we couldnt solve it still? I can make a demo acc for yo if u like to see or if it d help more?

Re: Users can upload avatars over set pixels limit

Yeah, give me a link to your forum and I'll check it out.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

http://www.benbigun.com/forum/index.php

u: test
p: test

Re: Users can upload avatars over set pixels limit

Works fine for me.

http://www.benbigun.com/forum/viewtopic.php?pid=26#26

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

Did u try to change and upload another avatar? It ll be better to see the problem if u ll upload something different then this one bye size and name.

Re: Users can upload avatars over set pixels limit

Yes, I did. I just uploaded the one I have here and then changed to a different one.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

Well maybe the forum knows u re its master? and behaves u?:) hmm im stucked. When u clicked ur profile page was that in english or in turkish? maybe the turkish lang has a problem?

Re: Users can upload avatars over set pixels limit

I can't remember. I think it was turkish. What browser are you using? Have you tried different browsers?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Users can upload avatars over set pixels limit

im using ie last version (same browser that i use here and change my avaar here and that i dont get any errors) yes my forum is in turkish its a physicologic website. i ll download the english land and check if turkish one has problem

Re: Users can upload avatars over set pixels limit

Ok. Could someone else try it as well?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

20

Re: Users can upload avatars over set pixels limit

Tried it. The avatar which Rickard put there was called 7.gif. I changed that to an avatar called 1328.jpg with no problem. I then tried to change it to an avatar called 2.gif and then 9.gif. In both cases I just got Rickards 7.gif back again. Cleared my cache and my 2.gif is now showing up but it's had it's name changed to 7.gif. Everything is in Turkish as it should be.

Re: Users can upload avatars over set pixels limit

Paul. The name of the avatar will always be user_id.file_type. I.e. 7.gif, 7.png or 7.jpg.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

22

Re: Users can upload avatars over set pixels limit

Rickard wrote:

Paul. The name of the avatar will always be user_id.file_type. I.e. 7.gif, 7.png or 7.jpg.

That makes sense. In that case the site was working perfectly.