This commit is contained in:
themohooks 2024-07-18 19:09:32 +03:00
parent 485b61991a
commit 0cd1397ab1
3 changed files with 48 additions and 22 deletions

View file

@ -27,7 +27,7 @@ class Upload
} else {
$moderated = 1;
}
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time(), ':moderated'=>$moderated));
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :moderated, :place, 0, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time(), ':moderated'=>$moderated));
echo json_encode(
array(
'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'],

View file

@ -10,14 +10,14 @@ class Date
if ($date != null) {
if ($dateDiff <= 1) {
return "только что";
} elseif ($dateDiff <= 60) {
} elseif ($dateDiff < 60) {
return $dateDiff . " секунд " . self::getAgoSuffix($dateDiff);
} elseif ($dateDiff <= 3600) {
} elseif ($dateDiff < 3600) {
$minutes = floor($dateDiff / 60);
return $minutes . " минут " . self::getAgoSuffix($minutes);
} elseif ($dateDiff <= 86400) {
return $minutes . " " . self::getMinuteSuffix($minutes) . " " . self::getAgoSuffix($minutes);
} elseif ($dateDiff < 86400) {
$hours = floor($dateDiff / 3600);
return $hours . " часов " . self::getAgoSuffix($hours);
return $hours . " " . self::getHourSuffix($hours) . " " . self::getAgoSuffix($hours);
} else {
return self::formatDate($date);
}
@ -25,14 +25,33 @@ class Date
}
private static function getAgoSuffix($value)
{
return "назад";
}
private static function getMinuteSuffix($value)
{
$lastDigit = $value % 10;
if ($lastDigit == 1 && $value != 11) {
return "назад";
} elseif (($lastDigit == 2 || $lastDigit == 3 || $lastDigit == 4) && ($value < 10 || $value > 20)) {
return "назад";
$lastTwoDigits = $value % 100;
if ($lastDigit == 1 && $lastTwoDigits != 11) {
return "минуту";
} elseif (($lastDigit >= 2 && $lastDigit <= 4) && ($lastTwoDigits < 10 || $lastTwoDigits > 20)) {
return "минуты";
} else {
return "назад";
return "минут";
}
}
private static function getHourSuffix($value)
{
$lastDigit = $value % 10;
$lastTwoDigits = $value % 100;
if ($lastDigit == 1 && $lastTwoDigits != 11) {
return "час";
} elseif (($lastDigit >= 2 && $lastDigit <= 4) && ($lastTwoDigits < 10 || $lastTwoDigits > 20)) {
return "часа";
} else {
return "часов";
}
}

View file

@ -1,6 +1,6 @@
<?php
use \App\Services\Auth;
use \App\Services\{Auth, DB};
use \App\Models\User;
$user = new \App\Models\User(Auth::userid());
@ -74,8 +74,15 @@ if (NGALLERY['root']['title'] != null && NGALLERY['root']['showtitle'] === true)
<ul class="mm-level-2">
<li><a href="/lk/" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-info-circle"></i></span><span class="mm-label">Общая информация</span></a></li>
<?php
if ($user->i('admin') > 0) { ?>
<li><a href="/admin" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-info-circle"></i></span><span class="mm-label">Admin</span></a></li>
if ($user->i('admin') > 0) {
$nonreviewedimgs = DB::query('SELECT COUNT(*) FROM photos WHERE moderated=0')[0]['COUNT(*)'];
if ($nonreviewedimgs > 0) {
$nonr = '<span class="mm-notify notify-count">'.$nonreviewedimgs.'</span>';
}
?>
?>
<li><a href="/admin" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-info-circle"></i></span><span class="mm-label">Admin</span><?=$nonr?></a></li>
<?php } ?>
<li><a href="/lk/upload" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-plus-square"></i></span><span class="mm-label"><b>Предложить фото</b></span></a></li>
<li><a href="/lk/history" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-images"></i></span><span class="mm-label">Журнал</span></a></li>