use gravatar for default avatars
This commit is contained in:
parent
eae34f323b
commit
9be5a7c750
24
boot.php
24
boot.php
|
@ -376,6 +376,11 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
|
||||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||||
|
|
||||||
|
|
||||||
|
$curl_time = intval(get_config('system','curl_timeout'));
|
||||||
|
if($curl_time)
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time);
|
||||||
|
|
||||||
// by default we will allow self-signed certs
|
// by default we will allow self-signed certs
|
||||||
// but you can override this
|
// but you can override this
|
||||||
|
|
||||||
|
@ -434,6 +439,10 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
|
||||||
curl_setopt($ch, CURLOPT_POST,1);
|
curl_setopt($ch, CURLOPT_POST,1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
||||||
|
|
||||||
|
$curl_time = intval(get_config('system','curl_timeout'));
|
||||||
|
if($curl_time)
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, $curl_time);
|
||||||
|
|
||||||
if(is_array($headers))
|
if(is_array($headers))
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
|
@ -1451,3 +1460,18 @@ function valid_email($x){
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
if(! function_exists('gravatar_img')) {
|
||||||
|
function gravatar_img($email) {
|
||||||
|
$size = 175;
|
||||||
|
$opt = 'identicon'; // psuedo-random geometric pattern if not found
|
||||||
|
$rating = 'pg';
|
||||||
|
$hash = md5(trim(strtolower($email)));
|
||||||
|
|
||||||
|
$url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg'
|
||||||
|
. '?s=' . $size . '&d=' . $opt . '&r=' . $rating;
|
||||||
|
|
||||||
|
logger('gravatar: ' . $email . ' ' . $url);
|
||||||
|
return $url;
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,46 @@ function register_post(&$a) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once('include/Photo.php');
|
||||||
|
|
||||||
|
$photo = gravatar_img($email);
|
||||||
|
$photo_failure = false;
|
||||||
|
|
||||||
|
$filename = basename($photo);
|
||||||
|
$img_str = fetch_url($photo,true);
|
||||||
|
$img = new Photo($img_str);
|
||||||
|
if($img->is_valid()) {
|
||||||
|
|
||||||
|
$img->scaleImageSquare(175);
|
||||||
|
|
||||||
|
$hash = photo_new_resource();
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$img->scaleImage(80);
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
$img->scaleImage(48);
|
||||||
|
|
||||||
|
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
|
||||||
|
|
||||||
|
if($r === false)
|
||||||
|
$photo_failure = true;
|
||||||
|
|
||||||
|
if(! $photo_failure) {
|
||||||
|
q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
|
||||||
|
dbesc($hash)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $a->config['register_policy'] == REGISTER_OPEN ) {
|
if( $a->config['register_policy'] == REGISTER_OPEN ) {
|
||||||
$email_tpl = load_view_file("view/register_open_eml.tpl");
|
$email_tpl = load_view_file("view/register_open_eml.tpl");
|
||||||
$email_tpl = replace_macros($email_tpl, array(
|
$email_tpl = replace_macros($email_tpl, array(
|
||||||
|
|
Loading…
Reference in a new issue