mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-29 23:09:42 -05:00
Merge branch 'master' into InternetGameDatabase
This commit is contained in:
@@ -55,6 +55,15 @@
|
||||
"contributions": [
|
||||
"design"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "pbodq2",
|
||||
"name": "Morgan Wong",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/25418300?v=4",
|
||||
"profile": "https://github.com/pbodq2",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7
|
||||
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
##########################################################
|
||||
#### WhiteSource "Bolt for Github" configuration file ####
|
||||
##########################################################
|
||||
|
||||
# Configuration #
|
||||
#---------------#
|
||||
ws.repo.scan=true
|
||||
vulnerable.check.run.conclusion.level=failure
|
||||
{
|
||||
"generalSettings": {
|
||||
"shouldScanRepo": true
|
||||
},
|
||||
"checkRunSettings": {
|
||||
"vulnerableCheckRunConclusionLevel": "failure"
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -2,7 +2,9 @@
|
||||
|
||||
Contributions are **welcome**.
|
||||
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/UNIT3D/UNIT3D).
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/HDInnovations/UNIT3D).
|
||||
|
||||
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)\
|
||||
|
||||
|
||||
## Pull Requests / Commits
|
||||
@@ -13,12 +15,11 @@ Please use the following title schema.
|
||||
- (PREFIX) Title
|
||||
|
||||
Examples:
|
||||
- (Update) French Translations
|
||||
- (Fix) French Translations
|
||||
- (Security Fix) French Translations
|
||||
- (Remove) French Translations
|
||||
- (Add) French Translations
|
||||
- (Optimize) French Translations
|
||||
- (Update) French Translations :rocket:
|
||||
- (Fix) French Translations :bug:
|
||||
- (Security Fix) French Translations :closed_lock_with_key:
|
||||
- (Remove) French Translations :recycle:
|
||||
- (Add) French Translations :new:
|
||||
|
||||
**[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)**
|
||||
- Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``.
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: HDVinnie
|
||||
patreon: UNIT3D
|
||||
@@ -7,11 +7,14 @@
|
||||
<hr>
|
||||
|
||||
<p align="center">
|
||||
<a href="http://laravel.com"><img src="https://img.shields.io/badge/Laravel-5.8.3-f4645f.svg" /></a> <a href="https://github.com/UNIT3D/UNIT3D/blob/master/LICENSE"><img src="https://img.shields.io/aur/license/yaourt.svg" /></a>
|
||||
<a href="http://laravel.com"><img src="https://img.shields.io/badge/Laravel-5.8.16-f4645f.svg?style=flat-square" /></a>
|
||||
<a href="https://github.com/HDInnovations/UNIT3D/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-AGPL%20v3.0-yellow.svg?style=flat-square" /></a>
|
||||
<a href="https://github.styleci.io/repos/113471037"><img src="https://github.styleci.io/repos/113471037/shield?branch=master" alt="StyleCI"></a>
|
||||
<a class="badge-align" href="https://www.codacy.com/app/HDVinnie/UNIT3D?utm_source=github.com&utm_medium=referral&utm_content=UNIT3D/UNIT3D&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/6c6c6c940aec420e987ea82adea272ee"/></a>
|
||||
<a href="https://discord.gg/Yk4NBUU"><img alt="Discord chat" src="https://img.shields.io/badge/discord-Chat%20Now-a29bfe.svg" /></a>
|
||||
<a href="https://www.patreon.com/UNIT3D"><img src="https://img.shields.io/badge/patreon-Support%20UNIT3D-orange.svg"></a>
|
||||
<a href="https://discord.gg/ntnPxzG"><img alt="Discord chat" src="https://img.shields.io/badge/discord-Chat%20Now-a29bfe.svg?style=flat-square" /></a>
|
||||
<a href="https://www.patreon.com/UNIT3D"><img src="https://img.shields.io/badge/patreon-Support%20UNIT3D-orange.svg?style=flat-square"></a>
|
||||
<a href="https://observatory.mozilla.org/analyze/unit3d.org"><img src="https://img.shields.io/badge/A+-Mozilla%20Observatory-blueviolet.svg?style=flat-square"></a>
|
||||
<a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square"></a>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -38,7 +41,7 @@
|
||||
|
||||
## <a name="introduction"></a> :page_facing_up: Introduction
|
||||
|
||||
I have been developing a Nex-Gen Torrent Tracker Software called "UNIT3D." This is a PHP software based off the lovely Laravel Framework -- currently Laravel Framework 5.8.3, MySQL Strict Mode Compliant and PHP 7.1 Ready. The code is well-designed and follows the PSR-2 coding style. It uses a MVC Architecture to ensure clarity between logic and presentation. As a hashing algorithm of Bcrypt or Argon2 is used, to ensure a safe and proper way to store the passwords for the users. A lightweight Blade Templating Engine. Caching System Supporting: "apc,” "array,” "database,” "file," "memcached," and "redis" methods. Eloquent and much more!
|
||||
I have been developing a Nex-Gen Torrent Tracker Software called "UNIT3D." This is a PHP software based off the lovely Laravel Framework -- currently Laravel Framework 5.8.16, MySQL Strict Mode Compliant and PHP 7.1 Ready. The code is well-designed and follows the PSR-2 coding style. It uses a MVC Architecture to ensure clarity between logic and presentation. As a hashing algorithm of Bcrypt or Argon2 is used, to ensure a safe and proper way to store the passwords for the users. A lightweight Blade Templating Engine. Caching System Supporting: "apc,” "array,” "database,” "file," "memcached," and "redis" methods. Eloquent and much more!
|
||||
|
||||
## <a name="features"></a> 💎 Some Features
|
||||
|
||||
@@ -109,10 +112,11 @@ Video Tutorial Can Be Seen Here:
|
||||
https://www.youtube.com/watch?v=f2tiMWZ3KbA
|
||||
|
||||
### <a name="manual-install"></a> Manual Install
|
||||
If you rather setup UNIT3D manually you can follow the instructions here: https://github.com/HDInnovations/UNIT3D/wiki/Manual-Install
|
||||
If you rather setup UNIT3D manually you can follow the instructions here: http://docs.unit3d.org/manual_install.html
|
||||
|
||||
## <a name="updating"></a> :book: Documentation
|
||||
WIP - https://github.com/HDInnovations/UNIT3D-Docs
|
||||
Repo - https://github.com/HDInnovations/UNIT3D-Docs
|
||||
Site - http://docs.unit3d.org
|
||||
|
||||
## <a name="docs"></a> :computer: Updating
|
||||
`php artisan git:update`
|
||||
@@ -127,20 +131,11 @@ Here are some packages that are built for UNIT3D.
|
||||
- [An artisan package to import a U-232 database into UNIT3D](https://github.com/HDInnovations/u232-to-unit3d).
|
||||
|
||||
## <a name="versions"></a> 🚨 Version Support Information
|
||||
Version | Status | PHP Version
|
||||
:----------|:-------------------------|:------------
|
||||
1.9.1 | Active support :rocket: | >= 7.1.3
|
||||
1.9 | Active support :rocket: | >= 7.1.3
|
||||
1.8.9 | End of life | >= 7.1.3
|
||||
1.8.8 | End of life | >= 7.1.3
|
||||
1.8.7 | End of life | >= 7.1.3
|
||||
1.8.6 | End of life | >= 7.1.3
|
||||
1.8.5 | End of life | >= 7.1.3
|
||||
1.8 | End of life | >= 7.1.3
|
||||
1.7 | End of life | >= 7.1.3
|
||||
1.6.x | End of life | >= 7.0.13
|
||||
1.5.x | End of life | >= 7.0.13
|
||||
1.0 | End of life | >= 7.0.13
|
||||
Version | Status | PHP Version Required
|
||||
:------------|:-------------------------|:------------
|
||||
1.9.3 | Active Support :rocket: | >= 7.3
|
||||
1.9.2 | Active Support :rocket: | >= 7.2
|
||||
1.0 to 1.9.1| End Of Life :skull: | >= 7.1.3
|
||||
|
||||
## <a name="security"></a> :lock: Security
|
||||
|
||||
@@ -156,10 +151,6 @@ UNIT3D is open-sourced software licensed under the [GNU General Public License v
|
||||
|
||||
<b> As per license do not remove the license from sourcecode or from footer in `/resources/views/partials/footer.blade.php`</b>
|
||||
|
||||
## <a name="homestead"></a> :computer: Homestead (for local developement)
|
||||
|
||||
For instructions on how to use Homestead for running UNIT3D in a local development environment check here: https://github.com/HDInnovations/UNIT3D/wiki/Homestead
|
||||
|
||||
## <a name="demo"></a> :computer: Demo
|
||||
|
||||
URL: https://unit3d.org
|
||||
@@ -191,10 +182,11 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/all-contri
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||
<!-- prettier-ignore -->
|
||||
| [<img src="https://avatars2.githubusercontent.com/u/12850699?v=4" width="100px;" alt="HDVinnie"/><br /><sub><b>HDVinnie</b></sub>](https://github.com/HDVinnie)<br />[💻](https://github.com/HDInnovations/UNIT3D/commits?author=HDVinnie "Code") [🎨](#design-HDVinnie "Design") [📖](https://github.com/HDInnovations/UNIT3D/commits?author=HDVinnie "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/7263458?v=4" width="100px;" alt="Everett (Mike) Wiley"/><br /><sub><b>Everett (Mike) Wiley</b></sub>](https://github.com/poppabear8883)<br />[💻](https://github.com/HDInnovations/UNIT3D/commits?author=poppabear8883 "Code") | [<img src="https://avatars1.githubusercontent.com/u/46550600?v=4" width="100px;" alt="singularity43"/><br /><sub><b>singularity43</b></sub>](https://github.com/singularity43)<br />[💻](https://github.com/HDInnovations/UNIT3D/commits?author=singularity43 "Code") | [<img src="https://avatars1.githubusercontent.com/u/24521644?v=4" width="100px;" alt="VerioPL"/><br /><sub><b>VerioPL</b></sub>](https://github.com/VerioPL)<br />[🌍](https://github.com/HDInnovations/UNIT3D/commits?author=VerioPL "Translation") | [<img src="https://avatars0.githubusercontent.com/u/17199757?v=4" width="100px;" alt="artyuum"/><br /><sub><b>Artyuum</b></sub>](https://github.com/artyuum)<br />[🎨](https://github.com/HDInnovations/UNIT3D/commits?author=artyuum "Design") |
|
||||
| :---: | :---: | :---: | :---: | :---: |
|
||||
<table><tr><td align="center"><a href="https://github.com/HDVinnie"><img src="https://avatars2.githubusercontent.com/u/12850699?v=4" width="100px;" alt="HDVinnie"/><br /><sub><b>HDVinnie</b></sub></a><br /><a href="https://github.com/HDInnovations/UNIT3D/commits?author=HDVinnie" title="Code">💻</a> <a href="#design-HDVinnie" title="Design">🎨</a> <a href="https://github.com/HDInnovations/UNIT3D/commits?author=HDVinnie" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/poppabear8883"><img src="https://avatars1.githubusercontent.com/u/7263458?v=4" width="100px;" alt="Everett (Mike) Wiley"/><br /><sub><b>Everett (Mike) Wiley</b></sub></a><br /><a href="https://github.com/HDInnovations/UNIT3D/commits?author=poppabear8883" title="Code">💻</a></td><td align="center"><a href="https://github.com/singularity43"><img src="https://avatars1.githubusercontent.com/u/46550600?v=4" width="100px;" alt="singularity43"/><br /><sub><b>singularity43</b></sub></a><br /><a href="https://github.com/HDInnovations/UNIT3D/commits?author=singularity43" title="Code">💻</a></td><td align="center"><a href="https://github.com/VerioPL"><img src="https://avatars1.githubusercontent.com/u/24521644?v=4" width="100px;" alt="VerioPL"/><br /><sub><b>VerioPL</b></sub></a><br /><a href="#translation-VerioPL" title="Translation">🌍</a></td><td align="center"><a href="https://github.com/artyuum"><img src="https://avatars0.githubusercontent.com/u/17199757?v=4" width="100px;" alt="Artyum"/><br /><sub><b>Artyuum</b></sub></a><br /><a href="#design-artyuum" title="Design">🎨</a></td><td align="center"><a href="https://github.com/pbodq2"><img src="https://avatars0.githubusercontent.com/u/25418300?v=4" width="100px;" alt="Morgan Wong"/><br /><sub><b>Morgan Wong</b></sub></a><br /><a href="#translation-pbodq2" title="Translation">🌍</a></td></tr></table>
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
## <a name="thanks"></a> :heart: Special Thanks
|
||||
|
||||
<a href="https://www.jetbrains.com/store/?fromMenu#edition=personal"><img src="https://i.imgur.com/KgDXZV8.png"></a>
|
||||
<a href="https://www.themoviedb.org/"><img src="https://www.themoviedb.org/assets/2/v4/logos/208x226-stacked-green-9484383bd9853615c113f020def5cbe27f6d08a84ff834f41371f223ebad4a3c.png"></a>
|
||||
|
||||
+24
-5
@@ -26,19 +26,26 @@ use App\Http\Resources\UserAudibleResource;
|
||||
class CasinoBot
|
||||
{
|
||||
private $bot;
|
||||
|
||||
private $chat;
|
||||
|
||||
private $target;
|
||||
|
||||
private $type;
|
||||
|
||||
private $message;
|
||||
|
||||
private $targeted;
|
||||
|
||||
private $log;
|
||||
|
||||
private $expiresAt;
|
||||
|
||||
private $current;
|
||||
|
||||
/**
|
||||
* NerdBot Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
* @param ChatRepository $chat
|
||||
*/
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
@@ -51,6 +58,8 @@ class CasinoBot
|
||||
|
||||
/**
|
||||
* Replace Vars.
|
||||
* @param $output
|
||||
* @return mixed
|
||||
*/
|
||||
public function replaceVars($output)
|
||||
{
|
||||
@@ -70,6 +79,9 @@ class CasinoBot
|
||||
|
||||
/**
|
||||
* Send Bot Donation.
|
||||
* @param int $amount
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
public function putDonate($amount = 0, $note = '')
|
||||
{
|
||||
@@ -107,6 +119,8 @@ class CasinoBot
|
||||
|
||||
/**
|
||||
* Get Bot Donations.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getDonations($duration = 'default')
|
||||
{
|
||||
@@ -135,6 +149,11 @@ class CasinoBot
|
||||
|
||||
/**
|
||||
* Process Message.
|
||||
* @param $type
|
||||
* @param User $target
|
||||
* @param string $message
|
||||
* @param int $targeted
|
||||
* @return bool
|
||||
*/
|
||||
public function process($type, User $target, $message = '', $targeted = 0)
|
||||
{
|
||||
@@ -257,21 +276,21 @@ class CasinoBot
|
||||
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'echo') {
|
||||
if ($txt != '') {
|
||||
$room_id = 0;
|
||||
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'public') {
|
||||
if ($txt != '') {
|
||||
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
|
||||
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -16,8 +16,11 @@ namespace App\Bots;
|
||||
class IRCAnnounceBot
|
||||
{
|
||||
protected $socket = null;
|
||||
|
||||
private $channels = [];
|
||||
|
||||
private $username = null;
|
||||
|
||||
private $registered = false;
|
||||
|
||||
public function __construct()
|
||||
|
||||
+48
-5
@@ -30,19 +30,26 @@ use App\Http\Resources\UserAudibleResource;
|
||||
class NerdBot
|
||||
{
|
||||
private $bot;
|
||||
|
||||
private $chat;
|
||||
|
||||
private $target;
|
||||
|
||||
private $type;
|
||||
|
||||
private $message;
|
||||
|
||||
private $targeted;
|
||||
|
||||
private $log;
|
||||
|
||||
private $expiresAt;
|
||||
|
||||
private $current;
|
||||
|
||||
/**
|
||||
* NerdBot Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
* @param ChatRepository $chat
|
||||
*/
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
@@ -55,6 +62,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Replace Vars.
|
||||
* @param $output
|
||||
* @return mixed
|
||||
*/
|
||||
public function replaceVars($output)
|
||||
{
|
||||
@@ -74,6 +83,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Banker.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getBanker($duration = 'default')
|
||||
{
|
||||
@@ -88,6 +99,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Snatched.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getSnatched($duration = 'default')
|
||||
{
|
||||
@@ -102,6 +115,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Leeched.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getLeeched($duration = 'default')
|
||||
{
|
||||
@@ -116,6 +131,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Seeded.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getSeeded($duration = 'default')
|
||||
{
|
||||
@@ -130,6 +147,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get FL.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getFreeleech($duration = 'default')
|
||||
{
|
||||
@@ -144,6 +163,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get DU.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getDoubleUpload($duration = 'default')
|
||||
{
|
||||
@@ -158,6 +179,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Peers.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getPeers($duration = 'default')
|
||||
{
|
||||
@@ -172,6 +195,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Bans.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getBans($duration = 'default')
|
||||
{
|
||||
@@ -186,6 +211,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Warnings.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getWarnings($duration = 'default')
|
||||
{
|
||||
@@ -200,6 +227,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Uploads.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getUploads($duration = 'default')
|
||||
{
|
||||
@@ -214,6 +243,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Logins.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getLogins($duration = 'default')
|
||||
{
|
||||
@@ -228,6 +259,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Registrations.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getRegistrations($duration = 'default')
|
||||
{
|
||||
@@ -242,6 +275,8 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Get Bot Donations.
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
public function getDonations($duration = 'default')
|
||||
{
|
||||
@@ -278,6 +313,9 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Send Bot Donation.
|
||||
* @param int $amount
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
public function putDonate($amount = 0, $note = '')
|
||||
{
|
||||
@@ -315,6 +353,11 @@ class NerdBot
|
||||
|
||||
/**
|
||||
* Process Message.
|
||||
* @param $type
|
||||
* @param User $target
|
||||
* @param string $message
|
||||
* @param int $targeted
|
||||
* @return bool
|
||||
*/
|
||||
public function process($type, User $target, $message = '', $targeted = 0)
|
||||
{
|
||||
@@ -479,21 +522,21 @@ class NerdBot
|
||||
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'echo') {
|
||||
if ($txt != '') {
|
||||
$room_id = 0;
|
||||
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'public') {
|
||||
if ($txt != '') {
|
||||
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
|
||||
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
+21
-5
@@ -27,17 +27,22 @@ use App\Http\Resources\UserAudibleResource;
|
||||
class SystemBot
|
||||
{
|
||||
private $bot;
|
||||
|
||||
private $chat;
|
||||
|
||||
private $target;
|
||||
|
||||
private $type;
|
||||
|
||||
private $message;
|
||||
|
||||
private $targeted;
|
||||
|
||||
private $log;
|
||||
|
||||
/**
|
||||
* SystemBot Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
* @param ChatRepository $chat
|
||||
*/
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
@@ -48,6 +53,8 @@ class SystemBot
|
||||
|
||||
/**
|
||||
* Replace Vars.
|
||||
* @param $output
|
||||
* @return mixed
|
||||
*/
|
||||
public function replaceVars($output)
|
||||
{
|
||||
@@ -75,6 +82,10 @@ class SystemBot
|
||||
|
||||
/**
|
||||
* Send Gift.
|
||||
* @param string $receiver
|
||||
* @param int $amount
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
public function putGift($receiver = '', $amount = 0, $note = '')
|
||||
{
|
||||
@@ -129,6 +140,11 @@ class SystemBot
|
||||
|
||||
/**
|
||||
* Process Message.
|
||||
* @param $type
|
||||
* @param User $target
|
||||
* @param string $message
|
||||
* @param int $targeted
|
||||
* @return bool
|
||||
*/
|
||||
public function process($type, User $target, $message = '', $targeted = 0)
|
||||
{
|
||||
@@ -240,21 +256,21 @@ class SystemBot
|
||||
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'echo') {
|
||||
if ($txt != '') {
|
||||
$room_id = 0;
|
||||
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
} elseif ($type == 'public') {
|
||||
if ($txt != '') {
|
||||
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
|
||||
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -44,7 +44,7 @@ class AutoBan extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.max_warnings'))->get();
|
||||
|
||||
foreach ($bans as $ban) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Peer;
|
||||
use App\Models\User;
|
||||
use App\Models\BonTransactions;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -43,7 +43,7 @@ class AutoDisableInactiveUsers extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('pruning.user_pruning') == true) {
|
||||
$disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$current = Carbon::now();
|
||||
|
||||
$matches = User::whereIn('group_id', [config('pruning.group_ids')]);
|
||||
|
||||
@@ -64,14 +64,14 @@ class AutoGraveyard extends Command
|
||||
|
||||
$torrent = Torrent::where('id', '=', $reward->torrent_id)->first();
|
||||
|
||||
if ($user && $torrent) {
|
||||
if (isset($user) && isset($torrent)) {
|
||||
$history = History::where('info_hash', '=', $torrent->info_hash)
|
||||
->where('user_id', '=', $user->id)
|
||||
->where('seedtime', '>=', $reward->seedtime)
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($history) {
|
||||
if (isset($history)) {
|
||||
$reward->rewarded = 1;
|
||||
$reward->save();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class AutoGroup extends Command
|
||||
{
|
||||
// Temp Hard Coding of Immune Groups (Config Files To Come)
|
||||
$current = Carbon::now();
|
||||
$groups = Group::select('id')->where('autogroup', '=', 1)->get()->toArray();
|
||||
$groups = Group::select(['id'])->where('autogroup', '=', 1)->get()->toArray();
|
||||
$users = User::whereIn('group_id', $groups)->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
@@ -52,56 +52,55 @@ class AutoGroup extends Command
|
||||
|
||||
// Temp Hard Coding of Group Requirements (Config Files To Come) (Upload in Bytes!) (Seedtime in Seconds!)
|
||||
|
||||
//Leech ratio dropped below sites minimum
|
||||
if ($user->getRatio() <= config('other.ratio') && $user->group_id != 15) {
|
||||
// Leech ratio dropped below sites minimum
|
||||
if ($user->getRatio() < config('other.ratio') && $user->group_id != 15) {
|
||||
$user->group_id = 15;
|
||||
$user->can_request = 0;
|
||||
$user->can_invite = 0;
|
||||
$user->can_download = 0;
|
||||
$user->save();
|
||||
}
|
||||
//User >= 0 but < 1TB and ratio above sites minimum
|
||||
// User >= 0 and ratio above sites minimum
|
||||
if ($user->uploaded >= 0 && $user->getRatio() >= config('other.ratio') && $user->group_id != 3) {
|
||||
$user->group_id = 3;
|
||||
$user->can_download = 1;
|
||||
$user->can_request = 1;
|
||||
$user->can_invite = 1;
|
||||
$user->can_download = 1;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
//PowerUser >= 1TB but < 5TB and account 1 month old
|
||||
if ($user->uploaded >= 1073741824000 && $user->uploaded < 1073741824000 * 5 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 11) {
|
||||
// PowerUser >= 1TB and account 1 month old
|
||||
if ($user->uploaded >= 1073741824000 && $user->getRatio() >= config('other.ratio') && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 11) {
|
||||
$user->group_id = 11;
|
||||
$user->save();
|
||||
}
|
||||
//SuperUser >= 5TB but < 20TB and account 1 month old
|
||||
if ($user->uploaded >= 1073741824000 * 5 && $user->uploaded < 1073741824000 * 20 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 12) {
|
||||
// SuperUser >= 5TB and account 2 month old
|
||||
if ($user->uploaded >= 1073741824000 * 5 && $user->getRatio() >= config('other.ratio') && $user->created_at < $current->copy()->subDays(60)->toDateTimeString() && $user->group_id != 12) {
|
||||
$user->group_id = 12;
|
||||
$user->save();
|
||||
}
|
||||
//ExtremeUser >= 20TB but < 50TB and account 3 month old
|
||||
if ($user->uploaded >= 1073741824000 * 20 && $user->uploaded < 1073741824000 * 50 && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 13) {
|
||||
// ExtremeUser >= 20TB and account 3 month old
|
||||
if ($user->uploaded >= 1073741824000 * 20 && $user->getRatio() >= config('other.ratio') && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 13) {
|
||||
$user->group_id = 13;
|
||||
$user->save();
|
||||
}
|
||||
//InsaneUser >= 50TB but < 100TB and account 6 month old
|
||||
if ($user->uploaded >= 1073741824000 * 50 && $user->uploaded < 1073741824000 * 100 && $user->created_at < $current->copy()->subDays(180)->toDateTimeString() && $user->group_id != 14) {
|
||||
// InsaneUser >= 50TB and account 6 month old
|
||||
if ($user->uploaded >= 1073741824000 * 50 && $user->getRatio() >= config('other.ratio') && $user->created_at < $current->copy()->subDays(180)->toDateTimeString() && $user->group_id != 14) {
|
||||
$user->group_id = 14;
|
||||
$user->save();
|
||||
}
|
||||
//Veteran >= 100TB and account 1 year old
|
||||
if ($user->uploaded >= 1073741824000 * 100 && $user->created_at < $current->copy()->subDays(365)->toDateTimeString() && $user->group_id != 16) {
|
||||
$user->group_id = 16;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
//Seeder seeding >= 150 and account 1 month old and seedtime average 30 days or better
|
||||
if ($user->getSeeding() >= 150 && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 17) {
|
||||
// Seeder Seedsize >= 5TB and account 1 month old and seedtime average 30 days or better
|
||||
if ($user->getTotalSeedSize() >= 1073741824000 * 5 && $user->getRatio() >= config('other.ratio') && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 && $user->created_at < $current->copy()->subDays(30)->toDateTimeString() && $user->group_id != 17) {
|
||||
$user->group_id = 17;
|
||||
$user->save();
|
||||
}
|
||||
//Archivist seeding >= 300 and account 3 month old and seedtime average 60 days or better
|
||||
if ($user->getSeeding() >= 300 && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 * 2 && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 18) {
|
||||
// Veteran >= 100TB and account 1 year old
|
||||
if ($user->uploaded >= 1073741824000 * 100 && $user->getRatio() >= config('other.ratio') && $user->created_at < $current->copy()->subDays(365)->toDateTimeString() && $user->group_id != 16) {
|
||||
$user->group_id = 16;
|
||||
$user->save();
|
||||
}
|
||||
// Archivist Seedsize >= 10TB and account 3 month old and seedtime average 60 days or better
|
||||
if ($user->getTotalSeedSize() >= 1073741824000 * 10 && $user->getRatio() >= config('other.ratio') && round($user->getTotalSeedTime() / max(1, $hiscount)) > 2592000 * 2 && $user->created_at < $current->copy()->subDays(90)->toDateTimeString() && $user->group_id != 18) {
|
||||
$user->group_id = 18;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Peer;
|
||||
use App\Models\Client;
|
||||
use App\Models\Seedbox;
|
||||
use App\Models\Torrent;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -44,10 +44,10 @@ class AutoHighspeedTag extends Command
|
||||
{
|
||||
DB::table('torrents')->update(['highspeed' => 0]);
|
||||
|
||||
$seedbox_users = Client::select('user_id')->get()->toArray();
|
||||
$seedbox_users = Seedbox::select(['user_id'])->get()->toArray();
|
||||
|
||||
if (is_array($seedbox_users) && count($seedbox_users) > 0) {
|
||||
$torid = Peer::select('torrent_id')->whereIn('user_id', $seedbox_users)->where('seeder', '=', 1)->get()->toArray();
|
||||
$torid = Peer::select(['torrent_id'])->whereIn('user_id', $seedbox_users)->where('seeder', '=', 1)->get()->toArray();
|
||||
|
||||
foreach ($torid as $id) {
|
||||
$torrent = Torrent::where('id', '=', $id)->first();
|
||||
|
||||
@@ -58,11 +58,12 @@ class AutoNerdStat extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('chat.nerd_bot') == true) {
|
||||
$expiresAt = Carbon::now()->addMinutes(60);
|
||||
|
||||
// Current Timestamp
|
||||
$current = Carbon::now();
|
||||
|
||||
// Cache Expires Timestamp
|
||||
$expiresAt = $current->addMinutes(60);
|
||||
|
||||
// Site Birthday
|
||||
$bday = config('other.birthdate');
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\User;
|
||||
use App\Models\History;
|
||||
use App\Models\Warning;
|
||||
use App\Models\PrivateMessage;
|
||||
|
||||
@@ -42,11 +42,11 @@ class AutoRevokePermissions extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$leechGroup = Group::where('slug', '=', 'leech')->select('id')->first();
|
||||
$disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first();
|
||||
$prunedGroup = Group::where('slug', '=', 'pruned')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$leechGroup = Group::select(['id'])->where('slug', '=', 'leech')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
|
||||
User::whereNotIn('group_id', [$bannedGroup->id, $validatingGroup->id, $leechGroup->id, $disabledGroup->id, $prunedGroup->id])->update(['can_download' => '1', 'can_request' => '1']);
|
||||
User::whereIn('group_id', [$bannedGroup->id, $validatingGroup->id, $leechGroup->id, $disabledGroup->id, $prunedGroup->id])->update(['can_download' => '0', 'can_request' => '0']);
|
||||
|
||||
@@ -43,8 +43,8 @@ class AutoSoftDeleteDisabledUsers extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('pruning.user_pruning') == true) {
|
||||
$disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first();
|
||||
$prunedGroup = Group::where('slug', '=', 'pruned')->select('id')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
|
||||
$current = Carbon::now();
|
||||
$users = User::where('group_id', '=', $disabledGroup->id)
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Torrent;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\Clients\OmdbClient;
|
||||
|
||||
@@ -51,7 +52,7 @@ class DemoSeed extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->alert('Demo Seeder v1.0 Beta (Author: Poppabear)');
|
||||
$this->alert('Demo Seeder v1.0 (Author: Poppabear)');
|
||||
$this->warn('*** This process could take a few minutes ***');
|
||||
$this->warn('Press CTRL + C to abort');
|
||||
|
||||
@@ -59,33 +60,32 @@ class DemoSeed extends Command
|
||||
|
||||
$abort = false;
|
||||
|
||||
foreach ($this->ids() as $key => $value) {
|
||||
foreach ($this->ids() as $key => $id) {
|
||||
// Users
|
||||
$this->info('Creating User Account');
|
||||
|
||||
$uid = factory(User::class)->create()->id;
|
||||
|
||||
foreach ($value as $id) {
|
||||
// random boolean
|
||||
if ([false, true][rand(0, 1)]) {
|
||||
$r = $this->search('tt'.$id);
|
||||
// random boolean
|
||||
if ([false, true][rand(0, 1)]) {
|
||||
$r = $this->search('tt'.$id);
|
||||
|
||||
// Torrents
|
||||
$this->info('Creating Movie Torrents for Account ID #'.$uid);
|
||||
// Torrents
|
||||
$this->info('Creating Movie Torrents for Account ID #'.$uid);
|
||||
|
||||
try {
|
||||
factory(Torrent::class)->create([
|
||||
'user_id' => $uid,
|
||||
'imdb' => $id,
|
||||
'name' => $r['Title'],
|
||||
'slug' => str_slug($r['Title']),
|
||||
try {
|
||||
factory(Torrent::class)->create([
|
||||
'user_id' => $uid,
|
||||
'imdb' => $id,
|
||||
'name' => $r['Title'],
|
||||
'slug' => Str::slug($r['Title']),
|
||||
'description' => $r['Plot'],
|
||||
'category_id' => 1,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$abort = true;
|
||||
break;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$abort = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +131,190 @@ class DemoSeed extends Command
|
||||
private function ids()
|
||||
{
|
||||
return [
|
||||
['2948356', '2094766', '2592614', '0139809', '0088323', '1959409', '0076729', '0089175', '3553976'],
|
||||
['0051622', '0078788', '6315800', '0472033', '2488496', '3748528', '0230011', '0158983', '4972582'],
|
||||
['3783958', '4276820', '0311113', '4276820', '4972582', '2072233', '4385888', '0106611', '3640424'],
|
||||
['2713180', '2282016', '0402022', '0467406', '0448134', '0079116', '0386064', '0120657', '0111161'],
|
||||
['0113568', '0108399', '0265086', '0317248', '1675434', '1436045', '0416044', '0103639', '0399201'],
|
||||
['2960470', '0101414', '0325710', '2488496', '3631112', '0120591', '0395169', '1862079', '0133093'],
|
||||
['0289043', '3289956', '3521164', '0325980', '0377062', '1598778', '0401792', '4418398', '4303340'],
|
||||
['4276820', '0118929', '1540133', '0499549', '3393786', '1620935', '1878870', '0387808', '0159365'],
|
||||
['3470600', '3717252', '0266987', '0046438', '2094766', '1032755', '3521164', '3183660', '2119532'],
|
||||
['4662420', '4276820', '2278388', '1895315', '0342258', '0266308', '0477348', '0120746', '0129167'],
|
||||
'2948356',
|
||||
'2094766',
|
||||
'2592614',
|
||||
'0139809',
|
||||
'0088323',
|
||||
'1959409',
|
||||
'0076729',
|
||||
'0089175',
|
||||
'3553976',
|
||||
'0051622',
|
||||
'0078788',
|
||||
'6315800',
|
||||
'0472033',
|
||||
'2488496',
|
||||
'3748528',
|
||||
'0230011',
|
||||
'0158983',
|
||||
'4972582',
|
||||
'3783958',
|
||||
'4276820',
|
||||
'0311113',
|
||||
'4276820',
|
||||
'4972582',
|
||||
'2072233',
|
||||
'4385888',
|
||||
'0106611',
|
||||
'3640424',
|
||||
'2282016',
|
||||
'0402022',
|
||||
'0467406',
|
||||
'0448134',
|
||||
'0079116',
|
||||
'0386064',
|
||||
'0120657',
|
||||
'0111161',
|
||||
'0113568',
|
||||
'0108399',
|
||||
'0265086',
|
||||
'0317248',
|
||||
'1675434',
|
||||
'1436045',
|
||||
'0416044',
|
||||
'0103639',
|
||||
'0399201',
|
||||
'2960470',
|
||||
'0101414',
|
||||
'0325710',
|
||||
'2488496',
|
||||
'3631112',
|
||||
'0120591',
|
||||
'0395169',
|
||||
'1862079',
|
||||
'0133093',
|
||||
'0289043',
|
||||
'3289956',
|
||||
'3521164',
|
||||
'0325980',
|
||||
'0377062',
|
||||
'1598778',
|
||||
'0401792',
|
||||
'4418398',
|
||||
'4303340',
|
||||
'4276820',
|
||||
'0118929',
|
||||
'1540133',
|
||||
'0499549',
|
||||
'3393786',
|
||||
'1620935',
|
||||
'1878870',
|
||||
'0387808',
|
||||
'0159365',
|
||||
'3470600',
|
||||
'3717252',
|
||||
'0266987',
|
||||
'0046438',
|
||||
'2094766',
|
||||
'1032755',
|
||||
'3521164',
|
||||
'3183660',
|
||||
'2119532',
|
||||
'4276820',
|
||||
'2278388',
|
||||
'1895315',
|
||||
'0342258',
|
||||
'0266308',
|
||||
'0477348',
|
||||
'0120746',
|
||||
'0129167',
|
||||
'0272152',
|
||||
'0101272',
|
||||
'0120815',
|
||||
'0910970',
|
||||
'2096673',
|
||||
'4698684',
|
||||
'0338564',
|
||||
'0343660',
|
||||
'0758758',
|
||||
'0124298',
|
||||
'0208092',
|
||||
'3783958',
|
||||
'3783958',
|
||||
'1034303',
|
||||
'0498380',
|
||||
'3666024',
|
||||
'0093990',
|
||||
'0098662',
|
||||
'0097165',
|
||||
'3748528',
|
||||
'1211837',
|
||||
'0109506',
|
||||
'4572514',
|
||||
'0814314',
|
||||
'0112384',
|
||||
'0375912',
|
||||
'0408306',
|
||||
'1568921',
|
||||
'0094625',
|
||||
'2630336',
|
||||
'1718199',
|
||||
'0455824',
|
||||
'1979319',
|
||||
'3095734',
|
||||
'0119229',
|
||||
'0087985',
|
||||
'0114436',
|
||||
'1712261',
|
||||
'1250777',
|
||||
'1790885',
|
||||
'1800302',
|
||||
'5068650',
|
||||
'1753383',
|
||||
'0162661',
|
||||
'0356910',
|
||||
'0319262',
|
||||
'0892255',
|
||||
'4172430',
|
||||
'0374569',
|
||||
'0246578',
|
||||
'2277860',
|
||||
'3659388',
|
||||
'1628841',
|
||||
'0097814',
|
||||
'3756788',
|
||||
'0108188',
|
||||
'2381991',
|
||||
'0298228',
|
||||
'4094724',
|
||||
'1091191',
|
||||
'0116277',
|
||||
'0129167',
|
||||
'0129167',
|
||||
'0055630',
|
||||
'0210945',
|
||||
'3385516',
|
||||
'0080745',
|
||||
'0816692',
|
||||
'2802144',
|
||||
'0938283',
|
||||
'0119250',
|
||||
'2719848',
|
||||
'0074812',
|
||||
'1454468',
|
||||
'0084787',
|
||||
'3717252',
|
||||
'0111255',
|
||||
'5700672',
|
||||
'1054606',
|
||||
'0360201',
|
||||
'0093870',
|
||||
'0108052',
|
||||
'0372784',
|
||||
'0068646',
|
||||
'4846340',
|
||||
'3183660',
|
||||
'0113540',
|
||||
'1935859',
|
||||
'4902904',
|
||||
'0105323',
|
||||
'0078788',
|
||||
'0112573',
|
||||
'0120631',
|
||||
'0078748',
|
||||
'0100802',
|
||||
'5788136',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ class FetchGenres extends Command
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Console\ConsoleTools;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
@@ -148,16 +149,19 @@ class GitUpdater extends Command
|
||||
$this->compile();
|
||||
}
|
||||
|
||||
$this->clearCache();
|
||||
|
||||
if ($this->io->confirm('Install new packages (composer install)', true)) {
|
||||
$this->composer();
|
||||
}
|
||||
|
||||
$this->updateUNIT3DConfig();
|
||||
|
||||
$this->clearCache();
|
||||
|
||||
$this->setCache();
|
||||
|
||||
$this->permissions();
|
||||
|
||||
$this->header('Bringing Site Live');
|
||||
$this->call('up');
|
||||
} else {
|
||||
$this->alertDanger('Aborted Update');
|
||||
@@ -223,7 +227,7 @@ class GitUpdater extends Command
|
||||
$this->header('Restoring Backups');
|
||||
|
||||
foreach ($paths as $path) {
|
||||
$to = str_replace_last('/.', '', base_path(dirname($path)));
|
||||
$to = Str::replaceLast('/.', '', base_path(dirname($path)));
|
||||
$from = storage_path('gitupdate').'/'.$path;
|
||||
|
||||
if (is_dir($from)) {
|
||||
@@ -294,12 +298,19 @@ class GitUpdater extends Command
|
||||
$this->done();
|
||||
}
|
||||
|
||||
private function permissions()
|
||||
{
|
||||
$this->header('Refreshing Permissions');
|
||||
$this->process('chown -R www-data: storage bootstrap public config');
|
||||
$this->done();
|
||||
}
|
||||
|
||||
private function validatePath($path)
|
||||
{
|
||||
if (! is_file(base_path($path)) && ! is_dir(base_path($path))) {
|
||||
$this->red("The path '$path' is invalid");
|
||||
$this->call('up');
|
||||
die();
|
||||
//$this->call('up');
|
||||
//die();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +350,8 @@ class GitUpdater extends Command
|
||||
'.env',
|
||||
'laravel-echo-server.json',
|
||||
'public/files',
|
||||
'public/img/emojione',
|
||||
'public/img/joypixels',
|
||||
];
|
||||
|
||||
return array_merge($paths, $additional);
|
||||
|
||||
@@ -25,37 +25,7 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
// Scheduled Commands
|
||||
\App\Console\Commands\AutoNerdStat::class,
|
||||
\App\Console\Commands\AutoBonAllocation::class,
|
||||
\App\Console\Commands\AutoHighspeedTag::class,
|
||||
\App\Console\Commands\AutoPreWarning::class,
|
||||
\App\Console\Commands\AutoWarning::class,
|
||||
\App\Console\Commands\AutoDeactivateWarning::class,
|
||||
\App\Console\Commands\AutoRevokePermissions::class,
|
||||
\App\Console\Commands\AutoBan::class,
|
||||
\App\Console\Commands\AutoFlushPeers::class,
|
||||
\App\Console\Commands\AutoGroup::class,
|
||||
\App\Console\Commands\AutoRemovePersonalFreeleech::class,
|
||||
\App\Console\Commands\AutoRemoveFeaturedTorrent::class,
|
||||
\App\Console\Commands\AutoGraveyard::class,
|
||||
\App\Console\Commands\IrcBroadcast::class,
|
||||
\App\Console\Commands\IrcMessage::class,
|
||||
\App\Console\Commands\AutoRecycleInvites::class,
|
||||
\App\Console\Commands\AutoRecycleActivityLog::class,
|
||||
\App\Console\Commands\AutoRecycleFailedLogins::class,
|
||||
\App\Console\Commands\AutoDisableInactiveUsers::class,
|
||||
\App\Console\Commands\AutoSoftDeleteDisabledUsers::class,
|
||||
\App\Console\Commands\AutoRecycleClaimedTorrentRequests::class,
|
||||
\App\Console\Commands\AutoCorrectHistory::class,
|
||||
|
||||
// Manually Run Commands
|
||||
\App\Console\Commands\DemoSeed::class,
|
||||
\App\Console\Commands\GitUpdater::class,
|
||||
\App\Console\Commands\ClearCache::class,
|
||||
\App\Console\Commands\SetCache::class,
|
||||
\App\Console\Commands\TestMailSettings::class,
|
||||
\App\Console\Commands\FetchGenres::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Message;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
@@ -31,16 +30,23 @@ class Chatter implements ShouldBroadcastNow
|
||||
* @var Message
|
||||
*/
|
||||
public $echoes;
|
||||
|
||||
public $target;
|
||||
|
||||
public $type;
|
||||
|
||||
public $message;
|
||||
|
||||
public $ping;
|
||||
|
||||
public $audibles;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param $type
|
||||
* @param $target
|
||||
* @param $payload
|
||||
*/
|
||||
public function __construct($type, $target, $payload)
|
||||
{
|
||||
@@ -62,7 +68,7 @@ class Chatter implements ShouldBroadcastNow
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
* @return PrivateChannel
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Message;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
@@ -35,7 +34,7 @@ class MessageDeleted implements ShouldBroadcastNow
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Message $message
|
||||
*/
|
||||
public function __construct(Message $message)
|
||||
{
|
||||
@@ -45,7 +44,7 @@ class MessageDeleted implements ShouldBroadcastNow
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
* @return PresenceChannel
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Message;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Http\Resources\ChatMessageResource;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
@@ -36,7 +35,7 @@ class MessageEdited implements ShouldBroadcastNow
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Message $message
|
||||
*/
|
||||
public function __construct(Message $message)
|
||||
{
|
||||
@@ -47,7 +46,7 @@ class MessageEdited implements ShouldBroadcastNow
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
* @return PresenceChannel
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Message;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Http\Resources\ChatMessageResource;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
@@ -36,7 +35,7 @@ class MessageSent implements ShouldBroadcastNow
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param Message $message
|
||||
*/
|
||||
public function __construct(Message $message)
|
||||
{
|
||||
@@ -54,7 +53,7 @@ class MessageSent implements ShouldBroadcastNow
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
* @return PresenceChannel
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
|
||||
+4
-3
@@ -13,7 +13,6 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
@@ -25,12 +24,14 @@ class Ping implements ShouldBroadcastNow
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $room;
|
||||
|
||||
public $ping;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
* @param $room
|
||||
* @param $id
|
||||
*/
|
||||
public function __construct($room, $id)
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class Ping implements ShouldBroadcastNow
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return Channel|array
|
||||
* @return PresenceChannel
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
|
||||
@@ -18,7 +18,10 @@ use PhpZip\ZipFile;
|
||||
class BackupEncryption
|
||||
{
|
||||
const ENCRYPTION_DEFAULT = ZipFile::ENCRYPTION_METHOD_TRADITIONAL;
|
||||
|
||||
const ENCRYPTION_WINZIP_AES_128 = ZipFile::ENCRYPTION_METHOD_WINZIP_AES_128;
|
||||
|
||||
const ENCRYPTION_WINZIP_AES_192 = ZipFile::ENCRYPTION_METHOD_WINZIP_AES_192;
|
||||
|
||||
const ENCRYPTION_WINZIP_AES_256 = ZipFile::ENCRYPTION_METHOD_WINZIP_AES_256;
|
||||
}
|
||||
|
||||
+391
-17
@@ -8,36 +8,410 @@
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author Ryuu
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Decoda\Decoda;
|
||||
use App\Hook\ClickableHook;
|
||||
|
||||
class Bbcode
|
||||
{
|
||||
private function __construct()
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $parsers = [
|
||||
'h1' => [
|
||||
'pattern' => '/\[h1\](.*?)\[\/h1\]/s',
|
||||
'replace' => '<h1>$1</h1>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'h2' => [
|
||||
'pattern' => '/\[h2\](.*?)\[\/h2\]/s',
|
||||
'replace' => '<h2>$1</h2>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'h3' => [
|
||||
'pattern' => '/\[h3\](.*?)\[\/h3\]/s',
|
||||
'replace' => '<h3>$1</h3>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'h4' => [
|
||||
'pattern' => '/\[h4\](.*?)\[\/h4\]/s',
|
||||
'replace' => '<h4>$1</h4>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'h5' => [
|
||||
'pattern' => '/\[h5\](.*?)\[\/h5\]/s',
|
||||
'replace' => '<h5>$1</h5>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'h6' => [
|
||||
'pattern' => '/\[h6\](.*?)\[\/h6\]/s',
|
||||
'replace' => '<h6>$1</h6>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'bold' => [
|
||||
'pattern' => '/\[b\](.*?)\[\/b\]/s',
|
||||
'replace' => '<span style="font-weight: bold;">$1</span>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'italic' => [
|
||||
'pattern' => '/\[i\](.*?)\[\/i\]/s',
|
||||
'replace' => '<em>$1</em>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'underline' => [
|
||||
'pattern' => '/\[u\](.*?)\[\/u\]/s',
|
||||
'replace' => '<u>$1</u>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'linethrough' => [
|
||||
'pattern' => '/\[s\](.*?)\[\/s\]/s',
|
||||
'replace' => '<span style="text-decoration: line-through;">$1</span>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'size' => [
|
||||
'pattern' => '/\[size\=(.*?)\](.*?)\[\/size\]/s',
|
||||
'replace' => '<span style="font-size: $1px;">$2</span>',
|
||||
'content' => '$2',
|
||||
],
|
||||
|
||||
'font' => [
|
||||
'pattern' => '/\[font\=(.*?)\](.*?)\[\/font\]/s',
|
||||
'replace' => '<span style="font-family: $1;">$2</span>',
|
||||
'content' => '$2',
|
||||
],
|
||||
|
||||
'color' => [
|
||||
'pattern' => '/\[color\=(.*?)\](.*?)\[\/color\]/s',
|
||||
'replace' => '<span style="color: $1;">$2</span>',
|
||||
'content' => '$2',
|
||||
],
|
||||
|
||||
'center' => [
|
||||
'pattern' => '/\[center\](.*?)\[\/center\]/s',
|
||||
'replace' => '<div style="text-align:center;">$1</div>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'left' => [
|
||||
'pattern' => '/\[left\](.*?)\[\/left\]/s',
|
||||
'replace' => '<div style="text-align:left;">$1</div>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'right' => [
|
||||
'pattern' => '/\[right\](.*?)\[\/right\]/s',
|
||||
'replace' => '<div style="text-align:right;">$1</div>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'quote' => [
|
||||
'pattern' => '/\[quote\](.*?)\[\/quote\]/s',
|
||||
'replace' => '<ul class="media-list comments-list">
|
||||
<li class="media" style="border-left-width: 5px; border-left-style: solid; border-left-color: rgb(1, 188, 140);">
|
||||
<div class="media-body">
|
||||
<div class="pt-5">$1</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'namedquote' => [
|
||||
'pattern' => '/\[quote\=(.*?)\](.*)\[\/quote\]/s',
|
||||
'replace' => '<ul class="media-list comments-list">
|
||||
<li class="media" style="border-left-width: 5px; border-left-style: solid; border-left-color: rgb(1, 188, 140);">
|
||||
<div class="media-body">
|
||||
<strong><span><i class="fas fa-quote-left"></i> Quoting $1 :</span></strong>
|
||||
<div class="pt-5">$2</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>',
|
||||
'content' => '$2',
|
||||
],
|
||||
|
||||
'link' => [
|
||||
'pattern' => '/\[url\](.*?)\[\/url\]/s',
|
||||
'replace' => '<a href="$1">$1</a>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'namedlink' => [
|
||||
'pattern' => '/\[url\=(.*?)\](.*?)\[\/url\]/s',
|
||||
'replace' => '<a href="$1">$2</a>',
|
||||
'content' => '$2',
|
||||
],
|
||||
|
||||
'image' => [
|
||||
'pattern' => '/\[img\](.*?)\[\/img\]/s',
|
||||
'replace' => '<img src="$1">',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'sized-image' => [
|
||||
'pattern' => '/\[img width\=(.*?)\](.*?)\[\/img\]/s',
|
||||
'replace' => '<img src="$2" width="$1px">',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'sized-image2' => [
|
||||
'pattern' => '/\[img\=(.*?)\](.*?)\[\/img\]/s',
|
||||
'replace' => '<img src="$2" width="$1px">',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'orderedlistnumerical' => [
|
||||
'pattern' => '/\[list=1\](.*?)\[\/list\]/s',
|
||||
'replace' => '<ol>$1</ol>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'orderedlistalpha' => [
|
||||
'pattern' => '/\[list=a\](.*?)\[\/list\]/s',
|
||||
'replace' => '<ol type="a">$1</ol>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'unorderedlist' => [
|
||||
'pattern' => '/\[list\](.*?)\[\/list\]/s',
|
||||
'replace' => '<ul>$1</ul>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'listitem' => [
|
||||
'pattern' => '/\[\*\](.*)/',
|
||||
'replace' => '<li>$1</li>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'code' => [
|
||||
'pattern' => '/\[code\](.*?)\[\/code\]/s',
|
||||
'replace' => '<pre>$1</pre>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'alert' => [
|
||||
'pattern' => '/\[alert\](.*?)\[\/alert\]/s',
|
||||
'replace' => '<div class="bbcode-alert">$1</div>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'note' => [
|
||||
'pattern' => '/\[note\](.*?)\[\/note\]/s',
|
||||
'replace' => '<div class="bbcode-note">$1</div>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'sub' => [
|
||||
'pattern' => '/\[sub\](.*?)\[\/sub\]/s',
|
||||
'replace' => '<sub>$1</sub>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'sup' => [
|
||||
'pattern' => '/\[sup\](.*?)\[\/sup\]/s',
|
||||
'replace' => '<sup>$1</sup>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'small' => [
|
||||
'pattern' => '/\[small\](.*?)\[\/small\]/s',
|
||||
'replace' => '<small>$1</small>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'table' => [
|
||||
'pattern' => '/\[table\](.*?)\[\/table\]/s',
|
||||
'replace' => '<table>$1</table>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'table-row' => [
|
||||
'pattern' => '/\[tr\](.*?)\[\/tr\]/s',
|
||||
'replace' => '<tr>$1</tr>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'table-data' => [
|
||||
'pattern' => '/\[td\](.*?)\[\/td\]/s',
|
||||
'replace' => '<td>$1</td>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'youtube' => [
|
||||
'pattern' => '/\[youtube\](.*?)\[\/youtube\]/s',
|
||||
'replace' => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/$1?rel=0"
|
||||
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'video' => [
|
||||
'pattern' => '/\[video\](.*?)\[\/video\]/s',
|
||||
'replace' => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/$1?rel=0"
|
||||
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'video-youtube' => [
|
||||
'pattern' => '/\[video="youtube"\](.*?)\[\/video\]/s',
|
||||
'replace' => '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/$1?rel=0"
|
||||
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'linebreak' => [
|
||||
'pattern' => '/\r\n/',
|
||||
'replace' => '<br />',
|
||||
'content' => '',
|
||||
],
|
||||
|
||||
'spoiler' => [
|
||||
'pattern' => '/\[spoiler\](.*?)\[\/spoiler\]/s',
|
||||
'replace' => '<details class="label label-primary"><summary>Spoiler</summary><pre><code>$1</code></pre></details>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'named-spoiler' => [
|
||||
'pattern' => '/\[spoiler\=(.*?)\](.*?)\[\/spoiler\]/s',
|
||||
'replace' => '<details class="label label-primary"><summary>$1</summary><pre><code>$2</code></pre></details>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
'ss-compare' => [
|
||||
'pattern' => '/\[ss-compare\=(.*?)\](.*?)\[\/ss-compare\]/s',
|
||||
'replace' => '<a class="ss-compare" href="#">
|
||||
<img src="$1" />
|
||||
<img src="$2" />
|
||||
</a>',
|
||||
'content' => '$1',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $enabledParsers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabledParsers = $this->parsers;
|
||||
}
|
||||
|
||||
public static function decodaWithDefaults($data)
|
||||
/**
|
||||
* Parses the BBCode string.
|
||||
*
|
||||
* @param $source
|
||||
* @param bool $caseInsensitive
|
||||
* @return string
|
||||
*/
|
||||
public function parse($source, $caseInsensitive = false)
|
||||
{
|
||||
$code = new Decoda($data);
|
||||
$code->defaults();
|
||||
$code->removeHook('Censor');
|
||||
$code->removeHook('Clickable');
|
||||
$code->addHook(new ClickableHook());
|
||||
$code->setXhtml(false);
|
||||
$code->setStrict(false);
|
||||
$code->setLineBreaks(true);
|
||||
foreach ($this->enabledParsers as $name => $parser) {
|
||||
$pattern = ($caseInsensitive) ? $parser['pattern'].'i' : $parser['pattern'];
|
||||
|
||||
return $code;
|
||||
$source = $this->searchAndReplace($pattern, $parser['replace'], $source);
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
public static function parse($data)
|
||||
/**
|
||||
* Remove all BBCode.
|
||||
*
|
||||
* @param string $source
|
||||
* @return string Parsed text
|
||||
*/
|
||||
public function stripBBCodeTags($source)
|
||||
{
|
||||
return self::decodaWithDefaults($data)->parse();
|
||||
foreach ($this->parsers as $name => $parser) {
|
||||
$source = $this->searchAndReplace($parser['pattern'].'i', $parser['content'], $source);
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches after a specified pattern and replaces it with provided structure.
|
||||
*
|
||||
* @param string $pattern Search pattern
|
||||
* @param string $replace Replacement structure
|
||||
* @param string $source Text to search in
|
||||
* @return string Parsed text
|
||||
*/
|
||||
protected function searchAndReplace($pattern, $replace, $source)
|
||||
{
|
||||
while (preg_match($pattern, $source)) {
|
||||
$source = preg_replace($pattern, $replace, $source);
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to parse case sensitive.
|
||||
*
|
||||
* @param string $source String containing the BBCode
|
||||
* @return string Parsed text
|
||||
*/
|
||||
public function parseCaseSensitive($source)
|
||||
{
|
||||
return $this->parse($source, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to parse case insensitive.
|
||||
*
|
||||
* @param string $source String containing the BBCode
|
||||
* @return string Parsed text
|
||||
*/
|
||||
public function parseCaseInsensitive($source)
|
||||
{
|
||||
return $this->parse($source, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of chosen parsers.
|
||||
*
|
||||
* @return array array of parsers
|
||||
*/
|
||||
public function getParsers()
|
||||
{
|
||||
return $this->enabledParsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parser pattern and replace.
|
||||
* This can be used for new parsers or overwriting existing ones.
|
||||
*
|
||||
* @param string $name Parser name
|
||||
* @param string $pattern Pattern
|
||||
* @param string $replace Replace pattern
|
||||
* @param string $content Parsed text pattern
|
||||
* @return void
|
||||
*/
|
||||
public function setParser($name, $pattern, $replace, $content)
|
||||
{
|
||||
$this->parsers[$name] = [
|
||||
'pattern' => $pattern,
|
||||
'replace' => $replace,
|
||||
'content' => $content,
|
||||
];
|
||||
|
||||
$this->enabledParsers[$name] = [
|
||||
'pattern' => $pattern,
|
||||
'replace' => $replace,
|
||||
'content' => $content,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,10 @@
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Services;
|
||||
namespace App\Helpers;
|
||||
|
||||
use function theodorejb\polycast\safe_int;
|
||||
|
||||
/**
|
||||
* Bencode library for torrents.
|
||||
*/
|
||||
class Bencode
|
||||
{
|
||||
public static function parse_integer($s, &$pos)
|
||||
@@ -158,6 +155,7 @@ class Bencode
|
||||
foreach (array_keys($d) as $key) {
|
||||
if (! is_int($key)) {
|
||||
$is_dict = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -203,26 +201,33 @@ class Bencode
|
||||
return self::bdecode($f);
|
||||
}
|
||||
|
||||
public static function bdecode_getinfo($filename, $need_info_hash = false)
|
||||
public static function get_infohash($t)
|
||||
{
|
||||
$t = self::bdecode_file($filename);
|
||||
$t['info_hash'] = $need_info_hash ? sha1(self::bencode($t['info'])) : null;
|
||||
return sha1(self::bencode($t['info']));
|
||||
}
|
||||
|
||||
if (isset($t['info']['files']) && is_array($t['info']['files'])) { //multifile
|
||||
$t['info']['size'] = 0;
|
||||
$t['info']['filecount'] = 0;
|
||||
public static function get_meta($t)
|
||||
{
|
||||
$result = [];
|
||||
$size = 0;
|
||||
$count = 0;
|
||||
|
||||
// Multifile
|
||||
if (isset($t['info']['files']) && is_array($t['info']['files'])) {
|
||||
foreach ($t['info']['files'] as $file) {
|
||||
$t['info']['filecount']++;
|
||||
$t['info']['size'] += $file['length'];
|
||||
$count++;
|
||||
$size += $file['length'];
|
||||
}
|
||||
} else {
|
||||
$t['info']['size'] = $t['info']['length'];
|
||||
$t['info']['filecount'] = 1;
|
||||
$size = $t['info']['length'];
|
||||
$count = 1;
|
||||
$t['info']['files'][0]['path'] = $t['info']['name'];
|
||||
$t['info']['files'][0]['length'] = $t['info']['length'];
|
||||
}
|
||||
|
||||
return $t;
|
||||
$result['count'] = $count;
|
||||
$result['size'] = $size;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/*
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
@@ -49,7 +51,7 @@ if (! function_exists('hrefRequest')) {
|
||||
function hrefRequest($torrentRequest)
|
||||
{
|
||||
$appurl = appurl();
|
||||
$slug = str_slug($torrentRequest->name);
|
||||
$slug = Str::slug($torrentRequest->name);
|
||||
|
||||
return "{$appurl}/request/{$torrentRequest->id}";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -76,59 +76,74 @@ class MediaInfo
|
||||
case 'complete name':
|
||||
case 'completename':
|
||||
$output['file_name'] = self::stripPath($value);
|
||||
|
||||
break;
|
||||
case 'format':
|
||||
$output['format'] = $value;
|
||||
|
||||
break;
|
||||
case 'duration':
|
||||
$output['duration'] = $value;
|
||||
|
||||
break;
|
||||
case 'file size':
|
||||
case 'filesize':
|
||||
$output['file_size'] = $this->parseFileSize($value);
|
||||
|
||||
break;
|
||||
case 'overall bit rate':
|
||||
case 'overallbitrate':
|
||||
$output['bit_rate'] = $this->parseBitRate($value);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'video':
|
||||
switch ($property) {
|
||||
case 'format':
|
||||
$output['format'] = $value;
|
||||
|
||||
break;
|
||||
case 'format version':
|
||||
case 'format_version':
|
||||
$output['format_version'] = $value;
|
||||
|
||||
break;
|
||||
case 'codec id':
|
||||
case 'codecid':
|
||||
$output['codec'] = $value;
|
||||
|
||||
break;
|
||||
case 'width':
|
||||
$output['width'] = $this->parseWidthHeight($value);
|
||||
|
||||
break;
|
||||
case 'height':
|
||||
$output['height'] = $this->parseWidthHeight($value);
|
||||
|
||||
break;
|
||||
case 'stream size':
|
||||
case 'stream_size':
|
||||
$output['stream_size'] = $this->parseFileSize($value);
|
||||
|
||||
break;
|
||||
case 'writing library':
|
||||
case 'encoded_library':
|
||||
$output['writing_library'] = $value;
|
||||
|
||||
break;
|
||||
case 'frame rate mode':
|
||||
case 'framerate_mode':
|
||||
$output['framerate_mode'] = $value;
|
||||
|
||||
break;
|
||||
case 'frame rate':
|
||||
case 'framerate':
|
||||
// if variable this becomes Original frame rate
|
||||
$output['frame_rate'] = $value;
|
||||
|
||||
break;
|
||||
case 'display aspect ratio':
|
||||
case 'displayaspectratio':
|
||||
@@ -137,42 +152,54 @@ class MediaInfo
|
||||
case 'bit rate':
|
||||
case 'bitrate':
|
||||
$output['bit_rate'] = $this->parseBitRate($value);
|
||||
|
||||
break;
|
||||
case 'bit rate mode':
|
||||
case 'bitrate_mode':
|
||||
$output['bit_rate_mode'] = $value;
|
||||
|
||||
break;
|
||||
case 'nominal bit rate':
|
||||
case 'bitrate_nominal':
|
||||
$output['bit_rate_nominal'] = $this->parseBitRate($value);
|
||||
|
||||
break;
|
||||
case 'bits/(pixel*frame)':
|
||||
case 'bits-(pixel*frame)':
|
||||
$output['bit_pixel_frame'] = $value;
|
||||
|
||||
break;
|
||||
case 'bit depth':
|
||||
case 'bitdepth':
|
||||
$output['bit_depth'] = $value;
|
||||
|
||||
break;
|
||||
case 'encoding settings':
|
||||
$output['encoding_settings'] = $value;
|
||||
|
||||
break;
|
||||
case 'language':
|
||||
$output['language'] = $value;
|
||||
|
||||
break;
|
||||
case 'format profile':
|
||||
$output['format_profile'] = $value;
|
||||
|
||||
break;
|
||||
case 'title':
|
||||
$output['title'] = $value;
|
||||
|
||||
break;
|
||||
case 'color primaries':
|
||||
$output['title'] = $value;
|
||||
|
||||
break;
|
||||
case 'scan type':
|
||||
$output['scan_type'] = $value;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'audio':
|
||||
@@ -180,32 +207,41 @@ class MediaInfo
|
||||
case 'codec id':
|
||||
case 'codecid':
|
||||
$output['codec'] = $value;
|
||||
|
||||
break;
|
||||
case 'format':
|
||||
$output['format'] = $value;
|
||||
|
||||
break;
|
||||
case 'bit rate':
|
||||
case 'bitrate':
|
||||
$output['bit_rate'] = $this->parseBitRate($value);
|
||||
|
||||
break;
|
||||
case 'channel(s)':
|
||||
$output['channels'] = $this->parseAudioChannels($value);
|
||||
|
||||
break;
|
||||
case 'title':
|
||||
$output['title'] = $value;
|
||||
|
||||
break;
|
||||
case 'language':
|
||||
$output['language'] = $value;
|
||||
|
||||
break;
|
||||
case 'format profile':
|
||||
case 'format_profile':
|
||||
$output['format_profile'] = $value;
|
||||
|
||||
break;
|
||||
case 'stream size':
|
||||
case 'stream_size':
|
||||
$output['stream_size'] = $this->parseFileSize($value);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
@@ -213,23 +249,30 @@ class MediaInfo
|
||||
case 'codec id':
|
||||
case 'codecid':
|
||||
$output['codec'] = $value;
|
||||
|
||||
break;
|
||||
case 'format':
|
||||
$output['format'] = $value;
|
||||
|
||||
break;
|
||||
case 'title':
|
||||
$output['title'] = $value;
|
||||
|
||||
break;
|
||||
case 'language':
|
||||
$output['language'] = $value;
|
||||
|
||||
break;
|
||||
case 'default':
|
||||
$output['default'] = $value;
|
||||
|
||||
break;
|
||||
case 'forced':
|
||||
$output['forced'] = $value;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@ namespace App\Helpers;
|
||||
class StringHelper
|
||||
{
|
||||
const KIB = 1024;
|
||||
|
||||
const MIB = 1024 * 1024;
|
||||
|
||||
const GIB = 1024 * 1024 * 1024;
|
||||
|
||||
const TIB = 1024 * 1024 * 1024 * 1024;
|
||||
|
||||
const PIB = 1024 * 1024 * 1024 * 1024 * 1024;
|
||||
|
||||
public static function generateRandomString($length = 20)
|
||||
@@ -60,7 +64,7 @@ class StringHelper
|
||||
/**
|
||||
* @method timeRemaining
|
||||
*
|
||||
* @param $seconds time in bigInt
|
||||
* @param time $seconds in bigInt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -102,13 +106,13 @@ class StringHelper
|
||||
$minutes++;
|
||||
$seconds -= 60;
|
||||
}
|
||||
$years = ($years == 0) ? '' : $years.'Y ';
|
||||
$months = ($months == 0) ? '' : $months.'M ';
|
||||
$weeks = ($weeks == 0) ? '' : $weeks.'W ';
|
||||
$days = ($days == 0) ? '' : $days.'D ';
|
||||
$hours = ($hours == 0) ? '' : $hours.'h ';
|
||||
$minutes = ($minutes == 0) ? '' : $minutes.'m ';
|
||||
$seconds = ($seconds == 0) ? '' : $seconds.'s';
|
||||
$years = ($years == 0) ? '' : $years.trans('common.abbrev-years');
|
||||
$months = ($months == 0) ? '' : $months.trans('common.abbrev-months');
|
||||
$weeks = ($weeks == 0) ? '' : $weeks.trans('common.abbrev-weeks');
|
||||
$days = ($days == 0) ? '' : $days.trans('common.abbrev-days');
|
||||
$hours = ($hours == 0) ? '' : $hours.trans('common.abbrev-hours');
|
||||
$minutes = ($minutes == 0) ? '' : $minutes.trans('common.abbrev-minutes');
|
||||
$seconds = ($seconds == 0) ? '' : $seconds.trans('common.abbrev-seconds');
|
||||
|
||||
return $years.$months.$weeks.$days.$hours.$minutes.$seconds;
|
||||
}
|
||||
@@ -116,7 +120,7 @@ class StringHelper
|
||||
/**
|
||||
* @method timeElapsed
|
||||
*
|
||||
* @param $seconds time in bigInt
|
||||
* @param time $seconds in bigInt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -156,13 +160,13 @@ class StringHelper
|
||||
$minutes++;
|
||||
$seconds -= 60;
|
||||
}
|
||||
$years = ($years == 0) ? '' : $years.'Y ';
|
||||
$months = ($months == 0) ? '' : $months.'M ';
|
||||
$weeks = ($weeks == 0) ? '' : $weeks.'W ';
|
||||
$days = ($days == 0) ? '' : $days.'D ';
|
||||
$hours = ($hours == 0) ? '' : $hours.'h ';
|
||||
$minutes = ($minutes == 0) ? '' : $minutes.'m ';
|
||||
$seconds = ($seconds == 0) ? '' : $seconds.'s';
|
||||
$years = ($years == 0) ? '' : $years.trans('common.abbrev-years');
|
||||
$months = ($months == 0) ? '' : $months.trans('common.abbrev-months');
|
||||
$weeks = ($weeks == 0) ? '' : $weeks.trans('common.abbrev-weeks');
|
||||
$days = ($days == 0) ? '' : $days.trans('common.abbrev-days');
|
||||
$hours = ($hours == 0) ? '' : $hours.trans('common.abbrev-hours');
|
||||
$minutes = ($minutes == 0) ? '' : $minutes.trans('common.abbrev-minutes');
|
||||
$seconds = ($seconds == 0) ? '' : $seconds.trans('common.abbrev-seconds');
|
||||
|
||||
return $years.$months.$weeks.$days.$hours.$minutes.$seconds;
|
||||
}
|
||||
|
||||
@@ -98,13 +98,13 @@ class TorrentHelper
|
||||
$appname = config('app.name');
|
||||
$bot = new IRCAnnounceBot();
|
||||
if ($anon == 0) {
|
||||
$bot->message('#announce', '['.$appname.'] User '.$username.' has uploaded '.$torrent->name.' grab it now!');
|
||||
$bot->message('#announce', '[Category: '.$torrent->category->name.'] [Type: '.$torrent->type.'] [Size:'.$torrent->getSize().']');
|
||||
$bot->message('#announce', "[Link: {$appurl}/torrents/".$slug.'.'.$id.']');
|
||||
$bot->message(config('irc-bot.channels'), '['.$appname.'] User '.$username.' has uploaded '.$torrent->name.' grab it now!');
|
||||
$bot->message(config('irc-bot.channels'), '[Category: '.$torrent->category->name.'] [Type: '.$torrent->type.'] [Size:'.$torrent->getSize().']');
|
||||
$bot->message(config('irc-bot.channels'), "[Link: {$appurl}/torrents/".$slug.'.'.$id.']');
|
||||
} else {
|
||||
$bot->message('#announce', '['.$appname.'] An anonymous user has uploaded '.$torrent->name.' grab it now!');
|
||||
$bot->message('#announce', '[Category: '.$torrent->category->name.'] [Type: '.$torrent->type.'] [Size: '.$torrent->getSize().']');
|
||||
$bot->message('#announce', "[Link: {$appurl}/torrents/".$slug.'.'.$id.']');
|
||||
$bot->message(config('irc-bot.channels'), '['.$appname.'] An anonymous user has uploaded '.$torrent->name.' grab it now!');
|
||||
$bot->message(config('irc-bot.channels'), '[Category: '.$torrent->category->name.'] [Type: '.$torrent->type.'] [Size: '.$torrent->getSize().']');
|
||||
$bot->message(config('irc-bot.channels'), "[Link: {$appurl}/torrents/".$slug.'.'.$id.']');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,8 @@
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Services;
|
||||
namespace App\Helpers;
|
||||
|
||||
/**
|
||||
* Various tools for torrents.
|
||||
*/
|
||||
class TorrentTools
|
||||
{
|
||||
/**
|
||||
@@ -30,40 +27,43 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Moves and decodes the torrent.
|
||||
* @param $torrentFile
|
||||
* @return array|int|string|void
|
||||
*/
|
||||
public static function moveAndDecode($torrentFile)
|
||||
public static function normalizeTorrent($torrentFile)
|
||||
{
|
||||
self::$decodedTorrent = Bencode::bdecode_file($torrentFile);
|
||||
$result = Bencode::bdecode_file($torrentFile);
|
||||
// The PID will be set if an user downloads the torrent, but for
|
||||
// security purposes it's better to overwrite the user-provided
|
||||
// announce URL.
|
||||
$announce = config('app.url');
|
||||
$announce .= '/announce/PID';
|
||||
self::$decodedTorrent['announce'] = $announce;
|
||||
self::$decodedTorrent['info']['source'] = config('torrent.source');
|
||||
self::$decodedTorrent['info']['private'] = 1;
|
||||
$result['announce'] = $announce;
|
||||
$result['info']['source'] = config('torrent.source');
|
||||
$result['info']['private'] = 1;
|
||||
$created_by = config('torrent.created_by', null);
|
||||
$created_by_append = config('torrent.created_by_append', false);
|
||||
if ($created_by !== null) {
|
||||
if ($created_by_append && array_key_exists('created by', self::$decodedTorrent)) {
|
||||
$c = self::$decodedTorrent['created by'];
|
||||
if ($created_by_append && array_key_exists('created by', $result)) {
|
||||
$c = $result['created by'];
|
||||
$c = trim($c, '. ');
|
||||
$c .= '. '.$created_by;
|
||||
$created_by = $c;
|
||||
}
|
||||
self::$decodedTorrent['created by'] = $created_by;
|
||||
$result['created by'] = $created_by;
|
||||
}
|
||||
$comment = config('torrent.comment', null);
|
||||
if ($comment !== null) {
|
||||
self::$decodedTorrent['comment'] = $comment;
|
||||
$result['comment'] = $comment;
|
||||
}
|
||||
$encoded = Bencode::bencode(self::$decodedTorrent);
|
||||
self::$fileName = uniqid().'.torrent'; // Generate a unique name
|
||||
file_put_contents(getcwd().'/files/torrents/'.self::$fileName, $encoded); // Create torrent
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of files in the torrent.
|
||||
* @param $decodedTorrent
|
||||
* @return int
|
||||
*/
|
||||
public static function getFileCount($decodedTorrent)
|
||||
{
|
||||
@@ -77,6 +77,8 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Returns the size of the torrent files.
|
||||
* @param $decodedTorrent
|
||||
* @return int|mixed
|
||||
*/
|
||||
public static function getTorrentSize($decodedTorrent)
|
||||
{
|
||||
@@ -97,6 +99,8 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Returns the torrent file list.
|
||||
* @param $decodedTorrent
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getTorrentFiles($decodedTorrent)
|
||||
{
|
||||
@@ -125,6 +129,8 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Returns the sha1 (hash) of the torrent.
|
||||
* @param $decodedTorrent
|
||||
* @return string
|
||||
*/
|
||||
public static function getTorrentHash($decodedTorrent)
|
||||
{
|
||||
@@ -133,6 +139,8 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Returns the number of the torrent file.
|
||||
* @param $decodedTorrent
|
||||
* @return int
|
||||
*/
|
||||
public static function getTorrentFileCount($decodedTorrent)
|
||||
{
|
||||
@@ -145,6 +153,8 @@ class TorrentTools
|
||||
|
||||
/**
|
||||
* Returns the NFO.
|
||||
* @param $inputFile
|
||||
* @return false|string|null
|
||||
*/
|
||||
public static function getNfo($inputFile)
|
||||
{
|
||||
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright 2006-2014, Miles Johnson - http://milesj.me
|
||||
* @license https://github.com/milesj/decoda/blob/master/license.md
|
||||
*
|
||||
* @link http://milesj.me/code/php/decoda
|
||||
*/
|
||||
|
||||
namespace App\Hook;
|
||||
|
||||
use Decoda\Hook\AbstractHook;
|
||||
|
||||
/**
|
||||
* Converts URLs and emails (not wrapped in tags) into clickable links.
|
||||
*/
|
||||
class ClickableHook extends AbstractHook
|
||||
{
|
||||
/**
|
||||
* Matches a link or an email, and converts it to an anchor tag.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function beforeParse($content)
|
||||
{
|
||||
$parser = $this->getParser();
|
||||
|
||||
// To make sure we won't parse links inside [url] or [img] tags, we'll first replace all urls/imgs with uniqids
|
||||
// and keep them in this array, and restore them at the end, after parsing
|
||||
$ignoredStrings = [];
|
||||
|
||||
// The tags we won't touch
|
||||
// For example, neither [url="http://www.example.com"] nor [img]http://www.example.com[/img] will be replaced.
|
||||
$ignoredTags = ['url', 'link', 'img', 'image'];
|
||||
|
||||
$i = 0;
|
||||
foreach ($ignoredTags as $tag) {
|
||||
if (preg_match_all(sprintf('/\[%s[\s=\]].*?\[\/%s\]/is', $tag, $tag), $content, $matches, PREG_SET_ORDER)) {
|
||||
$matches = array_unique(array_map(function ($x) {
|
||||
return $x[0];
|
||||
}, $matches));
|
||||
|
||||
foreach ($matches as $val) {
|
||||
$uniqid = uniqid($i++);
|
||||
|
||||
$ignoredStrings[$uniqid] = $val;
|
||||
$content = str_replace($val, $uniqid, $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($parser->hasFilter('Url')) {
|
||||
$protocols = $parser->getFilter('Url')->getConfig('protocols');
|
||||
$chars = preg_quote('-_=+|\;:&?/[]%,.!@#$*(){}"\'', '/');
|
||||
$split_char = "<>[] \n";
|
||||
$split_chars = [];
|
||||
$result = [];
|
||||
|
||||
$length = strlen($content);
|
||||
$split = [];
|
||||
$current = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if (strpos($split_char, $content[$i]) !== false) {
|
||||
array_push($split_chars, $content[$i]);
|
||||
array_push($split, $current);
|
||||
$current = '';
|
||||
} else {
|
||||
$current .= $content[$i];
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($current) != 0) {
|
||||
array_push($split, $current);
|
||||
}
|
||||
|
||||
$length = count($split);
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if (filter_var($split[$i], FILTER_VALIDATE_URL)) {
|
||||
$split[$i] = self::_urlCallback($split[$i]);
|
||||
} elseif (preg_match("/www\.[A-z,-]+\.[A-z,-]+/", $split[$i])) {
|
||||
$split[$i] = self::_urlCallback($split[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$split_length = count($split_chars);
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$result .= $split[$i];
|
||||
if ($i < $split_length) {
|
||||
$result .= $split_chars[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$content = $result;
|
||||
}
|
||||
|
||||
// Based on W3C HTML5 spec: https://www.w3.org/TR/html5/forms.html#valid-e-mail-address
|
||||
if ($parser->hasFilter('Email')) {
|
||||
$pattern = '(:\/\/[\w\.\+]+:)?([a-z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*)';
|
||||
|
||||
$content = preg_replace_callback('/'.$pattern.'/i', [$this, '_emailCallback'], $content);
|
||||
}
|
||||
|
||||
// We restore the tags we ommited
|
||||
foreach ($ignoredStrings as $key => $val) {
|
||||
$content = str_replace($key, $val, $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for email processing.
|
||||
*
|
||||
* @param array $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _emailCallback($matches)
|
||||
{
|
||||
// is like http://user:pass@domain.com ? Then we do not touch it.
|
||||
if ($matches[1]) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
return $this->getParser()->getFilter('Email')->parse([
|
||||
'tag' => 'email',
|
||||
'attributes' => [],
|
||||
], trim($matches[2]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for URL processing.
|
||||
*
|
||||
* @param array $matches
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _urlCallback($match)
|
||||
{
|
||||
return $this->getParser()->getFilter('Url')->parse([
|
||||
'tag' => 'url',
|
||||
'attributes' => [],
|
||||
], trim($match));
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class ChatController extends Controller
|
||||
/* STATUSES */
|
||||
public function statuses()
|
||||
{
|
||||
return response($this->chat->statuses(), 200);
|
||||
return response($this->chat->statuses());
|
||||
}
|
||||
|
||||
/* ECHOES */
|
||||
@@ -101,7 +101,7 @@ class ChatController extends Controller
|
||||
|
||||
public function config()
|
||||
{
|
||||
return response($this->chat->config(), 200);
|
||||
return response($this->chat->config());
|
||||
}
|
||||
|
||||
/* MESSAGES */
|
||||
@@ -357,14 +357,14 @@ class ChatController extends Controller
|
||||
return new ChatMessageResource($message);
|
||||
}
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
}
|
||||
|
||||
public function deleteMessage($id)
|
||||
{
|
||||
$this->chat->deleteMessage($id);
|
||||
|
||||
return response('success', 200);
|
||||
return response('success');
|
||||
}
|
||||
|
||||
public function deleteRoomEcho(Request $request, $user_id)
|
||||
@@ -386,7 +386,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
|
||||
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function deleteTargetEcho(Request $request, $user_id)
|
||||
@@ -401,7 +401,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
|
||||
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function deleteBotEcho(Request $request, $user_id)
|
||||
@@ -416,7 +416,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
|
||||
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function toggleRoomAudible(Request $request, $user_id)
|
||||
@@ -432,7 +432,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
|
||||
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function toggleTargetAudible(Request $request, $user_id)
|
||||
@@ -448,7 +448,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
|
||||
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function toggleBotAudible(Request $request, $user_id)
|
||||
@@ -464,7 +464,7 @@ class ChatController extends Controller
|
||||
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
|
||||
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
/* USERS */
|
||||
@@ -482,7 +482,7 @@ class ChatController extends Controller
|
||||
$user->chatStatus()->associate($status);
|
||||
$user->save();
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function updateUserRoom(Request $request, $id)
|
||||
@@ -520,20 +520,20 @@ class ChatController extends Controller
|
||||
event(new Chatter('echo', $id, UserEchoResource::collection($sender_echoes)));
|
||||
}
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function updateUserTarget(Request $request, $id)
|
||||
{
|
||||
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($id);
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
|
||||
public function updateBotTarget(Request $request, $id)
|
||||
{
|
||||
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($id);
|
||||
|
||||
return response($user, 200);
|
||||
return response($user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,19 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AchievementsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show User Achievements.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$achievements = $user->unlockedAchievements();
|
||||
$locked = $user->lockedAchievements();
|
||||
$pending = $user->inProgressAchievements();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace App\Http\Controllers;
|
||||
use Image;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Album;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Clients\OmdbClient;
|
||||
|
||||
@@ -27,21 +27,14 @@ class AlbumController extends Controller
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* AlbumController Constructor.
|
||||
*
|
||||
* @param OmdbClient $client
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(OmdbClient $client, Toastr $toastr)
|
||||
public function __construct(OmdbClient $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,16 +83,16 @@ class AlbumController extends Controller
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$imdb = starts_with($request->input('imdb'), 'tt') ? $request->input('imdb') : 'tt'.$request->input('imdb');
|
||||
$imdb = Str::startsWith($request->input('imdb'), 'tt') ? $request->input('imdb') : 'tt'.$request->input('imdb');
|
||||
$omdb = $this->client->find(['imdb' => $imdb]);
|
||||
|
||||
if ($omdb === null || $omdb === false) {
|
||||
return redirect()->route('create_album_form')
|
||||
->with($this->toastr->error('Bad IMDB Request!', 'Whoops!', ['options']));
|
||||
->withErrors('Bad IMDB Request!');
|
||||
}
|
||||
|
||||
$album = new Album();
|
||||
$album->user_id = auth()->user()->id;
|
||||
$album->user_id = $request->user()->id;
|
||||
$album->name = $omdb['Title'].' ('.$omdb['Year'].')';
|
||||
$album->description = $request->input('description');
|
||||
$album->imdb = $request->input('imdb');
|
||||
@@ -121,12 +114,12 @@ class AlbumController extends Controller
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('create_album_form')
|
||||
->withInput()
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$album->save();
|
||||
|
||||
return redirect()->route('show_album', ['id' => $album->id])
|
||||
->with($this->toastr->success('Your album has successfully published!', 'Yay!', ['options']));
|
||||
->withSuccess('Your album has successfully published!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,15 +130,15 @@ class AlbumController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$album = Album::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $album->user_id && Carbon::now()->lt($album->created_at->addDay()), 403);
|
||||
$album->delete();
|
||||
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->success('Album has successfully been deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Album has successfully been deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use App\Models\History;
|
||||
use App\Models\Torrent;
|
||||
use App\Services\Bencode;
|
||||
use App\Helpers\Bencode;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\FreeleechToken;
|
||||
use App\Models\PersonalFreeleech;
|
||||
@@ -29,58 +29,82 @@ class AnnounceController extends Controller
|
||||
/**
|
||||
* Announce Code.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $passkey
|
||||
*
|
||||
* @return Bencode response for the torrent client
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function announce(Request $request, $passkey)
|
||||
{
|
||||
$this->checkRequestType();
|
||||
// Check Announce Request Method
|
||||
$method = $request->method();
|
||||
if (! $request->isMethod('get')) {
|
||||
info('Announce Request Method Was Not GET');
|
||||
|
||||
$agent = $request->server('HTTP_USER_AGENT') ?: 'Unknown';
|
||||
return response(Bencode::bencode(['failure reason' => 'Invalid Request Type: Client Request Was Not A HTTP GET.']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
$this->checkBlacklist($agent);
|
||||
// Request Agent Information
|
||||
$agent = $request->server('HTTP_USER_AGENT');
|
||||
|
||||
// Blacklist
|
||||
if (config('client-blacklist.enabled') == true) {
|
||||
// Check If Browser Is Blacklisted
|
||||
$blockedBrowsers = config('client-blacklist.browsers');
|
||||
if (in_array($agent, $blockedBrowsers)) {
|
||||
abort(405, 'What Are You Trying To Do?');
|
||||
die();
|
||||
}
|
||||
|
||||
// Check If Client Is Blacklisted
|
||||
$blockedClients = config('client-blacklist.clients');
|
||||
if (in_array($agent, $blockedClients)) {
|
||||
//info('Blacklist Client Attempted To Connect To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'The Client You Are Trying To Use Has Been Blacklisted']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
}
|
||||
|
||||
// If Passkey Is Not Provided Return Error to Client
|
||||
if ($passkey == null) {
|
||||
//info('Client Attempted To Connect To Announce Without A Passkey');
|
||||
return response(Bencode::bencode(['failure reason' => 'Please Call Passkey']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Please Call Passkey']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Infohash Is Not Provided Return Error to Client
|
||||
if (! $request->has('info_hash')) {
|
||||
//info('Client Attempted To Connect To Announce Without A Infohash');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing info_hash']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing info_hash']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Peerid Is Not Provided Return Error to Client
|
||||
if (! $request->has('peer_id')) {
|
||||
//info('Client Attempted To Connect To Announce Without A Peerid');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing peer_id']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing peer_id']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Port Is Not Provided Return Error to Client
|
||||
if (! $request->has('port')) {
|
||||
//info('Client Attempted To Connect To Announce Without A Specified Port');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing port']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing port']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If "Left" Is Not Provided Return Error to Client
|
||||
if (! $request->has('left')) {
|
||||
//info('Client Attempted To Connect To Announce Without Supplying Any "Left" Information');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing left']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing left']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If "Upload" Is Not Provided Return Error to Client
|
||||
if (! $request->has('uploaded')) {
|
||||
//info('Client Attempted To Connect To Announce Without Supplying Any "Upload" Information');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing upload']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing upload']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If "Download" Is Not Provided Return Error to Client
|
||||
if (! $request->has('downloaded')) {
|
||||
//info('Client Attempted To Connect To Announce Without Supplying Any "Download" Information');
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing download']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Missing download']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// Check Passkey Against Users Table
|
||||
@@ -89,35 +113,35 @@ class AnnounceController extends Controller
|
||||
// If Passkey Doesn't Exist Return Error to Client
|
||||
if (! $user) {
|
||||
//info('Client Attempted To Connect To Announce With A Invalid Passkey');
|
||||
return response(Bencode::bencode(['failure reason' => 'Passkey is invalid']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Passkey is invalid']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
|
||||
// If User Is Banned Return Error to Client
|
||||
if ($user->group->id == $bannedGroup->id) {
|
||||
//info('A Banned User (' . $user->username . ') Attempted To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'You are no longer welcome here']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'You are no longer welcome here']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If User Is Disabled Return Error to Client
|
||||
if ($user->group->id == $disabledGroup->id) {
|
||||
//info('A Disabled User (' . $user->username . ') Attempted To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is disabled. Please login.']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is disabled. Please login.']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If User Account Is Unactivated Return Error to Client
|
||||
if ($user->active == 0) {
|
||||
//info('A Unactivated User (' . $user->username . ') Attempted To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is not activated']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is not activated']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If User Is Validating Return Error to Client
|
||||
if ($user->group->id == $validatingGroup->id) {
|
||||
//info('A Validating User (' . $user->username . ') Attempted To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is still validating']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Your account is still validating']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// Standard Information Fields
|
||||
@@ -144,19 +168,19 @@ class AnnounceController extends Controller
|
||||
// If User Download Rights Are Disabled Return Error to Client
|
||||
if ($user->can_download == 0 && $left != 0) {
|
||||
//info('A User With Revoked Download Privileges Attempted To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'You download privileges are Revoked']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'You download privileges are Revoked']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If User Client Is Sending Negative Values Return Error to Client
|
||||
if ($uploaded < 0 || $downloaded < 0 || $left < 0) {
|
||||
//info('Client Attempted To Send Data With A Negative Value');
|
||||
return response(Bencode::bencode(['failure reason' => 'Data from client is a negative value']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Data from client is a negative value']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If User Client Does Not Support Compact Return Error to Client
|
||||
if (! $compact) {
|
||||
//info('Client Attempted To Connect To Announce But Doesn't Support Compact');
|
||||
return response(Bencode::bencode(['failure reason' => "Your client doesn't support compact, please update your client"]), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => "Your client doesn't support compact, please update your client"]))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// Check Info Hash Against Torrents Table
|
||||
@@ -169,19 +193,25 @@ class AnnounceController extends Controller
|
||||
// If Torrent Doesnt Exsist Return Error to Client
|
||||
if (! $torrent || $torrent->id < 0) {
|
||||
//info('Client Attempted To Connect To Announce But The Torrent Doesn't Exist Using Hash ' . $info_hash);
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent not found']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent not found']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Torrent Is Pending Moderation Return Error to Client
|
||||
if ($torrent->status == 0) {
|
||||
//info('Client Attempted To Connect To Announce But The Torrent Is Pending Moderation');
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent is still pending moderation']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent is still pending moderation']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Torrent Is Rejected Return Error to Client
|
||||
if ($torrent->status == 2) {
|
||||
//info('Client Attempted To Connect To Announce But The Torrent Is Rejected');
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent has been rejected']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent has been rejected']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// If Torrent Is Postponed Return Error to Client
|
||||
if ($torrent->status == 2) {
|
||||
//info('Client Attempted To Connect To Announce But The Torrent Is Postponed');
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent has been postponed']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
$peers = $torrent->peers->where('info_hash', '=', $info_hash)->take(100)->toArray();
|
||||
@@ -192,7 +222,7 @@ class AnnounceController extends Controller
|
||||
// If Users Peer Count On A Single Torrent Is Greater Than X Return Error to Client
|
||||
if ($connections > config('announce.rate_limit')) {
|
||||
//info('Client Attempted To Connect To Announce But Has Hit Rate Limits');
|
||||
return response(Bencode::bencode(['failure reason' => 'You have reached the rate limit']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'You have reached the rate limit']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
// Get The Current Peer
|
||||
@@ -203,7 +233,7 @@ class AnnounceController extends Controller
|
||||
|
||||
// Creates a new client if not existing
|
||||
if (! $client && $event == 'completed') {
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent is complete but no record found.']), 200, ['Content-Type' => 'text/plain']);
|
||||
return response(Bencode::bencode(['failure reason' => 'Torrent is complete but no record found.']))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
} elseif (! $client) {
|
||||
if ($uploaded > 0 || $downloaded > 0) {
|
||||
$ghost = true;
|
||||
@@ -252,6 +282,7 @@ class AnnounceController extends Controller
|
||||
$history->agent = $agent;
|
||||
$history->active = 1;
|
||||
$history->seeder = ($left == 0) ? true : false;
|
||||
$history->immune = ($user->group->is_immune == 1) ? true : false;
|
||||
$history->uploaded += 0;
|
||||
$history->actual_uploaded += 0;
|
||||
$history->client_uploaded = $real_uploaded;
|
||||
@@ -328,6 +359,7 @@ class AnnounceController extends Controller
|
||||
$history->agent = $agent;
|
||||
$history->active = 0;
|
||||
$history->seeder = ($left == 0) ? true : false;
|
||||
$history->immune = ($user->group->is_immune == 1) ? true : false;
|
||||
$history->uploaded += $mod_uploaded;
|
||||
$history->actual_uploaded += $uploaded;
|
||||
$history->client_uploaded = 0;
|
||||
@@ -418,55 +450,68 @@ class AnnounceController extends Controller
|
||||
$torrent->save();
|
||||
|
||||
$res = [];
|
||||
$res['interval'] = (60 * 45);
|
||||
$res['min interval'] = (60 * 30);
|
||||
$min = 2400; // 40 Minutes
|
||||
$max = 3600; // 60 Minutes
|
||||
$res['interval'] = rand($min, $max);
|
||||
$res['min interval'] = 1800; // 30 Minutes
|
||||
$res['tracker_id'] = $md5_peer_id; // A string that the client should send back on its next announcements.
|
||||
$res['complete'] = $torrent->seeders;
|
||||
$res['incomplete'] = $torrent->leechers;
|
||||
$res['peers'] = $this->givePeers($peers, $compact, $no_peer_id);
|
||||
$res['peers6'] = $this->givePeers6($peers, $compact, $no_peer_id);
|
||||
|
||||
return response(Bencode::bencode($res), 200, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
private function checkBlacklist($client)
|
||||
{
|
||||
// Check If Browser Is Blacklisted
|
||||
$blockedBrowsers = config('client-blacklist.browsers', []);
|
||||
foreach ($blockedBrowsers as $b) {
|
||||
if ($b == $client) {
|
||||
//info('Blacklist Browser Attempted To Connect To Announce');
|
||||
abort(405, 'You Cannot Access This Through A Browser Bro!');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Check If Client Is Blacklisted
|
||||
$blockedClients = config('client-blacklist.clients', []);
|
||||
foreach ($blockedClients as $blocked) {
|
||||
if ($blocked == $client) {
|
||||
//info('Blacklist Client Attempted To Connect To Announce');
|
||||
return response(Bencode::bencode(['failure reason' => 'The Client You Are Trying To Use Has Been Blacklisted']), 200, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkRequestType()
|
||||
{
|
||||
// Check Announce Request Method
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
|
||||
info('Announce Request Method Was Not GET');
|
||||
|
||||
return response(Bencode::bencode(['failure reason' => 'Invalid Request Type: Client Request Was Not A HTTP GET.']), 200, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
return response(Bencode::bencode($res))->withHeaders(['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $peers
|
||||
* @param $compact
|
||||
* @param $no_peer_id
|
||||
* @return string
|
||||
*/
|
||||
private function givePeers($peers, $compact, $no_peer_id)
|
||||
{
|
||||
if ($compact) {
|
||||
$pcomp = '';
|
||||
foreach ($peers as &$p) {
|
||||
if (isset($p['ip']) && isset($p['port'])) {
|
||||
$pcomp .= pack('Nn', ip2long($p['ip']), (int) $p['port']);
|
||||
if (filter_var($p['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
$pcomp .= inet_pton($p['ip']);
|
||||
$pcomp .= pack('n', (int) $p['port']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pcomp;
|
||||
} elseif ($no_peer_id) {
|
||||
foreach ($peers as &$p) {
|
||||
unset($p['peer_id']);
|
||||
}
|
||||
|
||||
return $peers;
|
||||
} else {
|
||||
return $peers;
|
||||
}
|
||||
|
||||
return $peers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $peers
|
||||
* @param $compact
|
||||
* @param $no_peer_id
|
||||
* @return string
|
||||
*/
|
||||
private function givePeers6($peers, $compact, $no_peer_id)
|
||||
{
|
||||
if ($compact) {
|
||||
$pcomp = '';
|
||||
foreach ($peers as &$p) {
|
||||
if (isset($p['ip']) && isset($p['port'])) {
|
||||
if (filter_var($p['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$pcomp .= inet_pton($p['ip']);
|
||||
$pcomp .= pack('n', (int) $p['port']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ class ArticleController extends Controller
|
||||
/**
|
||||
* Show A Article.
|
||||
*
|
||||
* @param $slug
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function post($slug, $id)
|
||||
|
||||
Executable → Regular
+6
-20
@@ -14,31 +14,15 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\Group;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Models\UserActivation;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ActivationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ActivationController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
public function activate($token)
|
||||
{
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$memberGroup = Group::where('slug', '=', 'user')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
|
||||
$activation = UserActivation::with('user')->where('token', '=', $token)->firstOrFail();
|
||||
if ($activation->user->id && $activation->user->group->id != $bannedGroup->id) {
|
||||
@@ -56,9 +40,11 @@ class ActivationController extends Controller
|
||||
|
||||
$activation->delete();
|
||||
|
||||
return redirect()->route('login')->with($this->toastr->success('Account Confirmed! You May Now Login!', 'Yay!', ['options']));
|
||||
return redirect()->route('login')
|
||||
->withSuccess(trans('auth.activation-success'));
|
||||
} else {
|
||||
return redirect()->route('login')->with($this->toastr->error('Banned or Invalid Token Or Account Already Confirmed!', 'Whoops!', ['options']));
|
||||
return redirect()->route('login')
|
||||
->withErrors(trans('auth.activation-error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\Application;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ApplicationUrlProof;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -21,21 +20,6 @@ use App\Models\ApplicationImageProof;
|
||||
|
||||
class ApplicationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ApplicationController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Application Add Form.
|
||||
*
|
||||
@@ -60,40 +44,79 @@ class ApplicationController extends Controller
|
||||
$application->referrer = $request->input('referrer');
|
||||
|
||||
if (config('email-white-blacklist.enabled') === 'allow') {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:allow',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
if (config('captcha.enabled') == false) {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:allow',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:allow',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
}
|
||||
} elseif (config('email-white-blacklist.enabled') === 'block') {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:block',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
if (config('captcha.enabled') == false) {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:block',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications|email_list:block',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
if (config('captcha.enabled') == false) {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
]);
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'type' => 'required',
|
||||
'email' => 'required|email|unique:invites|unique:users|unique:applications',
|
||||
'referrer' => 'required',
|
||||
'images.*' => 'filled',
|
||||
'images' => 'min:2',
|
||||
'links.*' => 'filled',
|
||||
'links' => 'min:2',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('application.create')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$application->save();
|
||||
|
||||
@@ -110,7 +133,7 @@ class ApplicationController extends Controller
|
||||
$application->urlProofs()->saveMany($urls);
|
||||
|
||||
return redirect()->route('login')
|
||||
->with($this->toastr->success('Your Application Has Been Submitted. You will receive a email soon!', 'Yay!', ['options']));
|
||||
->withSuccess(trans('application-submitted'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
@@ -25,4 +26,16 @@ class ForgotPasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
protected function validateEmail(Request $request)
|
||||
{
|
||||
if (config('captcha.enabled') == false) {
|
||||
$request->validate(['email' => 'required|email']);
|
||||
} else {
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,28 +14,12 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Notifications\UsernameReminder;
|
||||
|
||||
class ForgotUsernameController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ForgotUsernameController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgot Username Form.
|
||||
*
|
||||
@@ -49,32 +33,40 @@ class ForgotUsernameController extends Controller
|
||||
/**
|
||||
* Send Username Reminder.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function sendUsernameReminder(Request $request)
|
||||
{
|
||||
$email = $request->get('email');
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'email' => 'required',
|
||||
]);
|
||||
if (config('captcha.enabled') == false) {
|
||||
$v = validator($request->all(), [
|
||||
'email' => 'required',
|
||||
]);
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'email' => 'required',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('username.request')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user = User::where('email', '=', $email)->first();
|
||||
|
||||
if (empty($user)) {
|
||||
return redirect()->route('username.request')
|
||||
->with($this->toastr->error('We could not find this email in our system!', 'Whoops!', ['options']));
|
||||
->withErrors(trans('email.no-email-found'));
|
||||
}
|
||||
|
||||
//send username reminder notification
|
||||
$user->notify(new UsernameReminder());
|
||||
|
||||
return redirect()->route('login')
|
||||
->with($this->toastr->success('Your username has been sent to your email address!', 'Yay!', ['options']));
|
||||
->withSuccess(trans('email.username-sent'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+26
-31
@@ -14,8 +14,6 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\Group;
|
||||
use App\Rules\Captcha;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
@@ -28,25 +26,17 @@ class LoginController extends Controller
|
||||
protected $redirectTo = '/';
|
||||
|
||||
// Max Attempts Until Lockout
|
||||
public $maxAttempts = 5;
|
||||
public $maxAttempts = 3;
|
||||
|
||||
// Minutes Lockout
|
||||
public $decayMinutes = 60;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* LoginController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest', ['except' => 'logout']);
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
public function username()
|
||||
@@ -65,29 +55,29 @@ class LoginController extends Controller
|
||||
$this->validate($request, [
|
||||
$this->username() => 'required|string',
|
||||
'password' => 'required|string',
|
||||
'g-recaptcha-response' => new Captcha(),
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
} else {
|
||||
$this->validate($request, [
|
||||
$this->username() => 'required|string',
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->validate($request, [
|
||||
$this->username() => 'required|string',
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function authenticated(Request $request, $user)
|
||||
{
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$disabledGroup = Group::where('slug', '=', 'disabled')->select('id')->first();
|
||||
$memberGroup = Group::where('slug', '=', 'user')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
|
||||
if ($user->active == 0 || $user->group_id == $validatingGroup->id) {
|
||||
$this->guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
return redirect()->route('login')
|
||||
->with($this->toastr->error('This account has not been activated and is still in validating group. Please check your email for activation link. If you did not receive the activation code, please click "forgot password" and complete the steps.', 'Whoops!', ['options']));
|
||||
->withErrors(trans('auth.not-activated'));
|
||||
}
|
||||
|
||||
if ($user->group_id == $bannedGroup->id) {
|
||||
@@ -95,7 +85,7 @@ class LoginController extends Controller
|
||||
$request->session()->invalidate();
|
||||
|
||||
return redirect()->route('login')
|
||||
->with($this->toastr->error('This account is Banned!', 'Whoops!', ['options']));
|
||||
->withErrors(trans('auth.banned'));
|
||||
}
|
||||
|
||||
if ($user->group_id == $disabledGroup->id) {
|
||||
@@ -109,11 +99,11 @@ class LoginController extends Controller
|
||||
$user->disabled_at = null;
|
||||
$user->save();
|
||||
|
||||
return redirect('/')
|
||||
->with($this->toastr->info('Welcome Back! Your Account Is No Longer Disabled!', $user->username, ['options']));
|
||||
return redirect()->to('/')
|
||||
->withSuccess(trans('auth.welcome-restore'));
|
||||
}
|
||||
|
||||
if (auth()->viaRemember() && auth()->user()->group_id == $disabledGroup->id) {
|
||||
if (auth()->viaRemember() && $user->group_id == $disabledGroup->id) {
|
||||
$user->group_id = $memberGroup->id;
|
||||
$user->can_upload = 1;
|
||||
$user->can_download = 1;
|
||||
@@ -124,11 +114,16 @@ class LoginController extends Controller
|
||||
$user->disabled_at = null;
|
||||
$user->save();
|
||||
|
||||
return redirect('/')
|
||||
->with($this->toastr->info('Welcome Back! Your Account Is No Longer Disabled!', $user->username, ['options']));
|
||||
return redirect()->to('/')
|
||||
->withSuccess(trans('auth.welcome-restore'));
|
||||
}
|
||||
|
||||
return redirect('/')
|
||||
->with($this->toastr->info('Welcome Back!', $user->username, ['options']));
|
||||
if ($user->read_rules == 0) {
|
||||
return redirect()->to(config('other.rules_url'))
|
||||
->withWarning(trans('auth.require-rules'));
|
||||
}
|
||||
|
||||
return redirect()->to('/')
|
||||
->withSuccess(trans('auth.welcome'));
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+21
-23
@@ -17,9 +17,8 @@ use Carbon\Carbon;
|
||||
use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use App\Models\Invite;
|
||||
use App\Rules\Captcha;
|
||||
use App\Models\UserPrivacy;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PrivateMessage;
|
||||
use App\Models\UserActivation;
|
||||
@@ -36,21 +35,14 @@ class RegisterController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* RegisterController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,10 +54,16 @@ class RegisterController extends Controller
|
||||
*/
|
||||
public function registrationForm($code = null)
|
||||
{
|
||||
// Make sure open reg is off and invite code is present
|
||||
// Make sure open reg is off, invite code is not present and application signups enabled
|
||||
if ($code === 'null' && config('other.invite-only') == 1 && config('other.application_signups') == true) {
|
||||
return redirect()->route('application.create')
|
||||
->withInfo(trans('auth.allow-invite-appl'));
|
||||
}
|
||||
|
||||
// Make sure open reg is off and invite code is not present
|
||||
if ($code === 'null' && config('other.invite-only') == 1) {
|
||||
return view('auth.login')
|
||||
->with($this->toastr->error('Open Reg Closed! You Must Be Invited To Register! You Have Been Redirected To Login Page!', 'Whoops!', ['options']));
|
||||
return redirect()->route('login')
|
||||
->withWarning(trans('auth.allow-invite'));
|
||||
}
|
||||
|
||||
return view('auth.register', ['code' => $code]);
|
||||
@@ -76,11 +74,11 @@ class RegisterController extends Controller
|
||||
// Make sure open reg is off and invite code exist and has not been used already
|
||||
$key = Invite::where('code', '=', $code)->first();
|
||||
if (config('other.invite-only') == 1 && (! $key || $key->accepted_by !== null)) {
|
||||
return view('auth.register', ['code' => $code])
|
||||
->with($this->toastr->error('Invalid or Expired Invite Key!', 'Whoops!', ['options']));
|
||||
return redirect()->route('registrationForm', ['code' => $code])
|
||||
->withErrors(trans('auth.invalid-key'));
|
||||
}
|
||||
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$user = new User();
|
||||
$user->username = $request->input('username');
|
||||
$user->email = $request->input('email');
|
||||
@@ -98,7 +96,7 @@ class RegisterController extends Controller
|
||||
'username' => 'required|alpha_dash|min:3|max:20|unique:users',
|
||||
'email' => 'required|email|max:255|unique:users|email_list:allow', // Whitelist
|
||||
'password' => 'required|min:8',
|
||||
'g-recaptcha-response' => new Captcha(),
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
} elseif (config('email-white-blacklist.enabled') === 'allow') {
|
||||
$v = validator($request->all(), [
|
||||
@@ -111,7 +109,7 @@ class RegisterController extends Controller
|
||||
'username' => 'required|alpha_dash|min:3|max:20|unique:users',
|
||||
'email' => 'required|email|max:255|unique:users|email_list:block', // Blacklist
|
||||
'password' => 'required|min:8',
|
||||
'g-recaptcha-response' => new Captcha(),
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
} elseif (config('email-white-blacklist.enabled') === 'block') {
|
||||
$v = validator($request->all(), [
|
||||
@@ -124,7 +122,7 @@ class RegisterController extends Controller
|
||||
'username' => 'required|alpha_dash|min:3|max:20|unique:users',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:8',
|
||||
'g-recaptcha-response' => new Captcha(),
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
]);
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
@@ -135,8 +133,8 @@ class RegisterController extends Controller
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('register', ['code' => $code])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('registrationForm', ['code' => $code])
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user->save();
|
||||
|
||||
@@ -158,7 +156,7 @@ class RegisterController extends Controller
|
||||
}
|
||||
|
||||
// Handle The Activation System
|
||||
$token = hash_hmac('sha256', $user->username.$user->email.str_random(16), config('app.key'));
|
||||
$token = hash_hmac('sha256', $user->username.$user->email.Str::random(16), config('app.key'));
|
||||
$activation = new UserActivation();
|
||||
$activation->user_id = $user->id;
|
||||
$activation->token = $token;
|
||||
@@ -195,7 +193,7 @@ class RegisterController extends Controller
|
||||
\LogActivity::addToLog('Member '.$user->username.' has successfully registered to site.');
|
||||
|
||||
return redirect()->route('login')
|
||||
->with($this->toastr->success('Thanks for signing up! Please check your email to Validate your account', 'Yay!', ['options']));
|
||||
->withSuccess(trans('auth.register-thanks'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ class ResetPasswordController extends Controller
|
||||
|
||||
protected function resetPassword($user, $password)
|
||||
{
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$memberGroup = Group::where('slug', '=', 'user')->select('id')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
$user->password = bcrypt($password);
|
||||
$user->remember_token = Str::random(60);
|
||||
|
||||
|
||||
@@ -23,9 +23,13 @@ class TwoStepController extends Controller
|
||||
use TwoStep;
|
||||
|
||||
private $_authCount;
|
||||
|
||||
private $_authStatus;
|
||||
|
||||
private $_twoStepAuth;
|
||||
|
||||
private $_remainingAttempts;
|
||||
|
||||
private $_user;
|
||||
|
||||
/**
|
||||
|
||||
Executable → Regular
+83
-94
@@ -18,7 +18,6 @@ use App\Models\Post;
|
||||
use App\Models\User;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\BonExchange;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notifications\NewBon;
|
||||
use App\Models\PrivateMessage;
|
||||
@@ -36,21 +35,14 @@ class BonusController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* BonusController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,16 +50,16 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function gifts()
|
||||
public function gifts(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$userbon = $user->getSeedbonus();
|
||||
$gifttransactions = BonTransactions::with(['senderObj', 'receiverObj'])->where(function ($query) {
|
||||
$query->where('sender', '=', auth()->user()->id)->orwhere('receiver', '=', auth()->user()->id);
|
||||
$gifttransactions = BonTransactions::with(['senderObj', 'receiverObj'])->where(function ($query) use ($user) {
|
||||
$query->where('sender', '=', $user->id)->orwhere('receiver', '=', $user->id);
|
||||
})->where('name', '=', 'gift')->orderBy('date_actioned', 'DESC')->paginate(25);
|
||||
|
||||
$gifts_sent = BonTransactions::where('sender', '=', auth()->user()->id)->where('name', '=', 'gift')->sum('cost');
|
||||
$gifts_received = BonTransactions::where('receiver', '=', auth()->user()->id)->where('name', '=', 'gift')->sum('cost');
|
||||
$gifts_sent = BonTransactions::where('sender', '=', $user->id)->where('name', '=', 'gift')->sum('cost');
|
||||
$gifts_received = BonTransactions::where('receiver', '=', $user->id)->where('name', '=', 'gift')->sum('cost');
|
||||
|
||||
return view('bonus.gifts', [
|
||||
'user' => $user,
|
||||
@@ -83,16 +75,16 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function tips()
|
||||
public function tips(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$userbon = $user->getSeedbonus();
|
||||
$bontransactions = BonTransactions::with(['senderObj', 'receiverObj'])->where(function ($query) {
|
||||
$query->where('sender', '=', auth()->user()->id)->orwhere('receiver', '=', auth()->user()->id);
|
||||
$bontransactions = BonTransactions::with(['senderObj', 'receiverObj'])->where(function ($query) use ($user) {
|
||||
$query->where('sender', '=', $user->id)->orwhere('receiver', '=', $user->id);
|
||||
})->where('name', '=', 'tip')->orderBy('date_actioned', 'DESC')->paginate(25);
|
||||
|
||||
$tips_sent = BonTransactions::where('sender', '=', auth()->user()->id)->where('name', '=', 'tip')->sum('cost');
|
||||
$tips_received = BonTransactions::where('receiver', '=', auth()->user()->id)->where('name', '=', 'tip')->sum('cost');
|
||||
$tips_sent = BonTransactions::where('sender', '=', $user->id)->where('name', '=', 'tip')->sum('cost');
|
||||
$tips_received = BonTransactions::where('receiver', '=', $user->id)->where('name', '=', 'tip')->sum('cost');
|
||||
|
||||
return view('bonus.tips', [
|
||||
'user' => $user,
|
||||
@@ -108,14 +100,14 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function store()
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$users = User::oldest('username')->get();
|
||||
$userbon = $user->getSeedbonus();
|
||||
$activefl = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
$BonExchange = new BonExchange();
|
||||
$bontransactions = BonTransactions::with('exchange')->where('sender', '=', auth()->user()->id)->where('itemID', '>', 0)->orderBy('date_actioned', 'DESC')->limit(25)->get();
|
||||
$bontransactions = BonTransactions::with('exchange')->where('sender', '=', $user->id)->where('itemID', '>', 0)->orderBy('date_actioned', 'DESC')->limit(25)->get();
|
||||
$uploadOptions = $BonExchange->getUploadOptions();
|
||||
$downloadOptions = $BonExchange->getDownloadOptions();
|
||||
$personalFreeleech = $BonExchange->getPersonalFreeleechOption();
|
||||
@@ -138,14 +130,12 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function gift()
|
||||
public function gift(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$users = User::oldest('username')->get();
|
||||
$user = $request->user();
|
||||
$userbon = $user->getSeedbonus();
|
||||
|
||||
return view('bonus.gift', [
|
||||
'users' => $users,
|
||||
'userbon' => $userbon,
|
||||
]);
|
||||
}
|
||||
@@ -153,37 +143,37 @@ class BonusController extends Controller
|
||||
/**
|
||||
* Show Bonus Earnings System.
|
||||
*
|
||||
* @param string $username
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function bonus($username = '')
|
||||
public function bonus(Request $request, $username = '')
|
||||
{
|
||||
$user = auth()->user();
|
||||
$users = User::oldest('username')->get();
|
||||
$user = $request->user();
|
||||
$userbon = $user->getSeedbonus();
|
||||
|
||||
//Dying Torrent
|
||||
$dying = $this->getDyingCount();
|
||||
$dying = $this->getDyingCount($request);
|
||||
//Legendary Torrents
|
||||
$legendary = $this->getLegendaryCount();
|
||||
$legendary = $this->getLegendaryCount($request);
|
||||
//Old Torrents
|
||||
$old = $this->getOldCount();
|
||||
$old = $this->getOldCount($request);
|
||||
//Large Torrents
|
||||
$huge = $this->getHugeCount();
|
||||
$huge = $this->getHugeCount($request);
|
||||
//Large Torrents
|
||||
$large = $this->getLargeCount();
|
||||
$large = $this->getLargeCount($request);
|
||||
//Everyday Torrents
|
||||
$regular = $this->getRegularCount();
|
||||
$regular = $this->getRegularCount($request);
|
||||
|
||||
//Participant Seeder
|
||||
$participant = $this->getParticipaintSeedCount();
|
||||
$participant = $this->getParticipaintSeedCount($request);
|
||||
//TeamPlayer Seeder
|
||||
$teamplayer = $this->getTeamPlayerSeedCount();
|
||||
$teamplayer = $this->getTeamPlayerSeedCount($request);
|
||||
//Committed Seeder
|
||||
$committed = $this->getCommitedSeedCount();
|
||||
$committed = $this->getCommitedSeedCount($request);
|
||||
//MVP Seeder
|
||||
$mvp = $this->getMVPSeedCount();
|
||||
$mvp = $this->getMVPSeedCount($request);
|
||||
//Legend Seeder
|
||||
$legend = $this->getLegendarySeedCount();
|
||||
$legend = $this->getLegendarySeedCount($request);
|
||||
|
||||
//Total points per hour
|
||||
$total =
|
||||
@@ -198,7 +188,6 @@ class BonusController extends Controller
|
||||
$second = $minute / 60;
|
||||
|
||||
return view('bonus.index', [
|
||||
'users' => $users,
|
||||
'userbon' => $userbon,
|
||||
'dying' => $dying,
|
||||
'legendary' => $legendary,
|
||||
@@ -229,9 +218,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function exchange($id)
|
||||
public function exchange(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$userbon = $user->seedbonus;
|
||||
|
||||
$BonExchange = new BonExchange();
|
||||
@@ -242,18 +231,18 @@ class BonusController extends Controller
|
||||
|
||||
if (! $flag) {
|
||||
return redirect()->route('bonus_store')
|
||||
->with($this->toastr->error('Bonus Exchange Failed!', 'Whoops!', ['options']));
|
||||
->withErrors('Bonus Exchange Failed!');
|
||||
}
|
||||
|
||||
$user->seedbonus -= $itemCost;
|
||||
$user->save();
|
||||
} else {
|
||||
return redirect()->route('bonus_store')
|
||||
->with($this->toastr->error('Bonus Exchange Failed!', 'Whoops!', ['options']));
|
||||
->withErrors('Bonus Exchange Failed!');
|
||||
}
|
||||
|
||||
return redirect()->route('bonus_store')
|
||||
->with($this->toastr->success('Bonus Exchange Successful', 'Yay!', ['options']));
|
||||
->withSuccess('Bonus Exchange Successful');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,7 +317,7 @@ class BonusController extends Controller
|
||||
*/
|
||||
public function sendGift(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'to_username' => 'required|exists:users,username|max:180',
|
||||
@@ -342,11 +331,11 @@ class BonusController extends Controller
|
||||
}
|
||||
|
||||
if ($v->passes()) {
|
||||
$recipient = User::where('username', 'LIKE', $request->input('to_username'))->first();
|
||||
$recipient = User::where('username', '=', $request->input('to_username'))->first();
|
||||
|
||||
if (! $recipient || $recipient->id == $user->id) {
|
||||
return redirect('/bonus/store')
|
||||
->with($this->toastr->error('Unable to find specified user', 'Whoops!', ['options']));
|
||||
return redirect()->to('/bonus/store')
|
||||
->withErrors('Unable to find specified user');
|
||||
}
|
||||
|
||||
$value = $request->input('bonus_points');
|
||||
@@ -367,7 +356,7 @@ class BonusController extends Controller
|
||||
$transaction->save();
|
||||
|
||||
if ($user->id != $recipient->id) {
|
||||
if ($recipient->acceptsNotification(auth()->user(), $recipient, 'bon', 'show_bon_gift')) {
|
||||
if ($recipient->acceptsNotification($request->user(), $recipient, 'bon', 'show_bon_gift')) {
|
||||
$recipient->notify(new NewBon('gift', $user->username, $transaction));
|
||||
}
|
||||
}
|
||||
@@ -381,11 +370,11 @@ class BonusController extends Controller
|
||||
|
||||
if ($dest == 'profile') {
|
||||
return redirect()->route('profile', ['username' => $recipient->slug, 'id'=> $recipient->id])
|
||||
->with($this->toastr->success('Gift Sent', 'Yay!', ['options']));
|
||||
->withSuccess('Gift Sent');
|
||||
}
|
||||
|
||||
return redirect()->route('bonus_gift')
|
||||
->with($this->toastr->success('Gift Sent', 'Yay!', ['options']));
|
||||
->withSuccess('Gift Sent');
|
||||
} else {
|
||||
$v = validator($request->all(), [
|
||||
'to_username' => 'required|exists:users,username|max:180',
|
||||
@@ -395,22 +384,22 @@ class BonusController extends Controller
|
||||
$recipient = User::where('username', 'LIKE', $request->input('to_username'))->first();
|
||||
|
||||
if (! $recipient || $recipient->id == $user->id) {
|
||||
return redirect('/bonus/gift')
|
||||
->with($this->toastr->error('Unable to find specified user', 'Whoops!', ['options']));
|
||||
return redirect()->to('/bonus/gift')
|
||||
->withErrors('Unable to find specified user');
|
||||
}
|
||||
|
||||
if ($dest == 'profile') {
|
||||
return redirect()->route('profile', ['username' => $recipient->slug, 'id'=> $recipient->id])
|
||||
->with($this->toastr->error('You Must Enter An Amount And Message!', 'Whoops!', ['options']));
|
||||
->withErrors('You Must Enter An Amount And Message!');
|
||||
}
|
||||
|
||||
return redirect()->route('bonus_gift')
|
||||
->with($this->toastr->error('You Must Enter An Amount And Message!', 'Whoops!', ['options']));
|
||||
->withErrors('You Must Enter An Amount And Message!');
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('/bonus/gift')
|
||||
->with($this->toastr->error('Unable to find specified user', 'Whoops!', ['options']));
|
||||
return redirect()->to('/bonus/gift')
|
||||
->withErrors('Unable to find specified user');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,22 +413,22 @@ class BonusController extends Controller
|
||||
*/
|
||||
public function tipUploader(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent = Torrent::withAnyStatus()->findOrFail($id);
|
||||
$uploader = User::where('id', '=', $torrent->user_id)->first();
|
||||
|
||||
$tip_amount = $request->input('tip');
|
||||
if ($tip_amount > $user->seedbonus) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error('Your To Broke To Tip The Uploader!', 'Whoops!', ['options']));
|
||||
->withErrors('Your To Broke To Tip The Uploader!');
|
||||
}
|
||||
if ($user->id == $torrent->user_id) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error('You Cannot Tip Yourself!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Tip Yourself!');
|
||||
}
|
||||
if ($tip_amount <= 0) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error('You Cannot Tip A Negative Amount!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Tip A Negative Amount!');
|
||||
}
|
||||
$uploader->seedbonus += $tip_amount;
|
||||
$uploader->save();
|
||||
@@ -457,12 +446,12 @@ class BonusController extends Controller
|
||||
$transaction->torrent_id = $torrent->id;
|
||||
$transaction->save();
|
||||
|
||||
if ($uploader->acceptsNotification(auth()->user(), $uploader, 'torrent', 'show_torrent_tip')) {
|
||||
if ($uploader->acceptsNotification($request->user(), $uploader, 'torrent', 'show_torrent_tip')) {
|
||||
$uploader->notify(new NewUploadTip('torrent', $user->username, $tip_amount, $torrent));
|
||||
}
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->success('Your Tip Was Successfully Applied!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Tip Was Successfully Applied!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,7 +465,7 @@ class BonusController extends Controller
|
||||
*/
|
||||
public function tipPoster(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if ($request->has('post') && $request->input('post') > 0) {
|
||||
$p = (int) $request->input('post');
|
||||
@@ -489,15 +478,15 @@ class BonusController extends Controller
|
||||
$tip_amount = $request->input('tip');
|
||||
if ($tip_amount > $user->seedbonus) {
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->error('You Are To Broke To Tip The Poster!', 'Whoops!', ['options']));
|
||||
->withErrors('You Are To Broke To Tip The Poster!');
|
||||
}
|
||||
if ($user->id == $poster->id) {
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->error('You Cannot Tip Yourself!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Tip Yourself!');
|
||||
}
|
||||
if ($tip_amount <= 0) {
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->error('You Cannot Tip A Negative Amount!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Tip A Negative Amount!');
|
||||
}
|
||||
$poster->seedbonus += $tip_amount;
|
||||
$poster->save();
|
||||
@@ -518,7 +507,7 @@ class BonusController extends Controller
|
||||
$poster->notify(new NewPostTip('forum', $user->username, $tip_amount, $post));
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->success('Your Tip Was Successfully Applied!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Tip Was Successfully Applied!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,9 +515,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDyingCount()
|
||||
public function getDyingCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -545,9 +534,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLegendaryCount()
|
||||
public function getLegendaryCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -564,9 +553,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getOldCount()
|
||||
public function getOldCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -584,9 +573,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHugeCount()
|
||||
public function getHugeCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -602,9 +591,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLargeCount()
|
||||
public function getLargeCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -621,9 +610,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRegularCount()
|
||||
public function getRegularCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('peers')
|
||||
->select('peers.hash')->distinct()
|
||||
@@ -640,9 +629,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParticipaintSeedCount()
|
||||
public function getParticipaintSeedCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('history')
|
||||
->select('history.seedtime')->distinct()
|
||||
@@ -659,9 +648,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTeamPlayerSeedCount()
|
||||
public function getTeamPlayerSeedCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('history')
|
||||
->select('history.seedtime')->distinct()
|
||||
@@ -678,9 +667,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCommitedSeedCount()
|
||||
public function getCommitedSeedCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('history')
|
||||
->select('history.seedtime')->distinct()
|
||||
@@ -697,9 +686,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMVPSeedCount()
|
||||
public function getMVPSeedCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('history')
|
||||
->select('history.seedtime')->distinct()
|
||||
@@ -716,9 +705,9 @@ class BonusController extends Controller
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLegendarySeedCount()
|
||||
public function getLegendarySeedCount(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return DB::table('history')
|
||||
->select('history.seedtime')->distinct()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Bookmark;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PersonalFreeleech;
|
||||
|
||||
class BookmarkController extends Controller
|
||||
@@ -23,9 +23,9 @@ class BookmarkController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function bookmarks()
|
||||
public function bookmarks(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
$bookmarks = $user->bookmarks()->paginate(25);
|
||||
|
||||
|
||||
Executable → Regular
+1
-17
@@ -15,27 +15,11 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\Bug;
|
||||
use App\Models\User;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class BugController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* BugController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug Report Form.
|
||||
*
|
||||
@@ -62,6 +46,6 @@ class BugController extends Controller
|
||||
Mail::to($user->email, $user->username)->send(new Bug($input));
|
||||
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->success('Your Bug Was Successfully Sent!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Bug Was Successfully Sent!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Catalog;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\CatalogTorrent;
|
||||
|
||||
class CatalogController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Catalogs.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function catalogs()
|
||||
{
|
||||
$catalogs = Catalog::all();
|
||||
|
||||
return view('catalogs.catalogs', ['catalogs' => $catalogs]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show All Titles In A Catalog.
|
||||
*
|
||||
* @param $slug
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function catalog($slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$catalog = Catalog::findOrFail($id);
|
||||
$records = CatalogTorrent::where('catalog_id', '=', $id)->latest('imdb')->get();
|
||||
|
||||
return view('catalogs.catalog', [
|
||||
'user' => $user,
|
||||
'catalog' => $catalog,
|
||||
'records' => $records,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show All Torrents That Match Catalog Titles.
|
||||
*
|
||||
* @param $imdb
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function torrents($imdb)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$torrents = Torrent::where('imdb', '=', $imdb)->latest('size')->get();
|
||||
|
||||
return view('catalogs.torrents', ['torrents' => $torrents, 'user' => $user]);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PersonalFreeleech;
|
||||
|
||||
class CategoryController extends Controller
|
||||
@@ -39,9 +40,9 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function category($slug, $id)
|
||||
public function category(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$category = Category::select(['id', 'name', 'slug'])->findOrFail($id);
|
||||
$torrents = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->where('category_id', '=', $id)->orderBy('sticky', 'desc')->latest()->paginate(25);
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
|
||||
Executable → Regular
+52
-41
@@ -17,7 +17,6 @@ use App\Models\User;
|
||||
use App\Models\Article;
|
||||
use App\Models\Comment;
|
||||
use App\Models\Torrent;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Notifications\NewComment;
|
||||
@@ -48,23 +47,16 @@ class CommentController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* CommentController Constructor.
|
||||
*
|
||||
* @param TaggedUserRepository $tag
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(TaggedUserRepository $tag, ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(TaggedUserRepository $tag, ChatRepository $chat)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,11 +71,11 @@ class CommentController extends Controller
|
||||
public function article(Request $request, $slug, $id)
|
||||
{
|
||||
$article = Article::findOrFail($id);
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->can_comment == 0) {
|
||||
return redirect()->route('article', ['slug' => $article->slug, 'id' => $article->id])
|
||||
->with($this->toastr->error('Your Comment Rights Have Benn Revoked!!!', 'Whoops!', ['options']));
|
||||
->withErros('Your Comment Rights Have Benn Revoked!');
|
||||
}
|
||||
|
||||
$comment = new Comment();
|
||||
@@ -101,16 +93,23 @@ class CommentController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('article', ['slug' => $article->slug, 'id' => $article->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$comment->save();
|
||||
|
||||
$article_url = hrefArticle($article);
|
||||
$profile_url = hrefProfile($user);
|
||||
|
||||
$this->chat->systemMessage(
|
||||
"[url={$profile_url}]{$user->username}[/url] has left a comment on article [url={$article_url}]{$article->title}[/url]"
|
||||
);
|
||||
// Auto Shout
|
||||
if ($comment->anon == 0) {
|
||||
$this->chat->systemMessage(
|
||||
"[url={$profile_url}]{$user->username}[/url] has left a comment on article [url={$article_url}]{$article->title}[/url]"
|
||||
);
|
||||
} else {
|
||||
$this->chat->systemMessage(
|
||||
"An anonymous user has left a comment on article [url={$article_url}]{$article->title}[/url]"
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->tag->hasTags($request->input('content'))) {
|
||||
if ($this->tag->contains($request->input('content'), '@here') && $user->group->is_modo) {
|
||||
@@ -157,7 +156,7 @@ class CommentController extends Controller
|
||||
$user->addProgress(new UserMade900Comments(), 1);
|
||||
|
||||
return redirect()->route('article', ['slug' => $article->slug, 'id' => $article->id])
|
||||
->with($this->toastr->success('Your Comment Has Been Added!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Comment Has Been Added!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,11 +172,11 @@ class CommentController extends Controller
|
||||
public function torrent(Request $request, $slug, $id)
|
||||
{
|
||||
$torrent = Torrent::findOrFail($id);
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->can_comment == 0) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error('Your Comment Rights Have Benn Revoked!!!', 'Whoops!', ['options']));
|
||||
->withErros('Your Comment Rights Have Benn Revoked!');
|
||||
}
|
||||
|
||||
$comment = new Comment();
|
||||
@@ -195,7 +194,7 @@ class CommentController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$comment->save();
|
||||
|
||||
@@ -263,15 +262,14 @@ class CommentController extends Controller
|
||||
$user->addProgress(new UserMade900Comments(), 1);
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id, 'hash' => '#comments'])
|
||||
->with($this->toastr->success('Your Comment Has Been Added!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Comment Has Been Added!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add A Comment To A Request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $slug
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
@@ -279,11 +277,11 @@ class CommentController extends Controller
|
||||
public function request(Request $request, $id)
|
||||
{
|
||||
$tr = TorrentRequest::findOrFail($id);
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->can_comment == 0) {
|
||||
return redirect()->route('request', ['id' => $tr->id])
|
||||
->with($this->toastr->error('Your Comment Rights Have Benn Revoked!!!', 'Whoops!', ['options']));
|
||||
->withErros('Your Comment Rights Have Benn Revoked!');
|
||||
}
|
||||
|
||||
$comment = new Comment();
|
||||
@@ -301,7 +299,7 @@ class CommentController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('request', ['id' => $tr->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$comment->save();
|
||||
|
||||
@@ -368,7 +366,7 @@ class CommentController extends Controller
|
||||
$user->addProgress(new UserMade900Comments(), 1);
|
||||
|
||||
return redirect()->route('request', ['id' => $tr->id, 'hash' => '#comments'])
|
||||
->with($this->toastr->success('Your Comment Has Been Added!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Comment Has Been Added!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,22 +377,35 @@ class CommentController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function quickthanks($id)
|
||||
public function quickthanks(Request $request, $id)
|
||||
{
|
||||
$torrent = Torrent::findOrFail($id);
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->can_comment == 0) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error('Your Comment Rights Have Benn Revoked!!!', 'Whoops!', ['options']));
|
||||
->withErros('Your Comment Rights Have Benn Revoked!');
|
||||
}
|
||||
|
||||
$comment = new Comment();
|
||||
$thankArray = [
|
||||
'Thanks for the upload! :thumbsup_tone2:',
|
||||
'Time and effort is much appreciated :thumbsup_tone2:',
|
||||
'Great upload! :fire:', 'Thankyou :smiley:',
|
||||
];
|
||||
|
||||
if ($torrent->anon === 1) {
|
||||
$thankArray = [
|
||||
'Thanks for the upload! :thumbsup_tone2:',
|
||||
'Time and effort is much appreciated :thumbsup_tone2:',
|
||||
'Great upload! :fire:', 'Thankyou :smiley:',
|
||||
];
|
||||
} else {
|
||||
$uploader = User::where('id', '=', $torrent->user_id)->first();
|
||||
$uploader_url = hrefProfile($uploader);
|
||||
|
||||
$thankArray = [
|
||||
"Thanks for the upload [url={$uploader_url}][color={$uploader->group->color}][b]{$uploader->username}[/b][/color][/url] :vulcan_tone2:",
|
||||
"Beatiful upload [url={$uploader_url}][color={$uploader->group->color}][b]{$uploader->username}[/b][/color][/url] :fire:",
|
||||
"Cheers [url={$uploader_url}][color={$uploader->group->color}][b]{$uploader->username}[/b][/color][/url] for the upload :beers:",
|
||||
];
|
||||
}
|
||||
|
||||
$selected = mt_rand(0, count($thankArray) - 1);
|
||||
$comment->content = $thankArray[$selected];
|
||||
$comment->user_id = $user->id;
|
||||
@@ -408,7 +419,7 @@ class CommentController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$comment->save();
|
||||
|
||||
@@ -440,7 +451,7 @@ class CommentController extends Controller
|
||||
);
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])
|
||||
->with($this->toastr->success('Your Comment Has Been Added!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Comment Has Been Added!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,7 +465,7 @@ class CommentController extends Controller
|
||||
*/
|
||||
public function editComment(Request $request, $comment_id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$comment = Comment::findOrFail($comment_id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id == $comment->user_id, 403);
|
||||
@@ -462,7 +473,7 @@ class CommentController extends Controller
|
||||
$comment->content = $content;
|
||||
$comment->save();
|
||||
|
||||
return back()->with($this->toastr->success('Comment Has Been Edited.', 'Yay!', ['options']));
|
||||
return redirect()->back()->withSuccess('Comment Has Been Edited.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -472,14 +483,14 @@ class CommentController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteComment($comment_id)
|
||||
public function deleteComment(Request $request, $comment_id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$comment = Comment::findOrFail($comment_id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id == $comment->user_id, 403);
|
||||
$comment->delete();
|
||||
|
||||
return back()->with($this->toastr->success('Comment Has Been Deleted.', 'Yay!', ['options']));
|
||||
return redirect()->back()->withSuccess('Comment Has Been Deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,27 +15,11 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Mail\Contact;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ContactController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact Form.
|
||||
*
|
||||
@@ -49,6 +33,7 @@ class ContactController extends Controller
|
||||
/**
|
||||
* Send A Contact Email To Owner/First User.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function contact(Request $request)
|
||||
@@ -60,6 +45,6 @@ class ContactController extends Controller
|
||||
Mail::to($user->email, $user->username)->send(new Contact($input));
|
||||
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->success('Your Message Was Successfully Sent', 'Yay!', ['options']));
|
||||
->withSuccess('Your Message Was Successfully Sent');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,27 +15,12 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Follow;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Notifications\NewFollow;
|
||||
use App\Notifications\NewUnfollow;
|
||||
|
||||
class FollowController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* FollowController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow A User.
|
||||
*
|
||||
@@ -43,25 +28,25 @@ class FollowController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function follow(User $user)
|
||||
public function follow(Request $request, User $user)
|
||||
{
|
||||
if (auth()->user()->id == $user->id) {
|
||||
if ($request->user()->id == $user->id) {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error('Nice try, but sadly you can not follow yourself.', 'Whoops!', ['options']));
|
||||
} elseif (! auth()->user()->isFollowing($user->id)) {
|
||||
->withErrors('Nice try, but sadly you can not follow yourself.');
|
||||
} elseif (! $request->user()->isFollowing($user->id)) {
|
||||
$follow = new Follow();
|
||||
$follow->user_id = auth()->user()->id;
|
||||
$follow->user_id = $request->user()->id;
|
||||
$follow->target_id = $user->id;
|
||||
$follow->save();
|
||||
if ($user->acceptsNotification(auth()->user(), $user, 'account', 'show_account_follow')) {
|
||||
$user->notify(new NewFollow('user', auth()->user(), $user, $follow));
|
||||
if ($user->acceptsNotification($request->user(), $user, 'account', 'show_account_follow')) {
|
||||
$user->notify(new NewFollow('user', $request->user(), $user, $follow));
|
||||
}
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('You are now following '.$user->username, 'Yay!', ['options']));
|
||||
->withSuccess('You are now following '.$user->username);
|
||||
} else {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error('You are already following this user', 'Whoops!', ['options']));
|
||||
->withErrors('You are already following this user');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,20 +57,20 @@ class FollowController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function unfollow(User $user)
|
||||
public function unfollow(Request $request, User $user)
|
||||
{
|
||||
if (auth()->user()->isFollowing($user->id)) {
|
||||
$follow = auth()->user()->follows()->where('target_id', '=', $user->id)->first();
|
||||
if ($request->user()->isFollowing($user->id)) {
|
||||
$follow = $request->user()->follows()->where('target_id', '=', $user->id)->first();
|
||||
$follow->delete();
|
||||
if ($user->acceptsNotification(auth()->user(), $user, 'account', 'show_account_unfollow')) {
|
||||
$user->notify(new NewUnfollow('user', auth()->user(), $user, $follow));
|
||||
if ($user->acceptsNotification($request->user(), $user, 'account', 'show_account_unfollow')) {
|
||||
$user->notify(new NewUnfollow('user', $request->user(), $user, $follow));
|
||||
}
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('You are no longer following '.$user->username, 'Yay!', ['options']));
|
||||
->withSuccess('You are no longer following '.$user->username);
|
||||
} else {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error('You are not following this user to begin with', 'Whoops!', ['options']));
|
||||
->withErrors('You are not following this user to begin with');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+66
-73
@@ -14,10 +14,9 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Post;
|
||||
use App\Models\User;
|
||||
use App\Models\Forum;
|
||||
use App\Models\Topic;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\ChatRepository;
|
||||
use App\Achievements\UserMade25Posts;
|
||||
@@ -46,23 +45,16 @@ class ForumController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ForumController Constructor.
|
||||
*
|
||||
* @param TaggedUserRepository $tag
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(TaggedUserRepository $tag, ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(TaggedUserRepository $tag, ChatRepository $chat)
|
||||
{
|
||||
$this->tag = $tag;
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +68,7 @@ class ForumController extends Controller
|
||||
{
|
||||
$categories = Forum::oldest('position')->get();
|
||||
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
@@ -157,24 +149,25 @@ class ForumController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
$direction = 2;
|
||||
$order = 'desc';
|
||||
if ($request->has('direction') && $request->input('direction') == 1) {
|
||||
$direction = 1;
|
||||
$order = 'asc';
|
||||
}
|
||||
|
||||
if ($request->has('body') && $request->input('body') != '') {
|
||||
$sorting = 'posts.id';
|
||||
if ($request->has('sorting') && $request->input('sorting') == 'created_at') {
|
||||
$sorting = 'posts.created_at';
|
||||
if ($request->has('sorting') && $request->input('sorting') != null) {
|
||||
$sorting = "posts.{$request->input('sorting')}";
|
||||
$direction = $request->input('direction');
|
||||
} else {
|
||||
$sorting = 'posts.id';
|
||||
$direction = 'desc';
|
||||
}
|
||||
$results = $result->orderBy($sorting, $direction)->paginate(25);
|
||||
} else {
|
||||
$sorting = 'topics.last_reply_at';
|
||||
if ($request->has('sorting') && $request->input('sorting') == 'created_at') {
|
||||
$sorting = 'topics.created_at';
|
||||
if ($request->has('sorting') && $request->input('sorting') != null) {
|
||||
$sorting = "topics.{$request->input('sorting')}";
|
||||
$direction = $request->input('direction');
|
||||
} else {
|
||||
$sorting = 'topics.last_reply_at';
|
||||
$direction = 'desc';
|
||||
}
|
||||
$results = $result->orderBy($sorting, $order)->paginate(25);
|
||||
$results = $result->orderBy($sorting, $direction)->paginate(25);
|
||||
}
|
||||
|
||||
$results->setPath('?name='.$request->input('name'));
|
||||
@@ -210,7 +203,7 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function subscriptions(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
@@ -267,7 +260,7 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function latestTopics(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
@@ -301,7 +294,7 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function latestPosts(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$pests = $user->group->permissions->where('show_forum', '=', 0)->pluck('forum_id')->toArray();
|
||||
if (! is_array($pests)) {
|
||||
@@ -379,7 +372,7 @@ class ForumController extends Controller
|
||||
$category = Forum::findOrFail($forum->id);
|
||||
if ($category->getPermission()->show_forum != true) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Do Not Have Access To This Category!', 'Whoops!', ['options']));
|
||||
->withErrors('You Do Not Have Access To This Category!');
|
||||
}
|
||||
|
||||
// Fetch topics->posts in descending order
|
||||
@@ -424,7 +417,7 @@ class ForumController extends Controller
|
||||
$category = Forum::findOrFail($forum->parent_id);
|
||||
if ($category->getPermission()->show_forum != true) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Do Not Have Access To This Forum!', 'Whoops!', ['options']));
|
||||
->withErrors('You Do Not Have Access To This Forum!');
|
||||
}
|
||||
|
||||
// Fetch topics->posts in descending order
|
||||
@@ -469,7 +462,7 @@ class ForumController extends Controller
|
||||
if ($category->getPermission()->read_topic != true) {
|
||||
// Redirect him to the forum index
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Do Not Have Access To Read This Topic!', 'Whoops!', ['options']));
|
||||
->withErrors('You Do Not Have Access To Read This Topic!');
|
||||
}
|
||||
|
||||
// Increment view
|
||||
@@ -496,15 +489,15 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function reply(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
$forum = $topic->forum;
|
||||
$category = $forum->getCategory();
|
||||
|
||||
// The user has the right to create a topic here?
|
||||
if (! $category->getPermission()->reply_topic || ($topic->state == 'close' && ! auth()->user()->group->is_modo)) {
|
||||
if (! $category->getPermission()->reply_topic || ($topic->state == 'close' && ! $request->user()->group->is_modo)) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Cannot Reply To This Topic!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Reply To This Topic!');
|
||||
}
|
||||
|
||||
$post = new Post();
|
||||
@@ -520,7 +513,7 @@ class ForumController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$post->save();
|
||||
|
||||
@@ -609,8 +602,8 @@ class ForumController extends Controller
|
||||
$user->addProgress(new UserMade800Posts(), 1);
|
||||
$user->addProgress(new UserMade900Posts(), 1);
|
||||
|
||||
return redirect($realUrl)
|
||||
->with($this->toastr->success('Post Successfully Posted', 'Yay!', ['options']));
|
||||
return redirect()->to($realUrl)
|
||||
->withSuccess('Post Successfully Posted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +624,7 @@ class ForumController extends Controller
|
||||
// The user has the right to create a topic here?
|
||||
if ($category->getPermission()->start_topic != true) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Cannot Start A New Topic Here!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Start A New Topic Here!');
|
||||
}
|
||||
|
||||
return view('forum.new_topic', [
|
||||
@@ -652,20 +645,20 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function newTopic(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$forum = Forum::findOrFail($id);
|
||||
$category = $forum->getCategory();
|
||||
|
||||
// The user has the right to create a topic here?
|
||||
if ($category->getPermission()->start_topic != true) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error('You Cannot Start A New Topic Here!', 'Whoops!', ['options']));
|
||||
->withErrors('You Cannot Start A New Topic Here!');
|
||||
}
|
||||
|
||||
// Create The Topic
|
||||
$topic = new Topic();
|
||||
$topic->name = $request->input('title');
|
||||
$topic->slug = str_slug($request->input('title'));
|
||||
$topic->slug = Str::slug($request->input('title'));
|
||||
$topic->state = 'open';
|
||||
$topic->first_post_user_id = $topic->last_post_user_id = $user->id;
|
||||
$topic->first_post_user_username = $topic->last_post_user_username = $user->username;
|
||||
@@ -689,7 +682,7 @@ class ForumController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$topic->save();
|
||||
|
||||
@@ -706,7 +699,7 @@ class ForumController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('forum_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$post->save();
|
||||
$topic->num_post = 1;
|
||||
@@ -745,7 +738,7 @@ class ForumController extends Controller
|
||||
$user->addProgress(new UserMade900Posts(), 1);
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('Topic Created Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Topic Created Successfully!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -777,10 +770,10 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function editTopic(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$name = $request->input('name');
|
||||
$forum_id = $request->input('forum_id');
|
||||
$topic->name = $name;
|
||||
@@ -788,7 +781,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('Topic Successfully Edited', 'Yay!', ['options']));
|
||||
->withSuccess('Topic Successfully Edited');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -825,16 +818,16 @@ class ForumController extends Controller
|
||||
*/
|
||||
public function postEdit(Request $request, $postId)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$post = Post::findOrFail($postId);
|
||||
$postUrl = "forums/topic/{$post->topic->slug}.{$post->topic->id}?page={$post->getPageNumber()}#post-{$postId}";
|
||||
|
||||
abort_unless($user->group->is_modo || $post->user_id == $user->id, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $post->user_id, 403);
|
||||
$post->content = $request->input('content');
|
||||
$post->save();
|
||||
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->success('Post Successfully Edited!', 'Yay!', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withSuccess('Post Successfully Edited!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,16 +837,16 @@ class ForumController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postDelete($postId)
|
||||
public function postDelete(Request $request, $postId)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$post = Post::with('topic')->findOrFail($postId);
|
||||
|
||||
abort_unless($user->group->is_modo || $post->user_id == $user->id, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $post->user_id, 403);
|
||||
$post->delete();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])
|
||||
->with($this->toastr->success('This Post Is Now Deleted!', 'Success', ['options']));
|
||||
->withSuccess('This Post Is Now Deleted!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -864,9 +857,9 @@ class ForumController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function closeTopic($slug, $id)
|
||||
public function closeTopic(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
@@ -874,7 +867,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('This Topic Is Now Closed!', 'Success', ['options']));
|
||||
->withSuccess('This Topic Is Now Closed!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -885,9 +878,9 @@ class ForumController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function openTopic($slug, $id)
|
||||
public function openTopic(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
@@ -895,7 +888,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('This Topic Is Now Open!', 'Success', ['options']));
|
||||
->withSuccess('This Topic Is Now Open!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -906,18 +899,18 @@ class ForumController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteTopic($slug, $id)
|
||||
public function deleteTopic(Request $request, $slug, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$posts = $topic->posts();
|
||||
$posts->delete();
|
||||
$topic->delete();
|
||||
|
||||
return redirect()->route('forum_display', ['slug' => $topic->forum->slug, 'id' => $topic->forum->id])
|
||||
->with($this->toastr->error('This Topic Is Now Deleted!', 'Warning', ['options']));
|
||||
->withErrors('This Topic Is Now Deleted!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -935,7 +928,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('This Topic Is Now Pinned!', 'Success', ['options']));
|
||||
->withSuccess('This Topic Is Now Pinned!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -953,7 +946,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->success('This Topic Is Now Unpinned!', 'Success', ['options']));
|
||||
->withSuccess('This Topic Is Now Unpinned!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -975,7 +968,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function deniedTopic($slug, $id)
|
||||
@@ -989,7 +982,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function solvedTopic($slug, $id)
|
||||
@@ -1003,7 +996,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function invalidTopic($slug, $id)
|
||||
@@ -1017,7 +1010,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function bugTopic($slug, $id)
|
||||
@@ -1031,7 +1024,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function suggestionTopic($slug, $id)
|
||||
@@ -1045,7 +1038,7 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
|
||||
public function implementedTopic($slug, $id)
|
||||
@@ -1059,6 +1052,6 @@ class ForumController extends Controller
|
||||
$topic->save();
|
||||
|
||||
return redirect()->route('forum_topic', ['slug' => $topic->slug, 'id' => $topic->id])
|
||||
->with($this->toastr->info('Label Change Has Been Applied', 'Info', ['options']));
|
||||
->withInfo('Label Change Has Been Applied');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace App\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Graveyard;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\TorrentFacetedRepository;
|
||||
|
||||
@@ -27,21 +27,14 @@ class GraveyardController extends Controller
|
||||
*/
|
||||
private $faceted;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* GraveyardController Constructor.
|
||||
*
|
||||
* @param TorrentFacetedRepository $faceted
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(TorrentFacetedRepository $faceted, Toastr $toastr)
|
||||
public function __construct(TorrentFacetedRepository $faceted)
|
||||
{
|
||||
$this->faceted = $faceted;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,10 +42,10 @@ class GraveyardController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrents = Torrent::with('category')->where('created_at', '<', $current->copy()->subDays(30)->toDateTimeString())->paginate(25);
|
||||
$repository = $this->faceted;
|
||||
$deadcount = Torrent::where('seeders', '=', 0)->where('created_at', '<', $current->copy()->subDays(30)->toDateTimeString())->count();
|
||||
@@ -69,16 +62,17 @@ class GraveyardController extends Controller
|
||||
* Uses Input's To Put Together A Search.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $torrent Torrent
|
||||
* @param Torrent $torrent
|
||||
*
|
||||
* @return array
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function faceted(Request $request, Torrent $torrent)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$search = $request->input('search');
|
||||
$imdb_id = starts_with($request->get('imdb'), 'tt') ? $request->get('imdb') : 'tt'.$request->get('imdb');
|
||||
$imdb_id = Str::startsWith($request->get('imdb'), 'tt') ? $request->get('imdb') : 'tt'.$request->get('imdb');
|
||||
$imdb = str_replace('tt', '', $imdb_id);
|
||||
$tvdb = $request->input('tvdb');
|
||||
$tmdb = $request->input('tmdb');
|
||||
@@ -151,18 +145,18 @@ class GraveyardController extends Controller
|
||||
*/
|
||||
public function store(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent = Torrent::findOrFail($id);
|
||||
$resurrected = Graveyard::where('torrent_id', '=', $torrent->id)->first();
|
||||
|
||||
if ($resurrected) {
|
||||
return redirect()->route('graveyard.index')
|
||||
->with($this->toastr->error('Torrent Resurrection Failed! This torrent is already pending a resurrection.', 'Whoops!', ['options']));
|
||||
->withErrors('Torrent Resurrection Failed! This torrent is already pending a resurrection.');
|
||||
}
|
||||
|
||||
if ($user->id === $torrent->user_id) {
|
||||
return redirect()->route('graveyard.index')
|
||||
->with($this->toastr->error('Torrent Resurrection Failed! You cannot resurrect your own uploads.', 'Whoops!', ['options']));
|
||||
->withErrors('Torrent Resurrection Failed! You cannot resurrect your own uploads.');
|
||||
}
|
||||
|
||||
$resurrection = new Graveyard();
|
||||
@@ -178,12 +172,12 @@ class GraveyardController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('graveyard.index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$resurrection->save();
|
||||
|
||||
return redirect()->route('graveyard.index')
|
||||
->with($this->toastr->success('Torrent Resurrection Complete! You will be rewarded automatically once seedtime requirements are met.', 'Yay!', ['options']));
|
||||
->withSuccess('Torrent Resurrection Complete! You will be rewarded automatically once seedtime requirements are met.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,15 +188,15 @@ class GraveyardController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$resurrection = Graveyard::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $resurrection->user_id, 403);
|
||||
$resurrection->delete();
|
||||
|
||||
return redirect()->route('graveyard.index')
|
||||
->with($this->toastr->success('Ressurection Successfully Canceled!', 'Yay!', ['options']));
|
||||
->withSuccess('Resurrection Successfully Canceled!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,13 @@ use App\Models\Group;
|
||||
use App\Models\Topic;
|
||||
use App\Models\Article;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Bookmark;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\FreeleechToken;
|
||||
use App\Models\FeaturedTorrent;
|
||||
use App\Models\PersonalFreeleech;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -31,73 +35,124 @@ class HomeController extends Controller
|
||||
* Home Page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function home()
|
||||
public function home(Request $request)
|
||||
{
|
||||
// For Cache
|
||||
$current = Carbon::now();
|
||||
$expiresAt = $current->addMinutes(10);
|
||||
|
||||
// Authorized User
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
// Latest Articles/News Block
|
||||
$articles = Article::latest()->take(1)->get();
|
||||
$articles = cache()->remember('latest_article', $expiresAt, function () {
|
||||
return Article::latest()->take(1)->get();
|
||||
});
|
||||
|
||||
// Latest Torrents Block
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
|
||||
$newest = Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
$newest = cache()->remember('newest_torrents', $expiresAt, function () {
|
||||
return Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
});
|
||||
|
||||
$seeded = Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('seeders')
|
||||
->take(5)
|
||||
->get();
|
||||
$seeded = cache()->remember('seeded_torrents', $expiresAt, function () {
|
||||
return Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('seeders')
|
||||
->take(5)
|
||||
->get();
|
||||
});
|
||||
|
||||
$leeched = Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
$leeched = cache()->remember('leeched_torrents', $expiresAt, function () {
|
||||
return Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
});
|
||||
|
||||
$dying = Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 1)
|
||||
->where('times_completed', '>=', 1)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
$dying = cache()->remember('dying_torrents', $expiresAt, function () {
|
||||
return Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 1)
|
||||
->where('times_completed', '>=', 1)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
});
|
||||
|
||||
$dead = Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 0)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
$dead = cache()->remember('dead_torrents', $expiresAt, function () {
|
||||
return Torrent::with(['user', 'category'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 0)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
});
|
||||
|
||||
// Latest Topics Block
|
||||
$topics = Topic::latest()->take(5)->get();
|
||||
$topics = cache()->remember('latest_topics', $expiresAt, function () {
|
||||
return Topic::with('forum')->latest()->take(5)->get();
|
||||
});
|
||||
|
||||
// Latest Posts Block
|
||||
$posts = Post::latest()->take(5)->get();
|
||||
$posts = cache()->remember('latest_posts', $expiresAt, function () {
|
||||
return Post::with('topic', 'user')->latest()->take(5)->get();
|
||||
});
|
||||
|
||||
// Online Block
|
||||
$users = User::with(['privacy', 'group' => function ($query) {
|
||||
$query->select(['id', 'name', 'color', 'effect', 'icon', 'position']);
|
||||
}])->select(['id', 'username', 'hidden', 'group_id'])->oldest('username')->get();
|
||||
$groups = Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get();
|
||||
$users = User::with('group', 'privacy')
|
||||
->withCount([
|
||||
'warnings' => function (Builder $query) {
|
||||
$query->whereNotNull('torrent')->where('active', '1');
|
||||
},
|
||||
])
|
||||
->where('last_action', '>', now()->subMinutes(5))
|
||||
->get();
|
||||
|
||||
$groups = cache()->remember('user-groups', $expiresAt, function () {
|
||||
return Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get();
|
||||
});
|
||||
|
||||
// Featured Torrents Block
|
||||
$featured = FeaturedTorrent::with('torrent')->get();
|
||||
$featured = cache()->remember('latest_featured', $expiresAt, function () {
|
||||
return FeaturedTorrent::with('torrent')->get();
|
||||
});
|
||||
|
||||
// Latest Poll Block
|
||||
$poll = Poll::latest()->first();
|
||||
$poll = cache()->remember('latest_poll', $expiresAt, function () {
|
||||
return Poll::latest()->first();
|
||||
});
|
||||
|
||||
// Top Uploaders Block
|
||||
$current = Carbon::now();
|
||||
$uploaders = Torrent::with('user')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(10)->get();
|
||||
$past_uploaders = Torrent::with('user')->where('created_at', '>', $current->copy()->subDays(30)->toDateTimeString())->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(10)->get();
|
||||
$uploaders = cache()->remember('top_uploaders', $expiresAt, function () {
|
||||
return Torrent::with('user')
|
||||
->select(DB::raw('user_id, count(*) as value'))
|
||||
->groupBy('user_id')
|
||||
->latest('value')
|
||||
->take(10)
|
||||
->get();
|
||||
});
|
||||
|
||||
$past_uploaders = cache()->remember('month_uploaders', $expiresAt, function () use ($current) {
|
||||
return Torrent::with('user')
|
||||
->where('created_at', '>', $current->copy()->subDays(30)->toDateTimeString())
|
||||
->select(DB::raw('user_id, count(*) as value'))
|
||||
->groupBy('user_id')
|
||||
->latest('value')
|
||||
->take(10)
|
||||
->get();
|
||||
});
|
||||
|
||||
$freeleech_tokens = FreeleechToken::where('user_id', $user->id)->get();
|
||||
$bookmarks = Bookmark::where('user_id', $user->id)->get();
|
||||
|
||||
return view('home.home', [
|
||||
'user' => $user,
|
||||
@@ -116,6 +171,8 @@ class HomeController extends Controller
|
||||
'poll' => $poll,
|
||||
'uploaders' => $uploaders,
|
||||
'past_uploaders' => $past_uploaders,
|
||||
'freeleech_tokens' => $freeleech_tokens,
|
||||
'bookmarks' => $bookmarks,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,26 +15,10 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Album;
|
||||
use App\Models\Image;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ImageController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ImageController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image Add Form.
|
||||
*
|
||||
@@ -59,7 +43,7 @@ class ImageController extends Controller
|
||||
public function add(Request $request)
|
||||
{
|
||||
$image = new Image();
|
||||
$image->user_id = auth()->user()->id;
|
||||
$image->user_id = $request->user()->id;
|
||||
$image->album_id = $request->input('album_id');
|
||||
$image->description = $request->input('description');
|
||||
$image->type = $request->input('type');
|
||||
@@ -82,12 +66,12 @@ class ImageController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('add_image', ['id' => $request->input('album_id')])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$image->save();
|
||||
|
||||
return redirect()->route('show_album', ['id' => $request->input('album_id')])
|
||||
->with($this->toastr->success('Your image has successfully published!', 'Yay!', ['options']));
|
||||
->withSuccess('Your image has successfully published!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +84,7 @@ class ImageController extends Controller
|
||||
*/
|
||||
public function move(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
$image = Image::findOrFail($request->input('photo'));
|
||||
@@ -113,7 +97,7 @@ class ImageController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('gallery')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$image->save();
|
||||
|
||||
@@ -135,7 +119,7 @@ class ImageController extends Controller
|
||||
|
||||
if (! file_exists(getcwd().'/files/img/'.$filename)) {
|
||||
return redirect()->route('show_album', ['id' => $image->album_id])
|
||||
->with($this->toastr->error('Image File Not Found! Please Report This To Staff!', 'Error!', ['options']));
|
||||
->withErrors('Image File Not Found! Please Report This To Staff!');
|
||||
}
|
||||
|
||||
$image->downloads++;
|
||||
@@ -151,15 +135,15 @@ class ImageController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$image = Image::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $image->user_id, 403);
|
||||
$image->delete();
|
||||
|
||||
return redirect()->route('show_album', ['id' => $image->album_id])
|
||||
->with($this->toastr->success('Image has successfully been deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Image has successfully been deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,47 +18,31 @@ use App\Models\User;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Models\Invite;
|
||||
use App\Mail\InviteUser;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class InviteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* InviteController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite Form.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function invite()
|
||||
public function invite(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if (config('other.invite-only') == false) {
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->error('Invitations Are Disabled Due To Open Registration!', 'Whoops!', ['options']));
|
||||
->withErrors('Invitations Are Disabled Due To Open Registration!');
|
||||
}
|
||||
if ($user->can_invite == 0) {
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->error('Your Invite Rights Have Been Revoked!!!', 'Whoops!', ['options']));
|
||||
->withErrors('Your Invite Rights Have Been Revoked!');
|
||||
}
|
||||
if (config('other.invites_restriced') == true && ! in_array($user->group->name, config('other.invite_groups'))) {
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->error('Invites are currently disabled for your group.', 'Whoops!', ['options']));
|
||||
->withErrors('Invites are currently disabled for your group.');
|
||||
}
|
||||
|
||||
return view('user.invite', ['user' => $user, 'route' => 'invite']);
|
||||
@@ -70,27 +54,28 @@ class InviteController extends Controller
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if (config('other.invites_restriced') == true && ! in_array($user->group->name, config('other.invite_groups'))) {
|
||||
return redirect()->route('home')
|
||||
->with($this->toastr->error('Invites are currently disabled for your group.', 'Whoops!', ['options']));
|
||||
->withErrors('Invites are currently disabled for your group.');
|
||||
}
|
||||
|
||||
if ($user->invites <= 0) {
|
||||
return redirect()->route('invite')
|
||||
->with($this->toastr->error('You do not have enough invites!', 'Whoops!', ['options']));
|
||||
->withErrors('You do not have enough invites!');
|
||||
}
|
||||
|
||||
$exist = Invite::where('email', '=', $request->input('email'))->first();
|
||||
|
||||
if ($exist) {
|
||||
return redirect()->route('invite')
|
||||
->with($this->toastr->error('The email address your trying to send a invite to has already been sent one.', 'Whoops!', ['options']));
|
||||
->withErrors('The email address your trying to send a invite to has already been sent one.');
|
||||
}
|
||||
|
||||
$code = Uuid::uuid4()->toString();
|
||||
@@ -120,7 +105,7 @@ class InviteController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('invite')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
Mail::to($request->input('email'))->send(new InviteUser($invite));
|
||||
$invite->save();
|
||||
@@ -132,7 +117,7 @@ class InviteController extends Controller
|
||||
\LogActivity::addToLog("Member {$user->username} has sent a invite to {$invite->email} .");
|
||||
|
||||
return redirect()->route('invite')
|
||||
->with($this->toastr->success('Invite was sent successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Invite was sent successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,16 +128,16 @@ class InviteController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function reProcess($id)
|
||||
public function reProcess(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$invite = Invite::findOrFail($id);
|
||||
|
||||
abort_unless($invite->user_id === $user->id, 403);
|
||||
|
||||
if ($invite->accepted_by !== null) {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error('The invite you are trying to resend has already been used.', 'Whoops!', ['options']));
|
||||
return redirect()->route('user_invites', ['slug' => $user->slug, 'id' => $user->id])
|
||||
->withErrors('The invite you are trying to resend has already been used.');
|
||||
}
|
||||
|
||||
Mail::to($invite->email)->send(new InviteUser($invite));
|
||||
@@ -160,8 +145,8 @@ class InviteController extends Controller
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Member {$user->username} has resent invite to {$invite->email} .");
|
||||
|
||||
return redirect()->back()
|
||||
->with($this->toastr->success('Invite was resent successfully!', 'Yay!', ['options']));
|
||||
return redirect()->route('user_invites', ['slug' => $user->slug, 'id' => $user->id])
|
||||
->withSuccess('Invite was resent successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,9 +157,9 @@ class InviteController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function invites($username, $id)
|
||||
public function invites(Request $request, $username, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$owner = User::findOrFail($id);
|
||||
abort_unless($user->group->is_modo || $user->id === $owner->id, 403);
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ class LanguageController extends Controller
|
||||
{
|
||||
$this->setLocale($locale, $request);
|
||||
|
||||
return redirect(url('/'));
|
||||
return redirect()->route('home')
|
||||
->withSuccess('Language Changed!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,7 @@ class LanguageController extends Controller
|
||||
{
|
||||
$this->setLocale($locale, $request);
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->back()
|
||||
->withSuccess('Language Changed!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,25 +15,10 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Like;
|
||||
use App\Models\Post;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LikeController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* LikeController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like A Post.
|
||||
*
|
||||
@@ -41,21 +26,21 @@ class LikeController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store($postId)
|
||||
public function store(Request $request, $postId)
|
||||
{
|
||||
$post = Post::findOrFail($postId);
|
||||
$postUrl = "forums/topic/{$post->topic->slug}.{$post->topic->id}?page={$post->getPageNumber()}#post-{$postId}";
|
||||
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$like = $user->likes()->where('post_id', '=', $post->id)->where('like', '=', 1)->first();
|
||||
$dislike = $user->likes()->where('post_id', '=', $post->id)->where('dislike', '=', 1)->first();
|
||||
|
||||
if ($like || $dislike) {
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->error('You have already liked/disliked this post!', 'Bro', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withErrors('You have already liked/disliked this post!');
|
||||
} elseif ($user->id == $post->user_id) {
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->error('You cannot like your own post!', 'Umm', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withErrors('You cannot like your own post!');
|
||||
} else {
|
||||
$new = new Like();
|
||||
$new->user_id = $user->id;
|
||||
@@ -63,8 +48,8 @@ class LikeController extends Controller
|
||||
$new->like = 1;
|
||||
$new->save();
|
||||
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->success('Like Successfully Applied!', 'Yay', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withSuccess('Like Successfully Applied!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,21 +60,21 @@ class LikeController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($postId)
|
||||
public function destroy(Request $request, $postId)
|
||||
{
|
||||
$post = Post::findOrFail($postId);
|
||||
$postUrl = "forums/topic/{$post->topic->slug}.{$post->topic->id}?page={$post->getPageNumber()}#post-{$postId}";
|
||||
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$like = $user->likes()->where('post_id', '=', $post->id)->where('like', '=', 1)->first();
|
||||
$dislike = $user->likes()->where('post_id', '=', $post->id)->where('dislike', '=', 1)->first();
|
||||
|
||||
if ($like || $dislike) {
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->error('You have already liked/disliked this post!', 'Bro', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withErrors('You have already liked/disliked this post!');
|
||||
} elseif ($user->id == $post->user_id) {
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->error('You cannot dislike your own post!', 'Umm', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withErrors('You cannot dislike your own post!');
|
||||
} else {
|
||||
$new = new Like();
|
||||
$new->user_id = $user->id;
|
||||
@@ -97,8 +82,8 @@ class LikeController extends Controller
|
||||
$new->dislike = 1;
|
||||
$new->save();
|
||||
|
||||
return redirect($postUrl)
|
||||
->with($this->toastr->success('Dislike Successfully Applied!', 'Yay', ['options']));
|
||||
return redirect()->to($postUrl)
|
||||
->withSuccess('Dislike Successfully Applied!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,106 +15,202 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Models\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* NotificationController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show All Notifications.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function get()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$notification = auth()->user()->notifications()->paginate(25);
|
||||
$notifications = $request->user()->notifications()->paginate(25);
|
||||
|
||||
return view('notification.notifications', ['notification' => $notification]);
|
||||
return view('notification.index', ['notifications' => $notifications]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Input's To Put Together A Search.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Notification $notification
|
||||
*
|
||||
* @return array
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function faceted(Request $request, Notification $notification)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$notification = $user->notifications();
|
||||
|
||||
if ($request->has('bon_gifts') && $request->input('bon_gifts') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewBon::class);
|
||||
}
|
||||
|
||||
if ($request->has('comments') && $request->input('comments') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewComment::class);
|
||||
}
|
||||
|
||||
if ($request->has('comment_tags') && $request->input('comment_tags') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewCommentTag::class);
|
||||
}
|
||||
|
||||
if ($request->has('followers') && $request->input('followers') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewFollow::class);
|
||||
}
|
||||
|
||||
if ($request->has('posts') && $request->input('posts') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewPost::class);
|
||||
}
|
||||
|
||||
if ($request->has('post_tags') && $request->input('post_tags') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewPostTag::class);
|
||||
}
|
||||
|
||||
if ($request->has('post_tips') && $request->input('post_tips') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewPostTip::class);
|
||||
}
|
||||
|
||||
if ($request->has('request_bounties') && $request->input('request_bounties') != null) {
|
||||
$notification->where('type', '=', 'App\Notifications\NewRequestCounty');
|
||||
}
|
||||
|
||||
if ($request->has('request_claims') && $request->input('request_claims') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewRequestClaim::class);
|
||||
}
|
||||
|
||||
if ($request->has('request_fills') && $request->input('request_fills') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewRequestFill::class);
|
||||
}
|
||||
|
||||
if ($request->has('request_approvals') && $request->input('request_approvals') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewRequestFillApprove::class);
|
||||
}
|
||||
|
||||
if ($request->has('request_rejections') && $request->input('request_rejections') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewRequestFillReject::class);
|
||||
}
|
||||
|
||||
if ($request->has('request_unclaims') && $request->input('request_unclaims') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewRequestUnclaim::class);
|
||||
}
|
||||
|
||||
if ($request->has('reseed_requests') && $request->input('reseed_requests') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewReseedRequest::class);
|
||||
}
|
||||
|
||||
if ($request->has('thanks') && $request->input('thanks') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewThank::class);
|
||||
}
|
||||
|
||||
if ($request->has('upload_tips') && $request->input('upload_tips') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewUploadTip::class);
|
||||
}
|
||||
|
||||
if ($request->has('topics') && $request->input('topics') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewTopic::class);
|
||||
}
|
||||
|
||||
if ($request->has('unfollows') && $request->input('unfollows') != null) {
|
||||
$notification->where('type', '=', 'App\Notifications\NewUnfollowt');
|
||||
}
|
||||
|
||||
if ($request->has('uploads') && $request->input('uploads') != null) {
|
||||
$notification->where('type', '=', \App\Notifications\NewUpload::class);
|
||||
}
|
||||
|
||||
$notifications = $notification->paginate(25);
|
||||
|
||||
return view('notification.results', [
|
||||
'user' => $user,
|
||||
'notifications' => $notifications,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Notification And Mark As Read.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function show($id)
|
||||
public function show(Request $request, $id)
|
||||
{
|
||||
$notification = auth()->user()->notifications()->findOrFail($id);
|
||||
$notification = $request->user()->notifications()->findOrFail($id);
|
||||
$notification->markAsRead();
|
||||
|
||||
return redirect($notification->data['url'])->with($this->toastr->success('Notification Marked As Read!', 'Yay!', ['options']));
|
||||
return redirect()->to($notification->data['url'])
|
||||
->withSuccess('Notification Marked As Read!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set A Notification To Read.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function read($id)
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
auth()->user()->unreadNotifications()->findOrFail($id)->markAsRead();
|
||||
$request->user()->unreadNotifications()->findOrFail($id)->markAsRead();
|
||||
|
||||
return redirect()->route('get_notifications')
|
||||
->with($this->toastr->success('Notification Marked As Read!', 'Yay!', ['options']));
|
||||
return redirect()->route('notifications.index')
|
||||
->withSuccess('Notification Marked As Read!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass Update All Notification's To Read.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function massRead()
|
||||
public function updateAll(Request $request)
|
||||
{
|
||||
$current = new Carbon();
|
||||
auth()->user()->unreadNotifications()->update(['read_at' => $current]);
|
||||
$request->user()->unreadNotifications()->update(['read_at' => $current]);
|
||||
|
||||
return redirect()->route('get_notifications')
|
||||
->with($this->toastr->success('All Notifications Marked As Read!', 'Yay!', ['options']));
|
||||
return redirect()->route('notifications.index')
|
||||
->withSuccess('All Notifications Marked As Read!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A Notification.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function delete($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
auth()->user()->notifications()->findOrFail($id)->delete();
|
||||
$request->user()->notifications()->findOrFail($id)->delete();
|
||||
|
||||
return redirect()->route('get_notifications')
|
||||
->with($this->toastr->success('Notification Deleted!', 'Yay!', ['options']));
|
||||
return redirect()->route('notifications.index')
|
||||
->withSuccess('Notification Deleted!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass Delete All Notification's.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteAll()
|
||||
public function destroyAll(Request $request)
|
||||
{
|
||||
auth()->user()->notifications()->delete();
|
||||
$request->user()->notifications()->delete();
|
||||
|
||||
return redirect()->route('get_notifications')
|
||||
->with($this->toastr->success('All Notifications Deleted!', 'Yay!', ['options']));
|
||||
return redirect()->route('notifications.index')
|
||||
->withSuccess('All Notifications Deleted!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class PageController extends Controller
|
||||
*/
|
||||
public function staff()
|
||||
{
|
||||
$staff = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_admin', 1)->orWhere('groups.is_modo', 1)->get();
|
||||
$staff = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select(['users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon'])->where('groups.is_admin', 1)->orWhere('groups.is_modo', 1)->get();
|
||||
|
||||
return view('page.staff', ['staff' => $staff]);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class PageController extends Controller
|
||||
*/
|
||||
public function internal()
|
||||
{
|
||||
$internal = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_internal', 1)->get();
|
||||
$internal = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select(['users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon'])->where('groups.is_internal', 1)->get();
|
||||
|
||||
return view('page.internal', ['internal' => $internal]);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Poll;
|
||||
use App\Models\Voter;
|
||||
use App\Models\Option;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\VoteOnPoll;
|
||||
use App\Repositories\ChatRepository;
|
||||
|
||||
@@ -27,21 +27,14 @@ class PollController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PollController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,15 +56,15 @@ class PollController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show($slug)
|
||||
public function show(Request $request, $slug)
|
||||
{
|
||||
$poll = Poll::whereSlug($slug)->firstOrFail();
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$user_has_voted = $poll->voters->where('user_id', '=', $user->id)->isNotEmpty();
|
||||
|
||||
if ($user_has_voted) {
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->info('You have already vote on this poll. Here are the results.', 'Hey There!', ['options']));
|
||||
->withInfo('You have already vote on this poll. Here are the results.');
|
||||
}
|
||||
|
||||
return view('poll.show', compact('poll'));
|
||||
@@ -86,7 +79,7 @@ class PollController extends Controller
|
||||
*/
|
||||
public function vote(VoteOnPoll $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$poll = Option::findOrFail($request->input('option.0'))->poll;
|
||||
|
||||
foreach ($request->input('option') as $option) {
|
||||
@@ -95,7 +88,7 @@ class PollController extends Controller
|
||||
|
||||
if (Voter::where('user_id', '=', $user->id)->where('poll_id', '=', $poll->id)->exists()) {
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->error('Bro have already vote on this poll. Your vote has not been counted.', 'Whoops!', ['options']));
|
||||
->withErros('Bro have already vote on this poll. Your vote has not been counted.');
|
||||
}
|
||||
|
||||
if ($poll->ip_checking == 1) {
|
||||
@@ -114,7 +107,7 @@ class PollController extends Controller
|
||||
);
|
||||
|
||||
return redirect('poll/'.$poll->slug.'/result')
|
||||
->with($this->toastr->success('Your vote has been counted.', 'Yay!', ['options']));
|
||||
->withSuccess('Your vote has been counted.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,27 +14,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PrivateMessage;
|
||||
|
||||
class PrivateMessageController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PrivateMessageController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search PM Inbox.
|
||||
*
|
||||
@@ -44,7 +28,7 @@ class PrivateMessageController extends Controller
|
||||
*/
|
||||
public function searchPMInbox(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pms = PrivateMessage::where('receiver_id', '=', $user->id)->where([
|
||||
['subject', 'like', '%'.$request->input('subject').'%'],
|
||||
])->latest()->paginate(20);
|
||||
@@ -61,7 +45,7 @@ class PrivateMessageController extends Controller
|
||||
*/
|
||||
public function searchPMOutbox(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pms = PrivateMessage::where('sender_id', '=', $user->id)->where([
|
||||
['subject', 'like', '%'.$request->input('subject').'%'],
|
||||
])->latest()->paginate(20);
|
||||
@@ -74,9 +58,9 @@ class PrivateMessageController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getPrivateMessages()
|
||||
public function getPrivateMessages(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pms = PrivateMessage::where('receiver_id', '=', $user->id)->latest()->paginate(25);
|
||||
|
||||
return view('pm.inbox', ['pms' => $pms, 'user' => $user]);
|
||||
@@ -87,9 +71,9 @@ class PrivateMessageController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getPrivateMessagesSent()
|
||||
public function getPrivateMessagesSent(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pms = PrivateMessage::where('sender_id', '=', $user->id)->latest()->paginate(20);
|
||||
|
||||
return view('pm.outbox', ['pms' => $pms, 'user' => $user]);
|
||||
@@ -102,9 +86,9 @@ class PrivateMessageController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getPrivateMessageById($id)
|
||||
public function getPrivateMessageById(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pm = PrivateMessage::where('id', '=', $id)->firstOrFail();
|
||||
|
||||
if ($pm->sender_id == $user->id || $pm->receiver_id == $user->id) {
|
||||
@@ -116,24 +100,23 @@ class PrivateMessageController extends Controller
|
||||
return view('pm.message', ['pm' => $pm, 'user' => $user]);
|
||||
} else {
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->error('What Are You Trying To Do Here!', 'Whoops!', ['options']));
|
||||
->withErrors('What Are You Trying To Do Here!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Message Form.
|
||||
*
|
||||
* @param $receiver_id
|
||||
* @param string $receiver_id
|
||||
*
|
||||
* @param string $username
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function makePrivateMessage($receiver_id = '', $username = '')
|
||||
public function makePrivateMessage(Request $request, $receiver_id = '', $username = '')
|
||||
{
|
||||
$user = auth()->user();
|
||||
$usernames = User::oldest('username')->get();
|
||||
$user = $request->user();
|
||||
|
||||
return view('pm.send', ['usernames' => $usernames, 'user' => $user, 'receiver_id' => $receiver_id,
|
||||
'username' => $username, ]);
|
||||
return view('pm.send', ['user' => $user, 'receiver_id' => $receiver_id, 'username' => $username]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,16 +128,23 @@ class PrivateMessageController extends Controller
|
||||
*/
|
||||
public function sendPrivateMessage(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$dest = 'default';
|
||||
if ($request->has('dest') && $request->input('dest') == 'profile') {
|
||||
$dest = 'profile';
|
||||
}
|
||||
|
||||
if ($request->has('receiver_id')) {
|
||||
$recipient = User::where('username', '=', $request->input('receiver_id'))->firstOrFail();
|
||||
} else {
|
||||
return redirect()->route('create', ['username' => $request->user()->username, 'id' => $request->user()->id])
|
||||
->withErrors($v->errors());
|
||||
}
|
||||
|
||||
$pm = new PrivateMessage();
|
||||
$pm->sender_id = $user->id;
|
||||
$pm->receiver_id = $request->input('receiver_id');
|
||||
$pm->receiver_id = $recipient->id;
|
||||
$pm->subject = $request->input('subject');
|
||||
$pm->message = $request->input('message');
|
||||
$pm->read = 0;
|
||||
@@ -167,30 +157,23 @@ class PrivateMessageController extends Controller
|
||||
'read' => 'required',
|
||||
]);
|
||||
|
||||
if ($request->has('receiver_id')) {
|
||||
$recipient = User::where('id', '=', (int) $request->input('receiver_id'))->firstOrFail();
|
||||
} else {
|
||||
return redirect()->route('create', ['username' => auth()->user()->username, 'id' => auth()->user()->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
}
|
||||
|
||||
if ($v->fails()) {
|
||||
if ($dest == 'profile') {
|
||||
return redirect()->route('profile', ['username' => $recipient->slug, 'id'=> $recipient->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
}
|
||||
|
||||
return redirect()->route('create', ['username' => auth()->user()->username, 'id' => auth()->user()->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('create', ['username' => $request->user()->username, 'id' => $request->user()->id])
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$pm->save();
|
||||
if ($dest == 'profile') {
|
||||
return redirect()->route('profile', ['username' => $recipient->slug, 'id'=> $recipient->id])
|
||||
->with($this->toastr->success('Your PM Was Sent Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Your PM Was Sent Successfully!');
|
||||
}
|
||||
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->success('Your PM Was Sent Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Your PM Was Sent Successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +187,7 @@ class PrivateMessageController extends Controller
|
||||
*/
|
||||
public function replyPrivateMessage(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$message = PrivateMessage::where('id', '=', $id)->firstOrFail();
|
||||
|
||||
@@ -227,12 +210,12 @@ class PrivateMessageController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$pm->save();
|
||||
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->success('Your PM Was Sent Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Your PM Was Sent Successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,19 +226,19 @@ class PrivateMessageController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deletePrivateMessage($id)
|
||||
public function deletePrivateMessage(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pm = PrivateMessage::where('id', '=', $id)->firstOrFail();
|
||||
|
||||
if ($pm->sender_id == $user->id || $pm->receiver_id == $user->id) {
|
||||
$pm->delete();
|
||||
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->success('PM Was Deleted Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('PM Was Deleted Successfully!');
|
||||
} else {
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->error('What Are You Trying To Do Here!', 'Whoops!', ['options']));
|
||||
->withErrors('What Are You Trying To Do Here!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,9 +247,9 @@ class PrivateMessageController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function markAllAsRead()
|
||||
public function markAllAsRead(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$pms = PrivateMessage::where('receiver_id', '=', $user->id)->get();
|
||||
foreach ($pms as $pm) {
|
||||
$pm->read = 1;
|
||||
@@ -274,6 +257,6 @@ class PrivateMessageController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('inbox')
|
||||
->with($this->toastr->success('Your Messages Have All Been Marked As Read!', 'Yay!', ['options']));
|
||||
->withSuccess('Your Messages Have All Been Marked As Read!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace App\Http\Controllers;
|
||||
use App\Models\User;
|
||||
use App\Models\Report;
|
||||
use App\Models\Torrent;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\TorrentRequest;
|
||||
|
||||
@@ -27,21 +26,14 @@ class ReportController extends Controller
|
||||
*/
|
||||
private $report;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ReportController Constructor.
|
||||
*
|
||||
* @param Report $report
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Report $report, Toastr $toastr)
|
||||
public function __construct(Report $report)
|
||||
{
|
||||
$this->report = $report;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +47,7 @@ class ReportController extends Controller
|
||||
public function request(Request $request, int $id)
|
||||
{
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
$reported_by = auth()->user();
|
||||
$reported_by = $request->user();
|
||||
$reported_user = $torrentRequest->user;
|
||||
|
||||
$v = validator($request->all(), [
|
||||
@@ -64,7 +56,7 @@ class ReportController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$this->report->create([
|
||||
'type' => 'Request',
|
||||
@@ -81,7 +73,7 @@ class ReportController extends Controller
|
||||
\LogActivity::addToLog("Member {$reported_by->username} has made a new Torrent Request report.");
|
||||
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success('Your report has been successfully sent', 'Yay!', ['options']));
|
||||
->withSuccess('Your report has been successfully sent');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +89,7 @@ class ReportController extends Controller
|
||||
public function torrent(Request $request, $slug, int $id)
|
||||
{
|
||||
$torrent = Torrent::findOrFail($id);
|
||||
$reported_by = auth()->user();
|
||||
$reported_by = $request->user();
|
||||
$reported_user = $torrent->user;
|
||||
|
||||
$v = validator($request->all(), [
|
||||
@@ -106,7 +98,7 @@ class ReportController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('torrent', ['slug' => $slug, 'id' => $id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$this->report->create([
|
||||
'type' => 'Torrent',
|
||||
@@ -123,7 +115,7 @@ class ReportController extends Controller
|
||||
\LogActivity::addToLog("Member {$reported_by->username} has made a new Torrent report.");
|
||||
|
||||
return redirect()->route('torrent', ['slug' => $slug, 'id' => $id])
|
||||
->with($this->toastr->success('Your report has been successfully sent', 'Yay!', ['options']));
|
||||
->withSuccess('Your report has been successfully sent');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +131,7 @@ class ReportController extends Controller
|
||||
public function user(Request $request, $username, int $id)
|
||||
{
|
||||
$reported_user = User::findOrFail($id);
|
||||
$reported_by = auth()->user();
|
||||
$reported_by = $request->user();
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'message' => 'required',
|
||||
@@ -147,7 +139,7 @@ class ReportController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('profile', ['username' => $username, 'id' => $id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$this->report->create([
|
||||
'type' => 'User',
|
||||
@@ -164,7 +156,7 @@ class ReportController extends Controller
|
||||
\LogActivity::addToLog("Member {$reported_by->username} has made a new User report.");
|
||||
|
||||
return redirect()->route('profile', ['username' => $username, 'id' => $id])
|
||||
->with($this->toastr->success('Your report has been successfully sent', 'Yay!', ['options']));
|
||||
->withSuccess('Your report has been successfully sent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,9 @@ namespace App\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Type;
|
||||
use App\Models\User;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Category;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PrivateMessage;
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Models\BonTransactions;
|
||||
use App\Models\TorrentRequestClaim;
|
||||
@@ -50,23 +48,16 @@ class RequestController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* RequestController Constructor.
|
||||
*
|
||||
* @param RequestFacetedRepository $faceted
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(RequestFacetedRepository $faceted, ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(RequestFacetedRepository $faceted, ChatRepository $chat)
|
||||
{
|
||||
$this->faceted = $faceted;
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,9 +65,9 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function requests()
|
||||
public function requests(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$num_req = TorrentRequest::count();
|
||||
$num_fil = TorrentRequest::whereNotNull('filled_by')->count();
|
||||
$num_unfil = TorrentRequest::whereNull('filled_by')->count();
|
||||
@@ -104,15 +95,16 @@ class RequestController extends Controller
|
||||
* Uses Input's To Put Together A Search.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param TorrentRequest $torrentRequest
|
||||
* @param TorrentRequest $torrentRequest
|
||||
*
|
||||
* @return array
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function faceted(Request $request, TorrentRequest $torrentRequest)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$search = $request->input('search');
|
||||
$imdb_id = starts_with($request->get('imdb'), 'tt') ? $request->get('imdb') : 'tt'.$request->get('imdb');
|
||||
$imdb_id = Str::startsWith($request->get('imdb'), 'tt') ? $request->get('imdb') : 'tt'.$request->get('imdb');
|
||||
$imdb = str_replace('tt', '', $imdb_id);
|
||||
$tvdb = $request->input('tvdb');
|
||||
$tmdb = $request->input('tmdb');
|
||||
@@ -202,12 +194,14 @@ class RequestController extends Controller
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \ErrorException
|
||||
* @throws \HttpInvalidParamException
|
||||
*/
|
||||
public function request($id)
|
||||
public function request(Request $request, $id)
|
||||
{
|
||||
// Find the torrent in the database
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequestClaim = TorrentRequestClaim::where('request_id', '=', $id)->first();
|
||||
$voters = $torrentRequest->requestBounty()->get();
|
||||
$comments = $torrentRequest->comments()->latest('created_at')->paginate(6);
|
||||
@@ -240,16 +234,22 @@ class RequestController extends Controller
|
||||
/**
|
||||
* Torrent Request Add Form.
|
||||
*
|
||||
* @param string $title
|
||||
* @param int $imdb
|
||||
* @param int $tmdb
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function addRequestForm()
|
||||
public function addRequestForm(Request $request, $title = '', $imdb = 0, $tmdb = 0)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
return view('requests.add_request', [
|
||||
'categories' => Category::all()->sortBy('position'),
|
||||
'types' => Type::all()->sortBy('position'),
|
||||
'user' => $user,
|
||||
'title' => $title,
|
||||
'imdb' => str_replace('tt', '', $imdb),
|
||||
'tmdb' => $tmdb,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function addrequest(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$category = Category::findOrFail($request->input('category_id'));
|
||||
$tr = new TorrentRequest();
|
||||
@@ -294,7 +294,7 @@ class RequestController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('requests')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors())->withInput();
|
||||
} else {
|
||||
$tr->save();
|
||||
|
||||
@@ -334,8 +334,8 @@ class RequestController extends Controller
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Member {$user->username} has made a new torrent request, ID: {$tr->id} NAME: {$tr->name} .");
|
||||
|
||||
return redirect('/requests')
|
||||
->with($this->toastr->success('Request Added.', 'Yay!', ['options']));
|
||||
return redirect()->to('/requests')
|
||||
->withSuccess('Request Added.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,9 +346,9 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function editRequestForm($id)
|
||||
public function editRequestForm(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
|
||||
return view('requests.edit_request', [
|
||||
@@ -368,7 +368,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function editrequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
abort_unless($user->group->is_modo || $user->id === $torrentRequest->user_id, 403);
|
||||
|
||||
@@ -407,7 +407,7 @@ class RequestController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('requests')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$torrentRequest->save();
|
||||
|
||||
@@ -420,7 +420,7 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('requests', ['id' => $torrentRequest->id])
|
||||
->with($this->toastr->success('Request Edited Successfully.', 'Yay!', ['options']));
|
||||
->withSuccess('Request Edited Successfully.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function addBonus(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$tr = TorrentRequest::with('user')->findOrFail($id);
|
||||
$tr->votes += 1;
|
||||
@@ -447,7 +447,7 @@ class RequestController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('request', ['id' => $tr->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$tr->save();
|
||||
|
||||
@@ -491,7 +491,7 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
$requester = $tr->user;
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_bounty')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_bounty')) {
|
||||
$requester->notify(new NewRequestBounty('torrent', $sender, $request->input('bonus_value'), $tr));
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ class RequestController extends Controller
|
||||
\LogActivity::addToLog("Member {$user->username} has added a BON bounty to torrent request, ID: {$tr->id} NAME: {$tr->name} .");
|
||||
|
||||
return redirect()->route('request', ['id' => $request->input('request_id')])
|
||||
->with($this->toastr->success('Your bonus has been successfully added.', 'Yay!', ['options']));
|
||||
->withSuccess('Your bonus has been successfully added.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function fillRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
$torrentRequest->filled_by = $user->id;
|
||||
@@ -529,7 +529,7 @@ class RequestController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('request', ['id' => $request->input('request_id')])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$torrentRequest->save();
|
||||
|
||||
@@ -543,27 +543,15 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
$requester = $torrentRequest->user;
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_fill')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_fill')) {
|
||||
$requester->notify(new NewRequestFill('torrent', $sender, $torrentRequest));
|
||||
}
|
||||
|
||||
$pm = new PrivateMessage();
|
||||
$pm->sender_id = 1;
|
||||
$pm->receiver_id = $torrentRequest->user_id;
|
||||
$pm->subject = 'Your Request '.$torrentRequest->name.' Has Been Filled!';
|
||||
$profile_url = hrefProfile($user);
|
||||
if ($torrentRequest->filled_anon == 0) {
|
||||
$pm->message = "[url={$profile_url}]{$user->username}[/url] Has Filled Your Request [url={$appurl}/request/".$torrentRequest->id.']'.$torrentRequest->name.'[/url]'.' Please Approve or Decline The FullFill! ';
|
||||
} else {
|
||||
$pm->message = "An Anonymous User Filled Your Request [url={$appurl}/request/".$torrentRequest->id.']'.$torrentRequest->name.'[/url]'.' Please Approve or Decline The FullFill! ';
|
||||
}
|
||||
$pm->save();
|
||||
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Member {$user->username} has filled torrent request, ID: {$torrentRequest->id} NAME: {$torrentRequest->name} . It is now pending approval.");
|
||||
|
||||
return redirect()->route('request', ['id' => $request->input('request_id')])
|
||||
->with($this->toastr->success('Your request fill is pending approval by the Requester.', 'Yay!', ['options']));
|
||||
->withSuccess('Your request fill is pending approval by the Requester.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,16 +562,16 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function approveRequest($id)
|
||||
public function approveRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$tr = TorrentRequest::findOrFail($id);
|
||||
|
||||
if ($user->id == $tr->user_id || auth()->user()->group->is_modo) {
|
||||
if ($user->id == $tr->user_id || $request->user()->group->is_modo) {
|
||||
if ($tr->approved_by != null) {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error('Seems this request was already approved', 'Whoops!', ['options']));
|
||||
->withErrors('Seems this request was already approved');
|
||||
}
|
||||
$tr->approved_by = $user->id;
|
||||
$tr->approved_when = Carbon::now();
|
||||
@@ -626,7 +614,7 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
$requester = $fill_user;
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_fill_approve')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_fill_approve')) {
|
||||
$requester->notify(new NewRequestFillApprove('torrent', $user->username, $tr));
|
||||
}
|
||||
|
||||
@@ -635,14 +623,14 @@ class RequestController extends Controller
|
||||
|
||||
if ($tr->filled_anon == 0) {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success("You have approved {$tr->name} and the bounty has been awarded to {$fill_user->username}", 'Yay!', ['options']));
|
||||
->withSuccess("You have approved {$tr->name} and the bounty has been awarded to {$fill_user->username}");
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success("You have approved {$tr->name} and the bounty has been awarded to a anonymous user", 'Yay!', ['options']));
|
||||
->withSuccess("You have approved {$tr->name} and the bounty has been awarded to a anonymous user");
|
||||
}
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error("You don't have access to approve this request", 'Whoops!', ['options']));
|
||||
->withErrors("You don't have access to approve this request");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,20 +641,20 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function rejectRequest($id)
|
||||
public function rejectRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$appurl = config('app.url');
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
|
||||
if ($user->id == $torrentRequest->user_id) {
|
||||
if ($torrentRequest->approved_by != null) {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error('Seems this request was already rejected', 'Whoops!', ['options']));
|
||||
->withErrors('Seems this request was already rejected');
|
||||
}
|
||||
|
||||
$requester = User::findOrFail($torrentRequest->filled_by);
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_fill_reject')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_fill_reject')) {
|
||||
$requester->notify(new NewRequestFillReject('torrent', $user->username, $torrentRequest));
|
||||
}
|
||||
|
||||
@@ -679,10 +667,10 @@ class RequestController extends Controller
|
||||
$torrentRequest->save();
|
||||
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success('This request has been reset.', 'Yay!', ['options']));
|
||||
->withSuccess('This request has been reset.');
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success("You don't have access to approve this request", 'Yay!', ['options']));
|
||||
->withSuccess("You don't have access to approve this request");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,9 +681,9 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteRequest($id)
|
||||
public function deleteRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
|
||||
if ($user->group->is_modo || $torrentRequest->user_id == $user->id) {
|
||||
@@ -706,10 +694,10 @@ class RequestController extends Controller
|
||||
\LogActivity::addToLog("Member {$user->username} has deleted torrent request, ID: {$torrentRequest->id} NAME: {$torrentRequest->name} .");
|
||||
|
||||
return redirect()->route('requests')
|
||||
->with($this->toastr->success("You have deleted {$name}", 'Yay!', ['options']));
|
||||
->withSuccess("You have deleted {$name}");
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error("You don't have access to delete this request.", 'Whoops!', ['options']));
|
||||
->withErrors("You don't have access to delete this request.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,7 +711,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function claimRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequest = TorrentRequest::with('user')->findOrFail($id);
|
||||
|
||||
if ($torrentRequest->claimed == null) {
|
||||
@@ -743,7 +731,7 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
$requester = $torrentRequest->user;
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_claim')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_claim')) {
|
||||
$requester->notify(new NewRequestClaim('torrent', $sender, $torrentRequest));
|
||||
}
|
||||
|
||||
@@ -751,10 +739,10 @@ class RequestController extends Controller
|
||||
\LogActivity::addToLog("Member {$user->username} has claimed torrent request, ID: {$torrentRequest->id} NAME: {$torrentRequest->name} .");
|
||||
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success('Request Successfully Claimed', 'Yay!', ['options']));
|
||||
->withSuccess('Request Successfully Claimed');
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error('Someone else has already claimed this request buddy.', 'Whoops!', ['options']));
|
||||
->withErrors('Someone else has already claimed this request buddy.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,9 +753,9 @@ class RequestController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function unclaimRequest($id)
|
||||
public function unclaimRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
$claimer = TorrentRequestClaim::where('request_id', '=', $id)->first();
|
||||
|
||||
@@ -788,7 +776,7 @@ class RequestController extends Controller
|
||||
}
|
||||
|
||||
$requester = $torrentRequest->user;
|
||||
if ($requester->acceptsNotification(auth()->user(), $requester, 'request', 'show_request_unclaim')) {
|
||||
if ($requester->acceptsNotification($request->user(), $requester, 'request', 'show_request_unclaim')) {
|
||||
$requester->notify(new NewRequestUnclaim('torrent', $sender, $torrentRequest));
|
||||
}
|
||||
|
||||
@@ -796,10 +784,10 @@ class RequestController extends Controller
|
||||
\LogActivity::addToLog("Member {$user->username} has un-claimed torrent request, ID: {$torrentRequest->id} NAME: {$torrentRequest->name} .");
|
||||
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success('Request Successfully Un-Claimed', 'Yay!', ['options']));
|
||||
->withSuccess('Request Successfully Un-Claimed');
|
||||
} else {
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->error('Nothing To Unclaim.', 'Whoops!', ['options']));
|
||||
->withErrors('Nothing To Unclaim.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ use App\Models\Group;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Category;
|
||||
use App\Models\TagTorrent;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Repositories\TorrentFacetedRepository;
|
||||
|
||||
@@ -31,21 +30,14 @@ class RssController extends Controller
|
||||
*/
|
||||
private $torrent_faceted;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* RssController Constructor.
|
||||
*
|
||||
* @param TorrentFacetedRepository $torrent_faceted
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(TorrentFacetedRepository $torrent_faceted, Toastr $toastr)
|
||||
public function __construct(TorrentFacetedRepository $torrent_faceted)
|
||||
{
|
||||
$this->torrent_faceted = $torrent_faceted;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,9 +46,9 @@ class RssController extends Controller
|
||||
* @param string $hash
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index($hash = null)
|
||||
public function index(Request $request, $hash = null)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$public_rss = Rss::where('is_private', '=', 0)->orderBy('position', 'ASC')->get();
|
||||
$private_rss = Rss::where('is_private', '=', 1)->where('user_id', '=', $user->id)->latest()->get();
|
||||
@@ -74,9 +66,9 @@ class RssController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent_repository = $this->torrent_faceted;
|
||||
|
||||
return view('rss.create', [
|
||||
@@ -95,7 +87,7 @@ class RssController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'name' => 'required|min:3|max:255',
|
||||
@@ -131,11 +123,11 @@ class RssController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('rss.create')
|
||||
->with($this->toastr->error($error, 'Whoops!', ['options']));
|
||||
->withErrors($error);
|
||||
}
|
||||
|
||||
return redirect()->route('rss.index.hash', ['hash' => 'private'])
|
||||
->with($this->toastr->success($success, 'Yay!', ['options']));
|
||||
->withSuccess($success);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,8 +142,8 @@ class RssController extends Controller
|
||||
$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();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
|
||||
if ($user->group->id == $bannedGroup->id) {
|
||||
abort(404);
|
||||
@@ -163,8 +155,6 @@ class RssController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$torrent = Torrent::with(['user', 'category']);
|
||||
|
||||
$search = $rss->object_torrent->search;
|
||||
$description = $rss->object_torrent->description;
|
||||
$uploader = $rss->object_torrent->uploader;
|
||||
@@ -204,7 +194,7 @@ class RssController extends Controller
|
||||
$description .= '%'.$keyword.'%';
|
||||
}
|
||||
|
||||
$torrent = $torrent->with(['user', 'category'])->withCount(['thanks', 'comments']);
|
||||
$torrent = Torrent::with(['user', 'category']);
|
||||
|
||||
if ($rss->object_torrent->search) {
|
||||
$torrent->where(function ($query) use ($search) {
|
||||
@@ -251,7 +241,7 @@ class RssController extends Controller
|
||||
}
|
||||
|
||||
if ($rss->object_torrent->genres && is_array($rss->object_torrent->genres)) {
|
||||
$genreID = TagTorrent::distinct()->select('torrent_id')->whereIn('tag_name', $genres)->get();
|
||||
$genreID = TagTorrent::select(['torrent_id'])->distinct()->whereIn('tag_name', $genres)->get();
|
||||
$torrent->whereIn('id', $genreID)->cursor();
|
||||
}
|
||||
|
||||
@@ -295,12 +285,9 @@ class RssController extends Controller
|
||||
$torrent->where('seeders', '=', $dead);
|
||||
}
|
||||
|
||||
$torrents = $torrent->latest()->paginate(50);
|
||||
$torrents = $torrent->latest()->take(50)->get();
|
||||
|
||||
return view('rss.show', [
|
||||
'torrents' => $torrents,
|
||||
'rsskey' => $user->rsskey,
|
||||
])->render();
|
||||
return response()->view('rss.show', ['torrents' => $torrents, 'rsskey' => $user->rsskey])->header('Content-Type', 'text/xml');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,9 +296,9 @@ class RssController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$rss = Rss::where('is_private', '=', 1)->findOrFail($id);
|
||||
$torrent_repository = $this->torrent_faceted;
|
||||
|
||||
@@ -333,7 +320,7 @@ class RssController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$rss = Rss::where('is_private', '=', 1)->findOrFail($id);
|
||||
|
||||
$v = validator($request->all(), [
|
||||
@@ -367,11 +354,11 @@ class RssController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('rss.edit', ['id' => $id])
|
||||
->with($this->toastr->error($error, 'Whoops!', ['options']));
|
||||
->withErrors($error);
|
||||
}
|
||||
|
||||
return redirect()->route('rss.index.hash', ['hash' => 'private'])
|
||||
->with($this->toastr->success($success, 'Yay!', ['options']));
|
||||
->withSuccess($success);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,6 +373,6 @@ class RssController extends Controller
|
||||
$rss->delete();
|
||||
|
||||
return redirect()->route('rss.index.hash', ['hash' => 'private'])
|
||||
->with($this->toastr->success('RSS Feed Deleted!', 'Yay!', ['options']));
|
||||
->withSuccess('RSS Feed Deleted!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Seedbox;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SeedboxController extends Controller
|
||||
{
|
||||
/**
|
||||
* Get A Users Registered Seedboxes.
|
||||
*
|
||||
* @param $username
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index(Request $request, $username)
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
abort_unless(($request->user()->group->is_modo || $request->user()->id == $user->id), 403);
|
||||
|
||||
$seedboxes = Seedbox::where('user_id', '=', $user->id)->paginate(25);
|
||||
|
||||
return view('seedbox.index', ['user' => $user, 'seedboxes' => $seedboxes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store A Seedbox.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $username
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function store(Request $request, $username)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$seedbox = new Seedbox();
|
||||
$seedbox->user_id = $user->id;
|
||||
$seedbox->name = $request->input('name');
|
||||
$seedbox->ip = $request->input('ip');
|
||||
|
||||
$v = validator($seedbox->toArray(), [
|
||||
'name' => 'required|alpha_num',
|
||||
'ip' => 'required|unique:clients,ip',
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('seedboxes.index', ['username' => $user->username])
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$seedbox->save();
|
||||
|
||||
// Activity Log
|
||||
\LogActivity::addToLog("Member {$user->username} has added a new seedbox to there account.");
|
||||
|
||||
return redirect()->route('seedboxes.index', ['username' => $user->username])
|
||||
->withSuccess('Seedbox Has Been Successfully Added!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A Seedbox.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function destroy(Request $request, $username, $id)
|
||||
{
|
||||
$user = $request->user();
|
||||
$seedbox = Seedbox::findOrFail($id);
|
||||
|
||||
abort_unless(($user->group->is_modo || $user->id == $seedbox->user_id), 403);
|
||||
|
||||
$seedbox->delete();
|
||||
|
||||
return redirect()->route('seedboxes.index', ['username' => $user->username])
|
||||
->withSuccess('Seedbox Has Been Successfully Deleted');
|
||||
}
|
||||
}
|
||||
@@ -14,26 +14,11 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\LogActivity;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ActivityLogController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ActivityLogController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display All Activities.
|
||||
*
|
||||
@@ -53,15 +38,15 @@ class ActivityLogController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$activity = LogActivity::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
$activity->delete();
|
||||
|
||||
return redirect()->route('activity.index')
|
||||
->with($this->toastr->success('Activity Record Has Successfully Been Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Activity Record Has Successfully Been Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ use Ramsey\Uuid\Uuid;
|
||||
use App\Models\Invite;
|
||||
use App\Mail\InviteUser;
|
||||
use App\Models\Application;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Mail\DenyApplication;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -25,21 +24,6 @@ use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class ApplicationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ApplicationController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Applications.
|
||||
*
|
||||
@@ -81,7 +65,7 @@ class ApplicationController extends Controller
|
||||
|
||||
if ($application->status !== 1) {
|
||||
$current = new Carbon();
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$code = Uuid::uuid4()->toString();
|
||||
$invite = new Invite();
|
||||
@@ -110,7 +94,7 @@ class ApplicationController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
Mail::to($application->email)->send(new InviteUser($invite));
|
||||
$invite->save();
|
||||
@@ -120,11 +104,11 @@ class ApplicationController extends Controller
|
||||
\LogActivity::addToLog("Staff member {$user->username} has approved {$application->email} application.");
|
||||
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->success('Application Approved', 'Yay!', ['options']));
|
||||
->withSuccess('Application Approved');
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error('Application Already Approved', 'Whoops!', ['options']));
|
||||
return redirect()->route('staff.applications.index')
|
||||
->withErrors('Application Already Approved');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,10 +133,10 @@ class ApplicationController extends Controller
|
||||
Mail::to($application->email)->send(new DenyApplication($denied_message));
|
||||
|
||||
return redirect()->route('staff.applications.index')
|
||||
->with($this->toastr->info('Application Rejected', 'Info!', ['options']));
|
||||
->withSuccess('Application Rejected');
|
||||
} else {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error('Application Already Rejected', 'Whoops!', ['options']));
|
||||
return redirect()->route('staff.applications.index')
|
||||
->withErrors('Application Already Rejected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+11
-26
@@ -15,27 +15,12 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use Image;
|
||||
use App\Models\Article;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ArticleController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Articles.
|
||||
*
|
||||
@@ -69,9 +54,9 @@ class ArticleController extends Controller
|
||||
{
|
||||
$article = new Article();
|
||||
$article->title = $request->input('title');
|
||||
$article->slug = str_slug($article->title);
|
||||
$article->slug = Str::slug($article->title);
|
||||
$article->content = $request->input('content');
|
||||
$article->user_id = auth()->user()->id;
|
||||
$article->user_id = $request->user()->id;
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
@@ -80,7 +65,7 @@ class ArticleController extends Controller
|
||||
Image::make($image->getRealPath())->fit(75, 75)->encode('png', 100)->save($path);
|
||||
$article->image = $filename;
|
||||
} else {
|
||||
// Use Default /public/img/missing-image.jpg
|
||||
// Use Default /public/img/missing-image.png
|
||||
$article->image = null;
|
||||
}
|
||||
|
||||
@@ -93,12 +78,12 @@ class ArticleController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_article_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$article->save();
|
||||
|
||||
return redirect()->route('staff_article_index')
|
||||
->with($this->toastr->success('Your article has successfully published!', 'Yay!', ['options']));
|
||||
->withSuccess('Your article has successfully published!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +115,7 @@ class ArticleController extends Controller
|
||||
{
|
||||
$article = Article::findOrFail($id);
|
||||
$article->title = $request->input('title');
|
||||
$article->slug = str_slug($article->title);
|
||||
$article->slug = Str::slug($article->title);
|
||||
$article->content = $request->input('content');
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
@@ -140,7 +125,7 @@ class ArticleController extends Controller
|
||||
Image::make($image->getRealPath())->fit(75, 75)->encode('png', 100)->save($path);
|
||||
$article->image = $filename;
|
||||
} else {
|
||||
// Use Default /public/img/missing-image.jpg
|
||||
// Use Default /public/img/missing-image.png
|
||||
$article->image = null;
|
||||
}
|
||||
|
||||
@@ -152,12 +137,12 @@ class ArticleController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_article_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$article->save();
|
||||
|
||||
return redirect()->route('staff_article_index')
|
||||
->with($this->toastr->success('Your article changes have successfully published!', 'Yay!', ['options']));
|
||||
->withSuccess('Your article changes have successfully published!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +160,6 @@ class ArticleController extends Controller
|
||||
$article->delete();
|
||||
|
||||
return redirect()->route('staff_article_index')
|
||||
->with($this->toastr->success('Article has successfully been deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Article has successfully been deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ class BackupController extends Controller
|
||||
/**
|
||||
* Display All Backups.
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
if (! count(config('backup.backup.destination.disks'))) {
|
||||
@@ -67,9 +67,9 @@ class BackupController extends Controller
|
||||
/**
|
||||
* Create A Backup.
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
try {
|
||||
@@ -89,14 +89,65 @@ class BackupController extends Controller
|
||||
return 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create A Backup.
|
||||
*/
|
||||
public function createFilesOnly(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
try {
|
||||
ini_set('max_execution_time', 900);
|
||||
// start the backup process
|
||||
Artisan::call('backup:run --only-files');
|
||||
$output = Artisan::output();
|
||||
|
||||
// log the results
|
||||
info('A new backup was initiated from the staff dashboard '.$output);
|
||||
// return the results as a response to the ajax call
|
||||
echo $output;
|
||||
} catch (Exception $e) {
|
||||
response($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
return 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create A Backup.
|
||||
*/
|
||||
public function createDatabaseOnly(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
try {
|
||||
ini_set('max_execution_time', 900);
|
||||
// start the backup process
|
||||
Artisan::call('backup:run --only-db');
|
||||
$output = Artisan::output();
|
||||
|
||||
// log the results
|
||||
info('A new backup was initiated from the staff dashboard '.$output);
|
||||
// return the results as a response to the ajax call
|
||||
echo $output;
|
||||
} catch (Exception $e) {
|
||||
response($e->getMessage(), 500);
|
||||
}
|
||||
|
||||
return 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
* Download A Backup.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return
|
||||
*/
|
||||
public function download(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
$disk = Storage::disk($request->input('disk'));
|
||||
@@ -119,11 +170,12 @@ class BackupController extends Controller
|
||||
/**
|
||||
* Deletes A Backup.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
$disk = Storage::disk($request->input('disk'));
|
||||
|
||||
@@ -19,28 +19,12 @@ use App\Models\User;
|
||||
use App\Mail\BanUser;
|
||||
use App\Models\Group;
|
||||
use App\Mail\UnbanUser;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class BanController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* BanController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Bans.
|
||||
*
|
||||
@@ -65,10 +49,10 @@ class BanController extends Controller
|
||||
public function ban(Request $request, $username, $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
$staff = auth()->user();
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$staff = $request->user();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
|
||||
abort_if($user->group->is_modo || auth()->user()->id == $user->id, 403);
|
||||
abort_if($user->group->is_modo || $request->user()->id == $user->id, 403);
|
||||
|
||||
$user->group_id = $bannedGroup->id;
|
||||
$user->can_upload = 0;
|
||||
@@ -89,7 +73,7 @@ class BanController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user->save();
|
||||
$ban->save();
|
||||
@@ -101,7 +85,7 @@ class BanController extends Controller
|
||||
Mail::to($user->email)->send(new BanUser($user->email, $ban));
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('User Is Now Banned!', 'Yay!', ['options']));
|
||||
->withSuccess('User Is Now Banned!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +101,9 @@ class BanController extends Controller
|
||||
public function unban(Request $request, $username, $id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
$staff = auth()->user();
|
||||
$staff = $request->user();
|
||||
|
||||
abort_if($user->group->is_modo || auth()->user()->id == $user->id, 403);
|
||||
abort_if($user->group->is_modo || $request->user()->id == $user->id, 403);
|
||||
|
||||
$user->group_id = $request->input('group_id');
|
||||
$user->can_upload = 1;
|
||||
@@ -142,7 +126,7 @@ class BanController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user->save();
|
||||
$ban->save();
|
||||
@@ -154,7 +138,7 @@ class BanController extends Controller
|
||||
Mail::to($user->email)->send(new UnbanUser($user->email, $ban));
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('User Is Now Relieved Of His Ban!', 'Yay!', ['options']));
|
||||
->withSuccess('User Is Now Relieved Of His Ban!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Bot;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class BotsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* BotsController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the Bots resource.
|
||||
*
|
||||
@@ -56,9 +41,9 @@ class BotsController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$bot = Bot::findOrFail($id);
|
||||
|
||||
return view('Staff.bots.edit', [
|
||||
@@ -76,7 +61,7 @@ class BotsController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$bot = Bot::findOrFail($id);
|
||||
|
||||
if ($request->has('command') && $request->input('command') == $bot->command) {
|
||||
@@ -111,7 +96,7 @@ class BotsController extends Controller
|
||||
|
||||
if ($v->passes()) {
|
||||
$bot->name = $request->input('name');
|
||||
$bot->slug = str_slug($request->input('name'));
|
||||
$bot->slug = Str::slug($request->input('name'));
|
||||
$bot->position = $request->input('position');
|
||||
$bot->color = $request->input('color');
|
||||
$bot->icon = $request->input('icon');
|
||||
@@ -130,11 +115,11 @@ class BotsController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.bots.edit', ['id' => $id])
|
||||
->with($this->toastr->error($error, 'Whoops!', ['options']));
|
||||
->withErrors($error);
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.bots.edit', ['id' => $id])
|
||||
->with($this->toastr->success($success, 'Yay!', ['options']));
|
||||
->withSuccess($success);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +134,7 @@ class BotsController extends Controller
|
||||
$bot->delete();
|
||||
|
||||
return redirect()->route('Staff.bots.index')
|
||||
->with($this->toastr->success('The Humans Vs Machines War Has Begun! Humans: 1 and Bots: 0', 'Yay!', ['options']));
|
||||
->withSuccess('The Humans Vs Machines War Has Begun! Humans: 1 and Bots: 0');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +150,7 @@ class BotsController extends Controller
|
||||
$bot->save();
|
||||
|
||||
return redirect()->route('Staff.bots.index')
|
||||
->with($this->toastr->success('The Bot Has Been Disabled', 'Yay!', ['options']));
|
||||
->withSuccess('The Bot Has Been Disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +166,6 @@ class BotsController extends Controller
|
||||
$bot->save();
|
||||
|
||||
return redirect()->route('Staff.bots.index')
|
||||
->with($this->toastr->success('The Bot Has Been Enabled', 'Yay!', ['options']));
|
||||
->withSuccess('The Bot Has Been Enabled');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Catalog;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\CatalogTorrent;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CatalogController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* CatalogController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Catalogs.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getCatalogs()
|
||||
{
|
||||
$catalogs = Catalog::latest('name')->get();
|
||||
|
||||
return view('Staff.catalog.catalogs', ['catalogs' => $catalogs]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create A Catalog.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postCatalog(Request $request)
|
||||
{
|
||||
$v = validator($request->all(), [
|
||||
'catalog' => 'required|min:3|max:20|regex:/^[(a-zA-Z\-)]+$/u',
|
||||
]);
|
||||
$catalog = Catalog::where('name', '=', $request->input('catalog'))->first();
|
||||
if ($catalog) {
|
||||
return redirect()->route('catalogs')
|
||||
->with($this->toastr->error('Catalog '.$catalog->name.' is already in database', 'Whoops!', ['options']));
|
||||
}
|
||||
$catalog = new Catalog();
|
||||
$catalog->name = $request->input('catalog');
|
||||
$catalog->slug = str_slug($request->input('catalog'));
|
||||
$catalog->save();
|
||||
|
||||
return redirect()->route('getCatalog')
|
||||
->with($this->toastr->success('Catalog '.$request->input('catalog').' has been successfully added', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit A Catalog.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $catalog_id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function editCatalog(Request $request, $catalog_id)
|
||||
{
|
||||
$v = validator($request->all(), [
|
||||
'catalog' => 'required|min:3|max:20|regex:/^[(a-zA-Z\-)]+$/u',
|
||||
]);
|
||||
$catalog = Catalog::findOrFail($catalog_id);
|
||||
if (! $catalog) {
|
||||
return redirect()->route('getCatalog')
|
||||
->with($this->toastr->error('Catalog '.$request->input('catalog').' is not in our DB!', 'Whoops!', ['options']));
|
||||
}
|
||||
$catalog->name = $request->input('catalog');
|
||||
$catalog->save();
|
||||
|
||||
return redirect()->route('getCatalog')
|
||||
->with($this->toastr->success('Catalog '.$request->input('catalog').' has been successfully edited', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A Catalog.
|
||||
*
|
||||
* @param $catalog_id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteCatalog($catalog_id)
|
||||
{
|
||||
$catalog = Catalog::findOrFail($catalog_id);
|
||||
if (! $catalog) {
|
||||
return redirect()->route('getCatalog')
|
||||
->with($this->toastr->error('That Catalog Is Not In Our DB!', 'Whoops!', ['options']));
|
||||
}
|
||||
$catalog->delete();
|
||||
|
||||
return redirect()->route('getCatalog')
|
||||
->with($this->toastr->success('Catalog '.$catalog->name.' has been successfully deleted', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog Torrent System.
|
||||
*/
|
||||
public function getCatalogTorrent()
|
||||
{
|
||||
$catalogs = Catalog::latest('name')->get();
|
||||
|
||||
return view('Staff.catalog.catalog_torrent')->with('catalogs', $catalogs);
|
||||
}
|
||||
|
||||
//Add New Catalog Torrent
|
||||
public function postCatalogTorrent(Request $request)
|
||||
{
|
||||
// Find the right catalog
|
||||
$catalog = Catalog::findOrFail($request->input('catalog_id'));
|
||||
$v = validator($request->all(), [
|
||||
'imdb' => 'required|numeric',
|
||||
'tvdb' => 'required|numeric',
|
||||
'catalog_id' => 'required|numeric|exists:catalog_id',
|
||||
]);
|
||||
$torrent = CatalogTorrent::where('imdb', '=', $request->input('imdb'))->first();
|
||||
if ($torrent) {
|
||||
return redirect()->route('getCatalogTorrent')->with($this->toastr->error('IMDB# '.$torrent->imdb.' is already in database', 'Whoops!', ['options']));
|
||||
}
|
||||
$torrent = new CatalogTorrent();
|
||||
$torrent->imdb = $request->input('imdb');
|
||||
$torrent->catalog_id = $request->input('catalog_id');
|
||||
$torrent->save();
|
||||
// Count and save the torrent number in this catalog
|
||||
$catalog->num_torrent = CatalogTorrent::where('catalog_id', '=', $catalog->id)->count();
|
||||
$catalog->save();
|
||||
|
||||
return redirect()->route('getCatalogTorrent')->with($this->toastr->success('IMDB# '.$request->input('imdb').' has been successfully added', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
// Get Catalogs Records
|
||||
public function getCatalogRecords($catalog_id)
|
||||
{
|
||||
$catalogs = Catalog::findOrFail($catalog_id);
|
||||
$records = CatalogTorrent::where('catalog_id', '=', $catalog_id)->latest('imdb')->get();
|
||||
|
||||
return view('Staff.catalog.catalog_records', ['catalog' => $catalogs, 'records' => $records]);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+8
-23
@@ -14,27 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Category;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* CategoryController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Categories.
|
||||
*
|
||||
@@ -68,7 +53,7 @@ class CategoryController extends Controller
|
||||
{
|
||||
$category = new Category();
|
||||
$category->name = $request->input('name');
|
||||
$category->slug = str_slug($category->name);
|
||||
$category->slug = Str::slug($category->name);
|
||||
$category->position = $request->input('position');
|
||||
$category->icon = $request->input('icon');
|
||||
$category->movie_meta = $request->input('movie_meta');
|
||||
@@ -91,12 +76,12 @@ class CategoryController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_category_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$category->save();
|
||||
|
||||
return redirect()->route('staff_category_index')
|
||||
->with($this->toastr->success('Category Successfully Added', 'Yay!', ['options']));
|
||||
->withSuccess('Category Successfully Added');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +113,7 @@ class CategoryController extends Controller
|
||||
{
|
||||
$category = Category::findOrFail($id);
|
||||
$category->name = $request->input('name');
|
||||
$category->slug = str_slug($category->name);
|
||||
$category->slug = Str::slug($category->name);
|
||||
$category->position = $request->input('position');
|
||||
$category->icon = $request->input('icon');
|
||||
$category->movie_meta = $request->input('movie_meta');
|
||||
@@ -151,12 +136,12 @@ class CategoryController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_category_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$category->save();
|
||||
|
||||
return redirect()->route('staff_category_index')
|
||||
->with($this->toastr->success('Category Successfully Modified', 'Yay!', ['options']));
|
||||
->withSuccess('Category Successfully Modified');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +159,6 @@ class CategoryController extends Controller
|
||||
$category->delete();
|
||||
|
||||
return redirect()->route('staff_category_index')
|
||||
->with($this->toastr->success('Category Successfully Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Category Successfully Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace App\Http\Controllers\Staff;
|
||||
use App\Models\Message;
|
||||
use App\Models\Chatroom;
|
||||
use App\Models\ChatStatus;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Events\MessageDeleted;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -29,21 +28,14 @@ class ChatController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ChatController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,12 +72,12 @@ class ChatController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$chatroom->save();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chatroom Successfully Added', 'Yay!', ['options']));
|
||||
->withSuccess('Chatroom Successfully Added');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +100,12 @@ class ChatController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$chatroom->save();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chatroom Successfully Modified', 'Yay!', ['options']));
|
||||
->withSuccess('Chatroom Successfully Modified');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +122,7 @@ class ChatController extends Controller
|
||||
$chatroom->delete();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chatroom Successfully Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Chatroom Successfully Deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,12 +147,12 @@ class ChatController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$chatstatus->save();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chat Status Successfully Added', 'Yay!', ['options']));
|
||||
->withSuccess('Chat Status Successfully Added');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,12 +179,12 @@ class ChatController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$chatstatus->save();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chat Status Successfully Modified', 'Yay!', ['options']));
|
||||
->withSuccess('Chat Status Successfully Modified');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,14 +201,12 @@ class ChatController extends Controller
|
||||
$chatstatus->delete();
|
||||
|
||||
return redirect()->route('chatManager')
|
||||
->with($this->toastr->success('Chat Status Successfully Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Chat Status Successfully Deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush Chat Messages.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function flushChat()
|
||||
@@ -230,7 +220,7 @@ class ChatController extends Controller
|
||||
'Chatbox Has Been Flushed! :broom:'
|
||||
);
|
||||
|
||||
return redirect('staff_dashboard')
|
||||
->with($this->toastr->success('Chatbox Has Been Flushed', 'Yay!', ['options']));
|
||||
return redirect()->to('staff_dashboard')
|
||||
->withSuccess('Chatbox Has Been Flushed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class CheaterController extends Controller
|
||||
public function leechCheaters()
|
||||
{
|
||||
$cheaters = History::with('user')
|
||||
->select('*')
|
||||
->select(['*'])
|
||||
->join(
|
||||
DB::raw('(SELECT MAX(id) AS id FROM history GROUP BY history.user_id) AS unique_history'),
|
||||
function ($join) {
|
||||
@@ -49,7 +49,7 @@ class CheaterController extends Controller
|
||||
/**
|
||||
* Possible Ratio Cheaters.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return void
|
||||
*/
|
||||
public function ratioCheaters()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D
|
||||
*
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @author HDVinnie
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CommandController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display All Commands.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
return view('Staff.commands.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bring Site Into Maintenance Mode.
|
||||
*
|
||||
* @param Request\ $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function maintanceEnable(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('down --allow='.$request->ip());
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bring Site Out Of Maintenance Mode.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function maintanceDisable(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('up');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Site Cache.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clearCache(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('cache:clear');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Site View Cache.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clearView(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('view:clear');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Site Routes Cache.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clearRoute(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('route:clear');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear Site Config Cache.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clearConfig(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('config:clear');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear All Site Cache At Once.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clearAllCache(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('clear:all_cache');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set All Site Cache At Once.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function setAllCache(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('set:all_cache');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Test Email To Test Email Configuration.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function testEmail(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_owner, 403);
|
||||
|
||||
\Artisan::call('test:email');
|
||||
|
||||
return redirect()->route('staff.commands.index')
|
||||
->withOutput(trim(\Artisan::output()));
|
||||
}
|
||||
}
|
||||
@@ -16,26 +16,10 @@ namespace App\Http\Controllers\Staff;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Peer;
|
||||
use App\Models\History;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class FlushController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* FlushController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete All Old Peers From Database.
|
||||
*
|
||||
@@ -55,7 +39,7 @@ class FlushController extends Controller
|
||||
$peer->delete();
|
||||
}
|
||||
|
||||
return redirect('staff_dashboard')
|
||||
->with($this->toastr->success('Ghost Peers Have Been Flushed', 'Yay!', ['options']));
|
||||
return redirect()->to('staff_dashboard')
|
||||
->withSuccess('Ghost Peers Have Been Flushed');
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+6
-21
@@ -16,27 +16,12 @@ namespace App\Http\Controllers\Staff;
|
||||
use App\Models\Forum;
|
||||
use App\Models\Group;
|
||||
use App\Models\Permission;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ForumController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ForumController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Forums.
|
||||
*
|
||||
@@ -76,7 +61,7 @@ class ForumController extends Controller
|
||||
$forum = new Forum();
|
||||
$forum->name = $request->input('title');
|
||||
$forum->position = $request->input('position');
|
||||
$forum->slug = str_slug($request->input('title'));
|
||||
$forum->slug = Str::slug($request->input('title'));
|
||||
$forum->description = $request->input('description');
|
||||
$forum->parent_id = $request->input('parent_id');
|
||||
$forum->save();
|
||||
@@ -104,7 +89,7 @@ class ForumController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('staff_forum_index')
|
||||
->with($this->toastr->success('Forum has been created successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Forum has been created successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +129,7 @@ class ForumController extends Controller
|
||||
|
||||
$forum->name = $request->input('title');
|
||||
$forum->position = $request->input('position');
|
||||
$forum->slug = str_slug($request->input('title'));
|
||||
$forum->slug = Str::slug($request->input('title'));
|
||||
$forum->description = $request->input('description');
|
||||
if ($request->input('forum_type') == 'category') {
|
||||
$forum->parent_id = 0;
|
||||
@@ -176,7 +161,7 @@ class ForumController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('staff_forum_index')
|
||||
->with($this->toastr->success('Forum has been edited successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Forum has been edited successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,6 +221,6 @@ class ForumController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('staff_forum_index')
|
||||
->with($this->toastr->success('Forum has been deleted successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Forum has been deleted successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,28 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\User;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PrivateMessage;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GiftController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* GiftController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Gift Form.
|
||||
*
|
||||
@@ -43,9 +27,7 @@ class GiftController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::oldest('username')->get();
|
||||
|
||||
return view('Staff.gift.index', ['users' => $users]);
|
||||
return view('Staff.gift.index');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +39,7 @@ class GiftController extends Controller
|
||||
*/
|
||||
public function gift(Request $request)
|
||||
{
|
||||
$staff = auth()->user();
|
||||
$staff = $request->user();
|
||||
|
||||
$username = $request->input('username');
|
||||
$seedbonus = $request->input('seedbonus');
|
||||
@@ -73,13 +55,13 @@ class GiftController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('systemGift')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$recipient = User::where('username', 'LIKE', $username)->first();
|
||||
$recipient = User::where('username', '=', $username)->first();
|
||||
|
||||
if (! $recipient) {
|
||||
return redirect()->route('systemGift')
|
||||
->with($this->toastr->error('Unable To Find Specified User', 'Whoops!', ['options']));
|
||||
->withErrors('Unable To Find Specified User');
|
||||
}
|
||||
|
||||
$recipient->seedbonus += $seedbonus;
|
||||
@@ -100,7 +82,7 @@ class GiftController extends Controller
|
||||
\LogActivity::addToLog("Staff Member {$staff->username} has sent a system gift to {$recipient->username} account.");
|
||||
|
||||
return redirect()->route('systemGift')
|
||||
->with($this->toastr->success('Gift Sent', 'Yay!', ['options']));
|
||||
->withSuccess('Gift Sent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,27 +16,12 @@ namespace App\Http\Controllers\Staff;
|
||||
use App\Models\Forum;
|
||||
use App\Models\Group;
|
||||
use App\Models\Permission;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class GroupsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* GroupsController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Groups.
|
||||
*
|
||||
@@ -70,7 +55,7 @@ class GroupsController extends Controller
|
||||
{
|
||||
$group = new Group();
|
||||
$group->name = $request->input('name');
|
||||
$group->slug = str_slug($request->input('name'));
|
||||
$group->slug = Str::slug($request->input('name'));
|
||||
$group->position = $request->input('position');
|
||||
$group->level = $request->input('level');
|
||||
$group->color = $request->input('color');
|
||||
@@ -97,7 +82,7 @@ class GroupsController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_groups_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$group->save();
|
||||
|
||||
@@ -113,7 +98,7 @@ class GroupsController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('staff_groups_index')
|
||||
->with($this->toastr->success('Group Was Created Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Group Was Created Successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +131,7 @@ class GroupsController extends Controller
|
||||
$group = Group::findOrFail($id);
|
||||
|
||||
$group->name = $request->input('name');
|
||||
$group->slug = str_slug($request->input('name'));
|
||||
$group->slug = Str::slug($request->input('name'));
|
||||
$group->position = $request->input('position');
|
||||
$group->level = $request->input('level');
|
||||
$group->color = $request->input('color');
|
||||
@@ -173,12 +158,12 @@ class GroupsController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_groups_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$group->save();
|
||||
|
||||
return redirect()->route('staff_groups_index')
|
||||
->with($this->toastr->success('Group Was Updated Successfully!', 'Yay!', ['options']));
|
||||
->withSuccess('Group Was Updated Successfully!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@ namespace App\Http\Controllers\Staff;
|
||||
use App\Models\Peer;
|
||||
use App\Models\User;
|
||||
use App\Models\Group;
|
||||
use App\Models\Client;
|
||||
use App\Models\Report;
|
||||
use App\Models\Seedbox;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Application;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helpers\SystemInformation;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Spatie\SslCertificate\SslCertificate;
|
||||
@@ -31,11 +32,11 @@ class HomeController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function home()
|
||||
public function home(Request $request)
|
||||
{
|
||||
// User Info
|
||||
$bannedGroup = Group::where('slug', '=', 'banned')->select('id')->first();
|
||||
$validatingGroup = Group::where('slug', '=', 'validating')->select('id')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
|
||||
$num_user = User::count();
|
||||
$banned = User::where('group_id', '=', $bannedGroup->id)->count();
|
||||
@@ -52,8 +53,8 @@ class HomeController extends Controller
|
||||
$leechers = Peer::where('seeder', '=', 0)->count();
|
||||
|
||||
// Seedbox Info
|
||||
$seedboxes = Client::count();
|
||||
$highspeed_users = Client::count();
|
||||
$seedboxes = Seedbox::count();
|
||||
$highspeed_users = Seedbox::count();
|
||||
$highspeed_torrents = Torrent::where('highspeed', '=', 1)->count();
|
||||
|
||||
// User Info
|
||||
@@ -63,7 +64,7 @@ class HomeController extends Controller
|
||||
|
||||
// SSL Info
|
||||
try {
|
||||
$certificate = request()->secure() ? SslCertificate::createForHostName(config('app.url')) : '';
|
||||
$certificate = $request->secure() ? SslCertificate::createForHostName(config('app.url')) : '';
|
||||
} catch (\Exception $e) {
|
||||
$certificate = '';
|
||||
}
|
||||
|
||||
@@ -15,27 +15,11 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Jobs\ProcessMassPM;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class MassPMController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* MassPMController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass PM Form.
|
||||
*
|
||||
@@ -55,7 +39,7 @@ class MassPMController extends Controller
|
||||
*/
|
||||
public function sendMassPM(Request $request)
|
||||
{
|
||||
$staff = auth()->user();
|
||||
$staff = $request->user();
|
||||
$users = User::all();
|
||||
|
||||
$sender_id = 1;
|
||||
@@ -69,7 +53,7 @@ class MassPMController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('massPM')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
foreach ($users as $user) {
|
||||
$this->dispatch(new ProcessMassPM($sender_id, $user->id, $subject, $message));
|
||||
@@ -79,7 +63,7 @@ class MassPMController extends Controller
|
||||
\LogActivity::addToLog("Staff Member {$staff->username} has sent a MassPM.");
|
||||
|
||||
return redirect()->route('massPM')
|
||||
->with($this->toastr->success('MassPM Sent', 'Yay!', ['options']));
|
||||
->withSuccess('MassPM Sent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Torrent;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Helpers\TorrentHelper;
|
||||
use App\Models\PrivateMessage;
|
||||
@@ -30,21 +29,14 @@ class ModerationController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ModerationController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,10 +92,10 @@ class ModerationController extends Controller
|
||||
TorrentHelper::approveHelper($torrent->slug, $torrent->id);
|
||||
|
||||
return redirect()->route('moderation')
|
||||
->with($this->toastr->success('Torrent Approved', 'Yay!', ['options']));
|
||||
->withSuccess('Torrent Approved');
|
||||
} else {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error('Torrent Already Approved', 'Whoops!', ['options']));
|
||||
return redirect()->route('moderation')
|
||||
->withErrors('Torrent Already Approved');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +116,9 @@ class ModerationController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('moderation')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent = Torrent::withAnyStatus()->where('id', '=', $request->input('id'))->first();
|
||||
$torrent->markPostponed();
|
||||
|
||||
@@ -138,7 +130,7 @@ class ModerationController extends Controller
|
||||
$pm->save();
|
||||
|
||||
return redirect()->route('moderation')
|
||||
->with($this->toastr->success('Torrent Postponed', 'Yay!', ['options']));
|
||||
->withSuccess('Torrent Postponed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +151,9 @@ class ModerationController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('moderation')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent = Torrent::withAnyStatus()->where('id', '=', $request->input('id'))->first();
|
||||
$torrent->markRejected();
|
||||
|
||||
@@ -173,7 +165,7 @@ class ModerationController extends Controller
|
||||
$pm->save();
|
||||
|
||||
return redirect()->route('moderation')
|
||||
->with($this->toastr->success('Torrent Rejected', 'Yay!', ['options']));
|
||||
->withSuccess('Torrent Rejected');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +176,9 @@ class ModerationController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function resetRequest($id)
|
||||
public function resetRequest(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
@@ -198,6 +190,6 @@ class ModerationController extends Controller
|
||||
$torrentRequest->save();
|
||||
|
||||
return redirect()->route('request', ['id' => $id])
|
||||
->with($this->toastr->success('The request has been reset!', 'Yay!', ['options']));
|
||||
->withSuccess('The request has been reset!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,27 +15,11 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Note;
|
||||
use App\Models\User;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class NoteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* NoteController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All User Notes.
|
||||
*
|
||||
@@ -59,7 +43,7 @@ class NoteController extends Controller
|
||||
*/
|
||||
public function postNote(Request $request, $username, $id)
|
||||
{
|
||||
$staff = auth()->user();
|
||||
$staff = $request->user();
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$note = new Note();
|
||||
@@ -75,7 +59,7 @@ class NoteController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$note->save();
|
||||
|
||||
@@ -83,7 +67,7 @@ class NoteController extends Controller
|
||||
\LogActivity::addToLog("Staff Member {$staff->username} has added a note on {$user->username} account.");
|
||||
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->success('Note Has Successfully Posted', 'Yay!', ['options']));
|
||||
->withSuccess('Note Has Successfully Posted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +81,10 @@ class NoteController extends Controller
|
||||
public function deleteNote($id)
|
||||
{
|
||||
$note = Note::findOrFail($id);
|
||||
$user = User::findOrFail($note->user_id);
|
||||
$note->delete();
|
||||
|
||||
return redirect()->back()
|
||||
->with($this->toastr->success('Note Has Successfully Been Deleted', 'Yay!', ['options']));
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->withSuccess('Note Has Successfully Been Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+8
-23
@@ -14,27 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Page;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PageController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Pages.
|
||||
*
|
||||
@@ -68,7 +53,7 @@ class PageController extends Controller
|
||||
{
|
||||
$page = new Page();
|
||||
$page->name = $request->input('name');
|
||||
$page->slug = str_slug($page->name);
|
||||
$page->slug = Str::slug($page->name);
|
||||
$page->content = $request->input('content');
|
||||
|
||||
$v = validator($page->toArray(), [
|
||||
@@ -79,12 +64,12 @@ class PageController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_page_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$page->save();
|
||||
|
||||
return redirect()->route('staff_page_index')
|
||||
->with($this->toastr->success('Page has been created successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Page has been created successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +101,7 @@ class PageController extends Controller
|
||||
{
|
||||
$page = Page::findOrFail($id);
|
||||
$page->name = $request->input('name');
|
||||
$page->slug = str_slug($page->name);
|
||||
$page->slug = Str::slug($page->name);
|
||||
$page->content = $request->input('content');
|
||||
|
||||
$v = validator($page->toArray(), [
|
||||
@@ -127,12 +112,12 @@ class PageController extends Controller
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('staff_page_index')
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$page->save();
|
||||
|
||||
return redirect()->route('staff_page_index')
|
||||
->with($this->toastr->success('Page has been edited successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Page has been edited successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +134,6 @@ class PageController extends Controller
|
||||
Page::findOrFail($id)->delete();
|
||||
|
||||
return redirect()->route('staff_page_index')
|
||||
->with($this->toastr->success('Page has been deleted successfully', 'Yay!', ['options']));
|
||||
->withSuccess('Page has been deleted successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Poll;
|
||||
use App\Models\Option;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Http\Requests\StorePoll;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\ChatRepository;
|
||||
@@ -27,21 +26,14 @@ class PollController extends Controller
|
||||
*/
|
||||
private $chat;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* PollController Constructor.
|
||||
*
|
||||
* @param ChatRepository $chat
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(ChatRepository $chat, Toastr $toastr)
|
||||
public function __construct(ChatRepository $chat)
|
||||
{
|
||||
$this->chat = $chat;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +51,7 @@ class PollController extends Controller
|
||||
/**
|
||||
* Show A Poll.
|
||||
*
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function poll($id)
|
||||
@@ -87,9 +80,9 @@ class PollController extends Controller
|
||||
*/
|
||||
public function store(StorePoll $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
if (auth()->check()) {
|
||||
if ($request->user()) {
|
||||
$poll = $user->polls()->create($request->all());
|
||||
} else {
|
||||
$poll = Poll::create($request->all());
|
||||
@@ -110,6 +103,6 @@ class PollController extends Controller
|
||||
);
|
||||
|
||||
return redirect('poll/'.$poll->slug)
|
||||
->with($this->toastr->success('Your poll has been created.', 'Yay!', ['options']));
|
||||
->withSuccess('Your poll has been created.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,28 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Report;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PrivateMessage;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* ReportController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Reports.
|
||||
*
|
||||
@@ -67,6 +51,7 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Solve A Report.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param $report_id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
@@ -84,7 +69,7 @@ class ReportController extends Controller
|
||||
|
||||
if ($report->solved == 1) {
|
||||
return redirect()->route('getReports')
|
||||
->with($this->toastr->error('This Report Has Already Been Solved', 'Whoops!', ['options']));
|
||||
->withErrors('This Report Has Already Been Solved');
|
||||
}
|
||||
|
||||
$report->verdict = $request->input('verdict');
|
||||
@@ -105,6 +90,6 @@ class ReportController extends Controller
|
||||
$pm->save();
|
||||
|
||||
return redirect()->route('getReports')
|
||||
->with($this->toastr->success('Report has been successfully resolved', 'Yay!', ['options']));
|
||||
->withSuccess('Report has been successfully resolved');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace App\Http\Controllers\Staff;
|
||||
use App\Models\Rss;
|
||||
use App\Models\Type;
|
||||
use App\Models\Category;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\TorrentFacetedRepository;
|
||||
@@ -28,21 +27,14 @@ class RssController extends Controller
|
||||
*/
|
||||
private $torrent_faceted;
|
||||
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* RssController Constructor.
|
||||
*
|
||||
* @param TorrentFacetedRepository $torrent_faceted
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(TorrentFacetedRepository $torrent_faceted, Toastr $toastr)
|
||||
public function __construct(TorrentFacetedRepository $torrent_faceted)
|
||||
{
|
||||
$this->torrent_faceted = $torrent_faceted;
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +58,9 @@ class RssController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$torrent_repository = $this->torrent_faceted;
|
||||
|
||||
return view('Staff.rss.create', [
|
||||
@@ -87,7 +79,7 @@ class RssController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
|
||||
$v = validator($request->all(), [
|
||||
'name' => 'required|min:3|max:255',
|
||||
@@ -125,11 +117,11 @@ class RssController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.rss.create')
|
||||
->with($this->toastr->error($error, 'Whoops!', ['options']));
|
||||
->withErrors($error);
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.rss.index')
|
||||
->with($this->toastr->success($success, 'Yay!', ['options']));
|
||||
->withSuccess($success);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,9 +130,9 @@ class RssController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$rss = Rss::where('is_private', '=', 0)->findOrFail($id);
|
||||
$torrent_repository = $this->torrent_faceted;
|
||||
|
||||
@@ -162,7 +154,7 @@ class RssController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = $request->user();
|
||||
$rss = Rss::where('is_private', '=', 0)->findOrFail($id);
|
||||
|
||||
$v = validator($request->all(), [
|
||||
@@ -200,11 +192,11 @@ class RssController extends Controller
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.rss.edit', ['id' => $id])
|
||||
->with($this->toastr->error($error, 'Whoops!', ['options']));
|
||||
->withErrors($error);
|
||||
}
|
||||
|
||||
return redirect()->route('Staff.rss.index')
|
||||
->with($this->toastr->success($success, 'Yay!', ['options']));
|
||||
->withSuccess($success);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,6 +211,6 @@ class RssController extends Controller
|
||||
$rss->delete();
|
||||
|
||||
return redirect()->route('Staff.rss.index')
|
||||
->with($this->toastr->success('RSS Feed Deleted!', 'Yay!', ['options']));
|
||||
->withSuccess('RSS Feed Deleted!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,27 +13,12 @@
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Client;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use App\Models\Seedbox;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class SeedboxController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* SeedboxController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display All Registered Seedboxes.
|
||||
*
|
||||
@@ -41,7 +26,7 @@ class SeedboxController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$seedboxes = Client::with('user')->latest()->paginate(50);
|
||||
$seedboxes = Seedbox::with('user')->latest()->paginate(50);
|
||||
|
||||
return view('Staff.seedbox.index', ['seedboxes' => $seedboxes]);
|
||||
}
|
||||
@@ -53,15 +38,15 @@ class SeedboxController extends Controller
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy($id)
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$seedbox = Client::findOrFail($id);
|
||||
$user = $request->user();
|
||||
$seedbox = Seedbox::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo, 403);
|
||||
$seedbox->delete();
|
||||
|
||||
return redirect()->route('staff.seedbox.index')
|
||||
->with($this->toastr->success('Seedbox Record Has Successfully Been Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Seedbox Record Has Successfully Been Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,27 +13,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Tag;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* RssController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Tags.
|
||||
*
|
||||
@@ -66,7 +51,7 @@ class TagController extends Controller
|
||||
{
|
||||
$tag = new Tag();
|
||||
$tag->name = $request->input('name');
|
||||
$tag->slug = str_slug($tag->name);
|
||||
$tag->slug = Str::slug($tag->name);
|
||||
|
||||
$v = validator($tag->toArray(), [
|
||||
'name' => 'required|unique:tags',
|
||||
@@ -74,13 +59,13 @@ class TagController extends Controller
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('staff_tag_index')
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$tag->save();
|
||||
|
||||
return redirect()->route('staff_tag_index')
|
||||
->with($this->toastr->success('Tag Successfully Added', 'Yay!', ['options']));
|
||||
->withSuccess('Tag Successfully Added');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,21 +95,21 @@ class TagController extends Controller
|
||||
{
|
||||
$tag = Tag::findOrFail($id);
|
||||
$tag->name = $request->input('name');
|
||||
$tag->slug = str_slug($tag->name);
|
||||
$tag->slug = Str::slug($tag->name);
|
||||
|
||||
$v = validator($type->toArray(), [
|
||||
$v = validator($tag->toArray(), [
|
||||
'name' => 'required',
|
||||
'slug' => 'required',
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('staff_tag_index')
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$tag->save();
|
||||
|
||||
return redirect()->route('staff_tag_index')
|
||||
->with($this->toastr->success('Tag Successfully Modified', 'Yay!', ['options']));
|
||||
->withSuccess('Tag Successfully Modified');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,12 @@
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\Models\Type;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class TypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Toastr
|
||||
*/
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* TypeController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
public function __construct(Toastr $toastr)
|
||||
{
|
||||
$this->toastr = $toastr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All Types.
|
||||
*
|
||||
@@ -68,7 +53,7 @@ class TypeController extends Controller
|
||||
{
|
||||
$type = new Type();
|
||||
$type->name = $request->input('name');
|
||||
$type->slug = str_slug($type->name);
|
||||
$type->slug = Str::slug($type->name);
|
||||
$type->position = $request->input('position');
|
||||
|
||||
$v = validator($type->toArray(), [
|
||||
@@ -78,13 +63,13 @@ class TypeController extends Controller
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('staff_type_index')
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$type->save();
|
||||
|
||||
return redirect()->route('staff_type_index')
|
||||
->with($this->toastr->success('Type Successfully Added', 'Yay!', ['options']));
|
||||
->withSuccess('Type Successfully Added');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +101,7 @@ class TypeController extends Controller
|
||||
{
|
||||
$type = Type::findOrFail($id);
|
||||
$type->name = $request->input('name');
|
||||
$type->slug = str_slug($type->name);
|
||||
$type->slug = Str::slug($type->name);
|
||||
$type->position = $request->input('position');
|
||||
|
||||
$v = validator($type->toArray(), [
|
||||
@@ -126,13 +111,13 @@ class TypeController extends Controller
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->back()
|
||||
->with($this->toastr->error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
return redirect()->route('staff_type_index')
|
||||
->withErrors($v->errors());
|
||||
} else {
|
||||
$type->save();
|
||||
|
||||
return redirect()->route('staff_type_index')
|
||||
->with($this->toastr->success('Type Successfully Modified', 'Yay!', ['options']));
|
||||
->withSuccess('Type Successfully Modified');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +135,6 @@ class TypeController extends Controller
|
||||
$type->delete();
|
||||
|
||||
return redirect()->route('staff_type_index')
|
||||
->with($this->toastr->success('Type Successfully Deleted', 'Yay!', ['options']));
|
||||
->withSuccess('Type Successfully Deleted');
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user