Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
head.php for habbo-imaging
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Detox" data-source="post: 321198" data-attributes="member: 596"><p>Okay so how do I turn this PHP code for just showing the heads?</p><p>so whenever I go to localhost/habbo-imaging/head.php?figure=</p><p>without having the &headonly=1</p><p></p><p>[PHP]</p><p><?php</p><p>header("Content-Type: image/png;");</p><p></p><p></p><p>class HabboImage</p><p>{</p><p> private $figure;</p><p> public $extra;</p><p> private $result;</p><p> private $local_url;</p><p></p><p> private $url = "http://www.habbo.com/habbo-imaging/avatarimage?";</p><p></p><p> public function __construct()</p><p> {</p><p> //NO NEED FOR CONSTRUCT NOW. MIGHT I ADD EDIT HERE LATER, AND ADD MORE STUFF... OR DELETE ALL THIS SHITZ</p><p> }</p><p></p><p> public function addParam($param, $result)</p><p> {</p><p> if($param == "figure")</p><p> $this->figure = $result;</p><p></p><p> $this->extra[$param] = $result;</p><p> }</p><p></p><p> public function existParam($paramKey)</p><p> {</p><p> if(array_key_exists($paramKey, $this->extra))</p><p> {</p><p> return true;</p><p> }</p><p> }</p><p></p><p> public function getParam($paramKey)</p><p> {</p><p> if($this->existParam($paramKey))</p><p> {</p><p> return $this->extra[$paramKey];</p><p> }</p><p> return null;</p><p> }</p><p></p><p> private function returnExtra()</p><p> {</p><p> $fields = "";</p><p> foreach($this->extra as $key=>$value) { $fields .= $key.'='.$value.'&'; }</p><p></p><p> return rtrim($fields, '&') . "&";</p><p> }</p><p> public function prepare()</p><p> {</p><p> </p><p> $this->result = file_get_contents($this->url . $this->returnExtra());</p><p> </p><p> $this->local_url = $this->url . $this->returnExtra();</p><p> }</p><p></p><p> private function makeOk($extra)</p><p> {</p><p> $extra = str_replace("&", ".", $extra);</p><p> $extra = str_replace("=", "-", $extra);</p><p> return md5($extra) . (strlen($extra) * 1024);</p><p> }</p><p></p><p> private function cacheExist()</p><p> {</p><p> if(file_exists("./cache/figure/" . $this->makeOk($this->returnExtra()) . ".png")){</p><p> return true;</p><p> }</p><p></p><p> return false;</p><p> }</p><p></p><p> public function getUrl()</p><p> {</p><p> return $this->local_url;</p><p> }</p><p></p><p> public function get()</p><p> {</p><p> return $this->result;</p><p> }</p><p>}</p><p></p><p>class Head</p><p>{</p><p></p><p> private $Crop = [[23, 20], [50, 50], [100, 110]];</p><p> private $w, $h;</p><p> private $image, $dest;</p><p> public function __construct(HabboImage $habboImage)</p><p> {</p><p> $size = $habboImage->existParam("size");</p><p> if($size)</p><p> {</p><p> if($habboImage->getParam("size") == "s")</p><p> {</p><p> $this->w = $this->Crop[0][0];</p><p> $this->h = $this->Crop[0][1];</p><p> }</p><p> else if($habboImage->getParam("size") == "l")</p><p> {</p><p> $this->w = $this->Crop[2][0];</p><p> $this->h = $this->Crop[2][1];</p><p> }</p><p> else</p><p> {</p><p> $this->w = $this->Crop[1][0];</p><p> $this->h = $this->Crop[1][1];</p><p> }</p><p> }</p><p> else</p><p> {</p><p> $this->w = $this->Crop[1][0];</p><p> $this->h = $this->Crop[1][1];</p><p> }</p><p> $this->image = imagecreatefrompng($habboImage->getUrl());</p><p> }</p><p> private function applyAlpha($img)</p><p> {</p><p> imagealphablending($img, true);</p><p> imagesavealpha($img, true);</p><p> }</p><p> private function createImage()</p><p> {</p><p> $this->dest = imagecreate($this->w, $this->h);</p><p> }</p><p> private function applyCopy()</p><p> {</p><p> imagecopy($this->dest, $this->image, -5, 0, 0, 12, $this->w, $this->h);</p><p> }</p><p> public function get()</p><p> {</p><p> $this->applyAlpha($this->image);</p><p> $this->createImage();</p><p> $this->applyCopy();</p><p> $this->applyAlpha($this->dest);</p><p></p><p> return imagepng($this->dest);</p><p> }</p><p> public function Destroy()</p><p> {</p><p> imagedestroy($this->dest);</p><p> imagedestroy($this->image);</p><p> }</p><p>}</p><p></p><p>$HabboImage = new HabboImage();</p><p></p><p>foreach ($_GET as $key => $value){</p><p> if($key == "head")</p><p> continue;</p><p> $HabboImage->addParam($key, $value);</p><p>}</p><p>$HabboImage->prepare();</p><p></p><p>if(isset($_GET['head']))</p><p>{</p><p> $Head = new Head($HabboImage);</p><p> $head = $Head->get();</p><p> $Head->Destroy();</p><p> die($head);</p><p>}</p><p>else{</p><p> die($HabboImage->get());</p><p>}</p><p>?></p><p>[/PHP]</p></blockquote><p></p>
[QUOTE="Detox, post: 321198, member: 596"] Okay so how do I turn this PHP code for just showing the heads? so whenever I go to localhost/habbo-imaging/head.php?figure= without having the &headonly=1 [PHP] <?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()); } ?> [/PHP] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
head.php for habbo-imaging
Top