Guest User

get_avatar.php

a guest
Apr 16th, 2015
209
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. $size = isset($_GET['s']) ? max(8,min(250,$_GET['s'])) : 20;
  5. $user = isset($_GET['u']) ? $_GET['u'] : 'char';
  6.  
  7. function get_avatar($user = 'char') {
  8.     $ch = curl_init();
  9.     curl_setopt($ch, CURLOPT_URL, 'http://skins.minecraft.net/MinecraftSkins/' . $user . '.png');
  10.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  12.     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  13.     $output = curl_exec($ch);
  14.     $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  15.     curl_close($ch);
  16.     if($status!='200') {
  17.         // Default Avatar: http://www.minecraft.net/skin/char.png
  18.         $output = 'R0lGODlhMAAQAPUuALV7Z6p9ZkUiDkEhDIpMPSgcC2pAMFI9ibSEbZxpTP///7uJciodDTMkEYNVO7eCcpZfQJBeQ5xjRkIdCsaWgL2OdL';
  19.         $output .= '6IbL2OcqJqRyweDj8qFXpOMy8fDyQYCC8gDUIqEiYaCraJbL2Lco9ePoBTNG1DKpxyXK2AbbN7Yqx2WjQlEoFTOW9FLCseDQAAAAAAAAA';
  20.         $output .= 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C1hNUCBEYXRhWE1QRD94cDIzRThDRkQwQzcyIiB4';
  21.         $output .= 'bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTVBQzAwMDFwYWNrZXQgZW5kPSJyIj8+ACH5BAUAAC4ALAAAAAAwABAAQAZkQJdwSCwaj';
  22.         $output .= '8ik0uVpcQodUIuxrFqv2OwRoTgAFgdFQEsum8/ocit0oYgqKVVaG4EMCATBaDXv+/+AgYKDVS2GDR8aGQWESAEIAScmCwkJjUcSKA8GBh';
  23.         $output .= 'YYJJdGLCUDEwICDhuEQQA7';
  24.         $output = base64_decode($output);
  25.     }
  26.     return $output;
  27. }
  28.  
  29. $skin = get_avatar($user);
  30.  
  31. $im = imagecreatefromstring($skin);
  32. $av = imagecreatetruecolor($size,$size);
  33. imagecopyresized($av,$im,0,0,8,8,$size,$size,8,8);    // Face
  34. imagecopyresized($av,$im,0,0,40,8,$size,$size,8,8);   // Accessories
  35. header('Content-type: image/png');
  36. imagepng($av);
  37. imagedestroy($im);
  38. imagedestroy($av);
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. ?>
RAW Paste Data