mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 03:31:10 +03:00
set admin routes
This commit is contained in:
parent
8e10948f82
commit
dd23f9f0e2
8 changed files with 32 additions and 6 deletions
18
app/Controllers/Api/Admin/Images/SetVisibility.php
Normal file
18
app/Controllers/Api/Admin/Images/SetVisibility.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controllers\Api\Admin\Images;
|
||||
|
||||
|
||||
|
||||
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
|
||||
use App\Models\{User, Vote};
|
||||
|
||||
|
||||
class SetVisibility
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::query('UPDATE photos SET moderated=:mod WHERE id=:id', array(':id'=>$_GET['id'], ':mod'=>$_GET['mod']));
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
|
@ -64,6 +64,9 @@ class Compress {
|
|||
$quality = 40;
|
||||
$max_width = 400;
|
||||
$max_height = 400;
|
||||
if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache')) {
|
||||
mkdir($_SERVER['DOCUMENT_ROOT'].'/cdn/imgcache', 0777, true);
|
||||
}
|
||||
|
||||
$cache_filename = self::generateCacheFilename($source_url, $quality, $max_width, $max_height);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use \App\Controllers\Api\Images\Comments\Create as PhotoComment;
|
|||
use \App\Controllers\Api\Images\Comments\Load as PhotoCommentLoad;
|
||||
use \App\Controllers\Api\Images\Comments\Rate as PhotoCommentVote;
|
||||
use \App\Controllers\Api\Profile\Update as ProfileUpdate;
|
||||
use \App\Controllers\Api\Admin\Images\SetVisibility as AdminPhotoSetVisibility;
|
||||
class ApiController
|
||||
{
|
||||
|
||||
|
@ -43,6 +44,9 @@ class ApiController
|
|||
public static function photocompress() {
|
||||
return new PhotoCompress();
|
||||
}
|
||||
public static function adminsetvis() {
|
||||
return new AdminPhotoSetVisibility();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -6,7 +6,6 @@ use \App\Services\{Router, Auth, DB};
|
|||
use \App\Core\{Page};
|
||||
|
||||
|
||||
|
||||
class Routes
|
||||
{
|
||||
public static function init()
|
||||
|
@ -26,6 +25,7 @@ class Routes
|
|||
|
||||
|
||||
if (Auth::userid() > 0) {
|
||||
$user = new \App\Models\User(Auth::userid());
|
||||
Router::get('/lk', 'ProfileController@lk');
|
||||
Router::get('/lk/upload', 'ProfileController@upload');
|
||||
Router::get('/lk/history', 'ProfileController@lkhistory');
|
||||
|
@ -40,9 +40,10 @@ class Routes
|
|||
Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload');
|
||||
Router::get('/api/photo/vote', 'ApiController@photovote');
|
||||
Router::get('/api/photo/comment/rate', 'ApiController@photocommentvote');
|
||||
|
||||
if ($user->i('admin') > 0) {
|
||||
Router::any('/admin', 'AdminController@index');
|
||||
|
||||
Router::any('/api/admin/images/setvisibility', 'AdminController@adminsetvis');
|
||||
}
|
||||
Router::get('/logout', 'MainController@logout');
|
||||
Router::get('/404', 'ExceptionRegister@notfound');
|
||||
} else {
|
||||
|
|
|
@ -74,7 +74,7 @@ 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') === 1) { ?>
|
||||
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>
|
||||
<?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>
|
||||
|
|
|
@ -32,7 +32,7 @@ use \App\Models\User;
|
|||
</tr>
|
||||
|
||||
<?php
|
||||
$photos = DB::query('SELECT * FROM photos ORDER BY id DESC');
|
||||
$photos = DB::query('SELECT * FROM photos WHERE moderated=0 ORDER BY id DESC');
|
||||
foreach ($photos as $p) {
|
||||
if ($p['moderated'] === 0) {
|
||||
$color = 's0';
|
||||
|
|
Loading…
Reference in a new issue