Advertisement
Guest User

Untitled

a guest
Dec 14th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('error_reporting', E_ALL);
  4.  
  5. $username=""; //Your MySQL Username.
  6. $password=""; // Your MySQL Pass.
  7. $database=""; // Your MySQL database.
  8. $host=""; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.
  9.  
  10. $player_name=$_GET['player_name']; // This gets the player his name from the previous page.
  11.  
  12. /* Next, we will make a connection to the mysql.
  13. If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */
  14.  
  15. mysql_connect($host,$username,$password); // Connection to the database.
  16. @mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error.
  17.  
  18. /* To protect MySQL injection. */
  19. $player_name = stripslashes($player_name);
  20. $player_name = mysql_real_escape_string($player_name);
  21.  
  22.  
  23.  
  24. $query="SELECT * FROM `playerbase` WHERE `name` = '%s' LIMIT 1", 'pname'; // Gets all the information about the player.
  25. $result=mysql_query($query);
  26. $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us.
  27.  
  28. /* We will now put the player's information into variables so we can use them more easily. */
  29. /* DON'T FORGET: The names should be exact the same as in your mysql db.*/
  30.  
  31. if ($i == 1) // If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code.
  32. {
  33.  
  34. $Playername=mysql_result($result,0,"name"); // Gets the username of the player and put it in the variable $Playername.
  35. $Money=mysql_result($result,0,"money"); // Gets the money of the player and put it in the variable $Money.
  36. $Score=mysql_result($result,0,"score"); // Gets the score of the player and put it in the variable $Score.
  37.  
  38. $text_username = "$Playername"; // This gets the information about player name to be showed in the picture.
  39. $text_score = "$Score"; // Same as above ^^
  40. $text_money = "$Money"; // Same as above ^^
  41. // Establish image factors:
  42. $font_size = 18; // Font size is in pixels.
  43. $font_file = 'Tahoma.ttf'; // This is the path to your font file.
  44.  
  45. // Create image:
  46. $image = imagecreatetruecolor(450, 110); // Create a truecolor image 450x110
  47.  
  48. // Allocate text and background colors (RGB format):
  49. $bg_color = imagecolorallocate($image, 0, 0, 0);
  50. $text_color = imagecolorallocate($image,237,176,07);
  51.  
  52. // Fill image:
  53. imagefill($image, 0, 0, $bg_color);
  54.  
  55. // Bg IMG
  56. $bg_image = imagecreatefrompng("bg.png"); // Load PNG image
  57. imagecopy($image,$bg_image,0,0,0,0,450,110); // Then copy it into our image
  58.  
  59. // Add TrueType text to image:
  60. imagettftext($image, $font_size, 0, 100, 60, $text_color, $font_file, "This is a test!");
  61.  
  62. // Generate and send image to browser:
  63. header('Content-type: image/png');
  64. imagepng($image);
  65.  
  66. // Destroy image in memory to free-up resources:
  67. imagedestroy($image);
  68. } else echo('Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error.
  69.  
  70. mysql_close();
  71.  
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement