index page add top uploader

This commit is contained in:
xiaomlove
2022-04-25 01:22:07 +08:00
parent c3969aeee9
commit a47b33a983
18 changed files with 156 additions and 60 deletions

View File

@@ -107,7 +107,15 @@ class User extends Authenticatable
public function getClassTextAttribute(): string
{
return self::$classes[$this->class]['text'] ?? '';
if (!isset(self::$classes[$this->class]['text'])) {
return '';
}
$classText = self::$classes[$this->class]['text'];
$alias = Setting::get("account.{$this->class}_alias");
if (!empty($alias)) {
$classText .= "({$alias})";
}
return $classText;
}
public function getDonateStatusAttribute()

View File

@@ -27,10 +27,12 @@ return new class extends Migration
DB::statement($sql);
}
Schema::table($tableName, function (Blueprint $table) {
$table->index(['torrent', 'peer_id']);
$table->index('peer_id');
});
$sql = "alter table peers add index idx_torrent_peer(`torrent`, `peer_id`(20))";
DB::statement($sql);
$sql = "alter table peers add index idx_peer(`peer_id`(20))";
DB::statement($sql);
}
/**

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.4');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-23');
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.5');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-04-25');
defined('IN_TRACKER') || define('IN_TRACKER', true);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -2546,7 +2546,7 @@ else {
$Cache->cache_value('user_'.$CURUSER["id"].'_outbox_count', $outmessages, 900);
}
if (!$connect = $Cache->get_value('user_'.$CURUSER["id"].'_connect')){
$res3 = sql_query("SELECT connectable FROM peers WHERE userid=" . sqlesc($CURUSER["id"]) . " LIMIT 1");
$res3 = sql_query("SELECT connectable FROM peers WHERE userid=" . sqlesc($CURUSER["id"]) . " order by id desc LIMIT 1");
if($row = mysql_fetch_row($res3))
$connect = $row[0];
else $connect = 'unknown';
@@ -3164,9 +3164,9 @@ function writecomment($userid, $comment, $oldModcomment = null) {
if (is_null($oldModcomment)) {
$res = sql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
$modcomment = date("d-m-Y") . " - " . $comment . "" . ($arr['modcomment'] != "" ? "\n" : "") . $arr['modcomment'];
$modcomment = date("Y-m-d") . " - " . $comment . "" . ($arr['modcomment'] != "" ? "\n" : "") . $arr['modcomment'];
} else {
$modcomment = date("d-m-Y") . " - " . $comment . "" . ($oldModcomment != "" ? "\n" : "") .$oldModcomment;
$modcomment = date("Y-m-d") . " - " . $comment . "" . ($oldModcomment != "" ? "\n" : "") .$oldModcomment;
}
$modcom = sqlesc($modcomment);
do_log("update user: $userid prepend modcomment: $comment, with oldModcomment: $oldModcomment");

View File

@@ -607,8 +607,10 @@ function nexus_trans($key, $replace = [], $locale = null)
$getKey = $locale . "." . $key;
$result = arr_get($translations, $getKey);
if (empty($result) && $locale != 'en') {
$getKey = "en.$key";
$getKey = "en." . $key;
$result = arr_get($translations, $getKey);
} else {
do_log("original getKey: $getKey can not get any translations", 'error');
}
if (!empty($replace)) {
$search = array_map(function ($value) {return ":$value";}, array_keys($replace));

View File

@@ -99,6 +99,13 @@ $lang_index = array
'row_active_browsing_users' => "当前访问用户数",
'row_tracker_active_users' => "当前Tracker用户数",
'text_detail' => "详情",
'top_uploader_title' => '最多上传(种子数)',
'col_counts' => '数量',
'col_ranking' => '排名',
'top_uploader_toggle_time_range_tab' => '点击切换时间范围',
'top_uploader_toggle_time_range_recently' => '最近 30 天',
'top_uploader_toggle_time_range_all' => '全部时间',
);
?>

View File

@@ -270,20 +270,20 @@ $lang_settings = array
'text_giving_bonus_gift_note' => "允许用户间相互赠送魔力值。默认'是'。",
'head_account_settings' => "账号设定",
'row_never_delete' => "永远保留",
'text_delete_inactive_accounts' => "删除不活跃账号",
'text_delete_inactive_accounts' => "封禁不活跃账号",
'text_never_delete' => "及以上等级的账号将永远保留。默认",
'row_never_delete_if_packed' => "封存后永远保留",
'text_never_delete_if_packed' => "及以上等级的账号如果在封存后将永远保留。默认",
'row_delete_packed' => "删除封存账号",
'row_delete_packed' => "封禁封存账号",
'text_delete_packed_note_one' => "封存的账号如果连续",
'text_delete_packed_note_two' => "天不登录,将被删除。默认'400',设为'0'来禁止此规则。",
'row_delete_unpacked' => "删除未封存账号",
'text_delete_packed_note_two' => "天不登录,将被封禁。默认'400',设为'0'来禁止此规则。",
'row_delete_unpacked' => "封禁未封存账号",
'text_delete_unpacked_note_one' => "未封存的账号如果连续",
'text_delete_unpacked_note_two' => "天不登录,将被删除。默认'150',设为'0'来禁止此规则。",
'row_delete_no_transfer' => "删除没有流量的用户",
'text_delete_unpacked_note_two' => "天不登录,将被封禁。默认'150',设为'0'来禁止此规则。",
'row_delete_no_transfer' => "封禁没有流量的用户",
'text_delete_transfer_note_one' => "没有流量的用户(即上传/下载数据都为0如果连续",
'text_delete_transfer_note_two' => "天不登录,或者注册时间满",
'text_delete_transfer_note_three' => "天,将被删除账号。默认'60''0'。<br />注意两条规则是分开执行的。将其中任一规则设为0<b>只</b>禁止一条规则。",
'text_delete_transfer_note_three' => "天,将被封禁账号。默认'60''0'。<br />注意两条规则是分开执行的。将其中任一规则设为0<b>只</b>禁止一条规则。",
'text_user_promotion_demotion' => "用户升级和降级",
'row_ban_peasant_one' => "禁用",
'row_ban_peasant_two' => "",
@@ -742,6 +742,8 @@ $lang_settings = array
'text_alias' => '等级别名:',
'row_default_user_one' => '默认为',
'row_default_user_two' => '',
'row_show_top_uploader' => '显示最多上传(种子数)',
'text_show_top_uploader_note' => "默认'否'。在首页显示最多上传的用户(按种子数计算)。",
);
?>

View File

@@ -98,6 +98,12 @@ $lang_index = array
'row_active_browsing_users' => "當前訪問用戶數",
'row_tracker_active_users' => "當前Tracker用戶數",
'text_detail' => "詳情",
'top_uploader_title' => '最多上傳(種子數)',
'col_counts' => '數量',
'col_ranking' => '排名',
'top_uploader_toggle_time_range_tab' => '點擊切換時間範圍',
'top_uploader_toggle_time_range_recently' => '最近 30 天',
'top_uploader_toggle_time_range_all' => '全部時間',
);
?>

View File

@@ -271,20 +271,20 @@ $lang_settings = array
'text_giving_bonus_gift_note' => "允許用戶間相互贈送魔力值。預設'是'。",
'head_account_settings' => "賬號設定",
'row_never_delete' => "永遠保留",
'text_delete_inactive_accounts' => "移除不活躍賬號",
'text_delete_inactive_accounts' => "封禁不活躍賬號",
'text_never_delete' => "及以上等級的賬號將永遠保留。預設",
'row_never_delete_if_packed' => "封存后永遠保留",
'text_never_delete_if_packed' => "及以上等級的賬號如果在封存后將永遠保留。預設",
'row_delete_packed' => "移除封存賬號",
'row_delete_packed' => "封禁封存賬號",
'text_delete_packed_note_one' => "封存的賬號如果連續",
'text_delete_packed_note_two' => "天不登入,將被移除。預設'400',設為'0'來禁止此規則。",
'row_delete_unpacked' => "移除未封存賬號",
'text_delete_packed_note_two' => "天不登入,將被封禁。預設'400',設為'0'來禁止此規則。",
'row_delete_unpacked' => "封禁未封存賬號",
'text_delete_unpacked_note_one' => "未封存的賬號如果連續",
'text_delete_unpacked_note_two' => "天不登入,將被移除。預設'150',設為'0'來禁止此規則。",
'row_delete_no_transfer' => "移除沒有流量的用戶",
'text_delete_unpacked_note_two' => "天不登入,將被封禁。預設'150',設為'0'來禁止此規則。",
'row_delete_no_transfer' => "封禁沒有流量的用戶",
'text_delete_transfer_note_one' => "沒有流量的用戶(即上傳/下載資料都為0如果連續",
'text_delete_transfer_note_two' => "天不登入,或者註冊時間滿",
'text_delete_transfer_note_three' => "天,將被移除賬號。預設'60''0'。<br />注意兩條規則是分開執行的。將其中任一規則設為0<b>只</b>禁止一條規則。",
'text_delete_transfer_note_three' => "天,將被封禁賬號。預設'60''0'。<br />注意兩條規則是分開執行的。將其中任一規則設為0<b>只</b>禁止一條規則。",
'text_user_promotion_demotion' => "用戶升級和降級",
'row_ban_peasant_one' => "禁用",
'row_ban_peasant_two' => "",

View File

@@ -98,6 +98,12 @@ $lang_index = array
'row_active_browsing_users' => "Active Browsing Users",
'row_tracker_active_users' => "Tracker Active Users",
'text_detail' => "Detail",
'top_uploader_title' => 'Top Uploader(Torrent count)',
'col_counts' => 'Counts',
'col_ranking' => 'Ranking',
'top_uploader_toggle_time_range_tab' => 'Click to toggle the time range',
'top_uploader_toggle_time_range_recently' => 'Last 30 days',
'top_uploader_toggle_time_range_all' => 'All time',
);
?>

View File

@@ -269,18 +269,18 @@ $lang_settings = array
'row_allow_giving_bonus_gift' => "Allow giving bonus gift",
'text_giving_bonus_gift_note' => "Allow users to give bonus gift to each other. Default 'yes'.",
'head_account_settings' => "Account Settings",
'row_never_delete' => "Never delete",
'text_delete_inactive_accounts' => "Delete Inactive User Accounts",
'text_never_delete' => " or above would never be deleted. Default ",
'row_never_delete_if_packed' => "Never delete if packed",
'text_never_delete_if_packed' => " or above would never be deleted if packed. Default ",
'row_delete_packed' => "Delete packed accounts",
'text_delete_packed_note_one' => "Packed accounts would be deleted if users have not logged in for more than ",
'row_never_delete' => "Never disable",
'text_delete_inactive_accounts' => "Disable Inactive User Accounts",
'text_never_delete' => " or above would never be disable. Default ",
'row_never_delete_if_packed' => "Never disable if packed",
'text_never_delete_if_packed' => " or above would never be disabled if packed. Default ",
'row_delete_packed' => "Disable packed accounts",
'text_delete_packed_note_one' => "Packed accounts would be disabled if users have not logged in for more than ",
'text_delete_packed_note_two' => " days in a row. Default '400', set it to '0' to disable the rule.",
'row_delete_unpacked' => "Delete unpacked accounts",
'text_delete_unpacked_note_one' => "Unpacked accounts would be deleted if users have not logged in for more than ",
'row_delete_unpacked' => "Disable unpacked accounts",
'text_delete_unpacked_note_one' => "Unpacked accounts would be disabled if users have not logged in for more than ",
'text_delete_unpacked_note_two' => " days in a row. Default '150', set it to '0' to disable the rule.",
'row_delete_no_transfer' => "Delete accounts with no transfer data",
'row_delete_no_transfer' => "Disable accounts with no transfer data",
'text_delete_transfer_note_one' => "Accounts with both uploaded and downloaded amount being 0 would be deleted if users have not logged in for more than ",
'text_delete_transfer_note_two' => " days in a row, or users have been registered for more than ",
'text_delete_transfer_note_three' => " days. Default '60', '0'. <br />NOTE: Two rules work seperately. Setting one of them to '0' <b>ONLY</b> disables one rule.",

View File

@@ -89,6 +89,7 @@ return array (
'enable_pt_gen_system' => 'no',
'enable_technical_info' => 'no',
'site_language_enabled' => \App\Models\Language::DEFAULT_ENABLED,
'show_top_uploader' => 'no',
),
'smtp' =>
array (

View File

@@ -188,6 +188,64 @@ if ($showlastxtorrents_main == "yes") {
}
}
// ------------- end: latest torrents ------------------//
// ------------- start: top uploader ------------------//
if (get_setting('main.show_top_uploader') == "yes") {
$topUploaderBaseQuery = \App\Models\Torrent::query()
->selectRaw("owner, count(*) as counts")
->groupBy('owner')
->orderBy("counts", "desc")
->take(10);
$userStatResult = \Nexus\Database\NexusDB::remember("index_top_uploader_all", 60, function () use ($topUploaderBaseQuery) {
return (clone $topUploaderBaseQuery)->get();
});
if($userStatResult->isNotEmpty())
{
\Nexus\Nexus::css('.tr-top-uploader-tab>td {cursor: pointer}', 'footer', false);
$toggleTimeRangeJs = <<<JS
jQuery(".tr-top-uploader-tab").on("click", "td", function () {
let _this = jQuery(this)
if (_this.hasClass("colhead")) {
return
}
_this.parent().children().removeClass("colhead")
_this.addClass("colhead")
jQuery(".top-uploader").hide()
jQuery("." + _this.attr("data-table")).fadeIn()
})
JS;
\Nexus\Nexus::js($toggleTimeRangeJs, "footer", false);
print ("<h2>".$lang_index['top_uploader_title']."</h2>");
print("<table width='100%'><tr class='tr-top-uploader-tab' title='{$lang_index['top_uploader_toggle_time_range_tab']}'><td class='colhead' align='center' data-table='top-uploader-recently'>{$lang_index['top_uploader_toggle_time_range_recently']}</td><td align='center' data-table='top-uploader-all'>{$lang_index['top_uploader_toggle_time_range_all']}</td></tr></table>");
$userTorrentCounts = $userStatResult->pluck('counts', 'owner');
$uidArr = $userStatResult->pluck('owner')->toArray();
$result = \App\Models\User::query()->whereIn('id', $uidArr)->orderByRaw(sprintf("field(id,%s)", implode(',', $uidArr)))->get(['id', 'username']);
print ("<table class='top-uploader top-uploader-all' width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\" style='display: none'><tr><td class=\"colhead\" width=\"\">".$lang_index['col_author']."</td><td class=\"colhead\" align=\"center\">".$lang_index['col_counts']."</td><td class=\"colhead\" align=\"center\">".$lang_index['col_ranking']."</td></tr>");
foreach ($result as $ranking => $row)
{
print ("<tr><td>" . get_username($row->id) . "</td><td align=\"center\">" . $userTorrentCounts->get($row->id, 0) . "</td><td align=\"center\">" . ($ranking + 1) . "</td></tr>");
}
print ("</table>");
$userStatResult = \Nexus\Database\NexusDB::remember("index_top_uploader_recently", 60, function () use ($topUploaderBaseQuery) {
return (clone $topUploaderBaseQuery)->where('added', '>=', \Carbon\Carbon::today()->subDays(30))->get();
});
$userTorrentCounts = $userStatResult->pluck('counts', 'owner');
$uidArr = $userStatResult->pluck('owner')->toArray();
$result = \App\Models\User::query()->whereIn('id', $uidArr)->orderByRaw(sprintf("field(id,%s)", implode(',', $uidArr)))->get(['id', 'username']);
print ("<table class='top-uploader top-uploader-recently' width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\"><tr><td class=\"colhead\" width=\"\">".$lang_index['col_author']."</td><td class=\"colhead\" align=\"center\">".$lang_index['col_counts']."</td><td class=\"colhead\" align=\"center\">".$lang_index['col_ranking']."</td></tr>");
foreach ($result as $ranking => $row)
{
print ("<tr><td>" . get_username($row->id) . "</td><td align=\"center\">" . $userTorrentCounts->get($row->id, 0) . "</td><td align=\"center\">" . ($ranking + 1) . "</td></tr>");
}
print ("</table>");
}
}
// ------------- end: top uploader ------------------//
// ------------- start: polls ------------------//
if ($CURUSER && $showpolls_main == "yes")
{

View File

@@ -43,7 +43,7 @@ if ($action == 'savesettings_main') // save main
'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket',
'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem',
'maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start',
'startsubid', 'logo', 'showlastxforumposts', 'enable_technical_info', 'site_language_enabled'
'startsubid', 'logo', 'showlastxforumposts', 'enable_technical_info', 'site_language_enabled', 'show_top_uploader',
);
GetVar($validConfig);
$MAIN = [];
@@ -694,6 +694,7 @@ elseif ($action == 'mainsettings') // main settings
yesorno($lang_settings['row_show_forum_stats'],'showforumstats', $MAIN['showforumstats'], $lang_settings['text_show_forum_stats_note']);
yesorno($lang_settings['row_show_hot'],'showhotmovies', $MAIN['showhotmovies'], $lang_settings['text_show_hot_note']);
yesorno($lang_settings['row_show_classic'],'showclassicmovies', $MAIN['showclassicmovies'], $lang_settings['text_show_classic_note']);
yesorno($lang_settings['row_show_top_uploader'],'show_top_uploader', $MAIN['show_top_uploader'], $lang_settings['text_show_top_uploader_note']);
yesorno($lang_settings['row_enable_imdb_system'],'showimdbinfo', $MAIN['showimdbinfo'], $lang_settings['text_imdb_system_note']);
yesorno($lang_settings['row_enable_pt_gen_system'],'enable_pt_gen_system', $MAIN['enable_pt_gen_system'], $lang_settings['text_enable_pt_gen_system_note']);
tr($lang_settings['row_pt_gen_api_point'],"<input type='text' name=\"pt_gen_api_point\" style=\"width: 300px\" value={$MAIN['pt_gen_api_point']}> ".$lang_settings['text_pt_gen_api_point_note'], 1);

View File

@@ -210,20 +210,23 @@ if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"])
else $locationinfo = "";
tr_small($lang_userdetails['row_ip_address'], $user['ip'].$locationinfo, 1);
}
$res = sql_query("SELECT agent, peer_id, ip, port FROM peers WHERE userid = {$user['id']} GROUP BY agent,ip") or sqlerr();
$clientselect = "";
$clientselect = '';
$res = sql_query("SELECT peer_id, agent, ipv4, ipv6, port FROM peers WHERE userid = {$user['id']} GROUP BY agent") or sqlerr();
if (mysql_num_rows($res) > 0)
{
$first = true;
$clientselect .= "<table border='1' cellspacing='0' cellpadding='5'><tr><td class='colhead'>Agent</td><td class='colhead'>IPV4</td><td class='colhead'>IPV6</td><td class='colhead'>Port</td></tr>";
while($arr = mysql_fetch_assoc($res))
{
$clientselect .= ($first == true ? "" : " ; ") . get_agent($arr["peer_id"], $arr["agent"]);
$first = false;
if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"])
$clientselect .= " (" . $arr["ip"] . ":" . $arr["port"] . ")";
$clientselect .= "<tr>";
$clientselect .= sprintf('<td>%s</td>', get_agent($arr['peer_id'], $arr['agent']));
if (get_user_class() >= $userprofile_class || $user["id"] == $CURUSER["id"]) {
$clientselect .= sprintf('<td>%s</td><td>%s</td><td>%s</td>', $arr['ipv4'], $arr['ipv6'], $arr['port']);
} else {
$clientselect .= sprintf('<td>%s</td><td>%s</td><td>%s</td>', '---', '---', '---');
}
$clientselect .= "</tr>";
}
$clientselect .= '</table>';
}
if ($clientselect)
tr_small($lang_userdetails['row_bt_client'], $clientselect, 1);

View File

@@ -2,9 +2,9 @@
return [
'ban_user_with_leech_warning_expired' => 'Banned by system because of leech warning expired.',
'delete_user_unconfirmed' => 'Delete by system because of unconfired excess deadline.',
'delete_user_no_transfer_alt_last_access_time' => 'Delete inactive user accounts, no transfer. Alt: last access time.',
'delete_user_no_transfer_alt_register_time' => 'Delete inactive user accounts, no transfer. Alt: register time.',
'delete_user_not_parked' => 'Delete inactive user accounts, not parked.',
'delete_user_parked' => 'Delete inactive user accounts, parked.',
'delete_user_unconfirmed' => 'Disable by system because of unconfirmed excess deadline.',
'delete_user_no_transfer_alt_last_access_time' => 'Disable inactive user accounts, no transfer. Alt: last access time.',
'delete_user_no_transfer_alt_register_time' => 'Disable inactive user accounts, no transfer. Alt: register time.',
'delete_user_not_parked' => 'Disable inactive user accounts, not parked.',
'delete_user_parked' => 'Disable inactive user accounts, parked.',
];

View File

@@ -2,9 +2,9 @@
return [
'ban_user_with_leech_warning_expired' => '上传警告到期,被系统禁用.',
'delete_user_unconfirmed' => '超时未确认,被系统删除.',
'delete_user_no_transfer_alt_last_access_time' => '删除非活跃的无流量账号,由最近访问时间断定.',
'delete_user_no_transfer_alt_register_time' => '删除非活跃的无流量账号,由注册时间时间断定.',
'delete_user_not_parked' => '定时删除未挂起的非活跃账号.',
'delete_user_parked' => '定时删除已挂起的非活跃账号.',
'delete_user_unconfirmed' => '超时未确认,被系统封禁.',
'delete_user_no_transfer_alt_last_access_time' => '封禁非活跃的无流量账号,由最近访问时间断定.',
'delete_user_no_transfer_alt_register_time' => '封禁非活跃的无流量账号,由注册时间时间断定.',
'delete_user_not_parked' => '定时封禁未挂起的非活跃账号.',
'delete_user_parked' => '定时封禁已挂起的非活跃账号.',
];

View File

@@ -2,9 +2,9 @@
return [
'ban_user_with_leech_warning_expired' => '上傳警告到期,被系統禁用.',
'delete_user_unconfirmed' => '超時未確認,被系統刪除.',
'delete_user_no_transfer_alt_last_access_time' => '刪除非活躍的無流量賬號,由最近訪問時間斷定.',
'delete_user_no_transfer_alt_register_time' => '刪除非活躍的無流量賬號,由註冊時間時間斷定.',
'delete_user_not_parked' => '定時刪除未掛起的非活躍賬號.',
'delete_user_parked' => '定時刪除已掛起的非活躍賬號.',
'delete_user_unconfirmed' => '超時未確認,被系統封禁.',
'delete_user_no_transfer_alt_last_access_time' => '封禁非活躍的無流量賬號,由最近訪問時間斷定.',
'delete_user_no_transfer_alt_register_time' => '封禁非活躍的無流量賬號,由註冊時間時間斷定.',
'delete_user_not_parked' => '定時封禁未掛起的非活躍賬號.',
'delete_user_parked' => '定時封禁已掛起的非活躍賬號.',
];