From 86d7002ac325f4081e37fb1d69c652319690067f Mon Sep 17 00:00:00 2001 From: Hyleus Date: Sat, 6 Jan 2018 09:49:38 +0100 Subject: [PATCH 1/5] Refactor JS for getting the torrent name into function updateTorrentName --- resources/views/torrent/upload.blade.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/views/torrent/upload.blade.php b/resources/views/torrent/upload.blade.php index fb8969462d..94280a0508 100755 --- a/resources/views/torrent/upload.blade.php +++ b/resources/views/torrent/upload.blade.php @@ -22,6 +22,16 @@ @stop @section('content') + @if($user->can_upload == 0)
@@ -56,7 +66,7 @@ {{ Form::open(['route' => 'upload', 'files' => true, 'class' => 'upload-form']) }}
- +
From 2b310182bad933f4c556b83c640e0c0299b1f0f5 Mon Sep 17 00:00:00 2001 From: Hyleus Date: Sat, 6 Jan 2018 10:08:28 +0100 Subject: [PATCH 2/5] Remove file-endings from torrent name --- resources/views/torrent/upload.blade.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/views/torrent/upload.blade.php b/resources/views/torrent/upload.blade.php index 94280a0508..0f57d7450a 100755 --- a/resources/views/torrent/upload.blade.php +++ b/resources/views/torrent/upload.blade.php @@ -26,8 +26,14 @@ function updateTorrentName() { let name = document.querySelector("#name"); let torrent = document.querySelector("#torrent"); + let fileEndings = [".mkv.torrent", ".torrent"]; if (name !== null && torrent !== null) { let value = torrent.value.split('\\').pop().split('/').pop(); + fileEndings.forEach(function(e) { + if (value.endsWith(e)) { + value = value.substr(0, value.length - e.length); + } + }); name.value = value; } } From 52970573f34f80a7828f3bef4290d32f7af23739 Mon Sep 17 00:00:00 2001 From: Hyleus Date: Sat, 6 Jan 2018 10:12:06 +0100 Subject: [PATCH 3/5] Remove unnecessary dots from torrent filename --- resources/views/torrent/upload.blade.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/views/torrent/upload.blade.php b/resources/views/torrent/upload.blade.php index 0f57d7450a..87587f5208 100755 --- a/resources/views/torrent/upload.blade.php +++ b/resources/views/torrent/upload.blade.php @@ -27,6 +27,7 @@ function updateTorrentName() { let name = document.querySelector("#name"); let torrent = document.querySelector("#torrent"); let fileEndings = [".mkv.torrent", ".torrent"]; + let allowed = ["2.0", "5.1", "7.1"]; if (name !== null && torrent !== null) { let value = torrent.value.split('\\').pop().split('/').pop(); fileEndings.forEach(function(e) { @@ -34,6 +35,11 @@ function updateTorrentName() { value = value.substr(0, value.length - e.length); } }); + value = value.replace(/\./g, " "); + allowed.forEach(function(a) { + search = a.replace(/\./g, " "); + value = value.replace(search, a); + }) name.value = value; } } From b49f7d62eed08034be20372a7c480e99817a0627 Mon Sep 17 00:00:00 2001 From: Hyleus Date: Sat, 6 Jan 2018 10:17:31 +0100 Subject: [PATCH 4/5] Remove dots replacement on the server side and handle it on the client side --- app/Http/Controllers/TorrentController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 7ef1a3f5b6..866d76fc41 100755 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -216,9 +216,10 @@ public function upload() // Find the right category $category = Category::findOrFail(Request::get('category_id')); // Create the torrent (DB) + $name = Request::get('name'); $torrent = new Torrent([ - 'name' => str_replace(".", " ", Request::get('name')), - 'slug' => str_slug(str_replace(".", " ", Request::get('name'))), + 'name' => $name, + 'slug' => str_slug($name), 'description' => Request::get('description'), 'mediainfo' => Request::get('mediainfo'), 'info_hash' => $info['info_hash'], From d948487f752f3e31e7f94f6b5af587ff27d74f19 Mon Sep 17 00:00:00 2001 From: Hyleus Date: Sat, 6 Jan 2018 10:39:49 +0100 Subject: [PATCH 5/5] Make 1.0 exempt from dot replacement --- resources/views/torrent/upload.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/torrent/upload.blade.php b/resources/views/torrent/upload.blade.php index 87587f5208..a55ce83214 100755 --- a/resources/views/torrent/upload.blade.php +++ b/resources/views/torrent/upload.blade.php @@ -27,7 +27,7 @@ function updateTorrentName() { let name = document.querySelector("#name"); let torrent = document.querySelector("#torrent"); let fileEndings = [".mkv.torrent", ".torrent"]; - let allowed = ["2.0", "5.1", "7.1"]; + let allowed = ["1.0", "2.0", "5.1", "7.1"]; if (name !== null && torrent !== null) { let value = torrent.value.split('\\').pop().split('/').pop(); fileEndings.forEach(function(e) {