From 93a8a8d37509d916151c8f3fd3e9bdc66cfb64fb Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Thu, 31 Aug 2023 09:22:36 +0000 Subject: [PATCH] PHP Style Change (Laravel Pint CI) --- app/Console/Commands/AutoPreWarning.php | 1 + app/Console/Commands/AutoWarning.php | 1 + app/Console/Commands/TestMailSettings.php | 3 ++- app/Helpers/HiddenCaptcha.php | 3 ++- app/Helpers/SystemInformation.php | 3 ++- app/Http/Controllers/API/TorrentController.php | 4 +++- app/Http/Controllers/PostController.php | 1 + app/Http/Controllers/Staff/HomeController.php | 2 +- app/Http/Controllers/TorrentDownloadController.php | 1 + app/Http/Requests/StoreTorrentRequest.php | 3 ++- app/Jobs/ProcessAnnounce.php | 1 + app/Models/Article.php | 1 + app/Models/Peer.php | 1 + app/Models/Post.php | 1 + 14 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Console/Commands/AutoPreWarning.php b/app/Console/Commands/AutoPreWarning.php index 6792d0fba..fe56647ce 100644 --- a/app/Console/Commands/AutoPreWarning.php +++ b/app/Console/Commands/AutoPreWarning.php @@ -70,6 +70,7 @@ class AutoPreWarning extends Command ->where('torrent', '=', $pre->torrent->id) ->where('user_id', '=', $pre->user->id) ->first(); + // Send Pre Warning PM If Actual Warning Doesnt Already Exsist if ($exsist === null) { $timeleft = config('hitrun.grace') - config('hitrun.prewarn'); diff --git a/app/Console/Commands/AutoWarning.php b/app/Console/Commands/AutoWarning.php index 46f9b7a0c..5c7fdc8d1 100644 --- a/app/Console/Commands/AutoWarning.php +++ b/app/Console/Commands/AutoWarning.php @@ -67,6 +67,7 @@ class AutoWarning extends Command ->where('torrent', '=', $hr->torrent->id) ->where('user_id', '=', $hr->user->id) ->first(); + // Insert Warning Into Warnings Table if doesnt already exsist if ($exsist === null) { $warning = new Warning(); diff --git a/app/Console/Commands/TestMailSettings.php b/app/Console/Commands/TestMailSettings.php index 979761058..ff6829c16 100644 --- a/app/Console/Commands/TestMailSettings.php +++ b/app/Console/Commands/TestMailSettings.php @@ -16,6 +16,7 @@ namespace App\Console\Commands; use App\Mail\TestEmail; use Illuminate\Console\Command; use Illuminate\Support\Facades\Mail; +use Exception; /** * @see \Tests\Todo\Unit\Console\Commands\TestMailSettingsTest @@ -48,7 +49,7 @@ class TestMailSettings extends Command try { Mail::to($owner)->send(new TestEmail()); - } catch (\Exception) { + } catch (Exception) { $this->error('Failed!'); $this->alert('Email failed to send. Please review your mail configs in the .env file.'); diff --git a/app/Helpers/HiddenCaptcha.php b/app/Helpers/HiddenCaptcha.php index 36db91b23..ccb137900 100644 --- a/app/Helpers/HiddenCaptcha.php +++ b/app/Helpers/HiddenCaptcha.php @@ -16,6 +16,7 @@ namespace App\Helpers; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Str; use Illuminate\Validation\Validator; +use Exception; class HiddenCaptcha { @@ -86,7 +87,7 @@ class HiddenCaptcha // Get the token values try { $token = Crypt::decrypt($captcha); - } catch (\Exception) { + } catch (Exception) { return false; } diff --git a/app/Helpers/SystemInformation.php b/app/Helpers/SystemInformation.php index 8fb5d2d93..0d8a71194 100644 --- a/app/Helpers/SystemInformation.php +++ b/app/Helpers/SystemInformation.php @@ -15,6 +15,7 @@ namespace App\Helpers; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; +use Exception; class SystemInformation { @@ -160,7 +161,7 @@ class SystemInformation { try { return substr(sprintf('%o', fileperms(base_path($path))), -4); - } catch (\Exception) { + } catch (Exception) { return trans('site.error'); } } diff --git a/app/Http/Controllers/API/TorrentController.php b/app/Http/Controllers/API/TorrentController.php index 5c5a66371..fc81250da 100644 --- a/app/Http/Controllers/API/TorrentController.php +++ b/app/Http/Controllers/API/TorrentController.php @@ -32,6 +32,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; +use Exception; /** * @see \Tests\Todo\Feature\Http\Controllers\TorrentControllerTest @@ -116,7 +117,7 @@ class TorrentController extends BaseController try { $meta = Bencode::get_meta($decodedTorrent); - } catch (\Exception) { + } catch (Exception) { return $this->sendError('Validation Error.', 'You Must Provide A Valid Torrent File For Upload!'); } @@ -245,6 +246,7 @@ class TorrentController extends BaseController // Save The Torrent $torrent->save(); + // Set torrent to featured if ($torrent->featured == 1) { $featuredTorrent = new FeaturedTorrent(); diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php index 6e96048c4..e99356131 100644 --- a/app/Http/Controllers/PostController.php +++ b/app/Http/Controllers/PostController.php @@ -108,6 +108,7 @@ class PostController extends Controller $topic->notifyStaffers($user, $topic, $post); } else { $this->chatRepository->systemMessage(sprintf('[url=%s]%s[/url] has left a reply on topic [url=%s]%s[/url]', $profileUrl, $user->username, $postUrl, $topic->name)); + // Notify All Subscribers Of New Reply if ($topic->first_post_user_id != $user->id) { $topic->notifyStarter($user, $topic, $post); diff --git a/app/Http/Controllers/Staff/HomeController.php b/app/Http/Controllers/Staff/HomeController.php index 21ec2ee5f..43a98c7bf 100644 --- a/app/Http/Controllers/Staff/HomeController.php +++ b/app/Http/Controllers/Staff/HomeController.php @@ -40,7 +40,7 @@ class HomeController extends Controller // SSL Info try { $certificate = $request->secure() ? SslCertificate::createForHostName(config('app.url')) : ''; - } catch (\Exception) { + } catch (Exception) { $certificate = ''; } diff --git a/app/Http/Controllers/TorrentDownloadController.php b/app/Http/Controllers/TorrentDownloadController.php index c3d3e419b..0a06f071d 100644 --- a/app/Http/Controllers/TorrentDownloadController.php +++ b/app/Http/Controllers/TorrentDownloadController.php @@ -45,6 +45,7 @@ class TorrentDownloadController extends Controller } $torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id); $hasHistory = $user->history()->where([['torrent_id', '=', $torrent->id], ['seeder', '=', 1]])->exists(); + // User's ratio is too low if ($user->ratio < config('other.ratio') && ! ($torrent->user_id === $user->id || $hasHistory)) { return to_route('torrents.show', ['id' => $torrent->id]) diff --git a/app/Http/Requests/StoreTorrentRequest.php b/app/Http/Requests/StoreTorrentRequest.php index 703361f6d..c480cb98c 100644 --- a/app/Http/Requests/StoreTorrentRequest.php +++ b/app/Http/Requests/StoreTorrentRequest.php @@ -22,6 +22,7 @@ use Illuminate\Foundation\Http\FormRequest; use Illuminate\Http\Request; use Illuminate\Validation\Rule; use Closure; +use Exception; class StoreTorrentRequest extends FormRequest { @@ -61,7 +62,7 @@ class StoreTorrentRequest extends FormRequest try { $meta = Bencode::get_meta($decodedTorrent); - } catch (\Exception) { + } catch (Exception) { $fail('You Must Provide A Valid Torrent File For Upload!'); } diff --git a/app/Jobs/ProcessAnnounce.php b/app/Jobs/ProcessAnnounce.php index 2906410e3..3b08469f5 100644 --- a/app/Jobs/ProcessAnnounce.php +++ b/app/Jobs/ProcessAnnounce.php @@ -167,6 +167,7 @@ class ProcessAnnounce implements ShouldQueue 'downloaded' => DB::raw('downloaded + '.(int) $modDownloaded), ]); } + // End User Update break; default: diff --git a/app/Models/Article.php b/app/Models/Article.php index 25bc2d504..f7e866c7e 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -59,6 +59,7 @@ class Article extends Model public function getBrief(int $length = 20, bool $ellipses = true, bool $stripHtml = false): string { $input = $this->content; + //strip tags, if desired if ($stripHtml) { $input = strip_tags($input); diff --git a/app/Models/Peer.php b/app/Models/Peer.php index bdf052fd5..1b8db6754 100644 --- a/app/Models/Peer.php +++ b/app/Models/Peer.php @@ -85,6 +85,7 @@ class Peer extends Model { if (config('announce.connectable_check')) { $tmp_ip = inet_ntop(pack('A'.\strlen($this->ip), $this->ip)); + // IPv6 Check if (filter_var($tmp_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { $tmp_ip = '['.$tmp_ip.']'; diff --git a/app/Models/Post.php b/app/Models/Post.php index bd03c3d56..afc51b3a5 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -128,6 +128,7 @@ class Post extends Model public function getBrief(int $length = 100, bool $ellipses = true, bool $stripHtml = false): string { $input = $this->content; + //strip tags, if desired if ($stripHtml) { $input = strip_tags($input);