1
0

bar.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function drawRating($rating)
  25. {
  26. $width = 300;
  27. $height = 15;
  28. $ratingbar = (($rating / 100) * $width) - 2;
  29. $image = imagecreate($width, $height);
  30. $fill = ImageColorAllocate($image, 67, 219, 0);
  31. if ($rating > 74) {
  32. $fill = ImageColorAllocate($image, 233, 233, 0);
  33. }
  34. if ($rating > 89) {
  35. $fill = ImageColorAllocate($image, 197, 6, 6);
  36. }
  37. if ($rating > 100) {
  38. echo "Overload Error!";
  39. exit();
  40. }
  41. $back = ImageColorAllocate($image, 255, 255, 255);
  42. $border = ImageColorAllocate($image, 151, 151, 151);
  43. ImageFilledRectangle($image, 0, 0, $width - 1, $height - 1, $back);
  44. ImageFilledRectangle($image, 1, 1, $ratingbar, $height - 1, $fill);
  45. ImageRectangle($image, 0, 0, $width - 1, $height - 1, $border);
  46. imagePNG($image);
  47. imagedestroy($image);
  48. }
  49. Header("Content-type: image/png");
  50. drawRating($_GET['rating']);
  51. ?>