diff --git a/app/Repositories/SeedBoxRepository.php b/app/Repositories/SeedBoxRepository.php index 13666832..2649046a 100644 --- a/app/Repositories/SeedBoxRepository.php +++ b/app/Repositories/SeedBoxRepository.php @@ -154,7 +154,7 @@ class SeedBoxRepository extends BaseRepository private function clearCache() { - return true; + NexusDB::cache_del('SEED_BOX_RECORD_APPROVAL_NONE'); // SeedBoxRecordUpdated::dispatch(); } diff --git a/include/cleanup.php b/include/cleanup.php index 6e58b676..3e301bfa 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -204,7 +204,7 @@ function ban_user_with_leech_warning_expired() } -function delete_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey) +function disable_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey) { $results = $query->where('enabled', \App\Models\User::ENABLED_YES)->get(['id', 'username', 'modcomment', 'lang']); if ($results->isEmpty()) { @@ -228,7 +228,7 @@ function delete_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey) ); sql_query($sql); \App\Models\UserBanLog::query()->insert($userBanLogData); - do_log("[DELETE_USER]($reasonKey): " . implode(', ', $uidArr)); + do_log("[DISABLE_USER]($reasonKey): " . implode(', ', $uidArr)); return $uidArr; } @@ -537,7 +537,7 @@ function docleanup($forceAll = 0, $printProgress = false) { ->whereRaw("added < FROM_UNIXTIME($deadtime)") ->whereRaw("last_login < FROM_UNIXTIME($deadtime)") ->whereRaw("last_access < FROM_UNIXTIME($deadtime)"); - delete_user($query, "cleanup.delete_user_unconfirmed"); + disable_user($query, "cleanup.disable_user_unconfirmed"); $log = "delete unconfirmed accounts"; do_log($log); if ($printProgress) { @@ -590,7 +590,7 @@ function docleanup($forceAll = 0, $printProgress = false) { ->where(function (\Illuminate\Database\Eloquent\Builder $query) use ($iniupload_main) { $query->where('uploaded', 0)->orWhere('uploaded', $iniupload_main); }); - delete_user($query, "cleanup.delete_user_no_transfer_alt_last_access_time"); + disable_user($query, "cleanup.disable_user_no_transfer_alt_last_access_time"); } $log = "delete inactive user accounts, no transfer. Alt. 1: last access time"; do_log($log); @@ -613,7 +613,7 @@ function docleanup($forceAll = 0, $printProgress = false) { ->where(function (\Illuminate\Database\Eloquent\Builder $query) use ($iniupload_main) { $query->where('uploaded', 0)->orWhere('uploaded', $iniupload_main); }); - delete_user($query, "cleanup.delete_user_no_transfer_alt_register_time"); + disable_user($query, "cleanup.disable_user_no_transfer_alt_register_time"); } $log = "delete inactive user accounts, no transfer. Alt. 2: registering time"; do_log($log); @@ -632,7 +632,7 @@ function docleanup($forceAll = 0, $printProgress = false) { ->where('status', 'confirmed') ->where("class","<", $maxclass) ->where("last_access","<", $dt); - delete_user($query, "cleanup.delete_user_not_parked"); + disable_user($query, "cleanup.disable_user_not_parked"); } $log = "delete inactive user accounts, not parked"; do_log($log); @@ -651,7 +651,7 @@ function docleanup($forceAll = 0, $printProgress = false) { ->where('status', 'confirmed') ->where("class","<", $maxclass) ->where("last_access","<", $dt); - delete_user($query, "cleanup.delete_user_parked"); + disable_user($query, "cleanup.disable_user_parked"); } $log = "delete parked user accounts, parked"; do_log($log); @@ -659,6 +659,22 @@ function docleanup($forceAll = 0, $printProgress = false) { printProgress($log); } + //destroy disabled accounts + $destroyDisabledDays = get_setting('account.destroy_disabled'); + if ($destroyDisabledDays > 0) { + $secs = $destroyDisabledDays*24*60*60; + $dt = date("Y-m-d H:i:s",(TIMENOW - $secs)); + \App\Models\User::query() + ->where('enabled', 'no') + ->where("last_access","<", $dt) + ->delete(); + } + $log = "destroy disabled accounts"; + do_log($log); + if ($printProgress) { + printProgress($log); + } + //remove VIP status if time's up $res = sql_query("SELECT id, modcomment FROM users WHERE vip_added='yes' AND vip_until < NOW()") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) diff --git a/include/functions.php b/include/functions.php index 844359f9..ddc1f374 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2800,6 +2800,19 @@ if ($msgalert) } } + //seed box approval + if (get_user_class() >= \App\Models\User::CLASS_ADMINISTRATOR && get_setting('seed_box.enabled') == 'yes') { + $cacheKey = 'SEED_BOX_RECORD_APPROVAL_NONE'; + $toApprovalCounts = $Cache->get_value($cacheKey); + if ($toApprovalCounts === false) { + $toApprovalCounts = get_row_count('seed_box_records', 'where status = 0'); + $Cache->cache_value($cacheKey, $toApprovalCounts, 60); + } + if ($toApprovalCounts) { + msgalert('/nexusphp/seed-box-records?tableFilters[status][value]=0', sprintf($lang_functions['text_seed_box_record_to_approval'], is_or_are($toApprovalCounts), $toApprovalCounts, add_s($toApprovalCounts)), 'darkred'); + } + } + if (user_can('staffmem')) { diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index 7bbb9b1f..082dc32f 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -329,6 +329,7 @@ $lang_functions = array 'input_check_all' => "全选", 'input_uncheck_all' => "全不选", 'select_at_least_one_record' => '至少选择一条记录!', + 'text_seed_box_record_to_approval' => '有 %s%u 条待审核的 SeedBox 记录%s', ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index e79009f5..75e82e5b 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -791,6 +791,9 @@ $lang_settings = array 'row_upload_deny_approval_deny_count' => '拒绝发布审核不通过数', 'text_upload_deny_approval_deny_count_note' => "当审核不通过的种子数大于等于此数值时,不允许发布。设置为 '0' 不使用此规则", 'row_nfo_view_style_default' => 'NFO 默认查看样式', + 'row_destroy_disabled' => '彻底删除账号', + 'text_destroy_disabled_note_one' => '被封禁的账号如果连续', + 'text_destroy_disabled_note_two' => "天不登录,将被从数据库彻底物理删除。默认'500',请设置一个大于上边任何一种导致封禁的值。设为'0'来禁止此规则。", ); ?> diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php index d1f50e6b..96ff35d5 100644 --- a/lang/cht/lang_functions.php +++ b/lang/cht/lang_functions.php @@ -336,6 +336,7 @@ $lang_functions = array 'input_check_all' => "全選", 'input_uncheck_all' => "全不選", 'select_at_least_one_record' => '至少選擇一條記錄!', + 'text_seed_box_record_to_approval' => '有 %s%u 條待審核的 SeedBox 記錄%s', ); ?> diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php index ee0df495..6aaf03e8 100644 --- a/lang/cht/lang_settings.php +++ b/lang/cht/lang_settings.php @@ -791,6 +791,9 @@ $lang_settings = array 'row_upload_deny_approval_deny_count' => '拒絕發布審核不通過數', 'text_upload_deny_approval_deny_count_note' => "當審核不通過的種子數大於等於此數值時,不允許發布。設置為 '0' 不使用此規則", 'row_nfo_view_style_default' => 'NFO 默認查看樣式', + 'row_destroy_disabled' => '徹底刪除賬號', + 'text_destroy_disabled_note_one' => '被封禁的賬號如果連續', + 'text_destroy_disabled_note_two' => "天不登錄,將被從數據庫徹底物理刪除。默認'500',請設置一個大於上邊任何一種導致封禁的值。設為'0'來禁止此規則。", ); ?> diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index 421ec32a..bc4fbe54 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -337,6 +337,7 @@ $lang_functions = array 'input_check_all' => "Check All", 'input_uncheck_all' => "Uncheck All", 'select_at_least_one_record' => 'Select at least one record!', + 'text_seed_box_record_to_approval' => 'There %s%u not approval seed box record%s.', ); ?> diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php index 10168383..a82eb6ad 100644 --- a/lang/en/lang_settings.php +++ b/lang/en/lang_settings.php @@ -791,6 +791,9 @@ $lang_settings = array 'row_upload_deny_approval_deny_count' => 'Refuse to upload approval deny count', 'text_upload_deny_approval_deny_count_note' => "When the number of torrents approval deny is greater than or equal to this value, publishing is not allowed. Set to '0' to not use this rule", 'row_nfo_view_style_default' => 'NFO view style default', + 'row_destroy_disabled' => 'Delete account completely', + 'text_destroy_disabled_note_one' => 'Disabled accounts if they are continuously', + 'text_destroy_disabled_note_two' => "Days without logging in, will be physically deleted from the database completely. Default '500', please set a value greater than any of the above to cause disable. Set to '0' to disable this rule." , ); ?> diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php index 978a056b..ed7f04d5 100644 --- a/nexus/Install/settings.default.php +++ b/nexus/Install/settings.default.php @@ -304,6 +304,7 @@ return array ( 8 => '5', 9 => '10', ), + 'destroy_disabled' => 500, ), 'torrent' => array ( diff --git a/public/getusertorrentlistajax.php b/public/getusertorrentlistajax.php index d5d234fa..cc1d963e 100644 --- a/public/getusertorrentlistajax.php +++ b/public/getusertorrentlistajax.php @@ -11,6 +11,7 @@ header("Pragma: no-cache" ); $torrentRep = new \App\Repositories\TorrentRepository(); $claimRep = new \App\Repositories\ClaimRepository(); +$seedBoxRep = new \App\Repositories\SeedBoxRepository(); $claimTorrentTTL = \App\Models\Claim::getConfigTorrentTTL(); $id = intval($_GET['userid'] ?? 0); $type = $_GET['type']; @@ -22,7 +23,7 @@ if(!user_can('torrenthistory') && $id != $CURUSER["id"]) function maketable($res, $mode = 'seeding') { global $lang_getusertorrentlistajax,$CURUSER,$smalldescription_main, $lang_functions, $id; - global $torrentRep, $claimRep, $claimTorrentTTL; + global $torrentRep, $claimRep, $claimTorrentTTL, $seedBoxRep; $showActionClaim = $showClient = false; switch ($mode) { @@ -107,6 +108,10 @@ function maketable($res, $mode = 'seeding') } default: break; } + $shouldShowClient = false; + if ($showClient && (user_can('userprofile') || $CURUSER['id'] == $id)) { + $shouldShowClient = true; + } $results = $torrentIdArr = []; while ($row = mysql_fetch_assoc($res)) { $results[] = $row; @@ -131,7 +136,7 @@ function maketable($res, $mode = 'seeding') $ret = "
| ".$lang_getusertorrentlistajax['col_type']." | ".$lang_getusertorrentlistajax['col_name']." | ".$lang_getusertorrentlistajax['col_added']." | ". ($showsize ? "![]() | " : "").($showsenum ? "![]() | " : "").($showlenum ? "![]() | " : "").($showuploaded ? "".$lang_getusertorrentlistajax['col_uploaded']." | " : "") . ($showdownloaded ? "".$lang_getusertorrentlistajax['col_downloaded']." | " : "").($showratio ? "".$lang_getusertorrentlistajax['col_ratio']." | " : "").($showsetime ? "".$lang_getusertorrentlistajax['col_se_time']." | " : "").($showletime ? "".$lang_getusertorrentlistajax['col_le_time']." | " : "").($showcotime ? "".$lang_getusertorrentlistajax['col_time_completed']." | " : "").($showanonymous ? "".$lang_getusertorrentlistajax['col_anonymous']." | " : ""); - if ($showClient) { + if ($shouldShowClient) { $ret .= sprintf('%s | IP | ', $lang_getusertorrentlistajax['col_client']); } $ret .= sprintf('%s | ', $lang_functions['std_action']); @@ -217,8 +222,11 @@ function maketable($res, $mode = 'seeding') $ret .= ""."". str_replace(" ", " ", gettime($arr['completedat'],false)). " | ";
if ($showanonymous)
$ret .= "".$arr['anonymous']." | "; - if ($showClient) { + if ($shouldShowClient) { $ipArr = array_filter([$arr['ipv4'], $arr['ipv6']]); + foreach ($ipArr as &$_ip) { + $_ip = sprintf('%s', $_ip . $seedBoxRep->renderIcon($_ip, $arr['userid'])); + } $ret .= sprintf( '%s %s | %s | ', get_agent($arr['peer_id'], $arr['agent']), $arr['port'], diff --git a/public/settings.php b/public/settings.php index 081737b9..7cfdfaed 100644 --- a/public/settings.php +++ b/public/settings.php @@ -134,7 +134,7 @@ elseif ($action == 'savesettings_account') // save account 'exutime', 'exudl', \App\Models\User::CLASS_EXTREME_USER . '_min_seed_points', 'exuprratio', 'exuderatio', \App\Models\User::CLASS_EXTREME_USER . '_alias', 'uutime', 'uudl', \App\Models\User::CLASS_ULTIMATE_USER . '_min_seed_points', 'uuprratio', 'uuderatio', \App\Models\User::CLASS_ULTIMATE_USER . '_alias', 'nmtime', 'nmdl', \App\Models\User::CLASS_NEXUS_MASTER . '_min_seed_points', 'nmprratio', 'nmderatio', \App\Models\User::CLASS_NEXUS_MASTER . '_alias', - 'getInvitesByPromotion' + 'getInvitesByPromotion', 'destroy_disabled' ); GetVar($validConfig); $ACCOUNT = []; @@ -486,8 +486,12 @@ elseif ($action == 'authoritysettings') //Authority settings tr($lang_settings['row_see_banned_torrents'], $lang_settings['text_minimum_class'].classlist('seebanned',$maxclass,$AUTHORITY['seebanned'],0,true).$lang_settings['text_default'].get_user_class_name(UC_UPLOADER,false,true,true).$lang_settings['text_see_banned_torrents_note'],1); tr($lang_settings['row_vote_against_offers'], $lang_settings['text_minimum_class'].classlist('againstoffer',$maxclass,$AUTHORITY['againstoffer'],0,true).$lang_settings['text_default'].get_user_class_name(UC_USER,false,true,true).$lang_settings['text_vote_against_offers_note'],1); tr($lang_settings['row_allow_userbar'], $lang_settings['text_minimum_class'].classlist('userbar',$maxclass,$AUTHORITY['userbar'],0,true).$lang_settings['text_default'].get_user_class_name(UC_POWER_USER,false,true,true).$lang_settings['text_allow_userbar_note'],1); - tr($lang_settings['row_save_settings'],"", 1); - print (""); + +// tr(nexus_trans('permission.not-counting-downloaded.text'), $lang_settings['text_minimum_class'].classlist('not-counting-downloaded',$maxclass,$AUTHORITY['not-counting-downloaded'] ?? '',0,true).nexus_trans('permission.not-counting-downloaded.desc'),1); +// tr(nexus_trans('permission.not-counting-hit-and-run.text'), $lang_settings['text_minimum_class'].classlist('not-counting-hit-and-run',$maxclass,$AUTHORITY['not-counting-hit-and-run'] ?? '',0,true).nexus_trans('permission.not-counting-hit-and-run.desc'),1); + + tr($lang_settings['row_save_settings'],"", 1); + print (""); } elseif ($action == 'basicsettings') // basic settings { @@ -651,6 +655,9 @@ elseif ($action == 'accountsettings'){ tr($lang_settings['row_delete_packed'],$lang_settings['text_delete_packed_note_one']."".$lang_settings['text_delete_packed_note_two'], 1); tr($lang_settings['row_delete_unpacked'],$lang_settings['text_delete_unpacked_note_one']."".$lang_settings['text_delete_unpacked_note_two'], 1); tr($lang_settings['row_delete_no_transfer'],$lang_settings['text_delete_transfer_note_one']."".$lang_settings['text_delete_transfer_note_two']."".$lang_settings['text_delete_transfer_note_three'], 1); + tr($lang_settings['row_destroy_disabled'],$lang_settings['text_destroy_disabled_note_one']."".$lang_settings['text_destroy_disabled_note_two'], 1); + + print("
| ".$lang_settings['text_user_promotion_demotion']." | |||||||||||||||||||
| " . $username ." | ".(user_can('userprofile') ? "".$arr['ip']." | " : "")."".$uploaded."@".$uprate.$lang_viewsnatches['text_per_second']." ".$downloaded."@".$downrate.$lang_viewsnatches['text_per_second']." | $ratio | $seedtime | $leechtime | ".gettime($arr['completedat'],true,false)." | ".gettime($arr['last_action'],true,false)." | ".($userrow['privacy'] != 'strong' || user_can('viewanonymous') ? "$reportImage" : $reportImage)." | |||||||||||
| " . $username ." | ".(user_can('userprofile') || $arr['userid'] == $CURUSER['id'] ? "".$arr['ip'].$seedBoxRep->renderIcon($arr['ip'], $arr['userid'])." | " : "")."".$uploaded."@".$uprate.$lang_viewsnatches['text_per_second']." ".$downloaded."@".$downrate.$lang_viewsnatches['text_per_second']." | $ratio | $seedtime | $leechtime | ".gettime($arr['completedat'],true,false)." | ".gettime($arr['last_action'],true,false)." | ".($userrow['privacy'] != 'strong' || user_can('viewanonymous') ? "$reportImage" : $reportImage)." | |||||||||||