Skip to content

Commit

Permalink
Merge pull request #3715 from HDInnovations/8.x.x
Browse files Browse the repository at this point in the history
(Release) v8.0.2
  • Loading branch information
HDVinnie authored Apr 2, 2024
2 parents 24da1cb + b6ac151 commit 17c49b7
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 21 deletions.
48 changes: 33 additions & 15 deletions app/Http/Controllers/AnnounceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,34 +552,30 @@ private function checkDownloadSlots(AnnounceQueryDTO $queries, Torrent $torrent,
*/
private function generateSuccessAnnounceResponse(AnnounceQueryDTO $queries, Torrent $torrent, User $user): string
{
// Build Response For Bittorrent Client
// Keys must be ordered alphabetically
$response = 'd8:completei'
.$torrent->seeders
.'e10:downloadedi'
.$torrent->times_completed
.'e10:incompletei'
.$torrent->leechers
.'e8:intervali'
.random_int(self::MIN, self::MAX)
.'e12:min intervali'
.random_int(intdiv(self::MIN * 95, 100), self::MIN)
.'e';

$peersIpv4 = '';
$peersIpv6 = '';
$peerCount = 0;
$seederCount = 0;
$leecherCount = 0;

/**
* For non `stopped` event only where either the torrent has at least one leech, or the user is a leech.
* We query peers from database and send peerlist, otherwise just quick return.
*/
if ($queries->event !== 'stopped' && ($queries->left !== 0 || $torrent->leechers !== 0)) {
if ($queries->event !== 'stopped') {
$limit = (min($queries->numwant, 25));

// Get Torrents Peers (Only include leechers in a seeder's peerlist)
if ($queries->left === 0) {
foreach ($torrent->peers as $peer) {
if ($peer->active && $peer->seeder) {
$seederCount++;
}

if ($peer->active && ! $peer->seeder) {
$leecherCount++;
}

// Don't include other seeders, inactive peers, invisible peers nor other peers belonging to the same user
if ($peer->seeder || !$peer->active || !$peer->visible || $peer->user_id === $user->id) {
continue;
Expand All @@ -602,6 +598,14 @@ private function generateSuccessAnnounceResponse(AnnounceQueryDTO $queries, Torr
}
} else {
foreach ($torrent->peers as $peer) {
if ($peer->active && $peer->seeder) {
$seederCount++;
}

if ($peer->active && ! $peer->seeder) {
$leecherCount++;
}

// Don't include inactive peers, invisible peers, nor other peers belonging to the same user
if (!$peer->active || !$peer->visible || $peer->user_id === $user->id) {
continue;
Expand All @@ -625,6 +629,20 @@ private function generateSuccessAnnounceResponse(AnnounceQueryDTO $queries, Torr
}
}

// Build Response For Bittorrent Client
// Keys must be ordered alphabetically
$response = 'd8:completei'
.$seederCount
.'e10:downloadedi'
.$torrent->times_completed
.'e10:incompletei'
.$leecherCount
.'e8:intervali'
.random_int(self::MIN, self::MAX)
.'e12:min intervali'
.random_int(intdiv(self::MIN * 95, 100), self::MIN)
.'e';

if ($peersIpv6 === '') {
return $response.'5:peers'.\strlen($peersIpv4).':'.$peersIpv4.'e';
}
Expand Down
14 changes: 13 additions & 1 deletion app/Http/Requests/Staff/UpdateGroupRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function rules(Request $request): array
'required',
'string',
]),
Rule::prohibitedIf($group->system_required),
Rule::prohibitedIf($group->system_required && $request->name !== $group->name),
],
'position' => [
'required',
Expand Down Expand Up @@ -150,4 +150,16 @@ public function rules(Request $request): array
],
];
}

/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'name.prohibited' => 'You cannot change the name of a system required group.',
];
}
}
2 changes: 1 addition & 1 deletion app/Providers/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function toResponse($request): \Illuminate\Http\RedirectResponse
$user->save();

return to_route('home.index')
->withSuccess('auth.welcome-restore');
->withSuccess(trans('auth.welcome-restore'));
}

// Check if user has read the rules
Expand Down
4 changes: 2 additions & 2 deletions config/unit3d.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
|
*/

'powered-by' => 'Powered By UNIT3D Community Edition v8.0.1',
'powered-by' => 'Powered By UNIT3D Community Edition v8.0.2',

/*
|--------------------------------------------------------------------------
Expand All @@ -43,7 +43,7 @@
|
*/

'version' => 'v8.0.1',
'version' => 'v8.0.2',

/*
|--------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions resources/js/unit3d/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class uploadExtensionBuilder {
// Remux fix
title = title.replace(/( +remux)( *)/i, ' REMUX$2');
if (title.includes(' REMUX')) {
let lowerTitle;
title = title.replace(/ Blu-ray /i, ' BluRay ');
lowerTitle = title.toLowerCase();
if (
Expand Down
38 changes: 36 additions & 2 deletions resources/views/user/buttons/user.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,44 @@ class="nav-tab__link"
</form>
@endif
</li>
<li class="nav-tabV2">
<button class="nav-tab__link" data-toggle="modal" data-target="#modal_user_report">
<li class="nav-tabV2" x-data="dialog">
<button class="nav-tab__link" x-bind="showDialog">
{{ __('user.report') }}
</button>
<dialog class="dialog" x-bind="dialogElement">
<h3 class="dialog__heading">Report user: {{ $user->username }}</h3>
<form
class="dialog__form"
method="POST"
action="{{ route('report_user', ['username' => $user->username]) }}"
x-bind="dialogForm"
>
@csrf
<p class="form__group">
<textarea
id="report_reason"
class="form__textarea"
name="message"
required
></textarea>
<label class="form__label form__label--floating" for="report_reason">
Reason
</label>
</p>
<p class="form__group">
<button class="form__button form__button--filled">
{{ __('common.save') }}
</button>
<button
formmethod="dialog"
formnovalidate
class="form__button form__button--outlined"
>
{{ __('common.cancel') }}
</button>
</p>
</form>
</dialog>
</li>
@endif
</ul>
Expand Down

0 comments on commit 17c49b7

Please sign in to comment.