1 (edited by sddarkman619 2006-06-23 10:42)

Topic: avatar upload problem

I am using punLA, a variation of punBB.
info:
Punbo version Punbo 0.3
PunBB version PunBB 1.2.8
system: Linux
PHP: 4.4.2 - Show info
Accelerator: N/A Database MySQL 4.0.27-standard
Rows: 1043
Size: 1.36 MB

The img/avatar directory is chmoded to 777

when I try to upload an avatar I hey a php error:
Warning: getimagesize(img/avatars/3.tmp): failed to open stream: No such file or directory in /home/divadevo/public_html/components/com_punbo/board/profile.php on line 377

and then in the info box for the BB I get:
The file you tried to upload is wider and/or higher than the maximum allowed 100x100 pixels

but its 100x99
so its not too big.

Line 377 is here:



LINE 376            // Now check the width/height
LINE 377 ------>>>>>>            list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
            if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height'])
            {
                @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                return message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
            }
            else if ($type == 1 && $uploaded_file['type'] != 'image/gif')    // Prevent dodgy uploads
           {
                @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                message($lang_profile['Bad type']);
           }

Re: avatar upload problem

Talk to the people who created PunLA

Re: avatar upload problem

why its a punBB thing as well.

Re: avatar upload problem

I'm using Punla the version of PunBB that integrates into Mambo/Joomla. I'm having the same problem as sddarkman619. Now I understand it might be and issue that is isolated to the Punla and not PunBB but any help on avatar uploading issues similar to this experienced by PunBB user would be appreciated.  The Punla site is down and a solution in short order has been asked of me. Any help would be appreciated.

5 (edited by Smartys 2006-06-23 17:52)

Re: avatar upload problem

sddarkman619 wrote:

why its a punBB thing as well.

Because they have modified the code in some way. The fact that it's based on PunBB does not mean we're familiar with any bugs caused by changes made to the code. And since they're releasing a premodded PunBB, they should be able to support it themselves wink
Paste the code a couple lines above 377 please and I'll see if I can figure it out

Re: avatar upload problem

here is the code, BTW thanks alot for looking at it....

// Determine type
            $extensions = null;
            if ($uploaded_file['type'] == 'image/gif')
                $extensions = array('.gif', '.jpg', '.png');
            else if ($uploaded_file['type'] == 'image/jpeg' || $uploaded_file['type'] == 'image/pjpeg')
                $extensions = array('.jpg', '.gif', '.png');
            else
                $extensions = array('.png', '.gif', '.jpg');

            // Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions.
            if (!@move_uploaded_file($uploaded_file['tmp_name'], PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp'))
                return message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');

            // Now check the width/height
LINE 377 ---->>>>>    list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
            if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height'])
            {
                @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                return message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
            }
            else if ($type == 1 && $uploaded_file['type'] != 'image/gif')    // Prevent dodgy uploads
           {
                @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                message($lang_profile['Bad type']);
           }         

            // Delete any old avatars and put the new one in place
            @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
            @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extensions[1]);
            @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extensions[2]);
            @rename(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp', PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
            @chmod(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.$extensions[0], 0644);
        }
        else
            return message($lang_profile['Unknown failure']);

Re: avatar upload problem

And now I see the bug
They prefixed most things with PUN_ROOT, but they missed a couple. So, some fixes (hopefully)

FIND

list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp');

REPLACE WITH

list($width, $height, $type,) = getimagesize(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp');

FIND

            else if ($type == 1 && $uploaded_file['type'] != 'image/gif')    // Prevent dodgy uploads
           {
                @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');

REPLACE WITH

            else if ($type == 1 && $uploaded_file['type'] != 'image/gif')    // Prevent dodgy uploads
           {
                @unlink(PUN_ROOT.$pun_config['o_avatars_dir'].'/'.$id.'.tmp');

Re: avatar upload problem

Thats it, worked like a charm. thank you SO MUCH!!!!

that was the fix.....