Commit fa60dae0 authored by Aaron Wells's avatar Aaron Wells
Browse files

Use standard Mahara curl methods for gravatar header request (Bug 1457032)

By using the standard methods we make sure that we respect proxy settings,
future security methods, etc.

Change-Id: I2870aac0e3a68080e8af35e4f113c151aa812352
(cherry picked from commit 854b64ae)
parent 6983aeaf
......@@ -2720,9 +2720,9 @@ function remote_avatar_url($email, $size) {
*
* @param string $email Email address of the user
* @param object $size Maximum size of the image
* @param boolean $notfound
* @param boolean $notfound The value to return if the avatar is not found
*
* @returns string The URL of the image or FALSE if none was found
* @returns string The URL of the image or $notfound if none was found
*/
function remote_avatar($email, $size, $notfound) {
if (!get_config('remoteavatars')) {
......@@ -2746,8 +2746,15 @@ function remote_avatar($email, $size, $notfound) {
$baseurl = get_config('remoteavatarbaseurl');
}
// Check if it is a valid avatar
$result = @get_headers("{$baseurl}{$md5sum}.jpg?d=404");
if (!$result || preg_match("#^HTTP/\d+\.\d+ 404 #i", $result[0])) {
$result = mahara_http_request(
array(
CURLOPT_URL => "{$baseurl}{$md5sum}.jpg?d=404",
CURLOPT_HEADER => true,
CURLOPT_NOBODY => true,
),
true
);
if (!$result || $result->error || $result->info['http_code'] == 404) {
return $notfound;
}
return "{$baseurl}{$md5sum}.jpg?r=g&s=$s";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment