diff --git a/static/css/style.css b/static/css/style.css index 985e01f..cf6cccf 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -235,7 +235,7 @@ a.prw { display:inline-block; position:relative; } .con-overlay { position:absolute; left:0; right:0; top:0; bottom:0; z-index:1; background:url('/img/questions_bg.png'); } .com-icon { background:url('/img/comment.svg') no-repeat; display:inline-block; padding-left:18px; } -.eye-icon { background:url('/img/eye.svg') no-repeat; display:inline-block; padding-left:20px; margin-left:10px; } +.eye-icon { background:url('/static/img/eye.svg') no-repeat; display:inline-block; padding-left:20px; margin-left:10px; } .hpshade, .hdshade { position:absolute; z-index:2; bottom:0; text-align:right; box-sizing:border-box; margin:-22px auto 0; width:250px; height:22px; padding:4px 5px 0 0; color:#fff; background:linear-gradient(to top,rgba(0,0,0,.5),transparent); } .vpshade { position:relative; z-index:2; display:inline-block; vertical-align:middle; height:120px; width:15px; margin-right:-15px; background:linear-gradient(to right,rgba(0,0,0,.3),transparent); } diff --git a/static/img/eye.svg b/static/img/eye.svg new file mode 100644 index 0000000..7f46745 --- /dev/null +++ b/static/img/eye.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/pages/Main.php b/views/pages/Main.php index 1b9835b..f8f19dd 100644 --- a/views/pages/Main.php +++ b/views/pages/Main.php @@ -105,7 +105,26 @@ use App\Models\{User, Vote, Comment};

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

- Когда-нибудь, этот раздел появится :) + = UNIX_TIMESTAMP(NOW()) - 86400 +GROUP BY photo_id +ORDER BY view_count DESC +LIMIT 10;'); +foreach ($photos as $pd) { + $photo = DB::query('SELECT * FROM photos WHERE id=:id', array(':id'=>$pd['photo_id'])); + foreach ($photo as $p) { + $author = new User($p['user_id']); + echo ' + +
+
+'.$pd['view_count'].'
+
+
'; + } +} + ?>
diff --git a/views/pages/Photo.php b/views/pages/Photo.php index e93dd1c..c75b787 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -7,6 +7,9 @@ $id = explode('/', $_SERVER['REQUEST_URI'])[2]; $photo = new \App\Models\Photo($id); if ($photo->i('id') !== null) { $photouser = new \App\Models\User($photo->i('user_id')); + if (DB::query('SELECT * FROM photos_views WHERE user_id=:uid AND photo_id=:pid ORDER BY id DESC LIMIT 1', array(':uid'=>Auth::userid(), ':pid'=>$id))[0]['time'] <= time()-86400) { + DB::query('INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)', array(':uid'=>Auth::userid(), ':pid'=>$id, ':time'=>time())); + } } ?>