Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- TODO: Compile all XML queries in a single function
- */
- $profile = $_GET["profile"];
- // PURPOSE: Check wether a string is a custom URL or community ID
- function GetXMLURL( $id )
- {
- $pattern = explode( "9", $id, -1 );
- if ( $pattern[0] == "765611" )
- {
- return simplexml_load_file( "http://steamcommunity.com/profiles/" . $id . "/?xml=1" );
- }
- else
- {
- return simplexml_load_file( "http://steamcommunity.com/id/" . $id . "/?xml=1" );
- }
- }
- // PURPOSE: Return the profile image
- function GetProfileImage( $profileurl )
- {
- $xmlloc = @GetXMLURL( $profileurl );
- if ( !$xmlloc )
- {
- return "error";
- }
- else
- {
- foreach( $xmlloc->children() as $child )
- {
- if ( $child->getName() == "error" )
- {
- return "error";
- }
- else
- {
- if ( $child->getName() == "avatarMedium" )
- {
- return $child;
- }
- }
- }
- }
- }
- // PURPOSE: Get Steam friends name
- function GetName( $profileurl )
- {
- $xmlloc = @GetXMLURL( $profileurl );
- if ( !$xmlloc )
- {
- return "error";
- }
- else
- {
- foreach( $xmlloc->children() as $child )
- {
- if ( $child->getName() == "error" )
- {
- return "error";
- }
- else
- {
- if ( $child->getName() == "steamID" )
- {
- return $child;
- }
- }
- }
- }
- }
- // PURPOSE: Returns if user is online or not
- function GetOnlineStatus( $profileurl )
- {
- $xmlloc = @GetXMLURL( $profileurl );
- if ( !$xmlloc )
- {
- return "error";
- }
- else
- {
- foreach( $xmlloc->children() as $child )
- {
- if ( $child->getName() == "error" )
- {
- return "error";
- }
- else
- {
- if ( $child->getName() == "onlineState" )
- {
- return $child;
- }
- }
- }
- }
- }
- // PURPOSE: Load the profile image and prepare it for use with GD
- function LoadJpeg( $profile )
- {
- $profileimg = GetProfileImage( $profile );
- $profilename = GetName( $profile );
- $profileolstatus = GetOnlineStatus( $profile );
- if ( $profileimg == "error" ) break;
- if ( $profilename == "error" ) $profilename = "faggot";
- $im = @imagecreatefromjpeg( $profileimg );
- $bg = imagecreatefrompng( 'res/template_lol.png' );
- if( !$im )
- {
- $im = imagecreatetruecolor( 100, 100 );
- $bgc = imagecolorallocate( $im, 255, 255, 255 );
- $tc = imagecolorallocate( $im, 0, 0, 0 );
- imagefilledrectangle( $im, 0, 0, 150, 30, $bgc );
- imagestring( $im, 1, 5, 5, 'Error', $tc );
- }
- // yay colors :3
- $col_white = imagecolorallocate( $im, 255, 255, 255 );
- $col_red = imagecolorallocate( $im, 255, 0, 0 );
- $col_green = imagecolorallocate( $im, 0, 255, 0 );
- $col_black = imagecolorallocate( $im, 0, 0, 0 );
- imagecopy( $bg, $im, 3, 3, 0, 0, imagesx( $im ), imagesy( $im ) );
- imagestring( $bg, 5, 75, 8, $profilename, $col_white );
- if ( $profileolstatus == "online" )
- {
- $profileolcolor = imagecolorallocate( $im, 57, 224, 54 );
- }
- else
- {
- $profileolcolor = imagecolorallocate( $im, 182, 182, 182 );
- }
- imagefilledrectangle( $bg, 75, 25, 83, 33, $profileolcolor );
- return $bg;
- }
- header( 'Content-Type: image/png' );
- $img = LoadJpeg( $profile );
- imagepng( $img );
- imagedestroy( $img );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment