mirror of
https://github.com/BillyOutlast/UNIT3D.git
synced 2026-02-13 15:31:02 +01:00
- requires new migration to be ran - make sure to run `php artisan clear:all` - This commit add soft deletes to warnings with the ability to restore them as well. - This fixes the issue where deleting a warning will only make the autoWarning command reissue it again if said user still hasn’t met seedtime requirement on said torrent.
658 lines
25 KiB
PHP
Executable File
658 lines
25 KiB
PHP
Executable File
<?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 Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use App\Group;
|
|
use App\User;
|
|
use App\Peer;
|
|
use App\Torrent;
|
|
use App\Client;
|
|
use App\PrivateMessage;
|
|
use App\Follow;
|
|
use App\History;
|
|
use App\Warning;
|
|
use App\BonTransactions;
|
|
use \Toastr;
|
|
use Image;
|
|
use Carbon\Carbon;
|
|
|
|
class UserController extends Controller
|
|
{
|
|
/**
|
|
* Get Users List
|
|
*
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function members()
|
|
{
|
|
$users = User::latest()->paginate(50);
|
|
|
|
return view('user.members', ['users' => $users]);
|
|
}
|
|
|
|
/**
|
|
* Search For A User (Public Use)
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function userSearch(Request $request)
|
|
{
|
|
$users = User::where([
|
|
['username', 'like', '%' . $request->input('username') . '%'],
|
|
])->paginate(25);
|
|
$users->setPath('?username=' . $request->input('username'));
|
|
|
|
return view('user.members')->with('users', $users);
|
|
}
|
|
|
|
/**
|
|
* Get A User Profile
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function profile($username, $id)
|
|
{
|
|
$user = User::findOrFail($id);
|
|
$groups = Group::all();
|
|
$followers = Follow::where('target_id', $id)->get();
|
|
$history = $user->history;
|
|
$warnings = Warning::where('user_id', $id)->whereNotNull('torrent')->where('active', 1)->take(3)->get();
|
|
$hitrun = Warning::where('user_id', $id)->latest()->paginate(10);
|
|
$bonupload = BonTransactions::where('sender', $id)->where([['name', 'like', '%Upload%'],])->sum('cost');
|
|
$realupload = $user->uploaded - $bonupload;
|
|
$bondownload = BonTransactions::where('sender', $id)->where([['name', 'like', '%Download%'],])->sum('cost');
|
|
$realdownload = $user->downloaded - $bondownload;
|
|
|
|
return view('user.profile', [
|
|
'user' => $user,
|
|
'groups' => $groups,
|
|
'followers' => $followers,
|
|
'history' => $history,
|
|
'warnings' => $warnings,
|
|
'hitrun' => $hitrun,
|
|
'bonupload' => $bonupload,
|
|
'realupload' => $realupload,
|
|
'bondownload' => $bondownload,
|
|
'realdownload' => $realdownload
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Edit Profile Form
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function editProfileForm($username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
|
|
return view('user.edit_profile', ['user' => $user]);
|
|
}
|
|
|
|
/**
|
|
* Edit User Profile
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function editProfile(Request $request, $username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
// Avatar
|
|
$max_upload = config('image.max_upload_size');
|
|
if ($request->hasFile('image') && $request->file('image')->getError() == 0) {
|
|
$image = $request->file('image');
|
|
if (in_array($image->getClientOriginalExtension(), ['jpg', 'JPG', 'jpeg', 'bmp', 'png', 'PNG', 'tiff', 'gif']) && preg_match('#image/*#', $image->getMimeType())) {
|
|
if ($max_upload >= $image->getSize()) {
|
|
$filename = $user->username . '.' . $image->getClientOriginalExtension();
|
|
$path = public_path('/files/img/' . $filename);
|
|
if ($image->getClientOriginalExtension() != 'gif') {
|
|
Image::make($image->getRealPath())->fit(150, 150)->encode('png', 100)->save($path);
|
|
} else {
|
|
$v = validator($request->all(), [
|
|
'image' => 'dimensions:ratio=1/1'
|
|
]);
|
|
if ($v->passes()) {
|
|
$image->move(public_path('/files/img/'), $filename);
|
|
} else {
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Because you are uploading a GIF, your avatar must be symmetrical!', 'Whoops!', ['options']));
|
|
}
|
|
}
|
|
$user->image = $user->username . '.' . $image->getClientOriginalExtension();
|
|
} else {
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Your avatar is too large, max file size: ' . ($max_upload / 1000000) . ' MB', 'Whoops!', ['options']));
|
|
}
|
|
}
|
|
}
|
|
// Define data
|
|
$user->title = $request->input('title');
|
|
$user->about = $request->input('about');
|
|
$user->signature = $request->input('signature');
|
|
// Save the user
|
|
$user->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has updated there profile.");
|
|
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Your Account Was Updated Successfully!', 'Yay!', ['options']));
|
|
}
|
|
|
|
|
|
/**
|
|
* User Account Settings
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function settings($username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
|
|
return view('user.settings', ['user' => $user]);
|
|
}
|
|
|
|
/**
|
|
* Change User Account Settings
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function changeSettings(Request $request, $username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
// General Settings
|
|
$user->censor = $request->input('censor');
|
|
$user->chat_hidden = $request->input('chat_hidden');
|
|
|
|
// Style Settings
|
|
$user->style = (int)$request->input('theme');
|
|
$css_url = $request->input('custom_css');
|
|
if (isset($css_url) && filter_var($css_url, FILTER_VALIDATE_URL) === false) {
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('The URL for the external CSS stylesheet is invalid, try it again with a valid URL.', 'Whoops!', ['options']));
|
|
} else {
|
|
$user->custom_css = $css_url;
|
|
}
|
|
$user->nav = $request->input('sidenav');
|
|
|
|
// Privacy Settings
|
|
$user->hidden = $request->input('onlinehide');
|
|
$user->private_profile = $request->input('private_profile');
|
|
$user->peer_hidden = $request->input('peer_hidden');
|
|
|
|
// Torrent Settings
|
|
$user->torrent_layout = (int)$request->input('torrent_layout');
|
|
$user->show_poster = $request->input('show_poster');
|
|
$user->ratings = $request->input('ratings');
|
|
|
|
// Security Settings
|
|
if (config('auth.TwoStepEnabled') == true) {
|
|
$user->twostep = $request->input('twostep');
|
|
}
|
|
$user->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has changed there account settings.");
|
|
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Your Account Was Updated Successfully!', 'Yay!', ['options']));
|
|
}
|
|
|
|
/**
|
|
* User Password Change
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
protected function changePassword(Request $request)
|
|
{
|
|
$user = auth()->user();
|
|
$v = validator($request->all(), [
|
|
'current_password' => 'required',
|
|
'new_password' => 'required|min:6|confirmed',
|
|
'new_password_confirmation' => 'required|min:6',
|
|
]);
|
|
if ($v->passes()) {
|
|
if (Hash::check($request->input('current_password'), $user->password)) {
|
|
$user->password = Hash::make($request->input('new_password'));
|
|
$user->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has changed there account password.");
|
|
|
|
return redirect('/')->with(Toastr::success('Your Password Has Been Reset', 'Yay!', ['options']));
|
|
} else {
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Your Password Was Incorrect!', 'Whoops!', ['options']));
|
|
}
|
|
} else {
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Your New Password Is To Weak!', 'Whoops!', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* User Email Change
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
protected function changeEmail(Request $request, $username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
$v = validator($request->all(), [
|
|
'current_password' => 'required',
|
|
'new_email' => 'required',
|
|
]);
|
|
if ($v->passes()) {
|
|
$user->email = $request->input('new_email');
|
|
$user->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has changed there email address on file.");
|
|
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Your Email Was Updated Successfully!', 'Yay!', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Change User PID
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function changePID(Request $request, $username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
$user->passkey = md5(uniqid() . time() . microtime());
|
|
$user->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has changed there account PID.");
|
|
|
|
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Your PID Was Changed Successfully!', 'Yay!', ['options']));
|
|
}
|
|
|
|
/**
|
|
* Get A Users Seedboxes/Clients
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function clients($username, $id)
|
|
{
|
|
$user = auth()->user();
|
|
$cli = Client::where('user_id', $user->id)->get();
|
|
|
|
return view('user.clients', ['user' => $user, 'clients' => $cli]);
|
|
}
|
|
|
|
/**
|
|
* Add A Seedbox/Client
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
protected function authorizeClient(Request $request, $username, $id)
|
|
{
|
|
$v = validator($request->all(), [
|
|
'password' => 'required',
|
|
'ip' => 'required|ipv4|unique:clients,ip',
|
|
'client_name' => 'required|alpha_num',
|
|
]);
|
|
|
|
$user = auth()->user();
|
|
if ($v->passes()) {
|
|
if (Hash::check($request->input('password'), $user->password)) {
|
|
if (Client::where('user_id', $user->id)->get()->count() >= config('other.max_cli')) {
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Max Clients Reached!', 'Whoops!', ['options']));
|
|
}
|
|
$cli = new Client;
|
|
$cli->user_id = $user->id;
|
|
$cli->name = $request->input('client_name');
|
|
$cli->ip = $request->input('ip');
|
|
$cli->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has added a new seedbox to there account.");
|
|
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Client Has Been Added!', 'Yay', ['options']));
|
|
} else {
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Password Invalid!', 'Whoops!', ['options']));
|
|
}
|
|
} else {
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('All required values not received or IP is already registered by a member.', 'Whoops!', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Delete A Seedbox/Client
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param $username
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
protected function removeClient(Request $request, $username, $id)
|
|
{
|
|
$v = validator($request->all(), [
|
|
'cliid' => 'required|exists:clients,id',
|
|
'userid' => 'required|exists:users,id',
|
|
]);
|
|
|
|
$user = auth()->user();
|
|
if ($v->passes()) {
|
|
$cli = Client::where('id', $request->input('cliid'));
|
|
$cli->delete();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Member {$user->username} has removed a seedbox from there account.");
|
|
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::success('Client Has Been Removed!', 'Yay!', ['options']));
|
|
} else {
|
|
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
|
->with(Toastr::error('Unable to remove this client.', 'Whoops!', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get A Users Warnings
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function getWarnings($username, $id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$user = User::findOrFail($id);
|
|
$warnings = Warning::where('user_id', $user->id)->with(['torrenttitle', 'warneduser'])->latest('active')->paginate(25);
|
|
$warningcount = Warning::where('user_id', $id)->count();
|
|
|
|
$softDeletedWarnings = Warning::where('user_id', $user->id)->with(['torrenttitle', 'warneduser'])->latest('created_at')->onlyTrashed()->paginate(25);
|
|
$softDeletedWarningCount = Warning::where('user_id', $id)->onlyTrashed()->count();
|
|
|
|
return view('user.warninglog', [
|
|
'warnings' => $warnings,
|
|
'warningcount' => $warningcount,
|
|
'softDeletedWarnings' => $softDeletedWarnings,
|
|
'softDeletedWarningCount' => $softDeletedWarningCount,
|
|
'user' => $user
|
|
]);
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Deactivate A Warning
|
|
*
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function deactivateWarning($id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$staff = auth()->user();
|
|
$warning = Warning::findOrFail($id);
|
|
$warning->expires_on = Carbon::now();
|
|
$warning->active = 0;
|
|
$warning->save();
|
|
|
|
// Send Private Message
|
|
$pm = new PrivateMessage;
|
|
$pm->sender_id = $staff->id;
|
|
$pm->receiver_id = $warning->user_id;
|
|
$pm->subject = "Hit and Run Warning Deactivated";
|
|
$pm->message = $staff->username . " has decided to deactivate your active warning for torrent " . $warning->torrent . " You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]";
|
|
$pm->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Staff Member {$staff->username} has deactivated a warning on {$warning->warneduser->username} account.");
|
|
|
|
return redirect()->route('warninglog', ['username' => $warning->warneduser->username, 'id' => $warning->warneduser->id])
|
|
->with(Toastr::success('Warning Was Successfully Deactivated', 'Yay!', ['options']));
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Deactivate All Warnings
|
|
*
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function deactivateAllWarnings($username, $id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$staff = auth()->user();
|
|
$user = User::findOrFail($id);
|
|
|
|
$warnings = Warning::where('user_id', $user->id)->get();
|
|
|
|
foreach ($warnings as $warning) {
|
|
$warning->expires_on = Carbon::now();
|
|
$warning->active = 0;
|
|
$warning->save();
|
|
}
|
|
|
|
// Send Private Message
|
|
$pm = new PrivateMessage;
|
|
$pm->sender_id = $staff->id;
|
|
$pm->receiver_id = $warning->user_id;
|
|
$pm->subject = "All Hit and Run Warning Deactivated";
|
|
$pm->message = $staff->username . " has decided to deactivate all of your active hit and run warnings. You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]";
|
|
$pm->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Staff Member {$staff->username} has deactivated all warnings on {$warning->warneduser->username} account.");
|
|
|
|
return redirect()->route('warninglog', ['username' => $warning->warneduser->username, 'id' => $warning->warneduser->id])
|
|
->with(Toastr::success('All Warnings Were Successfully Deactivated', 'Yay!', ['options']));
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Delete A Warning
|
|
*
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function deleteWarning($id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$staff = auth()->user();
|
|
$warning = Warning::findOrFail($id);
|
|
|
|
// Send Private Message
|
|
$pm = new PrivateMessage;
|
|
$pm->sender_id = $staff->id;
|
|
$pm->receiver_id = $warning->user_id;
|
|
$pm->subject = "Hit and Run Warning Deleted";
|
|
$pm->message = $staff->username . " has decided to delete your warning for torrent " . $warning->torrent . " You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]";
|
|
$pm->save();
|
|
|
|
$warning->deleted_by = $staff->id;
|
|
$warning->save();
|
|
$warning->delete();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Staff Member {$staff->username} has deleted a warning on {$warning->warneduser->username} account.");
|
|
|
|
return redirect()->route('warninglog', ['username' => $warning->warneduser->username, 'id' => $warning->warneduser->id])
|
|
->with(Toastr::success('Warning Was Successfully Deleted', 'Yay!', ['options']));
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Delete All Warnings
|
|
*
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function deleteAllWarnings($username, $id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$staff = auth()->user();
|
|
$user = User::findOrFail($id);
|
|
|
|
$warnings = Warning::where('user_id', $user->id)->get();
|
|
|
|
foreach ($warnings as $warning) {
|
|
$warning->deleted_by = $staff->id;
|
|
$warning->save();
|
|
$warning->delete();
|
|
}
|
|
|
|
// Send Private Message
|
|
$pm = new PrivateMessage;
|
|
$pm->sender_id = $staff->id;
|
|
$pm->receiver_id = $warning->user_id;
|
|
$pm->subject = "All Hit and Run Warnings Deleted";
|
|
$pm->message = $staff->username . " has decided to delete all of your warnings. You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]";
|
|
$pm->save();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Staff Member {$staff->username} has deleted all warnings on {$warning->warneduser->username} account.");
|
|
|
|
return redirect()->route('warninglog', ['username' => $warning->warneduser->username, 'id' => $warning->warneduser->id])
|
|
->with(Toastr::success('All Warnings Were Successfully Deleted', 'Yay!', ['options']));
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Restore A Soft Deleted Warning
|
|
*
|
|
* @param $id
|
|
* @return Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function restoreWarning($id)
|
|
{
|
|
if (auth()->user()->group->is_modo) {
|
|
$staff = auth()->user();
|
|
$warning = Warning::findOrFail($id);
|
|
$warning->restore();
|
|
|
|
// Activity Log
|
|
\LogActivity::addToLog("Staff Member {$staff->username} has restore a soft deleted warning on {$warning->warneduser->username} account.");
|
|
|
|
return redirect()->route('warninglog', ['username' => $warning->warneduser->username, 'id' => $warning->warneduser->id])
|
|
->with(Toastr::success('Warning Was Successfully Restored', 'Yay!', ['options']));
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get A Users Uploads
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function myUploads($username, $id)
|
|
{
|
|
$user = User::findOrFail($id);
|
|
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
|
|
$torrents = Torrent::withAnyStatus()->sortable(['created_at' => 'desc'])->where('user_id', $user->id)->paginate(50);
|
|
return view('user.uploads', ['user' => $user, 'torrents' => $torrents]);
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get A Users Active Table
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function myActive($username, $id)
|
|
{
|
|
$user = User::findOrFail($id);
|
|
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
|
|
$active = Peer::sortable(['created_at' => 'desc'])->where('user_id', $user->id)->with('torrent')->distinct('hash')->paginate(50);
|
|
return view('user.active', ['user' => $user, 'active' => $active]);
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get A Users History Table
|
|
*
|
|
* @param $username
|
|
* @param $id
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function myHistory($username, $id)
|
|
{
|
|
$user = User::findOrFail($id);
|
|
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
|
|
$his_upl = History::where('user_id', $id)->sum('actual_uploaded');
|
|
$his_upl_cre = History::where('user_id', $id)->sum('uploaded');
|
|
$his_downl = History::where('user_id', $id)->sum('actual_downloaded');
|
|
$his_downl_cre = History::where('user_id', $id)->sum('downloaded');
|
|
$history = History::sortable(['created_at' => 'desc'])->where('user_id', $user->id)->paginate(50);
|
|
|
|
return view('user.history', [
|
|
'user' => $user,
|
|
'history' => $history,
|
|
'his_upl' => $his_upl,
|
|
'his_upl_cre' => $his_upl_cre,
|
|
'his_downl' => $his_downl,
|
|
'his_downl_cre' => $his_downl_cre
|
|
]);
|
|
} else {
|
|
return back()->with(Toastr::error('You Are Not Authorized To Perform This Action!', 'Error 403', ['options']));
|
|
}
|
|
}
|
|
} |