Moved Gravatar hash function to a dedicated Gravatar class
This commit is contained in:
parent
8e7a8f15c7
commit
e420e3ad72
3 changed files with 85 additions and 4 deletions
42
classes/API/Gravatar.php
Normal file
42
classes/API/Gravatar.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gravatar Class File for PICKLES
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @author Josh Sherman <pickles@joshtronic.com>
|
||||||
|
* @copyright Copyright 2007-2012, Josh Sherman
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
|
* @package PICKLES
|
||||||
|
* @link https://github.com/joshtronic/pickles
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gravatar API Interface
|
||||||
|
*
|
||||||
|
* @link http://en.gravatar.com/site/implement/
|
||||||
|
*/
|
||||||
|
class API_Gravatar extends API_Common
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Hash
|
||||||
|
*
|
||||||
|
* Generates a hash from the passed string that can then be used for
|
||||||
|
* fetching an image or profile from Gravatar.com
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param string $string string to hash, should be an email address
|
||||||
|
* @return string resulting hash
|
||||||
|
*/
|
||||||
|
public static function hash($string)
|
||||||
|
{
|
||||||
|
// Trims whitespace, lowers the case then applies MD5
|
||||||
|
return md5(strtolower(trim($string)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -53,14 +53,14 @@ class String
|
||||||
* Generates a hash from the passed string that can then be used for
|
* Generates a hash from the passed string that can then be used for
|
||||||
* fetching an avatar from Gravatar.com
|
* fetching an avatar from Gravatar.com
|
||||||
*
|
*
|
||||||
|
* @deprecated
|
||||||
* @static
|
* @static
|
||||||
* @param string $string string to hash, should be an email address
|
* @param string $string string to hash, should be an email address
|
||||||
* @return string resulting hash
|
* @return string resulting hash
|
||||||
*/
|
*/
|
||||||
public static function generateGravatarHash($string)
|
public static function generateGravatarHash($string)
|
||||||
{
|
{
|
||||||
// Trims whitespace, lowers the case then applies MD5
|
return API_Gravatar::hash($string);
|
||||||
return md5(strtolower(trim($string)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
43
jar.php
43
jar.php
|
@ -84,6 +84,45 @@ class API_Google_Profanity extends API_Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gravatar Class File for PICKLES
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistribution of these files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @author Josh Sherman <pickles@joshtronic.com>
|
||||||
|
* @copyright Copyright 2007-2012, Josh Sherman
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html
|
||||||
|
* @package PICKLES
|
||||||
|
* @link https://github.com/joshtronic/pickles
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gravatar API Interface
|
||||||
|
*
|
||||||
|
* @link http://en.gravatar.com/site/implement/
|
||||||
|
*/
|
||||||
|
class API_Gravatar extends API_Common
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Hash
|
||||||
|
*
|
||||||
|
* Generates a hash from the passed string that can then be used for
|
||||||
|
* fetching an image or profile from Gravatar.com
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param string $string string to hash, should be an email address
|
||||||
|
* @return string resulting hash
|
||||||
|
*/
|
||||||
|
public static function hash($string)
|
||||||
|
{
|
||||||
|
// Trims whitespace, lowers the case then applies MD5
|
||||||
|
return md5(strtolower(trim($string)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tinychat Class File for PICKLES
|
* Tinychat Class File for PICKLES
|
||||||
*
|
*
|
||||||
|
@ -6970,14 +7009,14 @@ class String
|
||||||
* Generates a hash from the passed string that can then be used for
|
* Generates a hash from the passed string that can then be used for
|
||||||
* fetching an avatar from Gravatar.com
|
* fetching an avatar from Gravatar.com
|
||||||
*
|
*
|
||||||
|
* @deprecated
|
||||||
* @static
|
* @static
|
||||||
* @param string $string string to hash, should be an email address
|
* @param string $string string to hash, should be an email address
|
||||||
* @return string resulting hash
|
* @return string resulting hash
|
||||||
*/
|
*/
|
||||||
public static function generateGravatarHash($string)
|
public static function generateGravatarHash($string)
|
||||||
{
|
{
|
||||||
// Trims whitespace, lowers the case then applies MD5
|
return API_Gravatar::hash($string);
|
||||||
return md5(strtolower(trim($string)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue