mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 03:31:10 +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 {
|
} else {
|
||||||
$moderated = 1;
|
$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(
|
echo json_encode(
|
||||||
array(
|
array(
|
||||||
'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'],
|
'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'],
|
||||||
|
|
|
@ -8,31 +8,50 @@ class Date
|
||||||
$currentTime = time();
|
$currentTime = time();
|
||||||
$dateDiff = $currentTime - $date;
|
$dateDiff = $currentTime - $date;
|
||||||
if ($date != null) {
|
if ($date != null) {
|
||||||
if ($dateDiff <= 1) {
|
if ($dateDiff <= 1) {
|
||||||
return "только что";
|
return "только что";
|
||||||
} elseif ($dateDiff <= 60) {
|
} elseif ($dateDiff < 60) {
|
||||||
return $dateDiff . " секунд " . self::getAgoSuffix($dateDiff);
|
return $dateDiff . " секунд " . self::getAgoSuffix($dateDiff);
|
||||||
} elseif ($dateDiff <= 3600) {
|
} elseif ($dateDiff < 3600) {
|
||||||
$minutes = floor($dateDiff / 60);
|
$minutes = floor($dateDiff / 60);
|
||||||
return $minutes . " минут " . self::getAgoSuffix($minutes);
|
return $minutes . " " . self::getMinuteSuffix($minutes) . " " . self::getAgoSuffix($minutes);
|
||||||
} elseif ($dateDiff <= 86400) {
|
} elseif ($dateDiff < 86400) {
|
||||||
$hours = floor($dateDiff / 3600);
|
$hours = floor($dateDiff / 3600);
|
||||||
return $hours . " часов " . self::getAgoSuffix($hours);
|
return $hours . " " . self::getHourSuffix($hours) . " " . self::getAgoSuffix($hours);
|
||||||
} else {
|
} else {
|
||||||
return self::formatDate($date);
|
return self::formatDate($date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static function getAgoSuffix($value)
|
private static function getAgoSuffix($value)
|
||||||
|
{
|
||||||
|
return "назад";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getMinuteSuffix($value)
|
||||||
{
|
{
|
||||||
$lastDigit = $value % 10;
|
$lastDigit = $value % 10;
|
||||||
if ($lastDigit == 1 && $value != 11) {
|
$lastTwoDigits = $value % 100;
|
||||||
return "назад";
|
if ($lastDigit == 1 && $lastTwoDigits != 11) {
|
||||||
} elseif (($lastDigit == 2 || $lastDigit == 3 || $lastDigit == 4) && ($value < 10 || $value > 20)) {
|
return "минуту";
|
||||||
return "назад";
|
} elseif (($lastDigit >= 2 && $lastDigit <= 4) && ($lastTwoDigits < 10 || $lastTwoDigits > 20)) {
|
||||||
|
return "минуты";
|
||||||
} else {
|
} 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
|
<?php
|
||||||
|
|
||||||
use \App\Services\Auth;
|
use \App\Services\{Auth, DB};
|
||||||
use \App\Models\User;
|
use \App\Models\User;
|
||||||
|
|
||||||
$user = new \App\Models\User(Auth::userid());
|
$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">
|
<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>
|
<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
|
<?php
|
||||||
if ($user->i('admin') > 0) { ?>
|
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>
|
$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 } ?>
|
<?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/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>
|
<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