Oh boy, sorry for reviving an old thread but I could use some help with this script. Im doing my best with my very very very basic understanding of php to incorporate this in to my sites CMS(php-fusion) for users auto avatars. Also excuse me if I misuse the terminology here. Upon registering a user has to input their username in order to register. So I have your code.
<?php
header('Content-Type: image/png');
$user_minecraft = 'wide_load';
$width = 100;
$height = 100;
$cache_file = "player_skins/{$user_minecraft}_{$width}x{$height}.png";
if (!file_exists($cache_file) || time() - filemtime($cache_file) > 86400){
$skin = imagecreatefromstring(file_get_contents("http://s3.amazonaws.com/MinecraftSkins/ ... craft}.png"));
$face = imagecreatetruecolor($width, $height);
imagecopyresized($face, $skin, 0, 0, 8, 8, $width, $height, 8, 8);
imagecopyresized($face, $skin, 0, 0, 40, 8, $width, $height, 8, 8);
imagepng($face, $cache_file);
}
readfile($cache_file);
?>
My issue here is that 'wide_load' needs to call from the db query for a players username
The dq query for this is
".$data['user_minecraft'].">
I need to somehow make these files work with each other so that I can replace all the avatar code to this.
Heres what im using to test it at least
echo "<img src=h.../mcavatar.php?player_name=".$data['user_minecraft'].">\n";
The script runs fine and will load the player face of "wide_load"
In addition I also need a if/else for an invalid username say its unable to load an image then else it would load like a noavatar.png image.
I hope you understand what im trying to get it as im having trouble explaining this without knowing all the terms. Thanks in advance!