api.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 pretty_text_ttf($im, $fontsize, $angle, $x, $y, $color, $font, $string, $outline = false) {
  25. $black = imagecolorallocate($bgImg, 0, 0, 0);
  26. // Black outline
  27. if($outline){
  28. imagettftext($im, $fontsize, $angle, $x - 1, $y - 1, $black, $font, $string);
  29. imagettftext($im, $fontsize, $angle, $x - 1, $y, $black, $font, $string);
  30. imagettftext($im, $fontsize, $angle, $x - 1, $y + 1, $black, $font, $string);
  31. imagettftext($im, $fontsize, $angle, $x, $y - 1, $black, $font, $string);
  32. imagettftext($im, $fontsize, $angle, $x, $y + 1, $black, $font, $string);
  33. imagettftext($im, $fontsize, $angle, $x + 1, $y - 1, $black, $font, $string);
  34. imagettftext($im, $fontsize, $angle, $x + 1, $y, $black, $font, $string);
  35. imagettftext($im, $fontsize, $angle, $x + 1, $y + 1, $black, $font, $string);
  36. }
  37. // Your text
  38. imagettftext($im, $fontsize, $angle, $x, $y, $color, $font, $string);
  39. return $im;
  40. }
  41. function dsi_make_img($im = false, $cache_on = false, $cache_data = false, $force_cached = false, $format = false){
  42. header("Content-type: image/png");
  43. if($cache_on && $cache_data["file"]){
  44. $expire = gmdate("D, d M Y H:i:s", $cache_data["cache_expire"])." GMT";
  45. //$last = gmdate("D, d M Y H:i:s", filemtime($cache_data["file"]))." GMT";
  46. header("Expires: ".$expire);
  47. if(!$force_cached){ imagepng($im, $cache_data["file"], 9); }
  48. readfile($cache_data["file"]);
  49. }
  50. else{ imagepng($im, null, 9); }
  51. imagedestroy($im);
  52. exit;
  53. }
  54. error_reporting(E_ERROR);
  55. set_include_path(get_include_path() . PATH_SEPARATOR . "includes/" . PATH_SEPARATOR . "../");
  56. require_once("helpers.php");
  57. require_once("config.inc.php");
  58. require_once("lib_remote.php");
  59. require_once("lang.php");
  60. $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
  61. $error_text = "";
  62. if (get_db_error_text($db,$error_text))
  63. {
  64. print_failure($error_text);
  65. return;
  66. }
  67. startSession();
  68. if ( isset($_SESSION['users_login']) )
  69. {
  70. $userInfo = $db->getUser($_SESSION['users_login']);
  71. if( $db->isAdmin($_SESSION['user_id']) AND isset($_SESSION['users_passwd']) AND !empty($_SESSION['users_passwd']) AND $_SESSION['users_passwd'] == $userInfo['users_passwd'])
  72. {
  73. $remote_server = $db->getRemoteServer($_REQUEST['remote_server']);
  74. $remote = new OGPRemoteLibrary( $remote_server['agent_ip'], $remote_server['agent_port'],
  75. $remote_server['encryption_key'], $remote_server['timeout'] );
  76. if(isset($_REQUEST['mon_stats']))
  77. {
  78. $stats = $remote->mon_stats();
  79. $im = imagecreatefrompng("../images/term.png");
  80. $stats_lines_array = explode("\n", $stats);
  81. $text_color = ImageColorAllocate($im,225,225,225);
  82. $text_font = "./fonts/TIMES_SQ.TTF";
  83. $i = 40;
  84. foreach ($stats_lines_array as $stats_line)
  85. {
  86. pretty_text_ttf($im,11,0,5,$i,$text_color,$text_font,utf8_decode($stats_line), true); // Servername
  87. $i = $i+20;
  88. }
  89. dsi_make_img($im, true);
  90. return;
  91. }
  92. }
  93. }
  94. ?>