PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/web/show_graph.php

https://bitbucket.org/JabLuszko/hlstatsxce
PHP | 477 lines | 343 code | 70 blank | 64 comment | 66 complexity | c614678184f94a6b550a73b39688d0de MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. HLstatsX Community Edition - Real-time player and clan rankings and statistics
  4. Copyleft (L) 2008-20XX Nicholas Hastings (nshastings@gmail.com)
  5. http://www.hlxcommunity.com
  6. HLstatsX Community Edition is a continuation of
  7. ELstatsNEO - Real-time player and clan rankings and statistics
  8. Copyleft (L) 2008-20XX Malte Bayer (steam@neo-soft.org)
  9. http://ovrsized.neo-soft.org/
  10. ELstatsNEO is an very improved & enhanced - so called Ultra-Humongus Edition of HLstatsX
  11. HLstatsX - Real-time player and clan rankings and statistics for Half-Life 2
  12. http://www.hlstatsx.com/
  13. Copyright (C) 2005-2007 Tobias Oetzel (Tobi@hlstatsx.com)
  14. HLstatsX is an enhanced version of HLstats made by Simon Garner
  15. HLstats - Real-time player and clan rankings and statistics for Half-Life
  16. http://sourceforge.net/projects/hlstats/
  17. Copyright (C) 2001 Simon Garner
  18. This program is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU General Public License
  20. as published by the Free Software Foundation; either version 2
  21. of the License, or (at your option) any later version.
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26. You should have received a copy of the GNU General Public License
  27. along with this program; if not, write to the Free Software
  28. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. For support and installation notes visit http://www.hlxcommunity.com
  30. */
  31. foreach ($_SERVER as $key => $entry) {
  32. if ($key !== 'HTTP_COOKIE') {
  33. $search_pattern = array('/<script>/', '/<\/script>/', '/[^A-Za-z0-9.\-\/=:;_?#&~]/');
  34. $replace_pattern = array('', '', '');
  35. $entry = preg_replace($search_pattern, $replace_pattern, $entry);
  36. if ($key == 'PHP_SELF') {
  37. if ((strrchr($entry, '/') !== '/hlstats.php') &&
  38. (strrchr($entry, '/') !== '/ingame.php') &&
  39. (strrchr($entry, '/') !== '/show_graph.php') &&
  40. (strrchr($entry, '/') !== '/sig.php') &&
  41. (strrchr($entry, '/') !== '/sig2.php') &&
  42. (strrchr($entry, '/') !== '/index.php') &&
  43. (strrchr($entry, '/') !== '/status.php') &&
  44. (strrchr($entry, '/') !== '/top10.php') &&
  45. (strrchr($entry, '/') !== '/config.php') &&
  46. (strrchr($entry, '/') !== '/') &&
  47. ($entry !== '')) {
  48. header('Location: http://'.$_SERVER['HTTP_HOST'].'/hlstats.php');
  49. exit;
  50. }
  51. }
  52. $_SERVER[$key] = $entry;
  53. }
  54. }
  55. define('IN_HLSTATS', true);
  56. // Load database classes
  57. require ('config.php');
  58. require (INCLUDE_PATH . '/class_db.php');
  59. require (INCLUDE_PATH . '/functions.php');
  60. require (INCLUDE_PATH . '/functions_graph.php');
  61. $db_classname = 'DB_' . DB_TYPE;
  62. if (class_exists($db_classname))
  63. {
  64. $db = new $db_classname(DB_ADDR, DB_USER, DB_PASS, DB_NAME, DB_PCONNECT);
  65. }
  66. else
  67. {
  68. error('Database class does not exist. Please check your config.php file for DB_TYPE');
  69. }
  70. $g_options = getOptions();
  71. $width = 500;
  72. if ((isset($_GET['width'])) && (is_numeric($_GET['width'])))
  73. $width = valid_request($_GET['width'], 1);
  74. $server_id = 1;
  75. if ((isset($_GET['server_id'])) && (is_numeric($_GET['server_id'])))
  76. $server_id = valid_request($_GET['server_id'], 1);
  77. $height = 125;
  78. if ((isset($_GET['height'])) && (is_numeric($_GET['height'])))
  79. $height = valid_request($_GET['height'], 1);
  80. $player = 1;
  81. if ((isset($_GET['player'])) && (is_numeric($_GET['player'])))
  82. $player = valid_request($_GET['player'], 1);
  83. $game = "unset";
  84. if (isset($_GET['game']))
  85. $game = valid_request($_GET['game'], 0);
  86. $game_escaped=$db->escape($game);
  87. $bar_type = 0; // 0 == serverinfo last 100 entries
  88. // 1 == ?!
  89. // 2 == player trend history
  90. // 3 == masterserver load
  91. if ((isset($_GET['type'])) && (is_numeric($_GET['type'])))
  92. $bar_type = valid_request($_GET['type'], 1);
  93. $selectedStyle = (isset($_COOKIE['style']) && $_COOKIE['style']) ? $_COOKIE['style'] : $g_options['style'];
  94. // Determine if we have custom nav images available
  95. $selectedStyle = preg_replace('/\.css$/','',$selectedStyle);
  96. $iconpath = IMAGE_PATH . "/icons";
  97. if (file_exists($iconpath . "/" . $selectedStyle)) {
  98. $iconpath = $iconpath . "/" . $selectedStyle;
  99. }
  100. $bg_color = array('red' => 171, 'green' => 204, 'blue' => 214);
  101. if ((isset($_GET['bgcolor'])) && (is_string($_GET['bgcolor'])))
  102. $bg_color = hex2rgb(valid_request($_GET['bgcolor'], 0));
  103. $color = array('red' => 255, 'green' => 255, 'blue' => 255);
  104. if ((isset($_GET['color'])) && (is_string($_GET['color'])))
  105. $color = hex2rgb(valid_request($_GET['color'], 0));
  106. $bg_id = $bg_color['red'] + $bg_color['green'] + $bg_color['blue'];
  107. $server_load_type = 1;
  108. if ((isset($_GET['range'])) && (is_numeric($_GET['range'])))
  109. $server_load_type = valid_request($_GET['range'], 1);
  110. switch ($server_load_type)
  111. {
  112. case 1:
  113. $avg_step = 1;
  114. $update_interval = IMAGE_UPDATE_INTERVAL;
  115. break;
  116. case 2:
  117. $avg_step = 7;
  118. $update_interval = 60 * 60 * 6; // 6 Hours
  119. break;
  120. case 3:
  121. $avg_step = 33;
  122. $update_interval = 60 * 60 * 12; // 12 Hours
  123. break;
  124. case 4:
  125. $avg_step = 400;
  126. $update_interval = 60 * 60 * 24; // 24 Hours
  127. break;
  128. default:
  129. $avg_step = 1;
  130. $update_interval = IMAGE_UPDATE_INTERVAL;
  131. break;
  132. }
  133. if ($bar_type != 2)
  134. {
  135. $cache_image = IMAGE_PATH . '/progress/server_' . $width . '_' . $height . '_' . $bar_type . '_' . $game . '_' . $server_id . '_' . $bg_id . '_' . $server_load_type . '.png';
  136. if (file_exists($cache_image))
  137. {
  138. $file_timestamp = filemtime($cache_image);
  139. if ($file_timestamp + $update_interval > time())
  140. {
  141. if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
  142. {
  143. if ( strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) + $update_interval > time() )
  144. {
  145. header('HTTP/1.0 304 Not Modified');
  146. exit;
  147. }
  148. }
  149. $mod_date = date('D, d M Y H:i:s \G\M\T', $file_timestamp);
  150. header('Last-Modified:' . $mod_date);
  151. $image = imagecreatefrompng(IMAGE_PATH . '/progress/server_' . $width . '_' . $height . '_' . $bar_type . '_' . $game . '_' . $server_id . '_' . $bg_id . '_' . $server_load_type . '.png');
  152. imagepng($image);
  153. imagedestroy($image);
  154. exit;
  155. }
  156. }
  157. }
  158. $legend_x = 0;
  159. $max_pos_y = array();
  160. // array("width" => $width, "height" => $height, "indent_x" => array(20, 20), "indent_y" => array(10,15))
  161. // defined: function drawItems($image, $bounds, $data_array, $max_index, $name, $dot, $make_grid, $write_timestamp, $write_legend, $color)
  162. $image = imagecreatetruecolor($width, $height);
  163. imagealphablending($image, false);
  164. if (function_exists('imageantialias'))
  165. imageantialias($image, true);
  166. // load bgimage if exists...
  167. $drawbg = true;
  168. $normal_color = imagecolorallocate($image, 0xEF, 0xEF, 0xEF);
  169. $light_color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
  170. $dark_color = imagecolorallocate($image, 0x99, 0xAA, 0xAA);
  171. $font_color = imagecolorallocate($image, $color['red'], $color['green'], $color['blue']);
  172. $main_color = imagecolorallocate($image, $bg_color['red'], $bg_color['green'], $bg_color['blue']);
  173. $blue = imagecolorallocate($image, 0, 0, 255);
  174. $black = imagecolorallocate($image, 0, 0, 0);
  175. $red = imagecolorallocate($image, 255, 0, 0);
  176. $white = imagecolorallocate($image, 255, 255, 255);
  177. $orange = imagecolorallocate($image, 255, 165, 0);
  178. $gray = imagecolorallocate($image, 105, 105, 105);
  179. $light_gray = imagecolorallocate($image, 0xEF, 0xEF, 0xEF);
  180. $green = imagecolorallocate($image, 255, 0, 255);
  181. $gray_border = imagecolorallocate($image, 0xE0, 0xE0, 0xE0);
  182. if ($bar_type == 0)
  183. {
  184. $indent_x = array(30, 30);
  185. $indent_y = array(15, 15);
  186. // background
  187. if ($drawbg)
  188. {
  189. imagefilledrectangle($image, 0, 0, $width, $height, $main_color); // background color
  190. imagerectangle($image, $indent_x[0], $indent_y[0], $width - $indent_x[1], $height - $indent_y[1], $dark_color);
  191. imagefilledrectangle($image, $indent_x[0] + 1, $indent_y[0] + 1, $width - $indent_x[1] - 1, $height - $indent_y[1] - 1, $light_color);
  192. }
  193. $limit = '';
  194. if ($avg_step < 10)
  195. $limit = ' LIMIT 0, 2500';
  196. // entries
  197. $data_array = array();
  198. $result = $db->query("SELECT timestamp, act_players, min_players, max_players, map, uptime, fps FROM hlstats_server_load WHERE server_id=$server_id ORDER BY timestamp DESC$limit");
  199. // TSGK
  200. $last_map = 0;
  201. // TSGK
  202. $i = 0;
  203. $avg_values = array();
  204. while ($rowdata = $db->fetch_array($result))
  205. {
  206. $i++;
  207. $avg_values[] = array('timestamp' => $rowdata['timestamp'], 'act_players' => $rowdata['act_players'], 'min_players' => $rowdata['min_players'], 'max_players' => $rowdata['max_players'], 'uptime' => $rowdata['uptime'], 'fps' => $rowdata['fps'], 'map' => $rowdata['map']);
  208. if ($i == $avg_step)
  209. {
  210. $insert_values = array();
  211. $insert_values['timestamp'] = $avg_values[ceil($avg_step / 2) - 1]['timestamp'];
  212. $insert_values['act_players'] = 0;
  213. $insert_values['min_players'] = 0;
  214. $insert_values['max_players'] = 0;
  215. $insert_values['uptime'] = 0;
  216. $insert_values['fps'] = 0;
  217. $insert_values['map'] = "";
  218. foreach ($avg_values as $entry)
  219. {
  220. $insert_values['act_players'] += $entry['act_players'];
  221. $insert_values['min_players'] += $entry['min_players'];
  222. $insert_values['max_players'] += $entry['max_players'];
  223. $insert_values['uptime'] += $entry['uptime'];
  224. $insert_values['fps'] += $entry['fps'];
  225. $insert_values['map'] = $entry['map'];
  226. }
  227. $insert_values['act_players'] = round($insert_values['act_players'] / $avg_step);
  228. $insert_values['uptime'] = round($insert_values['uptime'] / $avg_step);
  229. $insert_values['fps'] = round($insert_values['fps'] / $avg_step);
  230. $insert_values['min_players'] = round($insert_values['min_players'] / $avg_step);
  231. $insert_values['max_players'] = round($insert_values['max_players'] / $avg_step);
  232. $data_array[] = array('timestamp' => $insert_values['timestamp'], 'act_players' => $insert_values['act_players'], 'min_players' => $insert_values['min_players'], 'max_players' => $insert_values['max_players'], 'uptime' => $insert_values['uptime'], 'fps' => $insert_values['fps'], 'map' => $insert_values['map']);
  233. $avg_values = array();
  234. $i = 0;
  235. }
  236. }
  237. //print_r($data_array);
  238. $last_map = '';
  239. if ($avg_step == 1)
  240. {
  241. $result = $db->query("SELECT act_players, max_players FROM hlstats_Servers WHERE serverId=$server_id");
  242. $rowdata = $db->fetch_array($result);
  243. $rowdata['uptime'] = 0;
  244. array_unshift($data_array, array('timestamp' => time(), 'act_players' => $rowdata['act_players'], 'min_players' => $data_array[0]['min_players'], 'max_players' => $rowdata['max_players'], 'uptime' => $rowdata['uptime'], 'fps' => $rowdata['uptime'], 'map' => $last_map));
  245. }
  246. if (count($data_array) > 1)
  247. {
  248. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'max_players', 0, 1, 0, 1, array($gray, $red, $font_color, $dark_color, $light_gray));
  249. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'min_players', 0, 0, 0, 1, array($dark_color, $red, $font_color, $dark_color));
  250. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'act_players', 0, 0, 1, 1, array($blue, $red, $font_color, $dark_color));
  251. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'uptime', 0, 0, 1, 1, array($orange, $red, $font_color, $dark_color));
  252. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'fps', 0, 0, 1, 1, array($red, $red, $font_color, $dark_color));
  253. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'max_players', 0, 1, 0, 0, array($gray, $red, $font_color, $dark_color, $light_gray));
  254. }
  255. if ($width >= 800)
  256. {
  257. if ($avg_step == 1)
  258. {
  259. $result = $db->query("SELECT avg(act_players) as players FROM hlstats_server_load WHERE server_id=$server_id AND timestamp>=" . (time() - 3600));
  260. $rowdata = $db->fetch_array($result);
  261. $players_last_hour = sprintf("%.1f", $rowdata['players']);
  262. $result = $db->query("SELECT avg(act_players) as players FROM hlstats_server_load WHERE server_id=$server_id AND timestamp>=" . (time() - 86400));
  263. $rowdata = $db->fetch_array($result);
  264. $players_last_day = sprintf("%.1f", $rowdata['players']);
  265. $str = 'Average Players Last 24h: ' . $players_last_day . ' Last 1h: ' . $players_last_hour;
  266. $str_width = (imagefontwidth(1) * strlen($str)) + 2;
  267. imagestring($image, 1, $width - $indent_x[1] - $str_width, $indent_y[0] - 11, $str, $font_color);
  268. }
  269. }
  270. } elseif ($bar_type == 1)
  271. {
  272. $indent_x = array(35, 35);
  273. $indent_y = array(15, 15);
  274. // background
  275. if ($drawbg)
  276. {
  277. imagefilledrectangle($image, 0, 0, $width, $height, $main_color); // background color
  278. imagerectangle($image, $indent_x[0], $indent_y[0], $width - $indent_x[1], $height - $indent_y[1], $dark_color);
  279. imagefilledrectangle($image, $indent_x[0] + 1, $indent_y[0] + 1, $width - $indent_x[1] - 1, $height - $indent_y[1] - 1, $light_color);
  280. }
  281. // entries
  282. $data_array = array();
  283. $result = $db->query("SELECT timestamp, players, kills, headshots, act_slots, max_slots FROM hlstats_Trend WHERE game='{$game_escaped}' ORDER BY timestamp DESC LIMIT 0, 350");
  284. while ($rowdata = $db->fetch_array($result))
  285. {
  286. $data_array[] = array('timestamp' => $rowdata['timestamp'], 'players' => $rowdata['players'], 'kills' => $rowdata['kills'], 'headshots' => $rowdata['headshots'], 'act_slots' => $rowdata['act_slots'], 'max_slots' => $rowdata['max_slots']);
  287. }
  288. $players_data = $db->query("SELECT count(playerId) as player_count FROM hlstats_Players WHERE game='{$game_escaped}'");
  289. $rowdata = $db->fetch_array($players_data);
  290. $total_players = $rowdata['player_count'];
  291. if (count($data_array) > 1)
  292. {
  293. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'kills', 0, 0, 0, 0, array($orange, $red, $font_color, $dark_color, $light_gray));
  294. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'headshots', 0, 0, 0, 1, array($dark_color, $red, $font_color, $dark_color, $light_gray));
  295. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'players', 0, 0, 0, 1, array($red, $red, $font_color, $dark_color, $light_gray));
  296. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'max_slots', 0, 0, 0, 1, array($gray, $red, $font_color, $dark_color, $light_gray));
  297. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'act_slots', 0, 0, 1, 1, array($blue, $red, $font_color, $dark_color));
  298. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'kills', 0, 1, 0, 1, array($orange, $red, $font_color, $dark_color, $light_gray));
  299. }
  300. if ($width >= 800)
  301. {
  302. $result = $db->query("SELECT players FROM hlstats_Trend WHERE game='{$game_escaped}' AND timestamp<=" . (time() - 3600) . " ORDER by timestamp DESC LIMIT 0,1");
  303. $rowdata = $db->fetch_array($result);
  304. $players_last_hour = $total_players - $rowdata['players'];
  305. $result = $db->query("SELECT players FROM hlstats_Trend WHERE game='{$game_escaped}' AND timestamp<=" . (time() - 86400) . " ORDER by timestamp DESC LIMIT 0,1");
  306. $rowdata = $db->fetch_array($result);
  307. $players_last_day = $total_players - $rowdata['players'];
  308. $str = 'New Players Last 24h: ' . $players_last_day . ' Last 1h: ' . $players_last_hour;
  309. $str_width = (imagefontwidth(1) * strlen($str)) + 2;
  310. imagestring($image, 1, $width - $indent_x[1] - $str_width, $indent_y[0] - 11, $str, $font_color);
  311. }
  312. } elseif ($bar_type == 2)
  313. {
  314. // PLAYER HISTORY GRAPH
  315. $indent_x = array(35, 35);
  316. $indent_y = array(15, 15);
  317. if (file_exists($iconpath . "/trendgraph.png")) {
  318. $trendgraph_bg = $iconpath . "/trendgraph.png";
  319. } else {
  320. $trendgraph_bg = IMAGE_PATH . "/graph/trendgraph.png";
  321. }
  322. $background_img = imagecreatefrompng($trendgraph_bg);
  323. if ($background_img)
  324. {
  325. imagecopy($image, $background_img, 0, 0, 0, 0, 400, 152);
  326. imagedestroy($background_img);
  327. $drawbg = false;
  328. }
  329. // background
  330. if ($drawbg)
  331. {
  332. imagefilledrectangle($image, 0, 0, $width, $height, $main_color); // background color
  333. imagerectangle($image, $indent_x[0], $indent_y[0], $width - $indent_x[1], $height - $indent_y[1], $dark_color);
  334. imagefilledrectangle($image, $indent_x[0] + 1, $indent_y[0] + 1, $width - $indent_x[1] - 1, $height - $indent_y[1] - 1, $light_color);
  335. }
  336. // entries
  337. $deletedays = $g_options['DeleteDays'];
  338. if ($deletedays == 0)
  339. $deletedays = 14;
  340. // define first day's timestamp range
  341. $ts = strtotime(date('Y-m-d'));
  342. $data_array = array();
  343. $arcount = 0;
  344. $result = $db->query("SELECT eventTime, skill, kills, deaths, headshots, connection_time, UNIX_TIMESTAMP(eventTime) AS ts FROM hlstats_Players_History WHERE playerId=" . $player . " ORDER BY eventTime DESC LIMIT 0, " . $deletedays);
  345. while (($rowdata = $db->fetch_array($result)) && ($arcount < $deletedays))
  346. {
  347. //echo $rowdata['eventTime']." - ".date("Y-m-d", $ts)."\n";
  348. while (($rowdata['eventTime'] != date("Y-m-d", $ts)) && ($arcount < $deletedays))
  349. {
  350. // insert null value
  351. $data_array[] = array('timestamp' => $ts, 'skill' => $rowdata['skill'], 'kills' => 0, 'headshots' => 0, 'deaths' => 0, 'time' => 0);
  352. $ts -= 86400;
  353. $arcount++;
  354. }
  355. $data_array[] = array('timestamp' => $rowdata['ts'], 'skill' => $rowdata['skill'], 'kills' => $rowdata['kills'], 'headshots' => $rowdata['headshots'], 'deaths' => $rowdata['deaths'], 'time' => $rowdata['connection_time']);
  356. $arcount++;
  357. $ts -= 86400;
  358. }
  359. while (($arcount < $deletedays))
  360. {
  361. // insert null value
  362. $data_array[] = array('timestamp' => $ts, 'skill' => $rowdata['skill'], 'kills' => 0, 'headshots' => 0, 'deaths' => 0, 'time' => 0);
  363. $ts -= 86400;
  364. $arcount++;
  365. }
  366. $deletedays = count($data_array);
  367. $first_entry = 10; // disable tsgk map function
  368. if (count($data_array) > 1)
  369. {
  370. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'kills', 0, 1, 0, 1, array($red, $red, $font_color, $dark_color, $light_gray));
  371. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'headshots', 0, 0, 0, 1, array($dark_color, $red, $font_color, $dark_color, $light_gray));
  372. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 0, 'skill', 0, 0, 0, 1, array($orange, $red, $font_color, $dark_color, $light_gray));
  373. drawItems($image, array('width' => $width, 'height' => $height, 'indent_x' => $indent_x, 'indent_y' => $indent_y), $data_array, 2, 'deaths', 0, 0, 0, 1, array($gray, $red, $font_color, $dark_color, $light_gray));
  374. }
  375. $str = $deletedays . ' days Trend';
  376. $str_width = (imagefontwidth(1) * strlen($str)) + 2;
  377. imagestring($image, 1, $width - $indent_x[1] - $str_width, $indent_y[0] - 11, $str, $font_color);
  378. }
  379. imageTrueColorToPalette($image, 0, 65535);
  380. // $bar_type=2;
  381. // achtung, hier ist noch ein pfad hardcoded!!!
  382. header('Content-Type: image/png');
  383. if ($bar_type != 2)
  384. {
  385. @imagepng($image, IMAGE_PATH . '/progress/server_' . $width . '_' . $height . '_' . $bar_type . '_' . $game . '_' . $server_id . '_' . $bg_id . '_' . $server_load_type . '.png');
  386. $mod_date = date('D, d M Y H:i:s \G\M\T', time());
  387. header('Last-Modified:'.$mod_date);
  388. imagepng($image);
  389. imagedestroy($image);
  390. //Opera doesn't like the redirect
  391. /*$mod_date = date('D, d M Y H:i:s \G\M\T', time());
  392. header('Last-Modified:'.$mod_date);
  393. header("Location: ".IMAGE_PATH."/progress/server_".$width."_".$height."_".$bar_type."_".$game."_".$server_id."_".$bg_id."_".$server_load_type.".png");*/
  394. }
  395. else
  396. {
  397. imagepng($image);
  398. imagedestroy($image);
  399. }
  400. ?>