mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
fix: various admin dashboard improvements.
This commit is contained in:
parent
f7a6b467af
commit
319b312b23
2 changed files with 45 additions and 37 deletions
|
@ -9,7 +9,7 @@ class User extends Model {
|
||||||
|
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'username', 'password', 'recovery_code_hash'
|
'username', 'password', 'recovery_code_hash', 'ip'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function session() {
|
public function session() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
define('IN_PONEPASTE', 1);
|
define('IN_PONEPASTE', 1);
|
||||||
require_once(__DIR__ . '/common.php');
|
require_once(__DIR__ . '/common.php');
|
||||||
|
|
||||||
use PonePaste\Models\AdminLog;
|
use PonePaste\Models\AdminLog;
|
||||||
use PonePaste\Models\User;
|
use PonePaste\Models\User;
|
||||||
|
@ -11,8 +11,8 @@ $today_users_count = 0;
|
||||||
$today_pastes_count = 0;
|
$today_pastes_count = 0;
|
||||||
|
|
||||||
$last_page_view = PageView::select('tpage', 'tvisit')
|
$last_page_view = PageView::select('tpage', 'tvisit')
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->first();
|
->first();
|
||||||
$today_page = $last_page_view->tpage;
|
$today_page = $last_page_view->tpage;
|
||||||
$today_visit = $last_page_view->tvisit;
|
$today_visit = $last_page_view->tvisit;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ $today_users_count = User::where(['created_at' => 'TODAY()'])->count();
|
||||||
/* Number of pastes today */
|
/* Number of pastes today */
|
||||||
$today_pastes_count = Paste::where(['created_at' => 'TODAY()'])->count();
|
$today_pastes_count = Paste::where(['created_at' => 'TODAY()'])->count();
|
||||||
|
|
||||||
|
|
||||||
foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) {
|
foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) {
|
||||||
$sdate = $row['date'];
|
$sdate = $row['date'];
|
||||||
$sdate = str_replace(date('Y'), '', $sdate);
|
$sdate = str_replace(date('Y'), '', $sdate);
|
||||||
|
@ -44,13 +43,24 @@ foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) {
|
||||||
$tvisit[] = $row['tvisit'];
|
$tvisit[] = $row['tvisit'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_histories = AdminLog::with('user')->orderBy('id', 'desc')->take(10)->get();
|
$admin_histories = AdminLog::with('user')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->take(10)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$most_recent_users = User::select('id', 'username', 'created_at', 'ip')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->limit(7)
|
||||||
|
->get();
|
||||||
|
|
||||||
function getRecentadmin($count = 5) {
|
function getRecentadmin($count = 5) {
|
||||||
return Paste::with('user')
|
return Paste::with('user')
|
||||||
->orderBy('id')
|
->orderBy('id', 'desc')
|
||||||
->limit($count)->get();
|
->limit($count)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_admin = $current_user->role >= User::ROLE_ADMIN;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -75,7 +85,7 @@ function getRecentadmin($count = 5) {
|
||||||
<ul class="top-right">
|
<ul class="top-right">
|
||||||
<li class="dropdown link">
|
<li class="dropdown link">
|
||||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle profilebox"><b>Admin</b><span
|
<a href="#" data-toggle="dropdown" class="dropdown-toggle profilebox"><b>Admin</b><span
|
||||||
class="caret"></span></a>
|
class="caret"></span></a>
|
||||||
<ul class="dropdown-menu dropdown-menu-list dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-list dropdown-menu-right">
|
||||||
<li><a href="admin.php">Settings</a></li>
|
<li><a href="admin.php">Settings</a></li>
|
||||||
<li><a href="?logout">Logout</a></li>
|
<li><a href="?logout">Logout</a></li>
|
||||||
|
@ -136,8 +146,8 @@ function getRecentadmin($count = 5) {
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Username</td>
|
<td>Username</td>
|
||||||
<td>Date</td>
|
<td>Title</td>
|
||||||
<td>IP</td>
|
<td>Created At</td>
|
||||||
<td>Views</td>
|
<td>Views</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -148,16 +158,18 @@ function getRecentadmin($count = 5) {
|
||||||
$p_date = new DateTime($paste['created_at']);
|
$p_date = new DateTime($paste['created_at']);
|
||||||
$p_date_formatted = $p_date->format('jS F Y h:i:s A');
|
$p_date_formatted = $p_date->format('jS F Y h:i:s A');
|
||||||
$title = truncate($title, 5, 30);
|
$title = truncate($title, 5, 30);
|
||||||
echo "
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$paste->id</td>
|
<td><?= pp_html_escape($paste->user->username); ?></td>
|
||||||
<td>" . pp_html_escape($paste->user->username) . "</td>
|
<td>
|
||||||
<td>$p_date_formatted</td>
|
<a href="<?= urlForPaste($paste); ?>">
|
||||||
<td><span class='label label-default'>$paste->ip</span></td>
|
<?= pp_html_escape($paste->title); ?>
|
||||||
<td>$paste->views</td>
|
</a>
|
||||||
</tr> ";
|
</td>
|
||||||
}
|
<td><?= pp_html_escape($p_date_formatted); ?></td>
|
||||||
?>
|
<td><?= pp_html_escape($paste->views); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -178,27 +190,23 @@ function getRecentadmin($count = 5) {
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>ID</td>
|
|
||||||
<td>Username</td>
|
<td>Username</td>
|
||||||
<td>Date</td>
|
<td>Date</td>
|
||||||
<td>IP</td>
|
<td>IP</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php foreach ($most_recent_users as $user): ?>
|
||||||
$most_recent_users = User::select('id', 'username', 'date', 'ip')->orderBy('id', 'desc')->limit(7);
|
<tr>
|
||||||
|
<td>
|
||||||
foreach ($most_recent_users as $user) {
|
<a href="<?= urlForMember($user); ?>">
|
||||||
echo "
|
<?= pp_html_escape($user->username); ?>
|
||||||
<tr>
|
</a>
|
||||||
<td>$user->id</td>
|
</td>
|
||||||
<td>" . pp_html_escape($user->username) . "</td>
|
<td><?= pp_html_escape($user->created_at ?? 'Unknown'); ?></td>
|
||||||
<td>$user->date</td>
|
<td><?= $is_admin ? pp_html_escape($user->ip ?? 'Unknown') : '[masked]' ?></td>
|
||||||
<td><span class='label label-default'>$user->ip</span></td>
|
</tr>
|
||||||
</tr> ";
|
<?php endforeach; ?>
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -232,7 +240,7 @@ function getRecentadmin($count = 5) {
|
||||||
<td><?= pp_html_escape($entry->user->username); ?></td>
|
<td><?= pp_html_escape($entry->user->username); ?></td>
|
||||||
<td><?= pp_html_escape($entry->time); ?></td>
|
<td><?= pp_html_escape($entry->time); ?></td>
|
||||||
<td><?= pp_html_escape(AdminLog::ACTION_NAMES[$entry->action]); ?></td>
|
<td><?= pp_html_escape(AdminLog::ACTION_NAMES[$entry->action]); ?></td>
|
||||||
<td><?= pp_html_escape($entry->ip); ?></td>
|
<td><?= $is_admin ? pp_html_escape($entry->ip) : '[masked]' ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Add table
Reference in a new issue