mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-22 08:30:56 +03:00
fixes
This commit is contained in:
parent
485b61991a
commit
0cd1397ab1
3 changed files with 48 additions and 22 deletions
|
@ -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'],
|
||||
|
|
|
@ -8,31 +8,50 @@ class Date
|
|||
$currentTime = time();
|
||||
$dateDiff = $currentTime - $date;
|
||||
if ($date != null) {
|
||||
if ($dateDiff <= 1) {
|
||||
return "только что";
|
||||
} elseif ($dateDiff <= 60) {
|
||||
return $dateDiff . " секунд " . self::getAgoSuffix($dateDiff);
|
||||
} elseif ($dateDiff <= 3600) {
|
||||
$minutes = floor($dateDiff / 60);
|
||||
return $minutes . " минут " . self::getAgoSuffix($minutes);
|
||||
} elseif ($dateDiff <= 86400) {
|
||||
$hours = floor($dateDiff / 3600);
|
||||
return $hours . " часов " . self::getAgoSuffix($hours);
|
||||
} else {
|
||||
return self::formatDate($date);
|
||||
if ($dateDiff <= 1) {
|
||||
return "только что";
|
||||
} elseif ($dateDiff < 60) {
|
||||
return $dateDiff . " секунд " . self::getAgoSuffix($dateDiff);
|
||||
} elseif ($dateDiff < 3600) {
|
||||
$minutes = floor($dateDiff / 60);
|
||||
return $minutes . " " . self::getMinuteSuffix($minutes) . " " . self::getAgoSuffix($minutes);
|
||||
} elseif ($dateDiff < 86400) {
|
||||
$hours = floor($dateDiff / 3600);
|
||||
return $hours . " " . self::getHourSuffix($hours) . " " . self::getAgoSuffix($hours);
|
||||
} else {
|
||||
return self::formatDate($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 "часов";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue