Guest User

Untitled

a guest
Aug 18th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2.  
  3. include "func.php";
  4.  
  5. $string = 0;
  6.  
  7. $bdd = getNewBddAccessor();
  8. $rban = $bdd->prepare("SELECT COUNT(*) AS nb_messages FROM banned_players");
  9. $rban->execute();
  10. $donnees = $rban->fetch();
  11. $string = $donnees['nb_messages'];
  12. $rban->closeCursor();
  13.  
  14. // Set your string somehow
  15. //$string = 'your@example.com';
  16.  
  17. // Set font size
  18. $font_size = 4;
  19.  
  20. // Create image width dependant on width of the string
  21. $width = imagefontwidth($font_size)*strlen($string);
  22. // Set height to that of the font
  23. $height = imagefontheight($font_size);
  24. // Create the image pallette
  25. $img = imagecreate($width,$height);
  26. // Grey background
  27. $bg = imagecolorallocate($img, 25, 25, 25);
  28. // White font color
  29. $color = imagecolorallocate($img, 255, 255, 255);
  30. // Length of the string
  31. $len = strlen($string);
  32. // Y-coordinate of character, X changes, Y is static
  33. $ypos = 0;
  34. // Loop through the string
  35. for($i=0;$i<$len;$i++){
  36. // Position of the character horizontally
  37. $xpos = $i * imagefontwidth($font_size);
  38. // Draw character
  39. imagechar($img, $font_size, $xpos, $ypos, $string, $color);
  40. // Remove character from string
  41. $string = substr($string, 1);
  42.  
  43. }
  44. // Return the image
  45. header("Content-Type: image/gif");
  46. imagegif($img);
  47. // Remove image
  48. imagedestroy($img);
  49.  
  50. ?>
Add Comment
Please, Sign In to add comment