mad@Max |
08-05-2009 11:18 PM |
Was same problem https://vborg.vbsupport.ru/showthread.php?t=220191
And i found that class vB_Upload_Image is not complete, as stated in the documentation http://members.vbulletin.com/api/vBu...oad_Image.html
Original look
PHP Code:
class vB_Upload_Image extends vB_Upload_Abstract { /** * Path that uploaded image is to be saved to * * @var string */ var $path = '';
function is_valid_extension($extension) { return !empty($this->image->info_extensions["{$this->upload['extension']}"]); }
function process_upload($uploadurl = '') { if ($uploadurl == '' OR $uploadurl == 'http://www.') { $uploadstuff =& $this->registry->GPC['upload']; } else { if (is_uploaded_file($this->registry->GPC['upload']['tmp_name'])) { $uploadstuff =& $this->registry->GPC['upload']; } else { $uploadstuff =& $uploadurl; } }
if ($this->accept_upload($uploadstuff)) { if ($this->image->is_valid_thumbnail_extension(file_extension($this->upload['filename']))) { if ($this->imginfo = $this->image->fetch_image_info($this->upload['location'])) { if (!$this->image->fetch_must_convert($this->imginfo[2])) { if (!$this->imginfo[2]) { $this->set_error('upload_invalid_image'); return false; }
if ($this->image->fetch_imagetype_from_extension($this->upload['extension']) != $this->imginfo[2]) { $this->set_error('upload_invalid_image_extension', $this->imginfo[2]); return false; } } else { $this->set_error('upload_invalid_image'); return false; } } else { $this->set_error('upload_imageinfo_failed_x', htmlspecialchars_uni($this->image->fetch_error())); return false; } } else { $this->set_error('upload_invalid_image'); return false; }
if (!$this->upload['filestuff']) { if (!($this->upload['filestuff'] = file_get_contents($this->upload['location']))) { $this->set_error('upload_file_failed'); return false; } } @unlink($this->upload['location']);
return $this->save_upload(); } else { return false; } }
function save_upload() { if (!is_writable($this->path) OR !($fp = fopen($this->path . '/' . $this->upload['filename'], 'wb'))) { $this->set_error('invalid_file_path_specified'); return false; }
if (@fwrite($fp, $this->upload['filestuff']) === false) { $this->set_error('error_writing_x', $this->upload['filename']); return false; }
@fclose($fp); return $this->path . '/' . $this->upload['filename']; } }
I assume
PHP Code:
class vB_Upload_Image extends vB_Upload_Abstract { /** * Path that uploaded image is to be saved to * * @var string */ var $path = '';
function is_valid_extension($extension) { return !empty($this->image->info_extensions["{$this->upload['extension']}"]); }
function process_upload($uploadurl = '') { if ($uploadurl == '' OR $uploadurl == 'http://www.') { $uploadstuff =& $this->registry->GPC['upload']; } else { if (is_uploaded_file($this->registry->GPC['upload']['tmp_name'])) { $uploadstuff =& $this->registry->GPC['upload']; } else { $uploadstuff =& $uploadurl; } }
if ($this->accept_upload($uploadstuff)) { if ($this->imginfo = $this->image->fetch_image_info($this->upload['location'])) { if ($this->image->is_valid_thumbnail_extension(file_extension($this->upload['filename']))) { if (!$this->imginfo[2]) { $this->set_error('upload_invalid_image'); return false; }
if ($this->image->fetch_imagetype_from_extension($this->upload['extension']) != $this->imginfo[2]) { $this->set_error('upload_invalid_image_extension', $this->imginfo[2]); return false; } } else { $this->set_error('upload_invalid_image'); return false; }
if ($this->allowanimation === false AND $this->imginfo[2] == 'GIF' AND $this->imginfo['animated']) { $this->set_error('upload_invalid_animatedgif'); return false; }
if (($this->maxwidth AND $this->imginfo[0] > $this->maxwidth) OR ($this->maxheight AND $this->imginfo[1] > $this->maxheight) OR $this->image->fetch_must_convert($this->imginfo[2])) { // shrink-a-dink a big fat image or an invalid image for browser display (PSD, BMP, etc) $this->upload['resized'] = $this->image->fetch_thumbnail($this->upload['filename'], $this->upload['location'], $this->maxwidth, $this->maxheight, $this->registry->options['thumbquality'], false, false, false, false); if (empty($this->upload['resized']['filedata'])) { $this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]); return false; } $jpegconvert = true; } } else { if ($this->registry->userinfo['permissions']['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['cancontrolpanel']) { $this->set_error('upload_imageinfo_failed_x', htmlspecialchars_uni($this->image->fetch_error())); } else { $this->set_error('upload_invalid_file'); } return false; }
if ($this->maxuploadsize > 0 AND (!$this->fetch_best_resize($jpegconvert))) { return false; }
if (!empty($this->upload['resized'])) { if (!empty($this->upload['resized']['filedata'])) { $this->upload['filestuff'] =& $this->upload['resized']['filedata']; $this->upload['filesize'] =& $this->upload['resized']['filesize']; $this->imginfo[0] =& $this->upload['resized']['width']; $this->imginfo[1] =& $this->upload['resized']['height']; } else { $this->set_error('upload_exceeds_dimensions', $this->maxwidth, $this->maxheight, $this->imginfo[0], $this->imginfo[1]); return false; } } else if (!($this->upload['filestuff'] = @file_get_contents($this->upload['location']))) { $this->set_error('upload_file_failed'); return false; } @unlink($this->upload['location']);
return $this->save_upload(); } else { return false; } }
function save_upload() { if (!is_writable($this->path) OR !($fp = fopen($this->path . '/' . $this->upload['filename'], 'wb'))) { $this->set_error('invalid_file_path_specified'); return false; }
if (@fwrite($fp, $this->upload['filestuff']) === false) { $this->set_error('error_writing_x', $this->upload['filename']); return false; }
@fclose($fp); return $this->path . '/' . $this->upload['filename']; } }
judging by the other classes.
Now $upload->maxwidth and $upload->maxheight works :)
|