EngineGP/system/engine/graph.php

58 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2023-03-04 23:45:46 +00:00
<?php
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['HTTP_HOST'] . '/404'));
2023-03-04 23:45:46 +00:00
$key = isset($url['key']) ? $url['key'] : exit;
2023-03-04 23:45:46 +00:00
if (sys::valid($key, 'md5'))
exit;
2023-03-04 23:45:46 +00:00
$sql->query('SELECT `id`, `server`, `time` FROM `graph` WHERE `key`="' . $key . '" LIMIT 1');
2023-03-04 23:45:46 +00:00
if (!$sql->num())
exit;
2023-03-04 23:45:46 +00:00
$graph = $sql->get();
2023-03-04 23:45:46 +00:00
if (isset($url['type'])) {
include(DATA . 'graph.php');
2023-03-04 23:45:46 +00:00
include(LIB . 'games/graph.php');
2023-03-04 23:45:46 +00:00
$style = isset($url['style']) ? $url['style'] : 'default';
2023-03-04 23:45:46 +00:00
if (!array_key_exists($style, $aStyle))
$style = 'default';
2023-03-04 23:45:46 +00:00
$type = isset($url['type']) ? $url['type'] : 'first';
2023-03-04 23:45:46 +00:00
if (!in_array($type, array('first', 'second')))
$type = 'first';
2023-03-04 23:45:46 +00:00
// Выхлоп кеш баннера
if (file_exists(TEMP . (md5($key . $style . $type)) . '.png') and $graph['time'] + 300 > $start_point) {
header('Content-type: image/png');
exit(file_get_contents(TEMP . (md5($key . $style . $type)) . '.png'));
}
2023-03-04 23:45:46 +00:00
$sql->query('SELECT `address`, `game`, `slots_start`, `online`, `status`, `name`, `map` FROM `servers` WHERE `id`="' . $graph['server'] . '" LIMIT 1');
if (!$sql->num())
exit;
2023-03-04 23:45:46 +00:00
$server = $sql->get();
2023-03-04 23:45:46 +00:00
$aPoints = graph::online_day($graph['server'], $server['slots_start']);
2023-03-04 23:45:46 +00:00
// Обновление баннеров
foreach ($aStyle as $name => $styles) {
graph::first($server, $aPoints, $aStyle, $name, $key);
graph::second($server, $aPoints, $aStyle, $name, $key);
}
2023-03-04 23:45:46 +00:00
// Обновление данных
$sql->query('UPDATE `graph` set `time`="' . $start_point . '" WHERE `id`="' . $graph['id'] . '" LIMIT 1');
2023-03-04 23:45:46 +00:00
header('Content-type: image/png');
exit(file_get_contents(TEMP . (md5($key . $style . $type)) . '.png'));
}
2023-03-04 23:45:46 +00:00
?>