hlsdk

generate_nope

Apr 8th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.28 KB | None | 0 0
  1. <?php
  2.     /*
  3.         TODO:   Compile all XML queries in a single function
  4.     */
  5.    
  6.     $profile = $_GET["profile"];
  7.  
  8.     // PURPOSE: Check wether a string is a custom URL or community ID
  9.     function GetXMLURL( $id )
  10.     {
  11.         $pattern = explode( "9", $id, -1 );
  12.        
  13.         if ( $pattern[0] == "765611" )
  14.         {
  15.             return simplexml_load_file( "http://steamcommunity.com/profiles/" . $id . "/?xml=1" );
  16.         }
  17.         else
  18.         {
  19.             return simplexml_load_file( "http://steamcommunity.com/id/" . $id . "/?xml=1" );
  20.         }
  21.     }
  22.  
  23.     // PURPOSE: Return the profile image
  24.     function GetProfileImage( $profileurl )
  25.     {
  26.         $xmlloc = @GetXMLURL( $profileurl );
  27.        
  28.         if ( !$xmlloc )
  29.         {
  30.             return "error";
  31.         }
  32.         else
  33.         {
  34.             foreach( $xmlloc->children() as $child )
  35.             {
  36.                 if ( $child->getName() == "error" )
  37.                 {
  38.                     return "error";
  39.                 }
  40.                 else
  41.                 {          
  42.                     if ( $child->getName() == "avatarMedium" )
  43.                     {
  44.                         return $child;
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.     }
  50.    
  51.     // PURPOSE: Get Steam friends name
  52.     function GetName( $profileurl )
  53.     {
  54.         $xmlloc = @GetXMLURL( $profileurl );
  55.        
  56.         if ( !$xmlloc )
  57.         {
  58.             return "error";
  59.         }
  60.         else
  61.         {
  62.             foreach( $xmlloc->children() as $child )
  63.             {
  64.                 if ( $child->getName() == "error" )
  65.                 {
  66.                     return "error";
  67.                 }
  68.                 else
  69.                 {          
  70.                     if ( $child->getName() == "steamID" )
  71.                     {
  72.                         return $child;
  73.                     }
  74.                 }
  75.             }
  76.         }
  77.     }
  78.    
  79.     // PURPOSE: Returns if user is online or not
  80.     function GetOnlineStatus( $profileurl )
  81.     {
  82.         $xmlloc = @GetXMLURL( $profileurl );
  83.        
  84.         if ( !$xmlloc )
  85.         {
  86.             return "error";
  87.         }
  88.         else
  89.         {
  90.             foreach( $xmlloc->children() as $child )
  91.             {
  92.                 if ( $child->getName() == "error" )
  93.                 {
  94.                     return "error";
  95.                 }
  96.                 else
  97.                 {          
  98.                     if ( $child->getName() == "onlineState" )
  99.                     {
  100.                         return $child;
  101.                     }
  102.                 }
  103.             }
  104.         }
  105.     }
  106.    
  107.     // PURPOSE: Load the profile image and prepare it for use with GD
  108.     function LoadJpeg( $profile )
  109.     {
  110.         $profileimg = GetProfileImage( $profile );
  111.         $profilename = GetName( $profile );
  112.         $profileolstatus = GetOnlineStatus( $profile );
  113.        
  114.         if ( $profileimg == "error" ) break;
  115.         if ( $profilename == "error" ) $profilename = "faggot";
  116.        
  117.        
  118.         $im = @imagecreatefromjpeg( $profileimg );
  119.         $bg = imagecreatefrompng( 'res/template_lol.png' );
  120.        
  121.         if( !$im )
  122.         {
  123.             $im  = imagecreatetruecolor( 100, 100 );
  124.            
  125.             $bgc = imagecolorallocate( $im, 255, 255, 255 );
  126.             $tc  = imagecolorallocate( $im, 0, 0, 0 );
  127.            
  128.             imagefilledrectangle( $im, 0, 0, 150, 30, $bgc );
  129.             imagestring( $im, 1, 5, 5, 'Error', $tc );
  130.         }
  131.        
  132.         // yay colors :3
  133.         $col_white   = imagecolorallocate( $im, 255, 255, 255 );
  134.         $col_red     = imagecolorallocate( $im, 255, 0, 0 );
  135.         $col_green   = imagecolorallocate( $im, 0, 255, 0 );
  136.         $col_black   = imagecolorallocate( $im, 0, 0, 0 );
  137.        
  138.         imagecopy( $bg, $im, 3, 3, 0, 0, imagesx( $im ), imagesy( $im ) );
  139.         imagestring( $bg, 5, 75, 8, $profilename, $col_white );
  140.        
  141.         if ( $profileolstatus == "online" )
  142.         {
  143.             $profileolcolor = imagecolorallocate( $im, 57, 224, 54 );
  144.         }
  145.         else
  146.         {
  147.             $profileolcolor = imagecolorallocate( $im, 182, 182, 182 );
  148.         }
  149.        
  150.         imagefilledrectangle( $bg, 75, 25, 83, 33, $profileolcolor );
  151.        
  152.         return $bg;
  153.     }
  154.  
  155.     header( 'Content-Type: image/png' );
  156.  
  157.     $img = LoadJpeg( $profile );
  158.  
  159.     imagepng( $img );
  160.     imagedestroy( $img );
  161. ?>
Advertisement
Add Comment
Please, Sign In to add comment