Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    NEMA ellijah's Avatar
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686

    Default Dynamic PHP image help

    I am a complete noob at PHP and really don't understand it. I have been googling and just can't figure it out.

    I want to make my own dynamic image that displays my high scores info from this link: http://services.runescape.com/m=hisc...ser1=ellijahRS

    Same concept as the image in my sig, but I want to learn how it works and I want to make my own.

    0 Not allowed! Not allowed!

  2. #2
    Aesthetic JesusLover666's Avatar
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368
         User Info     Contact     Gamer ID
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368

    Default





    http://bsaeger.com/rs/*yourRSname*.png

    Feel free to use. If anyone else wants one, let me know so I can whitelist your username. (I need to conserve bandwidth, so only allowed users can be generated)

    0 Not allowed! Not allowed!

  3. #3
    NEMA ellijah's Avatar
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686

    Default

    Could you post the source code JL or PM it to me? I want to learn how it's done. I want to make custom ones.

    0 Not allowed! Not allowed!

  4. #4
    Claptrap Fan
    Automotive Aficionado
    Icee's Avatar

    Badge

    Join Date
    Jul 2008
    Posts
    7,294
    Points
    23,697
         User Info     Contact     Gamer ID
    Join Date
    Jul 2008
    Posts
    7,294
    Points
    23,697

    Default

    30.8m xp? Noob.

    0 Not allowed! Not allowed!


  5. #5
    Aesthetic JesusLover666's Avatar
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368
         User Info     Contact     Gamer ID
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368

    Default

    Quote Originally Posted by ellijah View Post
    Could you post the source code JL or PM it to me? I want to learn how it's done. I want to make custom ones.
    It's not the cleanest code, but it works.

    A function to grab the highscores page using Simple HTML DOM (google it for a download), followed by use of the GD image library to draw the text and image.

    Also there is an .htaccess file that rewrites all the requests for a PNG to the PHP file, that's how you can embed it in forums.

    Blank.png is the template file/background for the image.

    Code:
    <?php 
    
       $allowed = array('Z I N G','ellijahRS'); //case sensitive array of allowed usernames
    
       function loadUser( $username )
       {
          global $allowed;
          
          if (!in_array($username, $allowed)) {
          	die();
          }
          include('simple_html_dom.php');
          
          $highscorePage = file_get_html("http://services.runescape.com/m=hiscore_oldschool/hiscorepersonal.ws?user1=".$username );
          
          foreach($highscorePage->find('div#contentHiscores table[border=0] tbody tr') as $skill) {
    	    $item['skill']    = $skill->find('td[align=left]', 0)->plaintext;
    	    $item['level']    = $skill->find('td[align=right]', 2)->plaintext;
    	    $skills[] = $item;
          }
          
          return array_splice($skills,3);
       }
    
    $playerName = $_GET['player'];
    $res = loadUser($playerName);
    
    //output header
    header('Content-Type: image/png'); 
    //output image
    $image = imagecreatefrompng("blank.png");
    
    //setup some colours
    $white = imagecolorallocate($image, 255, 255, 255);
    $whitesemi  = imagecolorallocatealpha($image, 255, 255, 255, 60);
    $black = imagecolorallocate($image, 0, 0, 0);
    $red = imagecolorallocate($image, 165,10,10);
    
    //create our semi transparent white rectangle for text
    imagefilledrectangle($image, 0, 0, 600, 20, $whitesemi);
    
    //choose a default php font number 1 to 5
    $font = 2;
    //write out our text to the image using the font, colour and positions entered
    imagestring($image, $font, 10, 4, 'Player Name: ', $black); 
    imagestring($image, $font, 85, 4, $playerName, $red);
    imagestring($image, $font, 155, 4, 'Total XP: ', $black);
    imagestring($image, $font, 215, 4, $res[0]['level'], $red);
    //begin skills
    //1st column
    imagestring($image, $font, 10, 25, 'Attack: ', $black); 
    imagestring($image, $font, 55, 25, $res[1]['level'], $white);
    
    imagestring($image, $font, 10, 40, 'Defense: ', $black); 
    imagestring($image, $font, 60, 40, $res[2]['level'], $white);
    
    imagestring($image, $font, 10, 55, 'Strength: ', $black); 
    imagestring($image, $font, 65, 55, $res[3]['level'], $white);
    
    imagestring($image, $font, 10, 70, 'Hitpoints: ', $black);
    imagestring($image, $font, 70, 70, $res[4]['level'], $white);
     
    imagestring($image, $font, 10, 85, 'Ranged: ', $black); 
    imagestring($image, $font, 55, 85, $res[5]['level'], $white);
    
    imagestring($image, $font, 10, 100, 'Prayer: ', $black); 
    imagestring($image, $font, 55, 100, $res[6]['level'], $white);
    
    //2nd column
    imagestring($image, $font, 85, 25, 'Magic: ', $black); 
    imagestring($image, $font, 125, 25, $res[7]['level'], $white);
    
    imagestring($image, $font, 85, 40, 'Cooking: ', $black); 
    imagestring($image, $font, 135, 40, $res[8]['level'], $white);
    
    imagestring($image, $font, 85, 55, 'Woodcutting: ', $black); 
    imagestring($image, $font, 158, 55, $res[9]['level'], $white);
    
    imagestring($image, $font, 85, 70, 'Fletching: ', $black); 
    imagestring($image, $font, 148, 70, $res[10]['level'], $white);
    
    imagestring($image, $font, 85, 85, 'Fishing: ', $black); 
    imagestring($image, $font, 135, 85, $res[11]['level'], $white);
    
    imagestring($image, $font, 85, 100, 'Firemaking: ', $black); 
    imagestring($image, $font, 153, 100, $res[12]['level'], $white);
    
    //3rd column
    imagestring($image, $font, 175, 25, 'Crafting: ', $black); 
    imagestring($image, $font, 232, 25, $res[13]['level'], $white);
    
    imagestring($image, $font, 175, 40, 'Smithing: ', $black); 
    imagestring($image, $font, 232, 40, $res[14]['level'], $white);
    
    imagestring($image, $font, 175, 55, 'Mining: ', $black); 
    imagestring($image, $font, 220, 55, $res[15]['level'], $white);
    
    imagestring($image, $font, 175, 70, 'Herblore: ', $black); 
    imagestring($image, $font, 232, 70, $res[16]['level'], $white);
    
    imagestring($image, $font, 175, 85, 'Agility: ', $black); 
    imagestring($image, $font, 225, 85, $res[17]['level'], $white);
    
    imagestring($image, $font, 175, 100, 'Thieving: ', $black); 
    imagestring($image, $font, 232, 100, $res[18]['level'], $white);
    
    //4th column
    imagestring($image, $font, 250, 25, 'Slayer: ', $black); 
    imagestring($image, $font, 295, 25, $res[19]['level'], $white);
    
    imagestring($image, $font, 250, 40, 'Farming: ', $black); 
    imagestring($image, $font, 302, 40, $res[20]['level'], $white);
    
    imagestring($image, $font, 250, 55, 'Runecr.: ', $black); 
    imagestring($image, $font, 302, 55, $res[21]['level'], $white);
    
    imagestring($image, $font, 250, 70, 'Hunter: ', $black); 
    imagestring($image, $font, 295, 70, $res[22]['level'], $white);
    
    imagestring($image, $font, 250, 85, 'Constr.: ', $black); 
    imagestring($image, $font, 302, 85, $res[23]['level'], $white);
    
    $font = 1;
    imagestring($image, $font, 253, 99, 'Created By:', $whitesemi);
    imagestring($image, $font, 248, 107, 'JesusLover666', $whitesemi);
    imagestring($image, $font, 243, 115, 'CodeLeakers.com', $whitesemi);
    
    imagepng($image);
    imagedestroy($image);
    ?>

    0 Not allowed! Not allowed!

  6. #6
    I agree. MatthewH's Avatar
    Join Date
    Jul 2011
    Location
    North Carolina
    Posts
    3,481
    Points
    15,810
         User Info     Contact     Gamer ID
    Join Date
    Jul 2011
    Location
    North Carolina
    Posts
    3,481
    Points
    15,810

    Default

    Quote Originally Posted by JesusLover666 View Post
    It's not the cleanest code, but it works.

    A function to grab the highscores page using Simple HTML DOM (google it for a download), followed by use of the GD image library to draw the text and image.

    Also there is an .htaccess file that rewrites all the requests for a PNG to the PHP file, that's how you can embed it in forums.

    Blank.png is the template file/background for the image.

    Code:
    <?php 
    
       $allowed = array('Z I N G','ellijahRS'); //case sensitive array of allowed usernames
    
       function loadUser( $username )
       {
          global $allowed;
          
          if (!in_array($username, $allowed)) {
          	die();
          }
          include('simple_html_dom.php');
          
          $highscorePage = file_get_html("http://services.runescape.com/m=hiscore_oldschool/hiscorepersonal.ws?user1=".$username );
          
          foreach($highscorePage->find('div#contentHiscores table[border=0] tbody tr') as $skill) {
    	    $item['skill']    = $skill->find('td[align=left]', 0)->plaintext;
    	    $item['level']    = $skill->find('td[align=right]', 2)->plaintext;
    	    $skills[] = $item;
          }
          
          return array_splice($skills,3);
       }
    
    $playerName = $_GET['player'];
    $res = loadUser($playerName);
    
    //output header
    header('Content-Type: image/png'); 
    //output image
    $image = imagecreatefrompng("blank.png");
    
    //setup some colours
    $white = imagecolorallocate($image, 255, 255, 255);
    $whitesemi  = imagecolorallocatealpha($image, 255, 255, 255, 60);
    $black = imagecolorallocate($image, 0, 0, 0);
    $red = imagecolorallocate($image, 165,10,10);
    
    //create our semi transparent white rectangle for text
    imagefilledrectangle($image, 0, 0, 600, 20, $whitesemi);
    
    //choose a default php font number 1 to 5
    $font = 2;
    //write out our text to the image using the font, colour and positions entered
    imagestring($image, $font, 10, 4, 'Player Name: ', $black); 
    imagestring($image, $font, 85, 4, $playerName, $red);
    imagestring($image, $font, 155, 4, 'Total XP: ', $black);
    imagestring($image, $font, 215, 4, $res[0]['level'], $red);
    //begin skills
    //1st column
    imagestring($image, $font, 10, 25, 'Attack: ', $black); 
    imagestring($image, $font, 55, 25, $res[1]['level'], $white);
    
    imagestring($image, $font, 10, 40, 'Defense: ', $black); 
    imagestring($image, $font, 60, 40, $res[2]['level'], $white);
    
    imagestring($image, $font, 10, 55, 'Strength: ', $black); 
    imagestring($image, $font, 65, 55, $res[3]['level'], $white);
    
    imagestring($image, $font, 10, 70, 'Hitpoints: ', $black);
    imagestring($image, $font, 70, 70, $res[4]['level'], $white);
     
    imagestring($image, $font, 10, 85, 'Ranged: ', $black); 
    imagestring($image, $font, 55, 85, $res[5]['level'], $white);
    
    imagestring($image, $font, 10, 100, 'Prayer: ', $black); 
    imagestring($image, $font, 55, 100, $res[6]['level'], $white);
    
    //2nd column
    imagestring($image, $font, 85, 25, 'Magic: ', $black); 
    imagestring($image, $font, 125, 25, $res[7]['level'], $white);
    
    imagestring($image, $font, 85, 40, 'Cooking: ', $black); 
    imagestring($image, $font, 135, 40, $res[8]['level'], $white);
    
    imagestring($image, $font, 85, 55, 'Woodcutting: ', $black); 
    imagestring($image, $font, 158, 55, $res[9]['level'], $white);
    
    imagestring($image, $font, 85, 70, 'Fletching: ', $black); 
    imagestring($image, $font, 148, 70, $res[10]['level'], $white);
    
    imagestring($image, $font, 85, 85, 'Fishing: ', $black); 
    imagestring($image, $font, 135, 85, $res[11]['level'], $white);
    
    imagestring($image, $font, 85, 100, 'Firemaking: ', $black); 
    imagestring($image, $font, 153, 100, $res[12]['level'], $white);
    
    //3rd column
    imagestring($image, $font, 175, 25, 'Crafting: ', $black); 
    imagestring($image, $font, 232, 25, $res[13]['level'], $white);
    
    imagestring($image, $font, 175, 40, 'Smithing: ', $black); 
    imagestring($image, $font, 232, 40, $res[14]['level'], $white);
    
    imagestring($image, $font, 175, 55, 'Mining: ', $black); 
    imagestring($image, $font, 220, 55, $res[15]['level'], $white);
    
    imagestring($image, $font, 175, 70, 'Herblore: ', $black); 
    imagestring($image, $font, 232, 70, $res[16]['level'], $white);
    
    imagestring($image, $font, 175, 85, 'Agility: ', $black); 
    imagestring($image, $font, 225, 85, $res[17]['level'], $white);
    
    imagestring($image, $font, 175, 100, 'Thieving: ', $black); 
    imagestring($image, $font, 232, 100, $res[18]['level'], $white);
    
    //4th column
    imagestring($image, $font, 250, 25, 'Slayer: ', $black); 
    imagestring($image, $font, 295, 25, $res[19]['level'], $white);
    
    imagestring($image, $font, 250, 40, 'Farming: ', $black); 
    imagestring($image, $font, 302, 40, $res[20]['level'], $white);
    
    imagestring($image, $font, 250, 55, 'Runecr.: ', $black); 
    imagestring($image, $font, 302, 55, $res[21]['level'], $white);
    
    imagestring($image, $font, 250, 70, 'Hunter: ', $black); 
    imagestring($image, $font, 295, 70, $res[22]['level'], $white);
    
    imagestring($image, $font, 250, 85, 'Constr.: ', $black); 
    imagestring($image, $font, 302, 85, $res[23]['level'], $white);
    
    $font = 1;
    imagestring($image, $font, 253, 99, 'Created By:', $whitesemi);
    imagestring($image, $font, 248, 107, 'JesusLover666', $whitesemi);
    imagestring($image, $font, 243, 115, 'CodeLeakers.com', $whitesemi);
    
    imagepng($image);
    imagedestroy($image);
    ?>
    Very nice! I was wondering how you did it. Thanks for the post JL.

    0 Not allowed! Not allowed!


  7. #7
    NEMA ellijah's Avatar
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686

    Default

    What did you put in your .htaccess file to make it redirect the link as a .png? Having trouble finding anything that works on google.

    Can't get it to work.

    0 Not allowed! Not allowed!

  8. #8
    NEMA ellijah's Avatar
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686

    Default

    /Bump.

    0 Not allowed! Not allowed!

  9. #9
    Aesthetic JesusLover666's Avatar
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368
         User Info     Contact     Gamer ID
    Join Date
    Dec 2009
    Location
    /bin/laden
    Posts
    1,122
    Points
    2,368

    Default

    Are you really just stealing my code? lol

    Code:
    RewriteEngine on
    RewriteRule ^(.*).png$ index.php?player=$1

    0 Not allowed! Not allowed!

  10. #10
    NEMA ellijah's Avatar
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Posts
    5,634
    Points
    8,686

    Default

    Not stealing it. Lol

    I just want to understand how it works so I can make dynamic sigs of stuff.

    I will put credit to you in the image.

    0 Not allowed! Not allowed!

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 04:52 AM.
Powered by vBulletin®
Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.