From 4e20c339d9594e93c61a1bf7480f6d7641fad75d Mon Sep 17 00:00:00 2001
From: xiaomlove
Date: Mon, 13 Jun 2022 15:52:23 +0800
Subject: [PATCH] userdetails page add H&R
---
include/functions.php | 8 ++++++--
lang/chs/lang_functions.php | 2 ++
lang/cht/lang_functions.php | 2 ++
lang/en/lang_functions.php | 2 ++
public/myhr.php | 15 ++++++++++++---
public/userdetails.php | 4 ++++
6 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/include/functions.php b/include/functions.php
index a17eb75e..063d6cbb 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -4003,9 +4003,13 @@ function classlist($selectname,$maxclass, $selected, $minClass = 0){
return $list;
}
-function permissiondenied(){
+function permissiondenied($allowMinimumClass = null){
global $lang_functions;
- stderr($lang_functions['std_error'], $lang_functions['std_permission_denied']);
+ if ($allowMinimumClass === null) {
+ stderr($lang_functions['std_error'], $lang_functions['std_permission_denied']);
+ } else {
+ stderr($lang_functions['std_sorry'],$lang_functions['std_permission_denied_only'].get_user_class_name($allowMinimumClass,false,true,true).$lang_functions['std_or_above_can_view'],false);
+ }
}
function gettime($time, $withago = true, $twoline = false, $forceago = false, $oneunit = false, $isfuturetime = false){
diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php
index d6afc155..9074804d 100644
--- a/lang/chs/lang_functions.php
+++ b/lang/chs/lang_functions.php
@@ -5,6 +5,8 @@ $lang_functions = array
'std_access_denied' => "访问拒绝!",
'std_fake_account' => "我们怀疑你在使用伪造账户,因此记录了本次行为!",
'std_permission_denied' => "你没有该权限!",
+ 'std_permission_denied_only' => "你没有该权限。只有",
+ 'std_or_above_can_view' => "及以上等级的用户才能查看。
请查看"."常见问题了解更多关于用户等级和权限的信息。
" .$SITENAME."管理组",
'std_target_not_exists' => '目标不存在',
'std_already_logged_in' => "你已经登录!",
'text_page_last_updated' => "本页面最后更新于",
diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php
index 4523fbee..4b926811 100644
--- a/lang/cht/lang_functions.php
+++ b/lang/cht/lang_functions.php
@@ -5,6 +5,8 @@ $lang_functions = array
'std_access_denied' => "訪問拒絕!",
'std_fake_account' => "我們懷疑你在使用偽造帳戶,因此記錄了本次行為!",
'std_permission_denied' => "你沒有該許可權!",
+ 'std_permission_denied_only' => "你沒有該許可權。只有",
+ 'std_or_above_can_view' => "及以上等級的用戶才能檢視。
請檢視"."常見問題了解更多關于用戶等級和許可權的資訊。
" .$SITENAME."管理組",
'std_target_not_exists' => '目標不存在',
'std_already_logged_in' => "你已經登錄!",
'text_page_last_updated' => "本頁面最後更新於",
diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php
index b9e5c43f..f0f314de 100644
--- a/lang/en/lang_functions.php
+++ b/lang/en/lang_functions.php
@@ -5,6 +5,8 @@ $lang_functions = array
'std_access_denied' => "Access Denied!",
'std_fake_account' => "We come to believe you are using a fake account, therefore we've logged this action!",
'std_permission_denied' => "Permission denied!",
+ 'std_permission_denied_only' => "Permission denied. Only ",
+ 'std_or_above_can_view' => " or above could view.
Please see the "."FAQ for more information on different user classes and what they can do.
The " .$SITENAME." Staff",
'std_target_not_exists' => 'Target not exists',
'std_already_logged_in' => "You have already logged in!",
'text_page_last_updated' => "This page last updated ",
diff --git a/public/myhr.php b/public/myhr.php
index 51aaaa22..6e00b098 100644
--- a/public/myhr.php
+++ b/public/myhr.php
@@ -5,8 +5,13 @@ dbconn();
loggedinorreturn();
require_once(get_langfile_path());
$userid = $CURUSER['id'];
-if (get_user_class() >= UC_ADMINISTRATOR && !empty($_GET['userid'])) {
+$pagerParams = [];
+if (!empty($_GET['userid'])) {
+ if (get_user_class() < $viewhistory_class && $_GET['userid'] != $CURUSER['id']) {
+ permissiondenied($viewhistory_class);
+ }
$userid = $_GET['userid'];
+ $pagerParams['userid'] = $userid;
}
$userInfo = \App\Models\User::query()->find($userid);
if (empty($userInfo)) {
@@ -20,8 +25,12 @@ print("$pageTitle
");
$status = $_GET['status'] ?? \App\Models\HitAndRun::STATUS_INSPECTING;
$allStatus = \App\Models\HitAndRun::listStatus();
$headerFilters = [];
+$pagerParams['status'] = $status;
+$filterParams = $pagerParams;
+$queryString = http_build_query($pagerParams);
foreach ($allStatus as $key => $value) {
- $headerFilters[] = sprintf('%s', $key, $key == $status ? 'faqlink' : '', $value['text']);
+ $filterParams['status'] = $key;
+ $headerFilters[] = sprintf('%s', http_build_query($filterParams), $key == $status ? 'faqlink' : '', $value['text']);
}
print("" . implode(' | ', $headerFilters) . "
");
@@ -40,7 +49,7 @@ print $filterForm;
$baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status);
$rescount = (clone $baseQuery)->count();
-list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status&");
+list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, sprintf('?%s&', $queryString));
print("");
print("
| {$lang_myhr['th_hr_id']} |
diff --git a/public/userdetails.php b/public/userdetails.php
index bc34c725..47a92e6b 100644
--- a/public/userdetails.php
+++ b/public/userdetails.php
@@ -308,6 +308,10 @@ tr_small($lang_userdetails['row_torrent_comment'], ($torrentcomments && ($user["
tr_small($lang_userdetails['row_forum_posts'], ($forumposts && ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) ? "".$forumposts."" : $forumposts), 1);
if ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) {
+ if (\App\Models\HitAndRun::getIsEnabled()) {
+ $hrStatus = (new \App\Repositories\HitAndRunRepository())->getStatusStats($user['id']);
+ tr_small('H&R', sprintf('%s', getSchemeAndHttpHost(), $user['id'], $hrStatus), 1);
+ }
tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1), 1);
tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1), 1);
}