DEV: Minor changes in the admin panel
This commit is contained in:
parent
adf61a1758
commit
7b932d8503
4 changed files with 109 additions and 63 deletions
|
@ -3,8 +3,8 @@
|
|||
namespace App\Controllers\Admin;
|
||||
|
||||
use Hleb\Scheme\App\Controllers\MainController;
|
||||
use App\Models\{HomeModel, AnswerModel, CommentModel, WebModel, FacetModel};
|
||||
use App\Models\Admin\UserModel;
|
||||
use App\Models\FacetModel;
|
||||
use App\Models\Admin\{UserModel, StatsModel};
|
||||
use Base, Translate;
|
||||
|
||||
class HomeController extends MainController
|
||||
|
@ -27,13 +27,9 @@ class HomeController extends MainController
|
|||
'meta' => meta($m = [], Translate::get('admin')),
|
||||
'uid' => $this->uid,
|
||||
'data' => [
|
||||
'topics_count' => FacetModel::getFacetsAllCount($this->uid['user_id'], 'all'),
|
||||
'posts_count' => HomeModel::feedCount([], $this->uid, 'all'),
|
||||
'count' => StatsModel::getCount(),
|
||||
'posts_no_topic' => FacetModel::getNoTopic(),
|
||||
'users_count' => UserModel::getUsersCount('all'),
|
||||
'answers_count' => AnswerModel::getAnswersAllCount('all'),
|
||||
'comments_count' => CommentModel::getCommentsAllCount('all'),
|
||||
'items_count' => WebModel::getItemsAllCount(),
|
||||
'last_visit' => UserModel::getLastVisit(),
|
||||
'bytes' => $bytes,
|
||||
'type' => 'admin',
|
||||
|
|
37
app/Models/Admin/StatsModel.php
Normal file
37
app/Models/Admin/StatsModel.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models\Admin;
|
||||
|
||||
use Hleb\Scheme\App\Models\MainModel;
|
||||
use DB;
|
||||
use PDO;
|
||||
|
||||
class StatsModel extends MainModel
|
||||
{
|
||||
// Страница аудита
|
||||
public static function getCount()
|
||||
{
|
||||
$sql = "SELECT
|
||||
(SELECT COUNT(post_id)
|
||||
FROM posts WHERE post_type = 'post')
|
||||
AS count_posts,
|
||||
|
||||
(SELECT COUNT(post_id)
|
||||
FROM posts WHERE post_type = 'page')
|
||||
AS count_pages,
|
||||
|
||||
(SELECT COUNT(answer_id)
|
||||
FROM answers )
|
||||
AS count_answers,
|
||||
|
||||
(SELECT COUNT(comment_id)
|
||||
FROM comments )
|
||||
AS count_comments,
|
||||
|
||||
( SELECT COUNT(facet_id)
|
||||
FROM facets WHERE facet_type = 'blog')
|
||||
AS count_blogs";
|
||||
|
||||
return DB::run($sql)->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
|
@ -10,11 +10,11 @@ class UserModel extends MainModel
|
|||
{
|
||||
// Страница участников
|
||||
public static function getUsers($page, $limit, $sheet)
|
||||
{
|
||||
{
|
||||
$string = "ORDER BY user_id DESC LIMIT";
|
||||
if ($sheet == 'users.ban') {
|
||||
$string = "WHERE user_ban_list > 0 ORDER BY user_id DESC LIMIT";
|
||||
}
|
||||
}
|
||||
|
||||
$start = ($page - 1) * $limit;
|
||||
$sql = "SELECT
|
||||
|
@ -60,7 +60,7 @@ class UserModel extends MainModel
|
|||
|
||||
return DB::run($sql)->rowCount();
|
||||
}
|
||||
|
||||
|
||||
// Информация по участнику (id, slug)
|
||||
public static function getUser($params, $name)
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ class UserModel extends MainModel
|
|||
|
||||
return $result->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
// Количество контента участника
|
||||
public static function contentCount($user_id)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ class UserModel extends MainModel
|
|||
|
||||
return DB::run($sql, ['user_id' => $user_id])->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
// Количество дублей IP по полю user_reg_ip
|
||||
public static function duplicatesRegistrationCount($ip)
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ class UserModel extends MainModel
|
|||
|
||||
return DB::run($sql, ['ip' => $ip])->rowCount();
|
||||
}
|
||||
|
||||
|
||||
// По логам
|
||||
public static function lastVisitLogs($user_id)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ class UserModel extends MainModel
|
|||
|
||||
return DB::run($sql, ['user_id' => $user_id])->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
public static function getUserRegsId($ip)
|
||||
{
|
||||
$sql = "SELECT
|
||||
|
@ -167,7 +167,7 @@ class UserModel extends MainModel
|
|||
user_trust_level,
|
||||
user_ban_list
|
||||
FROM users WHERE user_reg_ip = :ip";
|
||||
|
||||
|
||||
return DB::run($sql, ['ip' => $ip])->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ class UserModel extends MainModel
|
|||
ON latest_date.log_user_id = user_id";
|
||||
return DB::run($sql, ['ip' => $ip])->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
// Последние визиты
|
||||
public static function getLastVisit()
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ class UserModel extends MainModel
|
|||
|
||||
return DB::run($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
|
||||
public static function setLog($data)
|
||||
{
|
||||
$params = [
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="sticky mt5 top0 col-span-2 justify-between no-mob">
|
||||
<?= tabs_nav(
|
||||
'menu',
|
||||
$data['type'],
|
||||
$uid,
|
||||
$pages = Config::get('menu.admin'),
|
||||
); ?>
|
||||
'menu',
|
||||
$data['type'],
|
||||
$uid,
|
||||
$pages = Config::get('menu.admin'),
|
||||
); ?>
|
||||
</div>
|
||||
|
||||
<?= import(
|
||||
|
@ -17,42 +17,58 @@
|
|||
); ?>
|
||||
|
||||
<div class="grid grid-cols-12 gap-4 pr10 pl10 justify-between">
|
||||
<div class="col-span-2 bg-yellow-500 p10">
|
||||
<a class="white gray-hover size-21" title="<?= Translate::get('posts'); ?>" rel="noreferrer gray" href="<?= getUrlByName('admin.posts'); ?>">
|
||||
<i class="bi bi-journal-text white right"></i>
|
||||
<?= $data['posts_count']; ?>
|
||||
<div class="size-15"><?= Translate::get('posts'); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-span-2 bg-indigo-300 p10">
|
||||
<a class="white gray-hover size-21" title="<?= Translate::get('answers'); ?>" rel="noreferrer gray" href="<?= getUrlByName('admin.answers'); ?>">
|
||||
<i class="bi bi-chat-left-text white right"></i>
|
||||
<?= $data['answers_count']; ?>
|
||||
<div class="size-15"><?= Translate::get('answers'); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-span-2 bg-green-500 p10">
|
||||
<a class="white gray-hover size-21" title="<?= Translate::get('users'); ?>" rel="noreferrer" href="<?= getUrlByName('admin.users'); ?>">
|
||||
<i class="bi bi-people white right"></i>
|
||||
<?= $data['users_count']; ?>
|
||||
<div class="size-15"><?= Translate::get('users'); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-span-3 bg-blue-400 p10">
|
||||
<a class="white gray-hover size-21" title="<?= Translate::get('comments'); ?>" rel="noreferrer" href="<?= getUrlByName('admin.comments'); ?>">
|
||||
<i class="bi bi-chat-dots white right"></i>
|
||||
<?= $data['comments_count']; ?>
|
||||
<div class="size-15"><?= Translate::get('comments'); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-span-3 bg-gray-700 p10">
|
||||
<a class="white gray-hover size-21" title="<?= Translate::get('topics'); ?>" rel="noreferrer" href="<?= getUrlByName('admin.topics'); ?>">
|
||||
<i class="bi bi-columns-gap white right"></i>
|
||||
<?= $data['topics_count']; ?>
|
||||
<div class="size-15"><?= Translate::get('topics'); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
$sections = [
|
||||
[
|
||||
'bg' => 'bg-yellow-500',
|
||||
'icon' => 'bi-journal-text',
|
||||
'url' => 'admin.posts',
|
||||
'title' => 'posts',
|
||||
'count' => $data['count']['count_posts'],
|
||||
], [
|
||||
'bg' => 'bg-indigo-300',
|
||||
'icon' => 'bi-chat-left-text',
|
||||
'url' => 'admin.answers',
|
||||
'title' => 'answers',
|
||||
'count' => $data['count']['count_answers'],
|
||||
], [
|
||||
'bg' => 'bg-blue-400',
|
||||
'icon' => 'bi-chat-dots',
|
||||
'url' => 'admin.comments',
|
||||
'title' => 'comments',
|
||||
'count' => $data['count']['count_comments'],
|
||||
], [
|
||||
'bg' => 'bg-green-500',
|
||||
'icon' => 'bi-people',
|
||||
'url' => 'admin.users',
|
||||
'title' => 'users',
|
||||
'count' => $data['users_count'],
|
||||
], [
|
||||
'bg' => 'bg-gray-700',
|
||||
'icon' => 'bi-journals',
|
||||
'url' => 'admin.blogs',
|
||||
'title' => 'blogs',
|
||||
'count' => $data['count']['count_blogs'],
|
||||
], [
|
||||
'bg' => 'bg-gray-700',
|
||||
'icon' => 'bi-journal-richtext',
|
||||
'url' => 'admin.pages',
|
||||
'title' => 'pages',
|
||||
'count' => $data['count']['count_pages'],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($sections as $section) { ?>
|
||||
<div class="col-span-2 <?= $section['bg']; ?> p10">
|
||||
<a class="white gray-hover size-21" href="<?= getUrlByName($section['url']); ?>">
|
||||
<i class="bi <?= $section['icon']; ?> white right"></i>
|
||||
<?= $section['count']; ?>
|
||||
<div class="size-15"><?= Translate::get($section['title']); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="white-box mt10 pt5 pr15 pb5 pl15">
|
||||
<h4 class="mt5 mb5"><?= Translate::get('users'); ?></h4>
|
||||
<?php foreach ($data['last_visit'] as $user) { ?>
|
||||
|
@ -84,16 +100,13 @@
|
|||
</ul>
|
||||
<hr>
|
||||
<div class="mb20">
|
||||
<label for="name">PC:</label>
|
||||
<?= php_uname('s'); ?> <?php echo php_uname('r'); ?>
|
||||
<label for="name">PC:</label> <?= php_uname('s'); ?> <?php echo php_uname('r'); ?>
|
||||
</div>
|
||||
<div class="mb20">
|
||||
<label for="name">PHP:</label>
|
||||
<?= PHP_VERSION; ?>
|
||||
<label for="name">PHP:</label> <?= PHP_VERSION; ?>
|
||||
</div>
|
||||
<div class="mb20">
|
||||
<label for="name"><?= Translate::get('freely'); ?>:</label>
|
||||
<?= $data['bytes']; ?>
|
||||
<label for="name"><?= Translate::get('freely'); ?>:</label> <?= $data['bytes']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
Loading…
Reference in a new issue