mirror of
https://github.com/WerySkok/nativegallery.git
synced 2024-11-15 03:31:19 +03:00
add photos views
This commit is contained in:
parent
ea0e63f81d
commit
9941f1e561
4 changed files with 25 additions and 2 deletions
|
@ -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); }
|
||||
|
|
1
static/img/eye.svg
Normal file
1
static/img/eye.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path fill="white" d="M288 144a110.94 110.94 0 0 0-31.24 5 55.4 55.4 0 0 1 7.24 27 56 56 0 0 1-56 56 55.4 55.4 0 0 1-27-7.24A111.71 111.71 0 1 0 288 144zm284.52 97.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400c-98.65 0-189.09-55-237.93-144C98.91 167 189.34 112 288 112s189.09 55 237.93 144C477.1 345 386.66 400 288 400z"/></svg>
|
After Width: | Height: | Size: 702 B |
|
@ -105,7 +105,26 @@ use App\Models\{User, Vote, Comment};
|
|||
|
||||
<h4><a href="top30.php">Самые популярные за 24 часа</a></h4>
|
||||
<div>
|
||||
Когда-нибудь, этот раздел появится :)
|
||||
<?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 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 '<a href="/photo/'.$p['id'].'" target="_blank" class="prw pop-prw">
|
||||
<img width="250" src="'.$p['photourl'].'">
|
||||
<div class="hpshade">
|
||||
<div class="eye-icon">+'.$pd['view_count'].'</div>
|
||||
</div>
|
||||
</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue