From ecf87f56ac2d2807f6fa40f1d5281e48ab5521c6 Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Fri, 19 Jul 2024 01:13:24 +0300 Subject: [PATCH] Top30 --- app/Controllers/MainController.php | 5 +++ app/Core/Routes.php | 1 + views/pages/Main.php | 2 +- views/pages/Top30.php | 72 ++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 views/pages/Top30.php diff --git a/app/Controllers/MainController.php b/app/Controllers/MainController.php index b622d79..f7daa7c 100644 --- a/app/Controllers/MainController.php +++ b/app/Controllers/MainController.php @@ -31,6 +31,11 @@ class MainController { Page::set('Update'); + } + public static function top30() + { + Page::set('Top30'); + } public static function logout() diff --git a/app/Core/Routes.php b/app/Core/Routes.php index aa6dc1e..97c7915 100644 --- a/app/Core/Routes.php +++ b/app/Core/Routes.php @@ -21,6 +21,7 @@ class Routes Router::get('/about', 'MainController@about'); Router::get('/rules', 'MainController@rules'); Router::get('/update', 'MainController@update'); + Router::get('/top30', 'MainController@top30'); diff --git a/views/pages/Main.php b/views/pages/Main.php index 2d0a6c0..873dcd6 100644 --- a/views/pages/Main.php +++ b/views/pages/Main.php @@ -61,7 +61,7 @@ use App\Models\{User, Vote, Comment}; -

Самые популярные за 24 часа

+

Самые популярные за 24 часа

+ + + + + + + +
+ + + + + + + + + +
+
+

30 самых просматриваемых фото за 24 часа

+
+ = 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 '
+ + + + + + +
'.$top.'

Новых просмотров:
+'.$pd['view_count'].'

+ +
347 КБ + + + +

'.htmlspecialchars($p['place']).'

+ '.htmlspecialchars($p['postbody']).' +

'.Date::zmdate($p['timeupload']).'
Автор: '.htmlspecialchars($author->i('username')).'

+
+
'; + +} +} + ?> + + +
+
+
+ + + + \ No newline at end of file