mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-11-15 03:31:19 +03:00
update photoext
This commit is contained in:
parent
b6c6580b96
commit
d69509ad83
2 changed files with 45 additions and 105 deletions
|
@ -1,11 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controllers\Api\Images;
|
||||
|
||||
use \App\Services\{Auth, DB};
|
||||
|
||||
class Stats {
|
||||
class Stats
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$imageWidth = 1000;
|
||||
$imageHeight = 700;
|
||||
$image = imagecreatetruecolor($imageWidth, $imageHeight);
|
||||
|
@ -17,43 +20,39 @@ class Stats {
|
|||
|
||||
imagefill($image, 0, 0, $backgroundColor);
|
||||
|
||||
$data = [
|
||||
"22.06.2024" => 0,
|
||||
"23.06.2024" => 0,
|
||||
"24.06.2024" => 0,
|
||||
"25.06.2024" => 0,
|
||||
"26.06.2024" => 0,
|
||||
"27.06.2024" => 0,
|
||||
"28.06.2024" => 0,
|
||||
"29.06.2024" => 0,
|
||||
"30.06.2024" => 0,
|
||||
"01.07.2024" => 0,
|
||||
"02.07.2024" => 0,
|
||||
"03.07.2024" => 0,
|
||||
"04.07.2024" => 0,
|
||||
"05.07.2024" => 0,
|
||||
"06.07.2024" => 0,
|
||||
"07.07.2024" => 0,
|
||||
"08.07.2024" => 0,
|
||||
"09.07.2024" => 0,
|
||||
"10.07.2024" => 0,
|
||||
"11.07.2024" => 0,
|
||||
"12.07.2024" => 0,
|
||||
"13.07.2024" => 0,
|
||||
"14.07.2024" => 0,
|
||||
"15.07.2024" => 292,
|
||||
"16.07.2024" => 292,
|
||||
"17.07.2024" => 154,
|
||||
"18.07.2024" => 892,
|
||||
"19.07.2024" => 606,
|
||||
"20.07.2024" => 0010,
|
||||
"21.07.2024" => 0
|
||||
];
|
||||
$results = DB::query("SELECT DATE_FORMAT(FROM_UNIXTIME(time), '%d.%m.%Y') AS date, COUNT(*) AS views FROM photos_views WHERE photo_id = :photo_id AND time >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY)) GROUP BY DATE_FORMAT(FROM_UNIXTIME(time), '%d.%m.%Y') ORDER BY date ASC;", array(':photo_id' => $_GET['id']));
|
||||
|
||||
|
||||
$data = [];
|
||||
$period = new \DatePeriod(
|
||||
new \DateTime('-30 days'),
|
||||
new \DateInterval('P1D'),
|
||||
new \DateTime('tomorrow')
|
||||
);
|
||||
|
||||
foreach ($period as $date) {
|
||||
$formattedDate = $date->format('d.m.Y');
|
||||
$data[$formattedDate] = 0;
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
$date = $result['date'];
|
||||
if (isset($data[$date])) {
|
||||
$data[$date] = $result['views'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$barWidth = 20;
|
||||
$barSpacing = 10;
|
||||
$maxBarHeight = $imageHeight - 110;
|
||||
$maxValue = max($data);
|
||||
if ($maxValue === 0) {
|
||||
$maxValue = 1;
|
||||
}
|
||||
|
||||
$x = 50;
|
||||
foreach ($data as $date => $value) {
|
||||
|
@ -71,7 +70,5 @@ class Stats {
|
|||
header('Content-Type: image/png');
|
||||
imagepng($image);
|
||||
imagedestroy($image);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -61,70 +61,13 @@ $photo = new \App\Models\Photo($_GET['id']);
|
|||
</center>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td id="adframe">
|
||||
<!-- Yandex.RTB R-A-115118-1 -->
|
||||
<div id="yandex_rtb_R-A-115118-1"></div>
|
||||
<script>
|
||||
window.yaContextCb.push(() => {
|
||||
Ya.Context.AdvManager.render({
|
||||
renderTo: 'yandex_rtb_R-A-115118-1',
|
||||
blockId: 'R-A-115118-1'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="footer"><b><a href="/">Главная</a> <a href="/lk/">Личный кабинет</a> <a href="https://forum.transphoto.org">Форум</a> <a href="/rules/">Правила</a> <a href="/admin/">Редколлегия</a></b><br>
|
||||
<a href="/set.php?dark=0" style="display:inline-block; padding:1px 10px; margin-top:5px; background-color:#ddd; color:#333">Светлая тема</a>
|
||||
<div class="sitecopy">© Администрация ТрансФото и авторы материалов, 2002—2024<br>Использование фотографий и иных материалов, опубликованных на сайте, допускается только с разрешения их авторов.</div>
|
||||
<div style="margin:15px 0">
|
||||
<noindex>
|
||||
|
||||
<!-- Yandex.Metrika informer -->
|
||||
<a href="https://metrika.yandex.ru/stat/?id=73971775&from=informer" target="_blank" rel="nofollow"><img src="https://informer.yandex.ru/informer/73971775/3_0_DDDDDDFF_DDDDDDFF_0_pageviews" style="width:88px; height:31px; border:0;" alt="Яндекс.Метрика" title="Яндекс.Метрика: данные за сегодня (просмотры, визиты и уникальные посетители)" class="ym-advanced-informer" data-cid="73971775" data-lang="ru" /></a>
|
||||
<!-- /Yandex.Metrika informer -->
|
||||
|
||||
</noindex>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
function c() {
|
||||
var b = a.contentDocument || a.contentWindow.document;
|
||||
if (b) {
|
||||
var d = b.createElement('script');
|
||||
d.innerHTML = "window.__CF$cv$params={r:'8a660706db3f005f',t:'MTcyMTUxMDc2NC4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";
|
||||
b.getElementsByTagName('head')[0].appendChild(d)
|
||||
}
|
||||
}
|
||||
if (document.body) {
|
||||
var a = document.createElement('iframe');
|
||||
a.height = 1;
|
||||
a.width = 1;
|
||||
a.style.position = 'absolute';
|
||||
a.style.top = 0;
|
||||
a.style.left = 0;
|
||||
a.style.border = 'none';
|
||||
a.style.visibility = 'hidden';
|
||||
document.body.appendChild(a);
|
||||
if ('loading' !== document.readyState) c();
|
||||
else if (window.addEventListener) document.addEventListener('DOMContentLoaded', c);
|
||||
else {
|
||||
var e = document.onreadystatechange || function() {};
|
||||
document.onreadystatechange = function(b) {
|
||||
e(b);
|
||||
'loading' !== document.readyState && (document.onreadystatechange = e, c())
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue