Advertisement
Guest User

Untitled

a guest
Mar 28th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. <?
  2.  
  3.  
  4.  
  5. function formatTime($time){
  6. $time_seconds = $time / 1000;
  7. $time_minutes = $time_seconds / 60;
  8. $time_hours = $time_minutes / 60;
  9. $time_days = floor($time_hours / 24);
  10. $seconds = $time_seconds % 60;
  11. $minutes = $time_minutes % 60;
  12. $hours = $time_hours % 24;
  13.  
  14. $days = floor($time_days % 365);
  15. $years = floor($time_days / 365);
  16.  
  17. return $years . "y " . $days . "d " .$hours . "h " . $minutes . "m ";
  18. }
  19.  
  20.  
  21. $username=""; //Your MySQL Username.
  22. $password=""; // Your MySQL Pass.
  23. $database=""; // Your MySQL database.
  24. $host=""; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.
  25.  
  26.  
  27.  
  28. $player_name=$_GET['player_name']; // This gets the player his name from the previous page.
  29.  
  30.  
  31. mysql_connect($host,$username,$password); // Connection to the database.
  32. @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.
  33.  
  34.  
  35. /* To protect MySQL injection. */
  36. $player_name = stripslashes($player_name);
  37. $player_name = mysql_real_escape_string($player_name);
  38. /* */
  39.  
  40.  
  41.  
  42. if($player_name == "ALL"){ // If you want to sum all of your users data, like I have in my signature, you need this.
  43.  
  44. $query="SELECT SUM(timeran) as timesum FROM Data";
  45. $result=mysql_query($query);
  46. $Timeran1= mysql_fetch_assoc($result);
  47. $Timeran = $Timeran1[timesum];
  48.  
  49.  
  50. $query="SELECT SUM(NPC_Caught) as npcCaughtSum FROM Data";
  51. $result=mysql_query($query);
  52. $NPC_Caught1= mysql_fetch_assoc($result);
  53. $NPCCaught = $NPC_Caught1[npcCaughtSum];
  54.  
  55.  
  56. $query="SELECT SUM(expgained) as expsum FROM Data";
  57. $result=mysql_query($query);
  58. $ExpGained1= mysql_fetch_assoc($result);
  59. $ExpGained = $ExpGained1[expsum];
  60.  
  61. $query="SELECT SUM(profit) as profitsum FROM Data";
  62. $result=mysql_query($query);
  63. $ProfitGained1= mysql_fetch_assoc($result);
  64. $ProfitGained = $ProfitGained1[profitsum];
  65.  
  66.  
  67. // Now for the creation of the image.
  68.  
  69.  
  70.  
  71. header('Content-Type: image/png;');
  72. // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
  73. $im = @imagecreatefrompng('AIO_Hunter_Dynamic_Sig.png') or die("Cannot find image, check naming and file location");
  74.  
  75.  
  76.  
  77. $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish.
  78.  
  79. $text_username = "ALL"; // $text_username = "ALL"; This gets the information about player name to be showed in the picture.
  80. $text_timeran = formatTime($Timeran); // Same as above ^^
  81. $text_expgained = number_format($ExpGained);
  82. $text_NPCCaught = number_format($NPCCaught);
  83. $text_profitgained = number_format($ProfitGained);
  84.  
  85.  
  86. $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed if you wish to customise it.
  87.  
  88. // 18 is the font size, 0 is the angel of the text, 165 is the x coordinate on your image, and 132 is the Y coordinate on your image.
  89.  
  90. imagettftext($im, 16, 0, 220, 93, $text_color, $font, $text_username);
  91.  
  92. imagettftext($im, 12, 0, 45, 50, $text_color, $font, $text_expgained);
  93.  
  94. imagettftext($im, 11, 0, 390, 50, $text_color, $font, $text_timeran); // done
  95.  
  96. imagettftext($im, 12, 0, 405, 135, $text_color, $font, $text_NPCCaught);
  97.  
  98. imagettftext($im, 12, 0, 55, 135, $text_color, $font, $text_profitgained);
  99.  
  100. imagepng($im);
  101.  
  102. imagedestroy($im);
  103.  
  104. return;
  105.  
  106. }
  107.  
  108. // Below is the code for regular players, it will not SUM
  109.  
  110. $query="SELECT * FROM Data WHERE Username='$player_name'"; // Gets all the information about the player.
  111.  
  112. $result=mysql_query($query);
  113. $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us.
  114.  
  115.  
  116. 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.
  117. {
  118.  
  119.  
  120. $Username=mysql_result($result,0,"Username");
  121. $Timeran=mysql_result($result,0,"timeran");
  122. $ExpGained=mysql_result($result,0,"expgained");
  123. $NPCCaught=mysql_result($result,0,"NPC_Caught");
  124. $ProfitGained=mysql_result($result,0,"profit");
  125.  
  126. // Creating of the .png image.
  127.  
  128. header('Content-Type: image/png;');
  129. // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
  130. $im = @imagecreatefrompng('AIO_Hunter_Dynamic_Sig.png') or die("Cannot find image, check naming and file location");
  131.  
  132. $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish.
  133. $text_username = "$Username"; // This gets the information about player name to be showed in the picture. // This gets the information about player name to be showed in the picture.
  134. $text_timeran = formatTime($Timeran); // Same as above ^^
  135. $text_expgained = number_format($ExpGained);
  136. $text_NPCCaught = number_format($NPCCaught);
  137. $text_profitgained = number_format($ProfitGained);
  138.  
  139. $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here.
  140.  
  141. // 18 is the font size, 0 is the angel of the text, 165 is the x coordinate on your image, and 132 is the Y coordinate on your image.
  142. imagettftext($im, 16, 0, 220, 93, $text_color, $font, $text_username);
  143.  
  144. imagettftext($im, 12, 0, 45, 50, $text_color, $font, $text_expgained);
  145.  
  146. imagettftext($im, 11, 0, 390, 50, $text_color, $font, $text_timeran); // done
  147.  
  148. imagettftext($im, 12, 0, 405, 135, $text_color, $font, $text_NPCCaught);
  149.  
  150. imagettftext($im, 12, 0, 55, 135, $text_color, $font, $text_profitgained);
  151.  
  152.  
  153.  
  154. imagepng($im);
  155. imagedestroy($im);
  156.  
  157. } 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.
  158.  
  159. mysql_close();
  160.  
  161. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement