mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-28 22:41:13 -05:00
Merge branch '7.x.x' into Refund-System
This commit is contained in:
@@ -18,6 +18,7 @@ use App\Models\FeaturedTorrent;
|
||||
use App\Models\FreeleechToken;
|
||||
use App\Models\Torrent;
|
||||
use App\Repositories\ChatRepository;
|
||||
use App\Services\Unit3dAnnounce;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@@ -92,42 +93,34 @@ class TorrentBuffController extends Controller
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
$torrent = Torrent::withAnyStatus()->findOrFail($id);
|
||||
$torrentUrl = href_torrent($torrent);
|
||||
$torrentFlAmount = $request->input('freeleech');
|
||||
|
||||
$v = validator($request->input(), [
|
||||
'freeleech' => 'numeric|not_in:0',
|
||||
$request->validate([
|
||||
'freeleech' => 'numeric|min:0|max:100',
|
||||
'fl_until' => 'nullable|numeric'
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return to_route('torrent', ['id' => $torrent->id])
|
||||
->withErrors($v->errors());
|
||||
}
|
||||
|
||||
if ($torrent->free == 0) {
|
||||
$torrent->free = $torrentFlAmount;
|
||||
$fl_until = $request->input('fl_until');
|
||||
if ($fl_until !== null) {
|
||||
$torrent->fl_until = Carbon::now()->addDays($request->input('fl_until'));
|
||||
if ($request->freeleech != 0) {
|
||||
if ($request->fl_until !== null) {
|
||||
$torrent->fl_until = Carbon::now()->addDays($request->fl_until);
|
||||
$this->chatRepository->systemMessage(
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted %s%% FreeLeech for '.$request->input('fl_until').' days. :stopwatch:', $torrentUrl, $torrent->name, $torrentFlAmount)
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted %s%% FreeLeech for '.$request->fl_until.' days. :stopwatch:', $torrentUrl, $torrent->name, $request->freeleech)
|
||||
);
|
||||
} else {
|
||||
$this->chatRepository->systemMessage(
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted %s%% FreeLeech! Grab It While You Can! :fire:', $torrentUrl, $torrent->name, $torrentFlAmount)
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been granted %s%% FreeLeech! Grab It While You Can! :fire:', $torrentUrl, $torrent->name, $request->freeleech)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Get amount of FL before revoking for chat announcement
|
||||
$torrentFlAmount = $torrent->free;
|
||||
$torrent->free = '0';
|
||||
|
||||
} elseif ($torrent->free != 0) {
|
||||
$this->chatRepository->systemMessage(
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been revoked of its %s%% FreeLeech! :poop:', $torrentUrl, $torrent->name, $torrentFlAmount)
|
||||
sprintf('Ladies and Gents, [url=%s]%s[/url] has been revoked of its %s%% FreeLeech! :poop:', $torrentUrl, $torrent->name, $torrent->free)
|
||||
);
|
||||
}
|
||||
|
||||
$torrent->free = $request->freeleech;
|
||||
$torrent->save();
|
||||
|
||||
Unit3dAnnounce::addTorrent($torrent);
|
||||
|
||||
return to_route('torrent', ['id' => $torrent->id])
|
||||
->withSuccess('Torrent FL Has Been Adjusted!');
|
||||
}
|
||||
@@ -148,6 +141,8 @@ class TorrentBuffController extends Controller
|
||||
$torrent->featured = '1';
|
||||
$torrent->save();
|
||||
|
||||
Unit3dAnnounce::addTorrent($torrent);
|
||||
|
||||
$featured = new FeaturedTorrent();
|
||||
$featured->user_id = $user->id;
|
||||
$featured->torrent_id = $torrent->id;
|
||||
@@ -179,19 +174,18 @@ class TorrentBuffController extends Controller
|
||||
$featured_torrent = FeaturedTorrent::where('torrent_id', '=', $id)->firstOrFail();
|
||||
|
||||
$torrent = Torrent::withAnyStatus()->findOrFail($id);
|
||||
$torrent->free = '0';
|
||||
$torrent->doubleup = '0';
|
||||
$torrent->featured = '0';
|
||||
$torrent->save();
|
||||
|
||||
if (isset($torrent)) {
|
||||
$torrent->free = '0';
|
||||
$torrent->doubleup = '0';
|
||||
$torrent->featured = '0';
|
||||
$torrent->save();
|
||||
Unit3dAnnounce::addTorrent($torrent);
|
||||
|
||||
$appurl = config('app.url');
|
||||
$appurl = config('app.url');
|
||||
|
||||
$this->chatRepository->systemMessage(
|
||||
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured. :poop:', $appurl, $torrent->id, $torrent->name)
|
||||
);
|
||||
}
|
||||
$this->chatRepository->systemMessage(
|
||||
sprintf('Ladies and Gents, [url=%s/torrents/%s]%s[/url] is no longer featured. :poop:', $appurl, $torrent->id, $torrent->name)
|
||||
);
|
||||
|
||||
$featured_torrent->delete();
|
||||
|
||||
@@ -232,6 +226,8 @@ class TorrentBuffController extends Controller
|
||||
|
||||
$torrent->save();
|
||||
|
||||
Unit3dAnnounce::addTorrent($torrent);
|
||||
|
||||
return to_route('torrent', ['id' => $torrent->id])
|
||||
->withSuccess('Torrent DoubleUpload Has Been Adjusted!');
|
||||
}
|
||||
@@ -252,6 +248,8 @@ class TorrentBuffController extends Controller
|
||||
$freeleechToken->torrent_id = $torrent->id;
|
||||
$freeleechToken->save();
|
||||
|
||||
Unit3dAnnounce::addFreeleechToken($user->id, $torrent->id);
|
||||
|
||||
$user->fl_tokens -= '1';
|
||||
$user->save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user