From ce6a5d27faf858362e9bac309367753629995832 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:26:21 -0500 Subject: [PATCH 01/18] (Update) Staff Dashboard View Add link to new Public RSS manager. --- resources/views/partials/dashboardmenu.blade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/views/partials/dashboardmenu.blade.php b/resources/views/partials/dashboardmenu.blade.php index 24cded5333..39d5a391d7 100644 --- a/resources/views/partials/dashboardmenu.blade.php +++ b/resources/views/partials/dashboardmenu.blade.php @@ -72,7 +72,11 @@ @lang('staff.polls') - +
  • + + @lang('rss.rss') + +
  • From db0fe446302ee21d7b881fbd48930f2419a859b6 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:32:21 -0500 Subject: [PATCH 02/18] (Delete) Unneeded RSS Default View Not needed in new implementation. --- resources/views/rss/default.blade.php | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 resources/views/rss/default.blade.php diff --git a/resources/views/rss/default.blade.php b/resources/views/rss/default.blade.php deleted file mode 100644 index d8f0c735de..0000000000 --- a/resources/views/rss/default.blade.php +++ /dev/null @@ -1,23 +0,0 @@ - - - {{ config('other.title') }} - {{ config('other.title') }} @lang('common.rss-system') - {{ url('/') }} - {{ config('app.locale') }} - @foreach ($torrents as $data) - - {{ $data->name }} - {{ route('rssDownload', ['id' => $data->id, 'passkey' => $passkey]) }} - {{ route('torrent', ['id' => $data->id ,'slug' => $data->slug]) }} - {{ $data->getSize() }} - - {{ $data->seeders }} - {{ $data->leechers }} - {{ $data->created_at }} - name }} || {{ $data->getSize() }} || {{ $data->category->name }} - || {{ $data->info_hash }}]]> - - - @endforeach - - From 80a1d45a9329483daaf759fc8481755524df366d Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:34:25 -0500 Subject: [PATCH 03/18] (Add) RSS Database Migration Add migration for new RSS module. Did a drop and recreate because table is not being used and there were significant changes. Made the down field just rebuild what original dev had. --- .../2019_01_11_001150_alter_rss_table.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2019_01_11_001150_alter_rss_table.php diff --git a/database/migrations/2019_01_11_001150_alter_rss_table.php b/database/migrations/2019_01_11_001150_alter_rss_table.php new file mode 100644 index 0000000000..e691b42a87 --- /dev/null +++ b/database/migrations/2019_01_11_001150_alter_rss_table.php @@ -0,0 +1,47 @@ +integer('id', true); + $table->integer('position')->default(0); + $table->string('name','255')->default('Default'); + $table->integer('user_id')->default(1); + $table->integer('staff_id')->default(0); + $table->boolean('is_private')->default(0)->index(); + $table->boolean('is_torrent')->default(0)->index(); + $table->json('json_torrent'); + $table->softDeletes(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('rss'); + Schema::create('rss', function (Blueprint $table) { + $table->integer('id', true); + $table->integer('userID')->index('userID'); + $table->string('category')->nullable(); + $table->timestamps(); + }); + } +} From 620d1c64af99d94bd4e0ba359cee8836dcda8934 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:35:48 -0500 Subject: [PATCH 04/18] (Update) Common English Lang File Add create/position words. --- resources/lang/en/common.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php index 8ebde53865..1b8db67610 100644 --- a/resources/lang/en/common.php +++ b/resources/lang/en/common.php @@ -29,6 +29,7 @@ 'contact' => 'Contact', 'contact-desc' => 'This contact request will be sent to the owner and will get back to you as soon as possible', 'contact-header' => 'Hello', + 'create' => 'Create', 'day' => 'Day', 'delete' => 'Delete', 'delete-your-comment' => 'Delete your comment', @@ -106,6 +107,7 @@ 'personal' => 'Personal', 'plural-suffix' => 's', 'port' => 'Port', + 'position' => 'Position', 'powered-by' => 'Powered by UNIT3D', 'preview' => 'Preview', 'previous' => 'Previous', From 7417eb05f7a117faeaecc54ec9e777661fa62c82 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:37:03 -0500 Subject: [PATCH 05/18] (Add) RSS English Language File Add rss english language words... provides base for translations. --- resources/lang/en/rss.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 resources/lang/en/rss.php diff --git a/resources/lang/en/rss.php b/resources/lang/en/rss.php new file mode 100644 index 0000000000..674963518f --- /dev/null +++ b/resources/lang/en/rss.php @@ -0,0 +1,22 @@ + 'Create', + 'create-private-feed' => 'Create Private RSS Feed', + 'create-public-feed' => 'Create Public RSS Feed', + 'delete' => 'Delete', + 'edit' => 'Edit', + 'edit-private-feed' => 'Edit Private RSS Feed', + 'edit-public-feed' => 'Edit Public RSS Feed', + 'feed' => 'Feed', + 'feeds' => 'Feeds', + 'name' => 'Name', + 'public' => 'Public', + 'private' => 'Private', + 'rss' => 'RSS', + 'type' => 'Type', +]; From 1137bbdf4aa6ce27c639d83d72cce94d519b30dc Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:37:37 -0500 Subject: [PATCH 06/18] (Update) User Model Add relationship to rss feeds. --- app/User.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/User.php b/app/User.php index 7d7291d7f2..d2cd2e3867 100755 --- a/app/User.php +++ b/app/User.php @@ -115,6 +115,16 @@ public function messages() return $this->hasMany(Message::class); } + /** + * Has Many RSS Feeds. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function rss() + { + return $this->hasMany(Rss::class); + } + /** * Has Many Thanks Given. * From 1d2f0f15f26d015d99649bc1c464f6e2a61991c4 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:39:11 -0500 Subject: [PATCH 07/18] (Add) RSS Model Base model for new RSS addon. --- app/Rss.php | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 app/Rss.php diff --git a/app/Rss.php b/app/Rss.php new file mode 100644 index 0000000000..f56c54f41f --- /dev/null +++ b/app/Rss.php @@ -0,0 +1,123 @@ + 'string', + 'json_torrent' => 'array', + ]; + + /** + * Create a new RSS instance. + * + * @return void + */ + public function __construct() + { + $this->expected = ['search' => null, 'description' => null, 'uploader' => null, 'imdb' => null, + 'mal' => null, 'categories' => null, 'types' => null, 'genres' => null, 'freeleech' => null, + 'doubleupload' => null, 'featured' => null, 'stream' => null, 'highspeed' => null, 'internal' => null, + 'alive' => null, 'dying' => null, 'dead' => null, 'sd' => null]; + } + + /** + * Belongs To A User. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user() + { + return $this->belongsTo(User::class)->withDefault([ + 'username' => 'System', + 'id' => '1', + ]); + } + + /** + * Belongs To A Staff Member. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function staff() + { + // Not needed yet. Just added for future extendability. + return $this->belongsTo(User::class, 'staff_id'); + } + + /** + * Get the RSS feeds JSON Torrent as object. + * + * @return string + */ + public function getObjectTorrentAttribute() + { + // Went with attribute to avoid () calls in views. Uniform ->object_torrent vs ->json_torrent. + if($this->json_torrent) { + $expected = $this->expected; + return (object) array_merge($expected, $this->json_torrent); + } + return false; + } + + /** + * Scope a query to only include private RSS feeds. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopePrivate($query) + { + return $query->where('is_private', 1); + } + + /** + * Scope a query to only include public RSS feeds. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopePublic($query) + { + return $query->where('is_private', 0); + } +} From 28a156d6263bcb98170b502dd7a237f12de88445 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:47:22 -0500 Subject: [PATCH 08/18] (Delete/Add) RssController Complete redo of RSSController. Issue: Unused $redirect ... I was going to do it based on variable .. but changed my mind. Left it in for now. --- app/Http/Controllers/RssController.php | 401 ++++++++++++++++++++++--- 1 file changed, 351 insertions(+), 50 deletions(-) diff --git a/app/Http/Controllers/RssController.php b/app/Http/Controllers/RssController.php index 208e4bd0c3..004682b8eb 100644 --- a/app/Http/Controllers/RssController.php +++ b/app/Http/Controllers/RssController.php @@ -1,96 +1,397 @@ where('rsskey', '=', $passkey)->first(); + $this->torrent_faceted = $torrent_faceted; + $this->toastr = $toastr; + } - if ($user) { - $this->userID = $id; - return true; - } - - return false; + /** + * @param Toastr $toastr + */ + public function setToastr($toastr) + { + $this->toastr = $toastr; } - private function getUserData() + /** + * Display a listing of the RSS resource. + * + * @param string $hash + * @return \Illuminate\Http\Response + */ + public function index($hash = null) { - $catArray = Rss::select('category')->where('user_id', '=', $this->userID)->first(); + $user = auth()->user(); - if ($catArray) { - return explode(',', $catArray); - } + $public_rss = Rss::public()->orderBy('position', 'ASC')->get(); + $private_rss = Rss::private()->where('user_id',$user->id)->latest()->get(); - return []; + return view('rss.index', [ + 'hash' => $hash, + 'public_rss' => $public_rss, + 'private_rss' => $private_rss, + 'user' => $user, + ]); } - private function getTorrents() + /** + * Show the form for creating a new RSS resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $user = auth()->user(); + $torrent_repository = $this->torrent_faceted; + + return view('rss.create', [ + 'torrent_repository' => $torrent_repository, + 'categories' => Category::all()->sortBy('position'), + 'types' => Type::all()->sortBy('position'), + 'user' => $user ]); + } + /** + * Store a newly created RSS resource in storage. + * + * @param \Illuminate\Http\Request $request + * + * @return \Illuminate\Http\Response + */ + public function store(Request $request) { - $catArray = $this->getUserData(); + $user = auth()->user(); + + $v = validator($request->all(), [ + 'name' => 'required|min:3|max:255', + 'search' => 'max:255', + 'description' => 'max:255', + 'uploader' => 'max:255', + 'categories' => "sometimes|array|max:999", + 'types' => 'sometimes|array|max:999', + 'genres' => 'sometimes|array|max:999', + 'position' => 'sometimes|integer|max:9999', + ]); - $torrents = Torrent::select('id', 'name', 'slug', 'size', 'seeders', 'leechers', 'info_hash', 'created_at') - ->whereIn('category', $catArray) - ->with('category') - ->latest() - ->take(25) - ->toArray(); + $params = $request->only(['name', 'search', 'description', 'uploader', 'imdb', 'tvdb', 'tmdb', 'mal', 'categories', + 'types', 'genres', 'freeleech' ,'doubleupload','featured','stream','highspeed','sd','internal','alive','dying','dead']); - return $torrents; + $error = null; + $success = null; + + if ($v->passes()) { + $rss = new Rss(); + $rss->name = $request->input('name'); + $rss->user_id = $user->id; + $expected = $rss->expected; + $rss->json_torrent = array_merge($expected,$params); + $rss->is_private = 1; + $rss->save(); + $success = "Private RSS Feed Created"; + } + if(!$success) { + $error = "Unable To Process Request"; + if ($v->errors()) { + $error = $v->errors(); + } + return redirect()->route('rss.create') + ->with($this->toastr->error($error, 'Uhoh!', ['options'])); + } + return redirect()->route('rss.index.hash', ['hash' => 'private']) + ->with($this->toastr->success($success, 'Congratulations!', ['options'])); } - public function getData($passkey) + /** + * Display the specified RSS resource. + * + * @param int $id + * @param string $rsskey + * @return \Illuminate\Http\Response + */ + public function show($id, $rsskey) { - if ($this->auth($passkey)) { - $torrents = $this->getTorrents(); + $user = User::where('rsskey', '=', (string) $rsskey)->firstOrFail(); + $rss = Rss::where('id', '=', (int) $id)->whereRaw('(user_id = ? OR is_private != ?)',[$user->id,1])->firstOrFail(); + + $bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first(); + $disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first(); - return view('rss.default', ['passkey' => $passkey, 'torrents' => $torrents])->header('Content-Type', 'text/xml'); + if ($user->group->id == $bannedGroup->id) { + abort(404); + } + if ($user->group->id == $disabledGroup->id) { + abort(404); + } + if ($user->active == 0) { + abort(404); } - return abort(404); - } + $torrent = new Torrent(); - public function download($passkey, $id) - { - if ($this->auth($passkey)) { + $search = $rss->object_torrent->search; + $description = $rss->object_torrent->description; + $uploader = $rss->object_torrent->uploader; + $imdb = $rss->object_torrent->imdb; + $tvdb = $rss->object_torrent->tvdb; + $tmdb = $rss->object_torrent->tmdb; + $mal = $rss->object_torrent->mal; + $categories = $rss->object_torrent->categories; + $types = $rss->object_torrent->types; + $genres = $rss->object_torrent->genres; + $freeleech = $rss->object_torrent->freeleech; + $doubleupload = $rss->object_torrent->doubleupload; + $featured = $rss->object_torrent->featured; + $stream = $rss->object_torrent->stream; + $highspeed = $rss->object_torrent->highspeed; + $sd = $rss->object_torrent->sd; + $internal = $rss->object_torrent->internal; + $alive = $rss->object_torrent->alive; + $dying = $rss->object_torrent->dying; + $dead = $rss->object_torrent->dead; + + $terms = explode(' ', $search); + $search = ''; + foreach ($terms as $term) { + $search .= '%'.$term.'%'; + } + + $usernames = explode(' ', $uploader); + $uploader = ''; + foreach ($usernames as $username) { + $uploader .= '%'.$username.'%'; + } + + $keywords = explode(' ', $description); + $description = ''; + foreach ($keywords as $keyword) { + $description .= '%'.$keyword.'%'; + } + + $torrent = $torrent->with(['user', 'category'])->withCount(['thanks', 'comments']); + + if ($rss->object_torrent->search) { + $torrent->where(function ($query) use ($search) { + $query->where('name', 'like', $search); + }); + } + + if ($rss->object_torrent->description) { + $torrent->where(function ($query) use ($description) { + $query->where('description', 'like', $description)->orWhere('mediainfo', 'like', $description); + }); + } + + if ($rss->object_torrent->uploader && $rss->object_torrent->uploader != null) { + $match = User::where('username', 'like', $uploader)->first(); + if (null === $match) { + return ['result' => [], 'count' => 0]; + } + $torrent->where('user_id', '=', $match->id)->where('anon', '=', 0); + } + + if ($rss->object_torrent->imdb && $rss->object_torrent->imdb != null) { + $torrent->where('imdb', '=', $imdb); + } + + if ($rss->object_torrent->tvdb && $rss->object_torrent->tvdb != null) { + $torrent->where('tvdb', '=', $tvdb); + } + + if ($rss->object_torrent->tmdb && $rss->object_torrent->tmdb != null) { + $torrent->where('tmdb', '=', $tmdb); } - return abort(404); + if ($rss->object_torrent->mal && $rss->object_torrent->mal != null) { + $torrent->where('mal', '=', $mal); + } + + if ($rss->object_torrent->categories && is_array($rss->object_torrent->categories)) { + $torrent->whereIn('category_id', $categories); + } + + if ($rss->object_torrent->types && is_array($rss->object_torrent->types)) { + $torrent->whereIn('type', $types); + } + + if ($rss->object_torrent->genres && is_array($rss->object_torrent->genres)) { + $genreID = TagTorrent::select('torrent_id')->whereIn('tag_name', $genres)->get(); + $torrent->whereIn('id', $genreID); + } + + if ($rss->object_torrent->freeleech && $rss->object_torrent->freeleech != null) { + $torrent->where('free', '=', $freeleech); + } + + if ($rss->object_torrent->doubleupload && $rss->object_torrent->doubleupload != null) { + $torrent->where('doubleup', '=', $doubleupload); + } + + if ($rss->object_torrent->featured && $rss->object_torrent->featured != null) { + $torrent->where('featured', '=', $featured); + } + + if ($rss->object_torrent->stream && $rss->object_torrent->stream != null) { + $torrent->where('stream', '=', $stream); + } + + if ($rss->object_torrent->highspeed && $rss->object_torrent->highspeed != null) { + $torrent->where('highspeed', '=', $highspeed); + } + + if ($rss->object_torrent->sd && $rss->object_torrent->sd != null) { + $torrent->where('sd', '=', $sd); + } + + if ($rss->object_torrent->internal && $rss->object_torrent->internal != null) { + $torrent->where('internal', '=', $internal); + } + + if ($rss->object_torrent->alive && $rss->object_torrent->alive != null) { + $torrent->where('seeders', '>=', $alive); + } + + if ($rss->object_torrent->dying && $rss->object_torrent->dying != null) { + $torrent->where('seeders', '=', $dying)->where('times_completed', '>=', 3); + } + + if ($rss->object_torrent->dead && $rss->object_torrent->dead != null) { + $torrent->where('seeders', '=', $dead); + } + + $torrents = $torrent->paginate(50); + + return view('rss.show', [ + 'torrents' => $torrents, + 'rsskey' => $user->rsskey ])->render(); } - public function setView() + /** + * Show the form for editing the specified RSS resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) { - redirect(); + $user = auth()->user(); + $rss = $user->rss()->where('is_private',1)->findOrFail($id); + $torrent_repository = $this->torrent_faceted; + + return view('rss.edit', [ + 'torrent_repository' => $torrent_repository, + 'categories' => Category::all()->sortBy('position'), + 'types' => Type::all()->sortBy('position'), + 'user' => $user, + 'rss' => $rss, + ]); } - public function getView() + /** + * Update the specified RSS resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) { $user = auth()->user(); + $rss = $user->rss()->where('is_private',1)->findOrFail($id); + + $v = validator($request->all(), [ + 'search' => 'max:255', + 'description' => 'max:255', + 'uploader' => 'max:255', + 'categories' => "sometimes|array|max:999", + 'types' => 'sometimes|array|max:999', + 'genres' => 'sometimes|array|max:999', + 'position' => 'sometimes|integer|max:9999', + ]); - $rssData = RSS::select('category')->where('user_id', '=', $user->id)->first(); + $params = $request->only(['search', 'description', 'uploader', 'imdb', 'tvdb', 'tmdb', 'mal', 'categories', + 'types', 'genres', 'freeleech' ,'doubleupload','featured','stream','highspeed','sd','internal','alive','dying','dead']); - $category = Category::select('id', 'name')->get(); + $error = null; + $success = null; + $redirect = null; + if ($v->passes()) { + $expected = $rss->expected; + $push = array_merge($expected,$params); + $rss->json_torrent = array_merge($rss->json_torrent,$push); + $rss->is_private = 1; + $rss->save(); + $success = "Private RSS Feed Updated"; + } + if(!$success) { + $error = "Unable To Process Request"; + if ($v->errors()) { + $error = $v->errors(); + } + return redirect()->route('rss.edit', ['id' => $id]) + ->with($this->toastr->error($error, 'Uhoh!', ['options'])); + } + return redirect()->route('rss.index.hash', ['hash' => 'private']) + ->with($this->toastr->success($success, 'Congratulations!', ['options'])); + } + + /** + * Remove the specified RSS resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $rss = auth()->user()->rss()->findOrFail($id); + if($rss->is_private) { + $rss->delete(); + return redirect()->route('rss.index.hash', ['hash' => 'private']) + ->with($this->toastr->success('RSS Feed Deleted!', 'Yay!', ['options'])); + } + return redirect()->route('rss.index') + ->with($this->toastr->error('You are not authorized to carry out this action', 'Uhoh!', ['options'])); } } From 88189094f72b51f9281b09d4b89980920e648a13 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:49:13 -0500 Subject: [PATCH 09/18] (Add) Staff RssController Add ability for staff to CRUD public rss controllers. HELP: Cleaner validation logic? max but of what. --- app/Http/Controllers/Staff/RssController.php | 227 +++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 app/Http/Controllers/Staff/RssController.php diff --git a/app/Http/Controllers/Staff/RssController.php b/app/Http/Controllers/Staff/RssController.php new file mode 100644 index 0000000000..d40aede1ef --- /dev/null +++ b/app/Http/Controllers/Staff/RssController.php @@ -0,0 +1,227 @@ +torrent_faceted = $torrent_faceted; + $this->toastr = $toastr; + } + + /** + * @param Toastr $toastr + */ + public function setToastr($toastr) + { + $this->toastr = $toastr; + } + + /** + * Display a listing of the RSS resource. + * + * @param string $hash + * @return \Illuminate\Http\Response + */ + public function index($hash = null) + { + $public_rss = Rss::public()->orderBy('position', 'ASC')->get(); + + return view('Staff.rss.index', [ + 'hash' => $hash, + 'public_rss' => $public_rss + ]); + } + + /** + * Show the form for creating a new RSS resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $user = auth()->user(); + $torrent_repository = $this->torrent_faceted; + + return view('Staff.rss.create', [ + 'torrent_repository' => $torrent_repository, + 'categories' => Category::all()->sortBy('position'), + 'types' => Type::all()->sortBy('position'), + 'user' => $user ]); + } + /** + * Store a newly created RSS resource in storage. + * + * @param \Illuminate\Http\Request $request + * + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $user = auth()->user(); + + $v = validator($request->all(), [ + 'name' => 'required|min:3|max:255', + 'search' => 'max:255', + 'description' => 'max:255', + 'uploader' => 'max:255', + 'categories' => "sometimes|array|max:999", + 'types' => 'sometimes|array|max:999', + 'genres' => 'sometimes|array|max:999', + 'position' => 'sometimes|integer|max:9999', + ]); + + $params = $request->only(['type', 'name', 'position', 'search', 'description', 'uploader', 'imdb', 'tvdb', 'tmdb', 'mal', 'categories', + 'types', 'genres', 'freeleech' ,'doubleupload','featured','stream','highspeed','sd','internal','alive','dying','dead']); + + $error = null; + $success = null; + + if ($v->passes()) { + $rss = new Rss(); + $rss->name = $request->input('name'); + $rss->user_id = $user->id; + $expected = $rss->expected; + $rss->json_torrent = array_merge($expected,$params); + $rss->is_private = 0; + $rss->staff_id = $user->id; + $rss->position = (int) $request->input('position'); + $rss->save(); + $success = "Public RSS Feed Created"; + } + if(!$success) { + $error = "Unable To Process Request"; + if ($v->errors()) { + $error = $v->errors(); + } + return redirect()->route('Staff.rss.create') + ->with($this->toastr->error($error, 'Uhoh!', ['options'])); + } + return redirect()->route('Staff.rss.index') + ->with($this->toastr->success($success, 'Congratulations!', ['options'])); + } + + /** + * Show the form for editing the specified RSS resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $user = auth()->user(); + $rss = $user->rss()->where('is_private',0)->findOrFail($id); + $torrent_repository = $this->torrent_faceted; + + return view('Staff.rss.edit', [ + 'torrent_repository' => $torrent_repository, + 'categories' => Category::all()->sortBy('position'), + 'types' => Type::all()->sortBy('position'), + 'user' => $user, + 'rss' => $rss, + ]); + } + + /** + * Update the specified RSS resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $user = auth()->user(); + $rss = $user->rss()->where('is_private',0)->findOrFail($id); + + $v = validator($request->all(), [ + 'name' => 'required|min:3|max:255', + 'search' => 'max:255', + 'description' => 'max:255', + 'uploader' => 'max:255', + 'categories' => "sometimes|array|max:999", + 'types' => 'sometimes|array|max:999', + 'genres' => 'sometimes|array|max:999', + 'position' => 'sometimes|integer|max:9999', + ]); + + $params = $request->only(['type', 'position', 'search', 'description', 'uploader', 'imdb', 'tvdb', 'tmdb', 'mal', 'categories', + 'types', 'genres', 'freeleech' ,'doubleupload','featured','stream','highspeed','sd','internal','alive','dying','dead']); + + $error = null; + $success = null; + $redirect = null; + + if ($v->passes()) { + $expected = $rss->expected; + $push = array_merge($expected,$params); + $rss->json_torrent = array_merge($rss->json_torrent,$push); + $rss->is_private = 0; + $rss->name = $request->input('name'); + $rss->position = (int) $request->input('position'); + $rss->save(); + $success = "Public RSS Feed Updated"; + } + if(!$success) { + $error = "Unable To Process Request"; + if ($v->errors()) { + $error = $v->errors(); + } + return redirect()->route('Staff.rss.edit', ['id' => $id]) + ->with($this->toastr->error($error, 'Uhoh!', ['options'])); + } + return redirect()->route('Staff.rss.index') + ->with($this->toastr->success($success, 'Congratulations!', ['options'])); + } + + /** + * Remove the specified RSS resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $rss = auth()->user()->rss()->where('is_private',0)->findOrFail($id); + $rss->delete(); + + return redirect()->route('Staff.rss.index') + ->with($this->toastr->success('RSS Feed Deleted!', 'Yay!', ['options'])); + } +} From 36c63819e14ec5619cb936fbf060c6f4afff790e Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:50:01 -0500 Subject: [PATCH 10/18] (Update) TorrentController Support downloading via rsskey (passed by RSS feed). --- app/Http/Controllers/TorrentController.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 3799100297..1f293d045f 100755 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -17,6 +17,7 @@ use App\Type; use App\User; use App\History; +use App\Rss; use App\Torrent; use App\Warning; use App\Category; @@ -61,7 +62,7 @@ class TorrentController extends Controller /** * RequestController Constructor. * - * @param RequestFacetedRepository $faceted + * @param TorrentFacetedRepository $faceted * @param ChatRepository $chat * @param Toastr $toastr */ @@ -166,11 +167,11 @@ public function groupingResults($category_id, $imdb) ->get(); return view('torrent.grouping_results', [ - 'user' => $user, + 'user' => $user, 'personal_freeleech' => $personal_freeleech, - 'torrents' => $torrents, - 'imdb' => $imdb, - 'category' => $category, + 'torrents' => $torrents, + 'imdb' => $imdb, + 'category' => $category, ]); } @@ -866,13 +867,19 @@ public function downloadCheck($slug, $id) * * @param $slug * @param $id + * @param $rsskey * * @return TorrentFile */ - public function download($slug, $id) + public function download($slug, $id, $rsskey = null) { - $torrent = Torrent::withAnyStatus()->findOrFail($id); + $user = auth()->user(); + if(!$user && $rsskey) { + $user = User::where('rsskey','=',$rsskey)->firstOrFail(); + } + + $torrent = Torrent::withAnyStatus()->findOrFail($id); // User's ratio is too low if ($user->getRatio() < config('other.ratio')) { From 0e323572b8b8187962ba6dbea26573242ee571c8 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:50:31 -0500 Subject: [PATCH 11/18] (Add) RSS Create View Self explanatory. --- resources/views/rss/create.blade.php | 163 +++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 resources/views/rss/create.blade.php diff --git a/resources/views/rss/create.blade.php b/resources/views/rss/create.blade.php new file mode 100644 index 0000000000..50607953cf --- /dev/null +++ b/resources/views/rss/create.blade.php @@ -0,0 +1,163 @@ +@extends('layout.default') + +@section('title') + @lang('rss.create-private-feed') - {{ config('other.title') }} +@endsection + +@section('breadcrumb') +
  • + +
  • +
  • + +
  • +@endsection + +@section('content') +
    +

    @lang('rss.create-private-feed')

    +
    + @csrf +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    + + + + + +
    + +
    + +
    + @foreach ($torrent_repository->categories() as $id => $category) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->types() as $id => $type) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->tags() as $id => $genre) + + + + @endforeach +
    +
    +
    + +
    + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +@endsection From 9713e92723859f196248e95b2800eb1ddd8d6a8c Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:50:56 -0500 Subject: [PATCH 12/18] (Add) RSS Edit View Self explanatory. --- resources/views/rss/edit.blade.php | 217 +++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 resources/views/rss/edit.blade.php diff --git a/resources/views/rss/edit.blade.php b/resources/views/rss/edit.blade.php new file mode 100644 index 0000000000..f27216ef7e --- /dev/null +++ b/resources/views/rss/edit.blade.php @@ -0,0 +1,217 @@ +@extends('layout.default') + +@section('title') + @lang('rss.edit-private-feed') - {{ config('other.title') }} +@endsection + +@section('breadcrumb') +
  • + +
  • +
  • + +
  • +@endsection + + +@section('content') +
    +

    @lang('rss.edit-private-feed')

    +
    + @csrf + @method('PUT') +
    +
    +
    + +
    {{ $rss->name }}
    +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    + + + + + + + + +
    + +
    + +
    + @foreach ($torrent_repository->categories() as $id => $category) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->types() as $id => $type) + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->tags() as $id => $genre) + + + @endforeach +
    +
    +
    + +
    + + + + + + + + + +
    +
    +
    + +
    + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +@endsection From 0121386f7c341fc277f653ecf32cace1a65f30d1 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:51:18 -0500 Subject: [PATCH 13/18] (Add) RSS Index View Self explanatory. --- resources/views/rss/index.blade.php | 151 ++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 resources/views/rss/index.blade.php diff --git a/resources/views/rss/index.blade.php b/resources/views/rss/index.blade.php new file mode 100644 index 0000000000..b80839a098 --- /dev/null +++ b/resources/views/rss/index.blade.php @@ -0,0 +1,151 @@ +@extends('layout.default') + +@section('breadcrumb') +
  • + +
  • +@endsection + +@section('content') +
    +
    +
    +
    +

    {{ trans('rss.rss') }} {{ trans('rss.feeds') }}

    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + @foreach($public_rss as $rss) + + + @if($rss->object_torrent) + + + + + + + @else + + + + + + + @endif + + @endforeach + +
    NameCategoriesTypesGenresDiscountsSpecialHealth
    {{ $rss->name }}@if ($rss->object_torrent->categories)@else@endif@if ($rss->object_torrent->types)@else@endif@if ($rss->object_torrent->genres)@else@endif@if ($rss->object_torrent->freeleech || $rss->object_torrent->doubleupload || $rss->object_torrent->featured)@else@endif@if ($rss->object_torrent->stream || $rss->object_torrent->highspeed || $rss->object_torrent->sd || $rss->object_torrent->internal)@else@endif@if ($rss->object_torrent->alive || $rss->object_torrent->dying || $rss->object_torrent->dead)@else@endif
    +
    +
    + + + + + + + + + + + + + + + @foreach($private_rss as $rss) + + + @if($rss->object_torrent) + + + + + + + @else + + + + + + + @endif + @if(auth()->user()->id == $rss->user_id) + + @endif + + @endforeach + +
    NameCategoriesTypesGenresDiscountsSpecialHealthAction
    {{ $rss->name }}@if ($rss->object_torrent->categories)@else@endif@if ($rss->object_torrent->types)@else@endif@if ($rss->object_torrent->genres)@else@endif@if ($rss->object_torrent->freeleech || $rss->object_torrent->doubleupload || $rss->object_torrent->featured)@else@endif@if ($rss->object_torrent->stream || $rss->object_torrent->highspeed || $rss->object_torrent->sd || $rss->object_torrent->internal)@else@endif@if ($rss->object_torrent->alive || $rss->object_torrent->dying || $rss->object_torrent->dead)@else@endif +
    + @csrf + @method('DELETE') + @lang('common.edit') + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +@endsection +@section('javascripts') + +@endsection \ No newline at end of file From c1c63e4d26bd8783da5aa2c8f18cb0aadfa5bfdf Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:51:42 -0500 Subject: [PATCH 14/18] (Add) RSS Show View The actual RSS feed. TODO: Let admins customize return output. --- resources/views/rss/show.blade.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 resources/views/rss/show.blade.php diff --git a/resources/views/rss/show.blade.php b/resources/views/rss/show.blade.php new file mode 100644 index 0000000000..81a25ffa14 --- /dev/null +++ b/resources/views/rss/show.blade.php @@ -0,0 +1,30 @@ +'; +?> + + + + + @if($torrents) + @foreach($torrents as $data) + + @if($data->isFreeleech()) + <![CDATA[{{ $data->name }} / {{ $data->getSize() }} / Free]]> + @else + <![CDATA[{{ $data->name }} / {{ $data->getSize() }}]]> + @endif + + {{ $data->created_at }} + {{ route('torrent.download.rsskey', ['slug' => $data->slug, 'id' => $data->id, 'rsskey' => $rsskey ]) }} + {{ route('torrent', ['slug' => $data->slug, 'id' => $data->id ]) }} + + @if(!$data->anon && $data->user) + {{ $data->user->username }} + @else + Anonymous + @endif + + @endforeach + @endif + + \ No newline at end of file From 574348ed35ee0187e37c782f9a3c5f94c74c70ab Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:52:11 -0500 Subject: [PATCH 15/18] (Add) Staff RSS Create View Self Explanatory. --- resources/views/Staff/rss/create.blade.php | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 resources/views/Staff/rss/create.blade.php diff --git a/resources/views/Staff/rss/create.blade.php b/resources/views/Staff/rss/create.blade.php new file mode 100644 index 0000000000..d599f6b6be --- /dev/null +++ b/resources/views/Staff/rss/create.blade.php @@ -0,0 +1,168 @@ +@extends('layout.default') + +@section('title') + @lang('rss.create-public-feed') - {{ config('other.title') }} +@endsection + +@section('breadcrumb') +
  • + +
  • +
  • + +
  • +
  • + +
  • +@endsection + +@section('content') +
    +

    @lang('rss.create-public-feed')

    +
    + @csrf +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    + + + + + +
    + +
    + +
    + @foreach ($torrent_repository->categories() as $id => $category) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->types() as $id => $type) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->tags() as $id => $genre) + + + + @endforeach +
    +
    +
    + +
    + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +@endsection From 2bab8dfd157f42b9794332f07239d9cd2e561a79 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:52:34 -0500 Subject: [PATCH 16/18] (Add) Staff RSS Edit View Self explanatory. --- resources/views/Staff/rss/edit.blade.php | 219 +++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 resources/views/Staff/rss/edit.blade.php diff --git a/resources/views/Staff/rss/edit.blade.php b/resources/views/Staff/rss/edit.blade.php new file mode 100644 index 0000000000..e86a0402f1 --- /dev/null +++ b/resources/views/Staff/rss/edit.blade.php @@ -0,0 +1,219 @@ +@extends('layout.default') + +@section('title') + @lang('rss.edit-public-feed') - {{ config('other.title') }} +@endsection + +@section('breadcrumb') +
  • + +
  • +
  • + +
  • +
  • + +
  • +@endsection + + +@section('content') +
    +

    @lang('rss.edit-public-feed')

    +
    + @csrf + @method('PUT') +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + +
    + + + + + +
    + +
    + +
    + @foreach ($torrent_repository->categories() as $id => $category) + + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->types() as $id => $type) + + + @endforeach +
    +
    +
    + +
    + @foreach ($torrent_repository->tags() as $id => $genre) + + + @endforeach +
    +
    +
    + +
    + + + + + + + + + +
    +
    +
    + +
    + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + + + + + + +
    +
    +
    +
    + +
    +
    +
    +@endsection From 9a40d537a6567e53cf8d82aea4f6fa1a02f225f1 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:53:09 -0500 Subject: [PATCH 17/18] (Add) Staff RSS Index View Self explanatory. --- resources/views/Staff/rss/index.blade.php | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 resources/views/Staff/rss/index.blade.php diff --git a/resources/views/Staff/rss/index.blade.php b/resources/views/Staff/rss/index.blade.php new file mode 100644 index 0000000000..dea880216c --- /dev/null +++ b/resources/views/Staff/rss/index.blade.php @@ -0,0 +1,96 @@ +@extends('layout.default') + +@section('breadcrumb') +
  • + +
  • +
  • + +
  • +@endsection + +@section('content') +
    +
    +

    Public RSS Feeds

    + Create RSS Feed + + +
    + + + + + @if(auth()->user() && auth()->user()->group->is_modo) + + @endif + + + + + + + + + + + @foreach($public_rss as $rss) + + + @if(auth()->user() && auth()->user()->group->is_modo) + + @endif + @if($rss->object_torrent) + + + + + + + @else + + + + + + + @endif + @if(auth()->user() && auth()->user()->id == $rss->user_id && auth()->user()->group->is_modo) + + @endif + + @endforeach + +
    NamePositionCategoriesTypesGenresDiscountsSpecialHealthAction
    {{ $rss->name }}{{ $rss->position }}@if ($rss->object_torrent->categories)@else@endif@if ($rss->object_torrent->types)@else@endif@if ($rss->object_torrent->genres)@else@endif@if ($rss->object_torrent->freeleech || $rss->object_torrent->doubleupload || $rss->object_torrent->featured)@else@endif@if ($rss->object_torrent->stream || $rss->object_torrent->highspeed || $rss->object_torrent->sd || $rss->object_torrent->internal)@else@endif@if ($rss->object_torrent->alive || $rss->object_torrent->dying || $rss->object_torrent->dead)@else@endif +
    + @csrf + @method('DELETE') + @lang('common.edit') + +
    +
    +
    + +
    +
    +@endsection +@section('javascripts') + +@endsection \ No newline at end of file From b0f24bd968360242f7fb1ba5484fa6821164fbd7 Mon Sep 17 00:00:00 2001 From: singularity43 <46550600+singularity43@users.noreply.github.com> Date: Sat, 12 Jan 2019 15:54:12 -0500 Subject: [PATCH 18/18] (Updated) Web Routes Add support for RSS CRUD/Staff RSS CRUD/RSS routes/Torrent download route update. --- routes/web.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/routes/web.php b/routes/web.php index 5a56e99015..2b989e97f5 100755 --- a/routes/web.php +++ b/routes/web.php @@ -56,9 +56,9 @@ // Announce Route::get('/announce/{passkey}', 'AnnounceController@announce')->name('announce'); - // RSS - //Route::get('/torrents/rss/{passkey}', 'RssController@getData')->name('rss'); - //Route::get('/rss/{passkey}/download/{id}','RssController@download')->name('rssDownload'); + // RSS Custom Routes (RSS Key Auth) + Route::get('/rss/{id}.{rsskey}', 'RssController@show')->name('rss.show.rsskey'); + Route::get('/torrent/download/{slug}.{id}.{rsskey}','TorrentController@download')->name('torrent.download.rsskey'); }); /* @@ -68,6 +68,14 @@ */ Route::group(['middleware' => ['auth', 'twostep', 'online', 'banned', 'active', 'private']], function () { + // RSS Custom Routes + Route::get('/rss#{hash?}', 'RssController@index')->name('rss.index.hash'); + + // RSS CRUD + Route::resource('rss', 'RssController')->except([ + 'show' + ]); + // Two Step Auth Route::get('/twostep/needed', 'Auth\TwoStepController@showVerification')->name('verificationNeeded'); Route::post('/twostep/verify', 'Auth\TwoStepController@verify')->name('verify'); @@ -191,6 +199,7 @@ Route::get('/request/{id}/unclaim', 'RequestController@unclaimRequest')->name('unclaimRequest'); // Torrent + Route::get('/feedizeTorrents/{type}', 'TorrentController@feedize')->name('feedizeTorrents')->middleware('modo'); Route::get('/filterTorrents', 'TorrentController@faceted'); Route::get('/torrents', 'TorrentController@torrents')->name('torrents'); Route::get('/torrents/{slug}.{id}', 'TorrentController@torrent')->name('torrent'); @@ -381,6 +390,18 @@ */ Route::group(['prefix' => 'staff_dashboard', 'middleware' => ['auth', 'twostep', 'modo', 'online', 'banned', 'active', 'private'], 'namespace' => 'Staff'], function () { + // RSS CRUD + Route::resource('rss', 'RssController')->except([ + 'show' + ])->names([ + 'create' => 'Staff.rss.create', + 'index' => 'Staff.rss.index', + 'edit' => 'Staff.rss.edit', + 'update' => 'Staff.rss.update', + 'store' => 'Staff.rss.store', + 'destroy' => 'Staff.rss.destroy', + ]); + // Staff Dashboard Route::get('/', 'HomeController@home')->name('staff_dashboard');