From 27daba1df8dbc10db18e3ea763b16e7ccb96e537 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 25 Apr 2007 16:30:42 +0000 Subject: [PATCH] Still fine-tuning remote avatar conversion. Prepare to be yelled at. git-svn-id: file:///svn/phpbb/trunk@7401 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_convert.php | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 90f820dae9..16972b3704 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -912,9 +912,37 @@ function get_remote_avatar_dim($src,$axis) return $avatar_cache[$src][$axis]; } + $url_info = parse_url($src); + $host = $url_info['host']; + $port = (isset($url_info['port'])) ? $url_info['port'] : 0; + $protocol = $url_info['scheme']; + if (empty($port)) + { + switch(strtolower($protocol)) + { + case 'ftp': + $port = 21; + break; + + case 'https': + $port = 443; + break; + + default: + $port = 80; + } + } + $timeout = @ini_get('default_socket_timeout'); @ini_set('default_socket_timeout', 5); - $avatar_cache[$src] = @getimagesize($src); + + // We're just trying to reach the server to avoid timeouts + $fp = @fsockopen($host, $port, $errno, $errstr, 3); + if ($fp) + { + $avatar_cache[$src] = @getimagesize($src); + fclose($fp); + } $default_x = (defined('DEFAULT_AVATAR_X_CUSTOM')) ? DEFAULT_AVATAR_X_CUSTOM : DEFAULT_AVATAR_X; $default_y = (defined('DEFAULT_AVATAR_Y_CUSTOM')) ? DEFAULT_AVATAR_Y_CUSTOM : DEFAULT_AVATAR_Y;