added identicons

This commit is contained in:
Chris
2023-09-03 10:34:35 +02:00
parent 4c1124da07
commit 21aa1fbb7d
4 changed files with 86 additions and 3 deletions

View 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');
}
}