mon_stats.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. require_once('includes/lib_remote.php');
  25. function pretty_text_ttf($im, $fontsize, $angle, $x, $y, $color, $font, $string, $outline = false) {
  26. $black = imagecolorallocate($im, 0, 0, 0);
  27. // Black outline
  28. if($outline){
  29. imagettftext($im, $fontsize, $angle, $x - 1, $y - 1, $black, $font, $string);
  30. imagettftext($im, $fontsize, $angle, $x - 1, $y, $black, $font, $string);
  31. imagettftext($im, $fontsize, $angle, $x - 1, $y + 1, $black, $font, $string);
  32. imagettftext($im, $fontsize, $angle, $x, $y - 1, $black, $font, $string);
  33. imagettftext($im, $fontsize, $angle, $x, $y + 1, $black, $font, $string);
  34. imagettftext($im, $fontsize, $angle, $x + 1, $y - 1, $black, $font, $string);
  35. imagettftext($im, $fontsize, $angle, $x + 1, $y, $black, $font, $string);
  36. imagettftext($im, $fontsize, $angle, $x + 1, $y + 1, $black, $font, $string);
  37. }
  38. // Your text
  39. imagettftext($im, $fontsize, $angle, $x, $y, $color, $font, $string);
  40. return $im;
  41. }
  42. function dsi_make_img($im = false, $cache_on = false, $cache_data = false, $force_cached = false, $format = false){
  43. header("Content-type: image/png");
  44. if($cache_on && $cache_data["file"]){
  45. $expire = gmdate("D, d M Y H:i:s", $cache_data["cache_expire"])." GMT";
  46. //$last = gmdate("D, d M Y H:i:s", filemtime($cache_data["file"]))." GMT";
  47. header("Expires: ".$expire);
  48. if(!$force_cached){ imagepng($im, $cache_data["file"], 9); }
  49. readfile($cache_data["file"]);
  50. }
  51. else{ imagepng($im, null, 9); }
  52. imagedestroy($im);
  53. exit;
  54. }
  55. function exec_ogp_module() {
  56. global $db;
  57. $remote_server = $db->getRemoteServer($_GET['remote_server_id']);
  58. $remote = new OGPRemoteLibrary( $remote_server['agent_ip'], $remote_server['agent_port'],
  59. $remote_server['encryption_key'], $remote_server['timeout'] );
  60. $stats = $remote->mon_stats();
  61. $im = imagecreatefrompng("images/term.png");
  62. $stats_lines_array = explode("\n", $stats);
  63. $text_color = ImageColorAllocate($im,225,225,225);
  64. $text_font = "includes/fonts/TIMES_SQ.TTF";
  65. $i = 40;
  66. foreach ($stats_lines_array as $stats_line)
  67. {
  68. pretty_text_ttf($im,11,0,5,$i,$text_color,$text_font,utf8_decode($stats_line), true); // Servername
  69. $i = $i+20;
  70. }
  71. dsi_make_img($im, true);
  72. return;
  73. }