Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Avatar Caching system [REL]

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jan 9, 2013
Messages
11
Reaction score
1
Hello,

i have code a advanced avatar caching system, because i'm boring..

PHP:
<?phpheader('Content-Type: image/png');// Avatar caching system// CODER: Karim, AKA iFuckR
// CONFIGdefine("HOST", "127.0.0.1"); // Gebruiker 127.0.0.1 voor snelheid!define("GEBRUIKER", "root"); // Gebruiker, meestal 'root'define("WACHTWOORD", "123"); // Wachtwoord, moet voor zichzelf sprekendefine("DATABASE", "bcstorm"); // Database naam.$map = './avatars'; // De map waar alles word opgeslagen.define("HOTEL", "habbo.co.uk"); // Het hotel waar de data vandaan moet komen, gebruik geen .com!// Verander niks onder deze lijn! Anders kan het systeem langzaam worden, of verknalt worden enzo.. xd

	mysql_connect(HOST, GEBRUIKER, WACHTWOORD) or die ('FATALE FOUT: Onmogelijk om met MySQL server te verbinden!');	mysql_select_db(DATABASE) or die ('FATALE FOUT: Onmogelijk om te verbinden met database!'); 


if (!is_dir($map)) 	{		if (!mkdir($map, 0, true)) 			{				die('FATALE FOUT: Onmogelijk om folder aan te maken!');			}	}
	$figure = $_GET['figure'];
if(isset($_GET['size'])){$size = $_GET['size'];} else { $size= 'b';}
if(isset($_GET['direction'])){$direction = $_GET['direction'];} else { $direction = '2';}
if(isset($_GET['head_direction'])){$head = $_GET['head_direction'];} else { $head = '2'; }
if(isset($_GET['gesture'])){$gesture = $_GET['gesture'];} else { $gesture = '';}
$lookhash = md5("$figure$size$direction$head$gesture");

if (file_exists("$map/$lookhash.png")) {    $finalavatar = require("$map/$lookhash.png");	} else {	$habbo = file_get_contents("http://".HOTEL."/habbo-imaging/avatarimage?figure=".$figure."&size=".$size."&direction=".$direction."&head_direction=".$head."&gesture=".$gesture."");    $fp = fopen("$map/$lookhash.png", 'w');	fwrite($fp, $habbo);	fclose($fp);	$finalavatar = $habbo;}
/// JAJAJAJAJ! EINDELIJK! DAAR IS DIE DAN, EN VELE MALEN SNELLER :o!echo $finalavatar;

How it works.
You make a php file, avatars.php or something, and it makes the source.




The first time the script is used, there will a folder created ..
and there are all avatars stored.


The first time this avatar being watched, get stored on habbo hotel, to your web server.


The next time you watched avatar, hosts.allow the avatar from the server read it does not use the internet, so equal * rads * from the server ..
 
idk what to put here
Loyal Member
Joined
Oct 19, 2007
Messages
491
Reaction score
159
When will people learn that caching speeds up load time but ruins disk space!? :<

He was bored so he coded something for the community? I didn't know that was so bad.

To the OP, good release, it'll help with small hotels who are looking to use this :).
 
Newbie Spellweaver
Joined
Dec 23, 2011
Messages
95
Reaction score
8
can anny1 give me some of his avatar images? (.png)

just alot :p
 
I don't even know
Loyal Member
Joined
Apr 7, 2010
Messages
1,699
Reaction score
420
<?php
header('Content-Type: image/png');

$path = trim($_SERVER['PATH_INFO'], '/');
$db = new MySQLi('p:localhost', 'root', 'admin', 'phoenix');

if ($row = $db->query('SELECT image FROM avatars WHERE uri = \''.$path.'\' LIMIT 1')->fetch_assoc())
{
exit($row['image']);
}

$data = file_get_contents('http://www.habbo.nl/habbo-imaging/avatarimage?'.$path);
$db->query('INSERT INTO avatars (uri, image) VALUES(\''.$db->real_escape_string($path).'\', \''.$db->real_escape_string($data).'\')');

echo $data;
?>

Better?
 
I don't even know
Loyal Member
Joined
Apr 7, 2010
Messages
1,699
Reaction score
420
<?php
header('Content-Type: image/png');

$path = trim($_SERVER['PATH_INFO'], '/');
$db = new MySQLi('p:localhost', 'root', 'admin', 'phoenix');

if ($row = $db->query('SELECT image FROM avatars WHERE uri = \''.$path.'\' LIMIT 1')->fetch_assoc())
{
exit($row['image']);
}

$data = file_get_contents('http://www.habbo.nl/habbo-imaging/avatarimage?'.$path);
$db->query('INSERT INTO avatars (uri, image) VALUES(\''.$db->real_escape_string($path).'\', \''.$db->real_escape_string($data).'\')');

echo $data;
?>

If you use this with my QuickTPL or UberCMS with a cron job which cleans the table every week, it will really help you speed up your site.
 
Newbie Spellweaver
Joined
Jan 9, 2013
Messages
11
Reaction score
1
No it is not bad.
If you have 1000 online, and 250,000 users ..
Will you approximately 8 million images have been cached but 8 gb.
 
[̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅]
Joined
May 4, 2008
Messages
831
Reaction score
741
If I am not mistaking with phoenix you can use last_updated to detect if the look of the user has changed and delete the old image.

 
Status
Not open for further replies.
Back
Top