Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function formatTime($time){
- $time_seconds = $time / 1000;
- $time_minutes = $time_seconds / 60;
- $time_hours = $time_minutes / 60;
- $time_days = floor($time_hours / 24);
- $seconds = $time_seconds % 60;
- $minutes = $time_minutes % 60;
- $hours = $time_hours % 24;
- $days = floor($time_days % 365);
- $years = floor($time_days / 365);
- return $years . "y " . $days . "d " .$hours . "h " . $minutes . "m ";
- }
- $username=""; //Your MySQL Username.
- $password=""; // Your MySQL Pass.
- $database=""; // Your MySQL database.
- $host=""; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.
- $player_name=$_GET['player_name']; // This gets the player his name from the previous page.
- mysql_connect($host,$username,$password); // Connection to the database.
- @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.
- /* To protect MySQL injection. */
- $player_name = stripslashes($player_name);
- $player_name = mysql_real_escape_string($player_name);
- /* */
- if($player_name == "ALL"){ // If you want to sum all of your users data, like I have in my signature, you need this.
- $query="SELECT SUM(timeran) as timesum FROM Data";
- $result=mysql_query($query);
- $Timeran1= mysql_fetch_assoc($result);
- $Timeran = $Timeran1[timesum];
- $query="SELECT SUM(NPC_Caught) as npcCaughtSum FROM Data";
- $result=mysql_query($query);
- $NPC_Caught1= mysql_fetch_assoc($result);
- $NPCCaught = $NPC_Caught1[npcCaughtSum];
- $query="SELECT SUM(expgained) as expsum FROM Data";
- $result=mysql_query($query);
- $ExpGained1= mysql_fetch_assoc($result);
- $ExpGained = $ExpGained1[expsum];
- $query="SELECT SUM(profit) as profitsum FROM Data";
- $result=mysql_query($query);
- $ProfitGained1= mysql_fetch_assoc($result);
- $ProfitGained = $ProfitGained1[profitsum];
- // Now for the creation of the image.
- header('Content-Type: image/png;');
- // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
- $im = @imagecreatefrompng('AIO_Hunter_Dynamic_Sig.png') or die("Cannot find image, check naming and file location");
- $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish.
- $text_username = "ALL"; // $text_username = "ALL"; This gets the information about player name to be showed in the picture.
- $text_timeran = formatTime($Timeran); // Same as above ^^
- $text_expgained = number_format($ExpGained);
- $text_NPCCaught = number_format($NPCCaught);
- $text_profitgained = number_format($ProfitGained);
- $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed if you wish to customise it.
- // 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.
- imagettftext($im, 16, 0, 220, 93, $text_color, $font, $text_username);
- imagettftext($im, 12, 0, 45, 50, $text_color, $font, $text_expgained);
- imagettftext($im, 11, 0, 390, 50, $text_color, $font, $text_timeran); // done
- imagettftext($im, 12, 0, 405, 135, $text_color, $font, $text_NPCCaught);
- imagettftext($im, 12, 0, 55, 135, $text_color, $font, $text_profitgained);
- imagepng($im);
- imagedestroy($im);
- return;
- }
- // Below is the code for regular players, it will not SUM
- $query="SELECT * FROM Data WHERE Username='$player_name'"; // Gets all the information about the player.
- $result=mysql_query($query);
- $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us.
- 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.
- {
- $Username=mysql_result($result,0,"Username");
- $Timeran=mysql_result($result,0,"timeran");
- $ExpGained=mysql_result($result,0,"expgained");
- $NPCCaught=mysql_result($result,0,"NPC_Caught");
- $ProfitGained=mysql_result($result,0,"profit");
- // Creating of the .png image.
- header('Content-Type: image/png;');
- // Your image must be in the same directory as your PHP Scripts for it to work, otherwise you will need to include a path
- $im = @imagecreatefrompng('AIO_Hunter_Dynamic_Sig.png') or die("Cannot find image, check naming and file location");
- $text_color = imagecolorallocate($im, 255,255,100); // RED, GREEN, BLUE , you can goto http://colorpicker.com to pick a nice colour if you wish.
- $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.
- $text_timeran = formatTime($Timeran); // Same as above ^^
- $text_expgained = number_format($ExpGained);
- $text_NPCCaught = number_format($NPCCaught);
- $text_profitgained = number_format($ProfitGained);
- $font = 'Calibri.ttf'; //Upload your custum font to the directory where this file is placed. Then change the name here.
- // 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.
- imagettftext($im, 16, 0, 220, 93, $text_color, $font, $text_username);
- imagettftext($im, 12, 0, 45, 50, $text_color, $font, $text_expgained);
- imagettftext($im, 11, 0, 390, 50, $text_color, $font, $text_timeran); // done
- imagettftext($im, 12, 0, 405, 135, $text_color, $font, $text_NPCCaught);
- imagettftext($im, 12, 0, 55, 135, $text_color, $font, $text_profitgained);
- imagepng($im);
- imagedestroy($im);
- } 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.
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement