<?php
header("Content-Type: image/png;");
class HabboImage
{
private $figure;
public $extra;
private $result;
private $local_url;
private $url = "http://www.habbo.com/habbo-imaging/avatarimage?";
public function __construct()
{
//NO NEED FOR CONSTRUCT NOW. MIGHT I ADD EDIT HERE LATER, AND ADD MORE STUFF... OR DELETE ALL THIS SHITZ
}
public function addParam($param, $result)
{
if($param == "figure")
$this->figure = $result;
$this->extra[$param] = $result;
}
public function existParam($paramKey)
{
if(array_key_exists($paramKey, $this->extra))
{
return true;
}
}
public function getParam($paramKey)
{
if($this->existParam($paramKey))
{
return $this->extra[$paramKey];
}
return null;
}
private function returnExtra()
{
$fields = "";
foreach($this->extra as $key=>$value) { $fields .= $key.'='.$value.'&'; }
return rtrim($fields, '&') . "&";
}
public function prepare()
{
$this->result = file_get_contents($this->url . $this->returnExtra());
$this->local_url = $this->url . $this->returnExtra();
}
private function makeOk($extra)
{
$extra = str_replace("&", ".", $extra);
$extra = str_replace("=", "-", $extra);
return md5($extra) . (strlen($extra) * 1024);
}
private function cacheExist()
{
if(file_exists("./cache/figure/" . $this->makeOk($this->returnExtra()) . ".png")){
return true;
}
return false;
}
public function getUrl()
{
return $this->local_url;
}
public function get()
{
return $this->result;
}
}
class Head
{
private $Crop = [[23, 20], [50, 50], [100, 110]];
private $w, $h;
private $image, $dest;
public function __construct(HabboImage $habboImage)
{
$size = $habboImage->existParam("size");
if($size)
{
if($habboImage->getParam("size") == "s")
{
$this->w = $this->Crop[0][0];
$this->h = $this->Crop[0][1];
}
else if($habboImage->getParam("size") == "l")
{
$this->w = $this->Crop[2][0];
$this->h = $this->Crop[2][1];
}
else
{
$this->w = $this->Crop[1][0];
$this->h = $this->Crop[1][1];
}
}
else
{
$this->w = $this->Crop[1][0];
$this->h = $this->Crop[1][1];
}
$this->image = imagecreatefrompng($habboImage->getUrl());
}
private function applyAlpha($img)
{
imagealphablending($img, true);
imagesavealpha($img, true);
}
private function createImage()
{
$this->dest = imagecreate($this->w, $this->h);
}
private function applyCopy()
{
imagecopy($this->dest, $this->image, -5, 0, 0, 12, $this->w, $this->h);
}
public function get()
{
$this->applyAlpha($this->image);
$this->createImage();
$this->applyCopy();
$this->applyAlpha($this->dest);
return imagepng($this->dest);
}
public function Destroy()
{
imagedestroy($this->dest);
imagedestroy($this->image);
}
}
$HabboImage = new HabboImage();
foreach ($_GET as $key => $value){
if($key == "head")
continue;
$HabboImage->addParam($key, $value);
}
$HabboImage->prepare();
if(isset($_GET['head']))
{
$Head = new Head($HabboImage);
$head = $Head->get();
$Head->Destroy();
die($head);
}
else{
die($HabboImage->get());
}
?>