mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-28 14:31:10 -05:00
Apply fixes from StyleCI
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE
|
||||
* 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\BonTransactions;
|
||||
use App\Client;
|
||||
use App\Follow;
|
||||
use App\Group;
|
||||
use App\History;
|
||||
use App\Invite;
|
||||
use App\Peer;
|
||||
use App\PrivateMessage;
|
||||
use App\Services\Bencode;
|
||||
use App\Torrent;
|
||||
use App\User;
|
||||
use App\Warning;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Carbon\Carbon;
|
||||
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 App\Invite;
|
||||
use App\Services\Bencode;
|
||||
use Brian2694\Toastr\Toastr;
|
||||
use Image;
|
||||
use ZipArchive;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
@@ -40,7 +40,7 @@ class UserController extends Controller
|
||||
private $toastr;
|
||||
|
||||
/**
|
||||
* UserController Constructor
|
||||
* UserController Constructor.
|
||||
*
|
||||
* @param Toastr $toastr
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Users List
|
||||
* Get Users List.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@@ -62,26 +62,28 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Search For A User (Public Use)
|
||||
* 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') . '%'],
|
||||
['username', 'like', '%'.$request->input('username').'%'],
|
||||
])->paginate(25);
|
||||
$users->setPath('?username=' . $request->input('username'));
|
||||
$users->setPath('?username='.$request->input('username'));
|
||||
|
||||
return view('user.members')->with('users', $users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A User Profile
|
||||
* Get A User Profile.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function profile($username, $id)
|
||||
@@ -92,32 +94,33 @@ class UserController extends Controller
|
||||
$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');
|
||||
$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');
|
||||
$bondownload = BonTransactions::where('sender', $id)->where([['name', 'like', '%Download%']])->sum('cost');
|
||||
$realdownload = $user->downloaded + $bondownload;
|
||||
$invitedBy = Invite::where('accepted_by', $user->id)->first();
|
||||
|
||||
return view('user.profile', [
|
||||
'user' => $user,
|
||||
'groups' => $groups,
|
||||
'followers' => $followers,
|
||||
'history' => $history,
|
||||
'warnings' => $warnings,
|
||||
'hitrun' => $hitrun,
|
||||
'bonupload' => $bonupload,
|
||||
'realupload' => $realupload,
|
||||
'bondownload' => $bondownload,
|
||||
'user' => $user,
|
||||
'groups' => $groups,
|
||||
'followers' => $followers,
|
||||
'history' => $history,
|
||||
'warnings' => $warnings,
|
||||
'hitrun' => $hitrun,
|
||||
'bonupload' => $bonupload,
|
||||
'realupload' => $realupload,
|
||||
'bondownload' => $bondownload,
|
||||
'realdownload' => $realdownload,
|
||||
'invitedBy' => $invitedBy
|
||||
'invitedBy' => $invitedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Profile Form
|
||||
* Edit Profile Form.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function editProfileForm($username, $id)
|
||||
@@ -128,11 +131,12 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit User Profile
|
||||
* Edit User Profile.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function editProfile(Request $request, $username, $id)
|
||||
@@ -144,13 +148,13 @@ class UserController extends Controller
|
||||
$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);
|
||||
$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'
|
||||
'image' => 'dimensions:ratio=1/1',
|
||||
]);
|
||||
if ($v->passes()) {
|
||||
$image->move(public_path('/files/img/'), $filename);
|
||||
@@ -159,10 +163,10 @@ class UserController extends Controller
|
||||
->with($this->toastr->error('Because you are uploading a GIF, your avatar must be symmetrical!', 'Whoops!', ['options']));
|
||||
}
|
||||
}
|
||||
$user->image = $user->username . '.' . $image->getClientOriginalExtension();
|
||||
$user->image = $user->username.'.'.$image->getClientOriginalExtension();
|
||||
} else {
|
||||
return redirect()->route('profile', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error('Your avatar is too large, max file size: ' . ($max_upload / 1000000) . ' MB', 'Whoops!', ['options']));
|
||||
->with($this->toastr->error('Your avatar is too large, max file size: '.($max_upload / 1000000).' MB', 'Whoops!', ['options']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,12 +184,12 @@ class UserController extends Controller
|
||||
->with($this->toastr->success('Your Account Was Updated Successfully!', 'Yay!', ['options']));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* User Account Settings
|
||||
* User Account Settings.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function settings($username, $id)
|
||||
@@ -196,11 +200,12 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Account Settings
|
||||
* Change User Account Settings.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changeSettings(Request $request, $username, $id)
|
||||
@@ -211,7 +216,7 @@ class UserController extends Controller
|
||||
$user->chat_hidden = $request->input('chat_hidden');
|
||||
|
||||
// Style Settings
|
||||
$user->style = (int)$request->input('theme');
|
||||
$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])
|
||||
@@ -227,7 +232,7 @@ class UserController extends Controller
|
||||
$user->peer_hidden = $request->input('peer_hidden');
|
||||
|
||||
// Torrent Settings
|
||||
$user->torrent_layout = (int)$request->input('torrent_layout');
|
||||
$user->torrent_layout = (int) $request->input('torrent_layout');
|
||||
$user->show_poster = $request->input('show_poster');
|
||||
$user->ratings = $request->input('ratings');
|
||||
|
||||
@@ -245,17 +250,18 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* User Password Change
|
||||
* 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',
|
||||
'current_password' => 'required',
|
||||
'new_password' => 'required|min:6|confirmed',
|
||||
'new_password_confirmation' => 'required|min:6',
|
||||
]);
|
||||
if ($v->passes()) {
|
||||
@@ -278,11 +284,12 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* User Email Change
|
||||
* User Email Change.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
protected function changeEmail(Request $request, $username, $id)
|
||||
@@ -319,17 +326,18 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User PID
|
||||
* 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->passkey = md5(uniqid().time().microtime());
|
||||
$user->save();
|
||||
|
||||
// Activity Log
|
||||
@@ -340,10 +348,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A Users Seedboxes/Clients
|
||||
* Get A Users Seedboxes/Clients.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function clients($username, $id)
|
||||
@@ -355,18 +364,19 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Add A Seedbox/Client
|
||||
* 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',
|
||||
'password' => 'required',
|
||||
'ip' => 'required|ipv4|unique:clients,ip',
|
||||
'client_name' => 'required|alpha_num',
|
||||
]);
|
||||
|
||||
@@ -377,7 +387,7 @@ class UserController extends Controller
|
||||
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])
|
||||
->with($this->toastr->error('Max Clients Reached!', 'Whoops!', ['options']));
|
||||
}
|
||||
$cli = new Client;
|
||||
$cli = new Client();
|
||||
$cli->user_id = $user->id;
|
||||
$cli->name = $request->input('client_name');
|
||||
$cli->ip = $request->input('ip');
|
||||
@@ -399,17 +409,18 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A Seedbox/Client
|
||||
* 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',
|
||||
'cliid' => 'required|exists:clients,id',
|
||||
'userid' => 'required|exists:users,id',
|
||||
]);
|
||||
|
||||
@@ -430,10 +441,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A Users Warnings
|
||||
* Get A Users Warnings.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getWarnings($username, $id)
|
||||
@@ -448,18 +460,19 @@ class UserController extends Controller
|
||||
$softDeletedWarningCount = Warning::where('user_id', $id)->onlyTrashed()->count();
|
||||
|
||||
return view('user.warninglog', [
|
||||
'warnings' => $warnings,
|
||||
'warningcount' => $warningcount,
|
||||
'softDeletedWarnings' => $softDeletedWarnings,
|
||||
'warnings' => $warnings,
|
||||
'warningcount' => $warningcount,
|
||||
'softDeletedWarnings' => $softDeletedWarnings,
|
||||
'softDeletedWarningCount' => $softDeletedWarningCount,
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate A Warning
|
||||
* Deactivate A Warning.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deactivateWarning($id)
|
||||
@@ -472,11 +485,11 @@ class UserController extends Controller
|
||||
$warning->save();
|
||||
|
||||
// Send Private Message
|
||||
$pm = new PrivateMessage;
|
||||
$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->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
|
||||
@@ -487,9 +500,10 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate All Warnings
|
||||
* Deactivate All Warnings.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deactivateAllWarnings($username, $id)
|
||||
@@ -507,11 +521,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
// Send Private Message
|
||||
$pm = new PrivateMessage;
|
||||
$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->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
|
||||
@@ -522,9 +536,10 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete A Warning
|
||||
* Delete A Warning.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteWarning($id)
|
||||
@@ -535,11 +550,11 @@ class UserController extends Controller
|
||||
$warning = Warning::findOrFail($id);
|
||||
|
||||
// Send Private Message
|
||||
$pm = new PrivateMessage;
|
||||
$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->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;
|
||||
@@ -554,9 +569,10 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete All Warnings
|
||||
* Delete All Warnings.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteAllWarnings($username, $id)
|
||||
@@ -575,11 +591,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
// Send Private Message
|
||||
$pm = new PrivateMessage;
|
||||
$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->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
|
||||
@@ -590,9 +606,10 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore A Soft Deleted Warning
|
||||
* Restore A Soft Deleted Warning.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function restoreWarning($id)
|
||||
@@ -611,10 +628,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A Users Uploads
|
||||
* Get A Users Uploads.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function myUploads($username, $id)
|
||||
@@ -628,10 +646,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A Users Active Table
|
||||
* Get A Users Active Table.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function myActive($username, $id)
|
||||
@@ -650,10 +669,11 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Get A Users History Table
|
||||
* Get A Users History Table.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function myHistory($username, $id)
|
||||
@@ -672,20 +692,21 @@ class UserController extends Controller
|
||||
->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
|
||||
'user' => $user,
|
||||
'history' => $history,
|
||||
'his_upl' => $his_upl,
|
||||
'his_upl_cre' => $his_upl_cre,
|
||||
'his_downl' => $his_downl,
|
||||
'his_downl_cre' => $his_downl_cre,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search A User's Uploads
|
||||
* Search A User's Uploads.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function myUploadsSearch(Request $request, $username, $id)
|
||||
@@ -695,17 +716,18 @@ class UserController extends Controller
|
||||
abort_unless(auth()->user()->group->is_modo || auth()->user()->id == $user->id, 403);
|
||||
$torrents = Torrent::withAnyStatus()->sortable(['created_at' => 'desc'])
|
||||
->where('user_id', $user->id)
|
||||
->where('name', 'like', '%' . $request->input('name') . '%')
|
||||
->where('name', 'like', '%'.$request->input('name').'%')
|
||||
->paginate(50);
|
||||
|
||||
return view('user.uploads', ['user' => $user, 'torrents' => $torrents]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download All History Torrents
|
||||
* Download All History Torrents.
|
||||
*
|
||||
* @param $username
|
||||
* @param $id
|
||||
*
|
||||
* @return \ZipArchive
|
||||
*/
|
||||
public function downloadHistoryTorrents($username, $id)
|
||||
@@ -728,7 +750,7 @@ class UserController extends Controller
|
||||
|
||||
abort_unless(auth()->user()->id == $user->id, 403);
|
||||
// Define Dir Folder
|
||||
$path = getcwd() . '/files/tmp_zip/';
|
||||
$path = getcwd().'/files/tmp_zip/';
|
||||
|
||||
// Zip File Name
|
||||
$zipFileName = "{$user->username}.zip";
|
||||
@@ -739,7 +761,7 @@ class UserController extends Controller
|
||||
// Get Users History
|
||||
$historyTorrents = History::where('user_id', '=', $user->id)->pluck('info_hash');
|
||||
|
||||
if ($zip->open($path.'/'.$zipFileName, ZipArchive::CREATE) === TRUE) {
|
||||
if ($zip->open($path.'/'.$zipFileName, ZipArchive::CREATE) === true) {
|
||||
// Match History Results To Torrents
|
||||
foreach ($historyTorrents as $historyTorrent) {
|
||||
// Get Torrent
|
||||
@@ -749,27 +771,27 @@ class UserController extends Controller
|
||||
$tmpFileName = "{$torrent->slug}.torrent";
|
||||
|
||||
// The Torrent File Exist?
|
||||
if (!file_exists(getcwd() . '/files/torrents/' . $torrent->file_name)) {
|
||||
if (!file_exists(getcwd().'/files/torrents/'.$torrent->file_name)) {
|
||||
return back()->with($this->toastr->error('Torrent File Not Found! Please Report This Torrent!', 'Error!', ['options']));
|
||||
} else {
|
||||
// Delete The Last Torrent Tmp File If Exist
|
||||
if (file_exists(getcwd() . '/files/tmp/' . $tmpFileName)) {
|
||||
unlink(getcwd() . '/files/tmp/' . $tmpFileName);
|
||||
if (file_exists(getcwd().'/files/tmp/'.$tmpFileName)) {
|
||||
unlink(getcwd().'/files/tmp/'.$tmpFileName);
|
||||
}
|
||||
}
|
||||
|
||||
// Get The Content Of The Torrent
|
||||
$dict = Bencode::bdecode(file_get_contents(getcwd() . '/files/torrents/' . $torrent->file_name));
|
||||
$dict = Bencode::bdecode(file_get_contents(getcwd().'/files/torrents/'.$torrent->file_name));
|
||||
// Set the announce key and add the user passkey
|
||||
$dict['announce'] = route('announce', ['passkey' => $user->passkey]);
|
||||
// Remove Other announce url
|
||||
unset($dict['announce-list']);
|
||||
|
||||
$fileToDownload = Bencode::bencode($dict);
|
||||
file_put_contents(getcwd() . '/files/tmp/' . $tmpFileName, $fileToDownload);
|
||||
file_put_contents(getcwd().'/files/tmp/'.$tmpFileName, $fileToDownload);
|
||||
|
||||
// Add Files To ZipArchive
|
||||
$zip->addFile(getcwd() . '/files/tmp/' . $tmpFileName, $tmpFileName);
|
||||
$zip->addFile(getcwd().'/files/tmp/'.$tmpFileName, $tmpFileName);
|
||||
}
|
||||
// Close ZipArchive
|
||||
$zip->close();
|
||||
|
||||
Reference in New Issue
Block a user