[feature/avatars] Fixing remote avatars size checks

Remote avatars size checks were broken. It assumed getimagesize() was
available and used the wrong template values.

PHPBB3-10018
This commit is contained in:
Cullen Walsh 2011-04-18 23:34:56 -07:00 committed by Cullen Walsh
parent 00d4b9d431
commit f02f621686
3 changed files with 26 additions and 16 deletions

View file

@ -73,7 +73,14 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
// Match all images in the gallery folder // Match all images in the gallery folder
if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image))
{ {
$dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); if (function_exists('getimagesize'))
{
$dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image);
}
else
{
$dims = array(0, 0);
}
$avatar_list[$cat][$image] = array( $avatar_list[$cat][$image] = array(
'file' => rawurlencode($cat) . '/' . rawurlencode($image), 'file' => rawurlencode($cat) . '/' . rawurlencode($image),
'filename' => rawurlencode($image), 'filename' => rawurlencode($image),

View file

@ -80,22 +80,25 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
} }
// Make sure getimagesize works... // Make sure getimagesize works...
if (($image_data = getimagesize($url)) === false && ($width <= 0 || $height <= 0)) if (function_exists('getimagesize'))
{ {
$error[] = 'UNABLE_GET_IMAGE_SIZE'; if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false))
return false; {
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}
if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0))
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
$width = ($width && $height) ? $width : $image_data[0];
$height = ($width && $height) ? $height : $image_data[1];
} }
if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) if ($width <= 0 || $height <= 0)
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
$width = ($width && $height) ? $width : $image_data[0];
$height = ($width && $height) ? $height : $image_data[1];
if ($width < 2 || $height < 2)
{ {
$error[] = 'AVATAR_NO_SIZE'; $error[] = 'AVATAR_NO_SIZE';
return false; return false;

View file

@ -5,7 +5,7 @@
<dl> <dl>
<dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> <dt><label for="width">{L_LINK_REMOTE_SIZE}:</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt>
<dd> <dd>
<label for="width"><input type="text" name="width" id="width" size="3" value="{AV_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> &times;&nbsp; <label for="av_remote_width"><input type="text" name="av_remote_width" id="av_remote_width" size="3" value="{AV_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL}</label> &times;&nbsp;
<label for="height"><input type="text" name="height" id="height" size="3" value="{AV_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label> <label for="av_remote_height"><input type="text" name="av_remote_height" id="av_remote_height" size="3" value="{AV_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}</label>
</dd> </dd>
</dl> </dl>