/NOTE
Last active
October 26, 2015 07:09
Gravatar Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_GET['mail'])){ | |
$email = "StaticTest@StaticExample.mail"; | |
$email = md5(strtolower(trim($email))); //get mail md5 Hash for Gravatar | |
} | |
else{ | |
$email = strtolower(trim($_GET['mail'])); //not really safe | |
$_GET['mail'] = null; | |
} | |
$opts = $_GET; // even this is really really insecure | |
header('Content-type: image/jpeg'); | |
echo curl_get("http://www.gravatar.com/avatar/".$email.'.jpg',$opts);//get image and ensure it ist an jpeg | |
/** | |
* Send a GET requst using cURL | |
* Taken from: http://php.net/manual/de/function.curl-exec.php#98628 | |
* @param string $url to request | |
* @param array $get values to send | |
* @param array $options for cURL | |
* @return string | |
*/ | |
function curl_get($url, array $get = NULL, array $options = array()) | |
{ | |
$defaults = array( | |
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get), | |
CURLOPT_HEADER => 0, | |
CURLOPT_RETURNTRANSFER => TRUE, | |
CURLOPT_TIMEOUT => 4 | |
); | |
$ch = curl_init(); | |
curl_setopt_array($ch, ($options + $defaults)); | |
if( ! $result = curl_exec($ch)) | |
{ | |
trigger_error(curl_error($ch)); | |
} | |
curl_close($ch); | |
return $result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A very basic gravatar privacy proxy | |
This is only very basic!!! | |
TODO: | |
- Cache | |
- GET validation | |
Install | |
- Put the script in the webserver directory | |
- Ensure that the php cURL is installed (php5-curl) | |
Usage | |
- Send a get request to the script and supply the mail hash with the "mail" parameter you can also apply all gravatar parameters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment