diff --git a/app/Http/Controllers/BookmarkController.php b/app/Http/Controllers/BookmarkController.php new file mode 100644 index 00000000..8db884c3 --- /dev/null +++ b/app/Http/Controllers/BookmarkController.php @@ -0,0 +1,73 @@ +repository = $repository; + } + + public function index(Request $request) + { + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $request->validate([ + 'torrent_id' => 'required|integer', + ]); + $result = $this->repository->add(Auth::user(), $request->torrent_id); + return $this->success($result->toArray(), nexus_trans('bookmark.actions.store_success')); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $result = $this->repository->remove(Auth::user(), $id); + return $this->success($result, nexus_trans('bookmark.actions.delete_success')); + } + +} diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 98fe2669..76df99a3 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -6,6 +6,7 @@ use App\Http\Resources\TorrentResource; use App\Models\Torrent; use App\Repositories\TorrentRepository; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class TorrentController extends Controller { @@ -52,10 +53,13 @@ class TorrentController extends Controller $result = Torrent::query()->with($with)->withCount(['peers', 'thank_users'])->visible()->findOrFail($id); + $isBookmarked = Auth::user()->bookmarks()->where('torrentid', $id)->exists(); + $resource = new TorrentResource($result); $resource->additional([ 'page_title' => nexus_trans('torrent.show.page_title'), 'field_labels' => Torrent::getFieldLabels(), + 'is_bookmarked' => (int)$isBookmarked, ]); return $this->success($resource); diff --git a/app/Http/Middleware/Platform.php b/app/Http/Middleware/Platform.php index 372592f6..03f65da7 100644 --- a/app/Http/Middleware/Platform.php +++ b/app/Http/Middleware/Platform.php @@ -4,6 +4,7 @@ namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; +use Illuminate\Validation\UnauthorizedException; class Platform { diff --git a/app/Models/Bookmark.php b/app/Models/Bookmark.php new file mode 100644 index 00000000..a1a90adc --- /dev/null +++ b/app/Models/Bookmark.php @@ -0,0 +1,11 @@ + ['name' => 'Uploaded', 'unit' => 'GB', 'source_user_field' => 'uploaded'], self::INDEX_SEED_TIME_AVERAGE => ['name' => 'Seed time average', 'unit' => 'Hour', 'source_user_field' => 'seedtime'], self::INDEX_DOWNLOADED => ['name' => 'Downloaded', 'unit' => 'GB', 'source_user_field' => 'downloaded'], - self::INDEX_SEED_BONUS => ['name' => 'Seed bonus', 'unit' => '', 'source_user_field' => 'seedbonus'], + self::INDEX_SEED_BONUS => ['name' => 'Seed bonus', 'unit' => '', 'source_user_field' => 'seed_points'], ]; const FILTER_USER_CLASS = 'classes'; diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 78428e21..9f32b76c 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -86,7 +86,7 @@ class Torrent extends NexusModel public static function getFieldLabels(): array { - $fields = ['comments', 'times_completed', 'peers_count', 'thank_users_count', 'numfiles']; + $fields = ['comments', 'times_completed', 'peers_count', 'thank_users_count', 'numfiles', 'bookmark_yes', 'bookmark_no']; $result = []; foreach($fields as $field) { $result[$field] = nexus_trans("torrent.show.{$field}_label"); diff --git a/app/Models/User.php b/app/Models/User.php index c598cca4..cf27d234 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Http\Middleware\Locale; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -41,15 +42,15 @@ class User extends Authenticatable public static $classes = [ self::CLASS_PEASANT => ['text' => 'Peasant'], - self::CLASS_USER => ['text' => 'User'], - self::CLASS_POWER_USER => ['text' => 'Power User'], - self::CLASS_ELITE_USER => ['text' => 'Elite User'], - self::CLASS_CRAZY_USER => ['text' => 'Crazy User'], - self::CLASS_INSANE_USER => ['text' => 'Insane User'], - self::CLASS_VETERAN_USER => ['text' => 'Veteran User'], - self::CLASS_EXTREME_USER => ['text' => 'Extreme User'], - self::CLASS_ULTIMATE_USER => ['text' => 'Ultimate User'], - self::CLASS_NEXUS_MASTER => ['text' => 'Nexus Master'], + self::CLASS_USER => ['text' => 'User', 'min_seed_points' => 0], + self::CLASS_POWER_USER => ['text' => 'Power User', 'min_seed_points' => 40000], + self::CLASS_ELITE_USER => ['text' => 'Elite User', 'min_seed_points' => 80000], + self::CLASS_CRAZY_USER => ['text' => 'Crazy User', 'min_seed_points' => 150000], + self::CLASS_INSANE_USER => ['text' => 'Insane User', 'min_seed_points' => 250000], + self::CLASS_VETERAN_USER => ['text' => 'Veteran User', 'min_seed_points' => 400000], + self::CLASS_EXTREME_USER => ['text' => 'Extreme User', 'min_seed_points' => 600000], + self::CLASS_ULTIMATE_USER => ['text' => 'Ultimate User', 'min_seed_points' => 800000], + self::CLASS_NEXUS_MASTER => ['text' => 'Nexus Master', 'min_seed_points' => 1000000], self::CLASS_VIP => ['text' => 'Vip'], self::CLASS_RETIREE => ['text' => 'Retiree'], self::CLASS_UPLOADER => ['text' => 'Uploader'], @@ -161,6 +162,20 @@ class User extends Authenticatable return 'en'; } + public static function getMinSeedPoints($class) + { + $setting = Setting::get("account.{$class}_min_seed_points"); + if (is_numeric($setting)) { + return $setting; + } + return self::$classes[$class]['min_seed_points'] ?? false; + } + + public function scopeNormal(Builder $query): Builder + { + return $query->where('status', self::STATUS_CONFIRMED)->where('enabled', self::ENABLED_YES); + } + public function exams() { @@ -215,6 +230,11 @@ class User extends Authenticatable return $this->hasMany(Torrent::class, 'owner'); } + public function bookmarks(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Bookmark::class, 'userid'); + } + public function peers_torrents() { diff --git a/app/Repositories/AuthenticateRepository.php b/app/Repositories/AuthenticateRepository.php index d22626d2..4ef1b8ec 100644 --- a/app/Repositories/AuthenticateRepository.php +++ b/app/Repositories/AuthenticateRepository.php @@ -16,7 +16,7 @@ class AuthenticateRepository extends BaseRepository if (!$user || md5($user->secret . $password . $user->secret) != $user->passhash) { throw new \InvalidArgumentException('Username or password invalid.'); } - if (!$user->canAccessAdmin()) { + if (IS_PLATFORM_ADMIN && !$user->canAccessAdmin()) { throw new UnauthorizedException('Unauthorized!'); } $tokenName = __METHOD__ . __LINE__; diff --git a/app/Repositories/BonusRepository.php b/app/Repositories/BonusRepository.php index 3729059a..9bfdb445 100644 --- a/app/Repositories/BonusRepository.php +++ b/app/Repositories/BonusRepository.php @@ -6,7 +6,9 @@ use App\Models\HitAndRun; use App\Models\Setting; use App\Models\User; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Expression; +use Illuminate\Support\Facades\DB; use Nexus\Database\NexusDB; class BonusRepository extends BaseRepository @@ -65,4 +67,25 @@ class BonusRepository extends BaseRepository return $result; } + + public function initSeedPoints(): int + { + $size = 10000; + $tableName = (new User())->getTable(); + $result = 0; + do { + $affectedRows = DB::table($tableName) + ->whereNull('seed_points') + ->limit($size) + ->update([ + 'seed_points' => DB::raw('seed_points = seedbonus') + ]); + $result += $affectedRows; + do_log("affectedRows: $affectedRows, query: " . last_query()); + } while ($affectedRows > 0); + + return $result; + } + + } diff --git a/app/Repositories/BookmarkRepository.php b/app/Repositories/BookmarkRepository.php new file mode 100644 index 00000000..5bdbb9e5 --- /dev/null +++ b/app/Repositories/BookmarkRepository.php @@ -0,0 +1,33 @@ +findOrFail($torrentId); + $torrent->checkIsNormal(); + $exists = $user->bookmarks()->where('torrentid', $torrentId)->exists(); + if ($exists) { + throw new NexusException("torrent: $torrentId already bookmarked."); + } + $result = $user->bookmarks()->create(['torrentid' => $torrentId]); + return $result; + } + + public function remove(User $user, $torrentId) + { + $torrent = Torrent::query()->findOrFail($torrentId); + $exists = $user->bookmarks()->where('torrentid', $torrentId)->exists(); + if (!$exists) { + throw new NexusException("torrent: $torrentId has not been bookmarked."); + } + $result = $user->bookmarks()->where('torrentid', $torrentId)->delete(); + return $result; + } +} diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index 55cbf4d9..7e317b55 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -247,7 +247,7 @@ class TorrentRepository extends BaseRepository ->paginate(); foreach ($snatches as &$snatch) { $snatch->upload_text = sprintf('%s@%s', mksize($snatch->uploaded), $this->getSnatchUploadSpeed($snatch)); - $snatch->download_text = sprintf('%s@%s', mksize($snatch->uploaded), $this->getSnatchDownloadSpeed($snatch)); + $snatch->download_text = sprintf('%s@%s', mksize($snatch->downloaded), $this->getSnatchDownloadSpeed($snatch)); $snatch->share_ratio = $this->getShareRatio($snatch); $snatch->seed_time = mkprettytime($snatch->seedtime); $snatch->leech_time = mkprettytime($snatch->leechtime); @@ -379,5 +379,12 @@ class TorrentRepository extends BaseRepository } + public function getStickyStatus($torrent) + { + if (!$torrent instanceof Torrent) { + $torrent = Torrent::query()->findOrFail((int)$torrent, ['id', 'pos_state']); + } + } + } diff --git a/database/migrations/2021_06_24_013107_add_seed_points_to_users_table.php b/database/migrations/2021_06_24_013107_add_seed_points_to_users_table.php new file mode 100644 index 00000000..4958be09 --- /dev/null +++ b/database/migrations/2021_06_24_013107_add_seed_points_to_users_table.php @@ -0,0 +1,32 @@ +decimal('seed_points', 20, 1)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('seed_points'); + }); + } +} diff --git a/include/cleanup.php b/include/cleanup.php index 759172a8..ed3ba82b 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -96,7 +96,11 @@ function promotion($class, $down_floor_gb, $minratio, $time_week, $addinvite = 0 if ($down_floor_gb){ $limit = $down_floor_gb*1024*1024*1024; $maxdt = date("Y-m-d H:i:s",(TIMENOW - 86400*7*$time_week)); - $sql = "SELECT id, max_class_once FROM users WHERE class = $oriclass AND downloaded >= $limit AND uploaded / downloaded >= $minratio AND added < ".sqlesc($maxdt); + $minSeedPoints = \App\Models\User::getMinSeedPoints($class); + if ($minSeedPoints === false) { + throw new \RuntimeException("class: $class can't get min seed points."); + } + $sql = "SELECT id, max_class_once FROM users WHERE class = $oriclass AND downloaded >= $limit AND seed_points >= $minSeedPoints AND uploaded / downloaded >= $minratio AND added < ".sqlesc($maxdt); $res = sql_query($sql) or sqlerr(__FILE__, __LINE__); $matchUserCount = mysql_num_rows($res); do_log("sql: $sql, match user count: $matchUserCount"); @@ -122,9 +126,12 @@ function promotion($class, $down_floor_gb, $minratio, $time_week, $addinvite = 0 function demotion($class,$deratio){ global $lang_cleanup_target; - $newclass = $class - 1; - $res = sql_query("SELECT id FROM users WHERE class = $class AND uploaded / downloaded < $deratio") or sqlerr(__FILE__, __LINE__); + $minSeedPoints = \App\Models\User::getMinSeedPoints($class); + if ($minSeedPoints === false) { + throw new \RuntimeException("class: $class can't get min seed points."); + } + $res = sql_query("SELECT id FROM users WHERE class = $class AND seed_points < $minSeedPoints AND uploaded / downloaded < $deratio") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $dt = sqlesc(date("Y-m-d H:i:s")); @@ -280,11 +287,12 @@ function docleanup($forceAll = 0, $printProgress = false) { } if ($count > $maxseeding_bonus) $count = $maxseeding_bonus; - $all_bonus = ($valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count)) / (3600 / $autoclean_interval_one); + $all_bonus = $seedPoints = ($valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count)) / (3600 / $autoclean_interval_one); $is_donor = get_single_value("users","donor","WHERE id=".$arr['userid']); if ($is_donor == 'yes' && $donortimes_bonus > 0) $all_bonus = $all_bonus * $donortimes_bonus; KPS("+",$all_bonus,$arr["userid"]); + \App\Models\User::query()->where('id', $arr["userid"])->update(['seed_points' => new \Illuminate\Database\Query\Expression("seed_points + $seedPoints")]); } } $log = 'calculate seeding bonus'; diff --git a/include/functions.php b/include/functions.php index 2c22de48..07063543 100644 --- a/include/functions.php +++ b/include/functions.php @@ -2476,14 +2476,16 @@ else { = UC_SYSOP) { ?> [] [] []: + : %s', $lang_functions['text_attendance']);}?> []: - H&R: %s/%s]', get_row_count('hit_and_runs', "where uid = {$CURUSER['id']} and status = 3"), get_setting('hr.ban_user_when_counts_reach'))?>
+
Torrents seeding Torrents leeching   + H&R: %s/%s]', get_row_count('hit_and_runs', "where uid = {$CURUSER['id']} and status = 3"), get_setting('hr.ban_user_when_counts_reach'))?> = UC_SYSOP) { ?> [] diff --git a/lang/chs/lang_functions.php b/lang/chs/lang_functions.php index e00cd513..9deb0dc5 100644 --- a/lang/chs/lang_functions.php +++ b/lang/chs/lang_functions.php @@ -319,6 +319,7 @@ $lang_functions = array 'text_technical_info' => '技术信息', 'text_technical_info_help_text' => '文件技术信息来自软件 MediaInfo,用该软件打开文件,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。', 'text_management_system' => '管理系统', + 'text_seed_points' => '做种积分', ); ?> diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php index f8b5ff33..75e1fc18 100644 --- a/lang/chs/lang_settings.php +++ b/lang/chs/lang_settings.php @@ -305,7 +305,8 @@ $lang_settings = array 'row_promote_to_two' => "", 'text_member_longer_than' => "注册时间大于", 'text_downloaded_more_than' => "周,下载量大于", - 'text_with_ratio_above' => " GB且分享率大于", + 'text_with_ratio_above' => " 且分享率大于", + 'text_seed_points_more_than' => 'GB,做种积分大于', 'text_be_promoted_to' => "的用户,将升级为", 'text_promote_to_default_one' => "。默认", 'text_promote_to_default_two' => ",他将被降级。默认", diff --git a/lang/cht/lang_functions.php b/lang/cht/lang_functions.php index 24376e04..08333451 100644 --- a/lang/cht/lang_functions.php +++ b/lang/cht/lang_functions.php @@ -320,6 +320,7 @@ $lang_functions = array 'text_technical_info' => '技術信息', 'text_technical_info_help_text' => '文件技術信息來自軟件 MediaInfo,用該軟件打開文件,點擊菜單視圖(View)->文件(Text),在框中右鍵->全選,再右鍵->復制,粘貼到這裏來。', 'text_management_system' => '管理系統', + 'text_seed_points' => '做種積分', ); ?> diff --git a/lang/en/lang_functions.php b/lang/en/lang_functions.php index 1e46f342..1cdd0cb5 100644 --- a/lang/en/lang_functions.php +++ b/lang/en/lang_functions.php @@ -321,6 +321,7 @@ $lang_functions = array 'text_technical_info' => 'Technical Info', 'text_technical_info_help_text' => 'Technical Information comes from software MediaInfo,open file, click the view menu > text > right click in the box > select all > copy > past into this box.', 'text_management_system' => 'Management system', + 'text_seed_points' => 'Seed points', ); ?> diff --git a/public/details.php b/public/details.php index 5ffd4239..f59ef9b3 100644 --- a/public/details.php +++ b/public/details.php @@ -11,7 +11,7 @@ int_check($id); if (!isset($id) || !$id) die(); -$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, +$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, categories.name AS cat_name, categories.mode as search_box_id, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN sources ON torrents.source = sources.id diff --git a/public/getusertorrentlistajax.php b/public/getusertorrentlistajax.php index d00e95d0..70d5ee1e 100644 --- a/public/getusertorrentlistajax.php +++ b/public/getusertorrentlistajax.php @@ -245,11 +245,11 @@ switch ($type) } } -if ($total_size){ - echo "
" . $count . "" . $lang_getusertorrentlistajax ['text_record'] . add_s ( $count ) . $lang_getusertorrentlistajax['text_total_size'] . mksize($total_size) . "

" . $torrentlist; - }elseif ($count){ - echo "
".$count."".$lang_getusertorrentlistajax['text_record'].add_s($count)."

".$torrentlist; - }else{ - echo $lang_getusertorrentlistajax['text_no_record']; +if (isset($total_size) && $total_size){ + echo "
" . $count . "" . $lang_getusertorrentlistajax ['text_record'] . add_s ( $count ) . $lang_getusertorrentlistajax['text_total_size'] . mksize($total_size) . "

" . $torrentlist; +} elseif ($count){ + echo "
".$count."".$lang_getusertorrentlistajax['text_record'].add_s($count)."

".$torrentlist; +} else { + echo $lang_getusertorrentlistajax['text_no_record']; } ?> diff --git a/public/settings.php b/public/settings.php index 310493b7..dfc75e93 100644 --- a/public/settings.php +++ b/public/settings.php @@ -114,7 +114,19 @@ elseif ($action == 'savesettings_account') // save account { stdhead($lang_settings['head_save_account_settings']); - $validConfig = array('neverdelete', 'neverdeletepacked', 'deletepacked', 'deleteunpacked', 'deletenotransfer', 'deletenotransfertwo', 'deletepeasant', 'psdlone', 'psratioone', 'psdltwo', 'psratiotwo', 'psdlthree', 'psratiothree', 'psdlfour', 'psratiofour', 'psdlfive', 'psratiofive', 'putime', 'pudl', 'puprratio', 'puderatio', 'eutime', 'eudl', 'euprratio', 'euderatio', 'cutime', 'cudl', 'cuprratio', 'cuderatio', 'iutime', 'iudl', 'iuprratio', 'iuderatio', 'vutime', 'vudl', 'vuprratio', 'vuderatio', 'exutime', 'exudl', 'exuprratio', 'exuderatio', 'uutime', 'uudl', 'uuprratio', 'uuderatio', 'nmtime', 'nmdl', 'nmprratio', 'nmderatio', 'getInvitesByPromotion'); + $validConfig = array( + 'neverdelete', 'neverdeletepacked', 'deletepacked', 'deleteunpacked', 'deletenotransfer', 'deletenotransfertwo', 'deletepeasant', + 'psdlone', 'psratioone', 'psdltwo', 'psratiotwo', 'psdlthree', 'psratiothree', 'psdlfour', 'psratiofour', 'psdlfive', 'psratiofive', + 'putime', 'pudl', \App\Models\User::CLASS_POWER_USER . '_min_seed_points', 'puprratio', 'puderatio', + 'eutime', 'eudl', \App\Models\User::CLASS_ELITE_USER . '_min_seed_points', 'euprratio', 'euderatio', + 'cutime', 'cudl', \App\Models\User::CLASS_CRAZY_USER . '_min_seed_points', 'cuprratio', 'cuderatio', + 'iutime', 'iudl', \App\Models\User::CLASS_INSANE_USER . '_min_seed_points', 'iuprratio', 'iuderatio', + 'vutime', 'vudl', \App\Models\User::CLASS_VETERAN_USER . '_min_seed_points', 'vuprratio', 'vuderatio', + 'exutime', 'exudl', \App\Models\User::CLASS_EXTREME_USER . '_min_seed_points', 'exuprratio', 'exuderatio', + 'uutime', 'uudl', \App\Models\User::CLASS_ULTIMATE_USER . '_min_seed_points', 'uuprratio', 'uuderatio', + 'nmtime', 'nmdl', \App\Models\User::CLASS_NEXUS_MASTER . '_min_seed_points', 'nmprratio', 'nmderatio', + 'getInvitesByPromotion' + ); GetVar($validConfig); $ACCOUNT = []; foreach($validConfig as $config) { @@ -567,25 +579,35 @@ elseif ($action == 'accountsettings'){
  • ".$lang_settings['text_downloaded_amount_larger_than']."".$lang_settings['text_and_ratio_below']."".$lang_settings['text_demote_peasant_default_four']."
  • ".$lang_settings['text_downloaded_amount_larger_than']."".$lang_settings['text_and_ratio_below']."".$lang_settings['text_demote_peasant_default_five']."

  • ".$lang_settings['text_demote_peasant_note'], 1); - function promotion_criteria($class, $input, $time, $dl, $prratio, $deratio, $defaultInvites=0){ + function promotion_criteria($class, $input, $time, $dl, $prratio, $deratio, $defaultInvites=0, $defaultSeedPoints = 0){ global $lang_settings; global $ACCOUNT; $inputtime = $input."time"; $inputdl = $input."dl"; $inputprratio = $input."prratio"; $inputderatio = $input."deratio"; + $inputSeedPoints = $class . "_min_seed_points"; if (!isset($class)) return; - tr($lang_settings['row_promote_to_one'].get_user_class_name($class,false,false,true).$lang_settings['row_promote_to_two'], $lang_settings['text_member_longer_than']."".$lang_settings['text_downloaded_more_than']."".$lang_settings['text_with_ratio_above']."".$lang_settings['text_be_promoted_to'].get_user_class_name($class,false,true,true).$lang_settings['text_promote_to_default_one']."'".$time."', '".$dl."', '".$prratio."'.
    ".$lang_settings['text_demote_with_ratio_below']."".$lang_settings['text_promote_to_default_two']."'".$deratio."'.
    ".$lang_settings['text_users_get']."".$lang_settings['text_invitations_default']."'".$defaultInvites."'.", 1); + $x = $lang_settings['row_promote_to_one'].get_user_class_name($class,false,false,true).$lang_settings['row_promote_to_two']; + $y = $lang_settings['text_member_longer_than']."" + .$lang_settings['text_downloaded_more_than']."" + .$lang_settings['text_seed_points_more_than']."" + .$lang_settings['text_with_ratio_above']."" + .$lang_settings['text_be_promoted_to'].get_user_class_name($class,false,true,true).$lang_settings['text_promote_to_default_one']."'".$time."', '".$dl."', '".$defaultSeedPoints."', '".$prratio."'.
    " + .$lang_settings['text_demote_with_ratio_below']."".$lang_settings['text_promote_to_default_two']."'".$deratio."'.
    " + .$lang_settings['text_users_get']."".$lang_settings['text_invitations_default']."'".$defaultInvites."'."; + + tr($x, $y, 1); } - promotion_criteria(UC_POWER_USER, "pu", 4, 50, 1.05, 0.95, 1); - promotion_criteria(UC_ELITE_USER, "eu", 8, 120, 1.55, 1.45, 0); - promotion_criteria(UC_CRAZY_USER, "cu", 15, 300, 2.05, 1.95, 2); - promotion_criteria(UC_INSANE_USER, "iu", 25, 500, 2.55, 2.45, 0); - promotion_criteria(UC_VETERAN_USER, "vu", 40, 750, 3.05, 2.95, 3); - promotion_criteria(UC_EXTREME_USER, "exu", 60, 1024, 3.55, 3.45, 0); - promotion_criteria(UC_ULTIMATE_USER, "uu", 80, 1536, 4.05, 3.95, 5); - promotion_criteria(UC_NEXUS_MASTER, "nm", 100, 3072, 4.55, 4.45, 10); + promotion_criteria(UC_POWER_USER, "pu", 4, 50, 1.05, 0.95, 1, \App\Models\User::$classes[UC_POWER_USER]['min_seed_points']); + promotion_criteria(UC_ELITE_USER, "eu", 8, 120, 1.55, 1.45, 0, \App\Models\User::$classes[UC_ELITE_USER]['min_seed_points']); + promotion_criteria(UC_CRAZY_USER, "cu", 15, 300, 2.05, 1.95, 2, \App\Models\User::$classes[UC_CRAZY_USER]['min_seed_points']); + promotion_criteria(UC_INSANE_USER, "iu", 25, 500, 2.55, 2.45, 0, \App\Models\User::$classes[UC_INSANE_USER]['min_seed_points']); + promotion_criteria(UC_VETERAN_USER, "vu", 40, 750, 3.05, 2.95, 3, \App\Models\User::$classes[UC_VETERAN_USER]['min_seed_points']); + promotion_criteria(UC_EXTREME_USER, "exu", 60, 1024, 3.55, 3.45, 0, \App\Models\User::$classes[UC_EXTREME_USER]['min_seed_points']); + promotion_criteria(UC_ULTIMATE_USER, "uu", 80, 1536, 4.05, 3.95, 5, \App\Models\User::$classes[UC_ULTIMATE_USER]['min_seed_points']); + promotion_criteria(UC_NEXUS_MASTER, "nm", 100, 3072, 4.55, 4.45, 10, \App\Models\User::$classes[UC_NEXUS_MASTER]['min_seed_points']); tr($lang_settings['row_save_settings'],"", 1); print (""); } diff --git a/public/userdetails.php b/public/userdetails.php index 11e1687c..18c84f70 100644 --- a/public/userdetails.php +++ b/public/userdetails.php @@ -236,14 +236,14 @@ if(mysql_num_rows($rs_true_trans) > 0) $row_true_trans = mysql_fetch_assoc($rs_true_trans); $true_upload = $row_true_trans['SUM(uploaded)']; $true_download = $row_true_trans['SUM(downloaded)']; - + } -if ($user["downloaded"] > 0 || $true_download > 0) +if ($user["downloaded"] > 0 && $true_download > 0) { $sr = floor($user["uploaded"] / $user["downloaded"] * 1000) / 1000; $true_ratio = floor($true_upload / $true_download * 1000) / 1000; $sr = "" . $lang_userdetails['row_share_ratio'] . ": " . number_format($sr, 3) . "".$lang_userdetails['row_real_share_ratio'].":".number_format($true_ratio, 3).")  " . get_ratio_img($sr) . ""; - + } //end @@ -283,8 +283,11 @@ 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) -tr_small($lang_userdetails['row_karma_points'], htmlspecialchars($user['seedbonus']), 1); +if ($user["id"] == $CURUSER["id"] || get_user_class() >= $viewhistory_class) { + tr_small($lang_userdetails['row_karma_points'], htmlspecialchars($user['seedbonus']), 1); + tr_small($lang_functions['text_seed_points'], htmlspecialchars($user['seed_points']), 1); +} + if ($user["ip"] && (get_user_class() >= $torrenthistory_class || $user["id"] == $CURUSER["id"])){ diff --git a/resources/lang/en/bookmark.php b/resources/lang/en/bookmark.php new file mode 100644 index 00000000..395fe79c --- /dev/null +++ b/resources/lang/en/bookmark.php @@ -0,0 +1,8 @@ + [ + 'store_success' => 'Add to bookmark success!', + 'delete_success' => 'Cancel bookmark success!', + ] +]; diff --git a/resources/lang/en/torrent.php b/resources/lang/en/torrent.php index b3ff11f7..9017df8d 100644 --- a/resources/lang/en/torrent.php +++ b/resources/lang/en/torrent.php @@ -19,9 +19,11 @@ return [ 'basic_team' => 'Team', 'size' => 'Size', 'comments_label' => 'Comments', - 'times_completed_label' => 'Times completed', + 'times_completed_label' => 'Snatched', 'peers_count_label' => 'Peers', - 'thank_users_count_label' => 'Thank user counts', - 'numfiles_label' => 'Files counts', + 'thank_users_count_label' => 'Thanks', + 'numfiles_label' => 'Files', + 'bookmark_yes_label' => 'Bookmarked', + 'bookmark_no_label' => 'Add to bookmark', ] ]; diff --git a/resources/lang/zh_CN/bookmark.php b/resources/lang/zh_CN/bookmark.php new file mode 100644 index 00000000..32132513 --- /dev/null +++ b/resources/lang/zh_CN/bookmark.php @@ -0,0 +1,8 @@ + [ + 'store_success' => '添加收藏成功!', + 'delete_success' => '取消收藏成功!', + ] +]; diff --git a/resources/lang/zh_CN/torrent.php b/resources/lang/zh_CN/torrent.php index b549fe86..9aa9d0e0 100644 --- a/resources/lang/zh_CN/torrent.php +++ b/resources/lang/zh_CN/torrent.php @@ -23,5 +23,7 @@ return [ 'peers_count_label' => '同伴', 'thank_users_count_label' => '谢谢', 'numfiles_label' => '文件', + 'bookmark_yes_label' => '已收藏', + 'bookmark_no_label' => '加入收藏', ] ]; diff --git a/resources/lang/zh_TW/bookmark.php b/resources/lang/zh_TW/bookmark.php new file mode 100644 index 00000000..32132513 --- /dev/null +++ b/resources/lang/zh_TW/bookmark.php @@ -0,0 +1,8 @@ + [ + 'store_success' => '添加收藏成功!', + 'delete_success' => '取消收藏成功!', + ] +]; diff --git a/resources/lang/zh_TW/torrent.php b/resources/lang/zh_TW/torrent.php index 096d136d..eefcf7bc 100644 --- a/resources/lang/zh_TW/torrent.php +++ b/resources/lang/zh_TW/torrent.php @@ -23,5 +23,7 @@ return [ 'peers_count_label' => '同伴', 'thank_users_count_label' => '謝謝', 'numfiles_label' => '文件', + 'bookmark_yes_label' => '已收藏', + 'bookmark_no_label' => '加入收藏', ] ]; diff --git a/routes/api.php b/routes/api.php index 441621bf..4cd5fb55 100644 --- a/routes/api.php +++ b/routes/api.php @@ -31,6 +31,7 @@ Route::group(['middleware' => ['auth:sanctum', 'locale']], function () { Route::resource('files', \App\Http\Controllers\FileController::class); Route::resource('thanks', \App\Http\Controllers\ThankController::class); Route::resource('snatches', \App\Http\Controllers\SnatchController::class); + Route::resource('bookmarks', \App\Http\Controllers\BookmarkController::class); Route::get('search-box', [\App\Http\Controllers\TorrentController::class, 'searchBox']); Route::group(['middleware' => ['admin']], function () {