diff --git a/app/Console/Commands/autoBan.php b/app/Console/Commands/autoBan.php index bc3fdcfaf..4321f4f40 100644 --- a/app/Console/Commands/autoBan.php +++ b/app/Console/Commands/autoBan.php @@ -42,12 +42,13 @@ class autoBan extends Command */ public function handle() { + $bannedGroup = Group::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) { - if ($ban->warneduser->group_id != 5 && !$ban->warneduser->group->is_immune) { + if ($ban->warneduser->group_id != $bannedGroup->id && !$ban->warneduser->group->is_immune) { // If User Has x or More Active Warnings Ban Set The Users Group To Banned - $ban->warneduser->group_id = 5; + $ban->warneduser->group_id = $bannedGroup->id; $ban->warneduser->can_upload = 0; $ban->warneduser->can_download = 0; $ban->warneduser->can_comment = 0; diff --git a/app/Http/Controllers/Auth/ActivationController.php b/app/Http/Controllers/Auth/ActivationController.php index 00bfda271..e5c7fc151 100755 --- a/app/Http/Controllers/Auth/ActivationController.php +++ b/app/Http/Controllers/Auth/ActivationController.php @@ -22,7 +22,7 @@ class ActivationController extends Controller public function activate($token) { $bannedGroup = Group::where('slug', '=', 'banned')->first(); - $defaultGroup = Group::where('slug', '=', 'member')->first(); + $memberGroup = Group::where('slug', '=', 'member')->first(); $activation = UserActivation::with('user')->where('token', $token)->firstOrFail(); if ($activation->user->id && $activation->user->group->id != $bannedGroup->id) { @@ -32,7 +32,7 @@ class ActivationController extends Controller $activation->user->can_request = 1; $activation->user->can_comment = 1; $activation->user->can_invite = 1; - $activation->user->group_id = $defaultGroup->id; + $activation->user->group_id = $memberGroup->id; $activation->user->save(); // Activity Log diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 33511b254..c0f5e2371 100755 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -69,6 +69,7 @@ class LoginController extends Controller $bannedGroup = Group::where('slug', '=', 'banned')->first(); $validatingGroup = Group::where('slug', '=', 'validating')->first(); $disabledGroup = Group::where('slug', '=', 'disabled')->first(); + $memberGroup = Group::where('slug', '=', 'member')->first(); if ($user->active == 0 || $user->group_id == $validatingGroup->id) { auth()->logout(); @@ -85,7 +86,7 @@ class LoginController extends Controller } if ($user->group_id == $disabledGroup->id) { - $user->group_id = 3; + $user->group_id = $memberGroup->id; $user->can_upload = 1; $user->can_download = 1; $user->can_comment = 1; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index a5d8f014d..54617a7e6 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -67,7 +67,7 @@ class RegisterController extends Controller ->with(Toastr::error('Invalid or Expired Invite Key!', 'Whoops!', ['options'])); } - $group = Group::where('slug', '=', 'validating')->first(); + $validatingGroup = Group::where('slug', '=', 'validating')->first(); $user = new User(); $user->username = $request->input('username'); $user->email = $request->input('email'); @@ -77,7 +77,7 @@ class RegisterController extends Controller $user->uploaded = config('other.default_upload'); $user->downloaded = config('other.default_download'); $user->style = config('other.default_style', 0); - $user->group_id = $group->id; + $user->group_id = $validatingGroup->id; if (config('email-white-blacklist.enabled') === 'allow' && config('captcha.enabled') == true) { $v = validator($request->all(), [ diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index a3fa65cf6..b0f74ed1e 100755 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -12,7 +12,6 @@ class ResetPasswordController extends Controller use ResetsPasswords; protected $redirectTo = '/'; - protected $group_id = 3; public function __construct() { @@ -21,11 +20,15 @@ class ResetPasswordController extends Controller protected function resetPassword($user, $password) { + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $memberGroup = Group::where('slug', '=', 'member')->first(); $user->password = bcrypt($password); $user->remember_token = Str::random(60); - if ($user->group_id === 1) { - $user->group_id = $this->group_id; + + if ($user->group_id === $validatingGroup->id) { + $user->group_id = $memberGroup->id; } + $user->active = true; $user->save(); diff --git a/app/Http/Controllers/Staff/BanController.php b/app/Http/Controllers/Staff/BanController.php index d7061e75e..04067c8a3 100644 --- a/app/Http/Controllers/Staff/BanController.php +++ b/app/Http/Controllers/Staff/BanController.php @@ -48,12 +48,13 @@ class BanController extends Controller { $user = User::findOrFail($id); $staff = auth()->user(); + $bannedGroup = Group::where('slug', '=', 'banned')->first(); if ($user->group->is_modo || auth()->user()->id == $user->id) { return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id]) ->with(Toastr::error('You Cannot Ban Yourself Or Other Staff!', 'Whoops!', ['options'])); } else { - $user->group_id = 5; + $user->group_id = $bannedGroup->id; $user->can_upload = 0; $user->can_download = 0; $user->can_comment = 0; diff --git a/app/Http/Controllers/Staff/HomeController.php b/app/Http/Controllers/Staff/HomeController.php index b2af8952c..fb50186ff 100644 --- a/app/Http/Controllers/Staff/HomeController.php +++ b/app/Http/Controllers/Staff/HomeController.php @@ -31,9 +31,12 @@ class HomeController extends Controller public function home() { // User Info + $bannedGroup = Group::where('slug', '=', 'banned')->first(); + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $num_user = User::all()->count(); - $banned = User::where('group_id', 5)->count(); - $validating = User::where('group_id', 1)->count(); + $banned = User::where('group_id', $bannedGroup->id)->count(); + $validating = User::where('group_id', $validatingGroup->id)->count(); // Torrent Info $num_torrent = Torrent::all()->count(); diff --git a/app/Http/Controllers/Staff/UserController.php b/app/Http/Controllers/Staff/UserController.php index c60ee07fe..c214e7fe4 100755 --- a/app/Http/Controllers/Staff/UserController.php +++ b/app/Http/Controllers/Staff/UserController.php @@ -278,10 +278,12 @@ class UserController extends Controller */ public function massValidateUsers() { - $users = User::where('active', '=', 0)->where('group_id', '=', 1)->get(); + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $memberGroup = Group::where('slug', '=', 'member')->first(); + $users = User::where('active', '=', 0)->where('group_id', '=', $validatingGroup->id)->get(); foreach ($users as $user) { - $user->group_id = 3; + $user->group_id = $memberGroup->id; $user->active = 1; $user->can_upload = 1; $user->can_download = 1; diff --git a/app/Http/Controllers/StatsController.php b/app/Http/Controllers/StatsController.php index 8b037767d..bd3496854 100644 --- a/app/Http/Controllers/StatsController.php +++ b/app/Http/Controllers/StatsController.php @@ -150,8 +150,13 @@ class StatsController extends Controller */ public function uploaded() { + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $bannedGroup = Group::where('slug', '=', 'banned')->first(); + $disabledGroup = Group::where('slug', '=', 'disabled')->first(); + $prunedGroup = Group::where('slug', '=', 'pruned')->first(); + // Fetch Top Uploaders - $uploaded = User::latest('uploaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get(); + $uploaded = User::latest('uploaded')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get(); return view('stats.users.uploaded', ['uploaded' => $uploaded]); } @@ -163,8 +168,13 @@ class StatsController extends Controller */ public function downloaded() { + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $bannedGroup = Group::where('slug', '=', 'banned')->first(); + $disabledGroup = Group::where('slug', '=', 'disabled')->first(); + $prunedGroup = Group::where('slug', '=', 'pruned')->first(); + // Fetch Top Downloaders - $downloaded = User::latest('downloaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get(); + $downloaded = User::latest('downloaded')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get(); return view('stats.users.downloaded', ['downloaded' => $downloaded]); } @@ -215,8 +225,13 @@ class StatsController extends Controller */ public function bankers() { + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + $bannedGroup = Group::where('slug', '=', 'banned')->first(); + $disabledGroup = Group::where('slug', '=', 'disabled')->first(); + $prunedGroup = Group::where('slug', '=', 'pruned')->first(); + // Fetch Top Bankers - $bankers = User::latest('seedbonus')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get(); + $bankers = User::latest('seedbonus')->whereNotIn('group_id', [$validatingGroup, $bannedGroup, $disabledGroup, $prunedGroup])->take(100)->get(); return view('stats.users.bankers', ['bankers' => $bankers]); } diff --git a/app/Http/Middleware/CheckIfActive.php b/app/Http/Middleware/CheckIfActive.php index 47a75aace..9b39453e0 100644 --- a/app/Http/Middleware/CheckIfActive.php +++ b/app/Http/Middleware/CheckIfActive.php @@ -28,12 +28,13 @@ class CheckIfActive public function handle($request, Closure $next, $guard = null) { $user = auth()->user(); - if ($user and $user->group_id == 1 || $user->active == 0) { + $validatingGroup = Group::where('slug', '=', 'validating')->first(); + + if ($user && $user->group_id == $validatingGroup || $user->active == 0) { auth()->logout(); $request->session()->flush(); return redirect('login') ->with(Toastr::warning('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'])); - ; } return $next($request); diff --git a/app/Http/Middleware/CheckIfBanned.php b/app/Http/Middleware/CheckIfBanned.php index aca1edc85..d494e7d24 100644 --- a/app/Http/Middleware/CheckIfBanned.php +++ b/app/Http/Middleware/CheckIfBanned.php @@ -20,18 +20,21 @@ class CheckIfBanned /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null $guard + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { $user = auth()->user(); - if ($user and $user->group_id == 5) { + $bannedGroup = Group::where('slug', '=', 'banned')->first(); + + if ($user && $user->group_id == $bannedGroup) { auth()->logout(); $request->session()->flush(); - return redirect('login')->with(Toastr::error('This account is Banned!', 'Whoops!', ['options'])); + return redirect('login') + ->with(Toastr::error('This account is Banned!', 'Whoops!', ['options'])); } return $next($request);