This commit is contained in:
themohooks 2024-07-19 01:13:24 +03:00
parent 414bb74001
commit ecf87f56ac
4 changed files with 79 additions and 1 deletions

View file

@ -31,6 +31,11 @@ class MainController
{ {
Page::set('Update'); Page::set('Update');
}
public static function top30()
{
Page::set('Top30');
} }
public static function logout() public static function logout()

View file

@ -21,6 +21,7 @@ class Routes
Router::get('/about', 'MainController@about'); Router::get('/about', 'MainController@about');
Router::get('/rules', 'MainController@rules'); Router::get('/rules', 'MainController@rules');
Router::get('/update', 'MainController@update'); Router::get('/update', 'MainController@update');
Router::get('/top30', 'MainController@top30');

View file

@ -61,7 +61,7 @@ use App\Models\{User, Vote, Comment};
<td style="vertical-align:top; padding-right:20px"> <td style="vertical-align:top; padding-right:20px">
<h4><a href="top30.php">Самые популярные за 24 часа</a></h4> <h4><a href="/top30">Самые популярные за 24 часа</a></h4>
<div> <div>
<?php <?php
$photos = DB::query('SELECT photo_id, COUNT(*) as view_count $photos = DB::query('SELECT photo_id, COUNT(*) as view_count

72
views/pages/Top30.php Normal file
View file

@ -0,0 +1,72 @@
<?php
use \App\Services\{Auth, DB, Date};
use \App\Models\User;
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
<body>
<div id="backgr"></div>
<table class="tmain">
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
<tr>
<td class="main">
<center>
<h1>30 самых просматриваемых фото за 24 часа</h1>
<div style="width:80%">
<?php
$photos = DB::query('SELECT photo_id, COUNT(*) as view_count
FROM photos_views
WHERE time >= UNIX_TIMESTAMP(NOW()) - 86400
GROUP BY photo_id
ORDER BY view_count DESC
LIMIT 30;');
$top = 0;
foreach ($photos as $pd) {
$photo = DB::query('SELECT * FROM photos WHERE id=:id', array(':id'=>$pd['photo_id']));
foreach ($photo as $p) {
$top++;
$author = new User($p['user_id']);
echo ' <div class="p20p">
<table>
<tr>
<td style="text-align:center; padding:10px"><b style="font-size:25px">'.$top.'</b><br><br><small>Новых просмотров:</small><br><b>+'.$pd['view_count'].'</b><br><br>
</td>
<td class="pb_photo" id="p1977446"><a href="/photo/1977446/" target="_blank" class="prw"><img class="f" src="'.$p['photourl'].'" alt="347 КБ">
</a></td>
<td class="pb_descr">
<p><b class="pw-place">'.htmlspecialchars($p['place']).'</b></p>
<span class="pw-descr">'.htmlspecialchars($p['postbody']).'</span>
<p class="sm"><b>'.Date::zmdate($p['timeupload']).'</b><br>Автор: <a href="/author/'.$author->i('user_id').'/">'.htmlspecialchars($author->i('username')).'</a></p>
</td>
</tr>
</table>
</div>';
}
}
?>
</div>
</center>
</td>
</tr>
<tr>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
</tr>
</table>
</body>
</html>