mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-14 04:04:01 +00:00
added identicons
This commit is contained in:
38
content-controllers/identicon/identicon.controller.php
Normal file
38
content-controllers/identicon/identicon.controller.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Bitverse\Identicon\Identicon;
|
||||
use Bitverse\Identicon\Color\Color;
|
||||
use Bitverse\Identicon\Generator\RingsGenerator;
|
||||
use Bitverse\Identicon\Preprocessor\MD5Preprocessor;
|
||||
|
||||
class IdenticonController implements ContentController
|
||||
{
|
||||
public const ctype = 'dynamic';
|
||||
|
||||
//returns all extensions registered by this type of content
|
||||
public function getRegisteredExtensions(){return array('identicon');}
|
||||
|
||||
public function handleHash($hash,$url)
|
||||
{
|
||||
unset($url[array_search('identicon',$url)]);
|
||||
$url = array_values($url);
|
||||
|
||||
|
||||
$generator = new RingsGenerator();
|
||||
$generator->setBackgroundColor(Color::parseHex('#EEEEEE'));
|
||||
|
||||
$identicon = new Identicon(new MD5Preprocessor(), $generator);
|
||||
|
||||
$icon = $identicon->getIcon($url[0]);
|
||||
|
||||
header('Content-type: image/svg+xml');
|
||||
echo $icon;
|
||||
}
|
||||
|
||||
public function handleUpload($tmpfile,$hash=false)
|
||||
{
|
||||
return array('status'=>'err','hash'=>$hash,'reason'=>'Cannot upload to Identicons');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user