| # | -Name | -Size | -Left(+pars) | -Done | -Status | -Delete | -Pause all | -Resume all | -
|---|---|---|---|---|---|---|---|---|
| ".$count.' | '. - "".$item['NZBName'].' | '. - "".$item['FileSizeMB'].' MB | '. - "".$item['RemainingSizeMB'].' MB | '. - "".($item['FileSizeMB'] === 0 ? 0 : round(100 - ($item['RemainingSizeMB'] / $item['FileSizeMB']) * 100)).'% | '. - "".($item['ActiveDownloads'] > 0 ? 'Downloading' : 'Paused').' | '. - "Delete | ". - "Pause | ". - "Resume | ". - '
The queue is currently empty.
"; - } - } else { - $output .= "Error retreiving queue.
"; - } - - echo $output; - } - - /** - * @throws \Exception - */ - public function sabnzbd() - { - $this->setPreferences(); - $sab = new SABnzbd($this); - - $output = ''; - - $json = $sab->getAdvQueue(); - - if ($json !== false) { - $obj = json_decode($json); - $queue = $obj->{'queue'}; - $count = 1; - - $output .= - "| # | -Name | -Size | -Left | -Done | -Time Left | -Delete | -Pause all | -Resume all | -
|---|---|---|---|---|---|---|---|---|
| ".$count.' | '. - "".$item->{'filename'}.' | '. - "".round($item->{'mb'}, 2).' MB | '. - "".round($item->{'mbleft'}, 2).' MB | '. - "".($item->{'mb'} === 0 ? 0 : round(100 - ($item->{'mbleft'} / $item->{'mb'}) * 100)).'% | '. - "".$item->{'timeleft'}.' | '. - "Delete | ". - "Pause | ". - "Resume | ". - '
The queue is currently empty.
"; - } - } else { - $output .= "Error retrieving queue.
"; - } - - echo $output; - } - - /** - * @throws \Exception - */ - public function nzbVortex() - { - $this->setPreferences(); - try { - if (isset($_GET['isAjax'])) { - $vortex = new NZBVortex; - - // I guess we Ajax this way. - if (isset($_GET['getOverview'])) { - $overview = $vortex->getOverview(); - $this->smarty->assign('overview', $overview); - $content = $this->smarty->fetch('nzbvortex-ajax.tpl'); - echo $content; - exit; - } - - if (isset($_GET['addQueue'])) { - $nzb = $_GET['addQueue']; - $vortex->addQueue($nzb); - exit; - } - - if (isset($_GET['resume'])) { - $vortex->resume((int) $_GET['resume']); - exit; - } - - if (isset($_GET['pause'])) { - $vortex->pause((int) $_GET['pause']); - exit; - } - - if (isset($_GET['moveup'])) { - $vortex->moveUp((int) $_GET['moveup']); - exit; - } - - if (isset($_GET['movedown'])) { - $vortex->moveDown((int) $_GET['movedown']); - exit; - } - - if (isset($_GET['movetop'])) { - $vortex->moveTop((int) $_GET['movetop']); - exit; - } - - if (isset($_GET['movebottom'])) { - $vortex->moveBottom((int) $_GET['movebottom']); - exit; - } - - if (isset($_GET['delete'])) { - $vortex->delete((int) $_GET['delete']); - exit; - } - - if (isset($_GET['filelist'])) { - $response = $vortex->getFilelist((int) $_GET['filelist']); - echo json_encode($response); - exit; - } - } - } catch (\Exception $e) { - header('HTTP/1.1 500 Internal Server Error'); - printf($e->getMessage()); - exit; - } - - $title = 'NZBVortex'; - - $content = $this->smarty->fetch('nzbvortex.tpl'); - - $this->smarty->assign(compact('title', 'content')); - - $this->pagerender(); - } -} diff --git a/app/Http/Controllers/SendReleaseController.php b/app/Http/Controllers/SendReleaseController.php deleted file mode 100644 index 24030bd3c..000000000 --- a/app/Http/Controllers/SendReleaseController.php +++ /dev/null @@ -1,114 +0,0 @@ -setPreferences(); - if (empty($request->input('id'))) { - $this->show404(); - } else { - $cp = new CouchPotato($this); - - if (empty($cp->cpurl)) { - $this->show404(); - } - - if (empty($cp->cpapi)) { - $this->show404(); - } - $id = $request->input('id'); - $cp->sendToCouchPotato($id); - } - } - - /** - * @throws \Exception - */ - public function sabNzbd(Request $request) - { - $this->setPreferences(); - if (empty($request->input('id'))) { - $this->show404(); - } - - $sab = new SABnzbd($this); - - if (empty($sab->url)) { - $this->show404(); - } - - if (empty($sab->apikey)) { - $this->show404(); - } - - $guid = $request->input('id'); - - $sab->sendToSab($guid); - } - - /** - * @throws \Exception - */ - public function nzbGet(Request $request): void - { - $this->setPreferences(); - if (empty($request->input('id'))) { - $this->show404(); - } - - $nzbget = new NZBGet($this); - - if (empty($nzbget->url)) { - $this->show404(); - } - - if (empty($nzbget->username)) { - $this->show404(); - } - - if (empty($nzbget->password)) { - $this->show404(); - } - - $guid = $request->input('id'); - - $nzbget->sendURLToNZBGet($guid); - } - - /** - * @throws \Exception - */ - public function queue(Request $request): void - { - $this->setPreferences(); - if (empty($request->input('id'))) { - $this->show404(); - } - - $user = $this->userdata; - if ((int) $this->userdata->queuetype !== 2) { - $sab = new SABnzbd($this); - if (empty($sab->url)) { - $this->show404(); - } - if (empty($sab->apikey)) { - $this->show404(); - } - $sab->sendToSab($request->input('id')); - } elseif ((int) $user['queuetype'] === 2) { - $nzbget = new NZBGet($this); - $nzbget->sendURLToNZBGet($request->input('id')); - } - } -} diff --git a/app/Models/User.php b/app/Models/User.php index ba8759627..50bfe1bb1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -7,6 +7,10 @@ use App\Jobs\SendAccountWillExpireEmail; use App\Jobs\SendInviteEmail; use Carbon\CarbonImmutable; use DariusIII\Token\Facades\Token; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Http\Request; use Illuminate\Notifications\Notifiable; @@ -54,7 +58,6 @@ use Spatie\Permission\Traits\HasRoles; * @property string|null $sabapikey * @property bool|null $sabapikeytype * @property bool|null $sabpriority - * @property bool $queuetype Type of queue, Sab or NZBGet * @property string|null $nzbgeturl * @property string|null $nzbgetusername * @property string|null $nzbgetpassword @@ -76,48 +79,47 @@ use Spatie\Permission\Traits\HasRoles; * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserRequest[] $request * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserSerie[] $series * - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereApiaccess($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereBookview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereConsoleview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereCpApi($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereCpUrl($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereCreatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereEmail($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereFirstname($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereGameview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereGrabs($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereHost($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereId($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereInvitedby($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereInvites($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereLastlogin($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereLastname($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereMovieview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereMusicview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNotes($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNzbgetpassword($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNzbgeturl($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNzbgetusername($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNzbvortexApiKey($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereNzbvortexServerUrl($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User wherePassword($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereQueuetype($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereRememberToken($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereResetguid($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereRolechangedate($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereRsstoken($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereSabapikey($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereSabapikeytype($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereSabpriority($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereSaburl($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereStyle($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereUpdatedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereUserRolesId($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereUsername($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereUserseed($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereXxxview($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereVerified($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereApiToken($value) + * @method static Builder|\App\Models\User whereApiaccess($value) + * @method static Builder|\App\Models\User whereBookview($value) + * @method static Builder|\App\Models\User whereConsoleview($value) + * @method static Builder|\App\Models\User whereCpApi($value) + * @method static Builder|\App\Models\User whereCpUrl($value) + * @method static Builder|\App\Models\User whereCreatedAt($value) + * @method static Builder|\App\Models\User whereEmail($value) + * @method static Builder|\App\Models\User whereFirstname($value) + * @method static Builder|\App\Models\User whereGameview($value) + * @method static Builder|\App\Models\User whereGrabs($value) + * @method static Builder|\App\Models\User whereHost($value) + * @method static Builder|\App\Models\User whereId($value) + * @method static Builder|\App\Models\User whereInvitedby($value) + * @method static Builder|\App\Models\User whereInvites($value) + * @method static Builder|\App\Models\User whereLastlogin($value) + * @method static Builder|\App\Models\User whereLastname($value) + * @method static Builder|\App\Models\User whereMovieview($value) + * @method static Builder|\App\Models\User whereMusicview($value) + * @method static Builder|\App\Models\User whereNotes($value) + * @method static Builder|\App\Models\User whereNzbgetpassword($value) + * @method static Builder|\App\Models\User whereNzbgeturl($value) + * @method static Builder|\App\Models\User whereNzbgetusername($value) + * @method static Builder|\App\Models\User whereNzbvortexApiKey($value) + * @method static Builder|\App\Models\User whereNzbvortexServerUrl($value) + * @method static Builder|\App\Models\User wherePassword($value) + * @method static Builder|\App\Models\User whereRememberToken($value) + * @method static Builder|\App\Models\User whereResetguid($value) + * @method static Builder|\App\Models\User whereRolechangedate($value) + * @method static Builder|\App\Models\User whereRsstoken($value) + * @method static Builder|\App\Models\User whereSabapikey($value) + * @method static Builder|\App\Models\User whereSabapikeytype($value) + * @method static Builder|\App\Models\User whereSabpriority($value) + * @method static Builder|\App\Models\User whereSaburl($value) + * @method static Builder|\App\Models\User whereStyle($value) + * @method static Builder|\App\Models\User whereUpdatedAt($value) + * @method static Builder|\App\Models\User whereUserRolesId($value) + * @method static Builder|\App\Models\User whereUsername($value) + * @method static Builder|\App\Models\User whereUserseed($value) + * @method static Builder|\App\Models\User whereXxxview($value) + * @method static Builder|\App\Models\User whereVerified($value) + * @method static Builder|\App\Models\User whereApiToken($value) * * @mixin \Eloquent * @@ -134,15 +136,14 @@ use Spatie\Permission\Traits\HasRoles; * @property-read \Spatie\Permission\Models\Role $role * @property-read \Illuminate\Database\Eloquent\Collection|\Spatie\Permission\Models\Role[] $roles * - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User newModelQuery() - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User newQuery() - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User permission($permissions) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User query() - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User role($roles, $guard = null) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereEmailVerifiedAt($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereRateLimit($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereRolesId($value) - * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User whereVerificationToken($value) + * @method static Builder|\App\Models\User newModelQuery() + * @method static Builder|\App\Models\User newQuery() + * @method static Builder|\App\Models\User permission($permissions) + * @method static Builder|\App\Models\User query() + * @method static Builder|\App\Models\User whereEmailVerifiedAt($value) + * @method static Builder|\App\Models\User whereRateLimit($value) + * @method static Builder|\App\Models\User whereRolesId($value) + * @method static Builder|\App\Models\User whereVerificationToken($value) */ class User extends Authenticatable { @@ -297,36 +298,23 @@ class User extends Authenticatable } /** - * @param int $id - * @param string $userName - * @param string $email - * @param int $grabs - * @param int $role - * @param string $notes - * @param int $invites - * @param int $movieview - * @param int $musicview - * @param int $gameview - * @param int $xxxview - * @param int $consoleview - * @param int $bookview - * @param string $queueType - * @param string $nzbgetURL - * @param string $nzbgetUsername - * @param string $nzbgetPassword - * @param string $saburl - * @param string $sabapikey - * @param string $sabpriority - * @param string $sabapikeytype - * @param bool $nzbvortexServerUrl - * @param bool $nzbvortexApiKey - * @param bool $cp_url - * @param bool $cp_api - * @param string $style - * - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @param int $id + * @param string $userName + * @param string $email + * @param int $grabs + * @param int $role + * @param string $notes + * @param int $invites + * @param int $movieview + * @param int $musicview + * @param int $gameview + * @param int $xxxview + * @param int $consoleview + * @param int $bookview + * @param string $style + * @return int */ - public static function updateUser($id, $userName, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $xxxview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl = false, $nzbvortexApiKey = false, $cp_url = false, $cp_api = false, $style = 'None'): int + public static function updateUser(int $id, string $userName, string $email, int $grabs, int $role, string $notes, int $invites, int $movieview, int $musicview, int $gameview, int $xxxview, int $consoleview, int $bookview, string $style = 'None'): int { $userName = trim($userName); @@ -345,18 +333,6 @@ class User extends Authenticatable 'consoleview' => $consoleview, 'bookview' => $bookview, 'style' => $style, - 'queuetype' => $queueType, - 'nzbgeturl' => $nzbgetURL, - 'nzbgetusername' => $nzbgetUsername, - 'nzbgetpassword' => $nzbgetPassword, - 'saburl' => $saburl, - 'sabapikey' => $sabapikey, - 'sabapikeytype' => $sabapikeytype, - 'sabpriority' => $sabpriority, - 'nzbvortex_server_url' => $nzbvortexServerUrl, - 'nzbvortex_api_key' => $nzbvortexApiKey, - 'cp_url' => $cp_url, - 'cp_api' => $cp_api, 'rate_limit' => $rateLimit ? $rateLimit['rate_limit'] : 60, ]; @@ -373,7 +349,8 @@ class User extends Authenticatable } /** - * @return \Illuminate\Database\Eloquent\Model|null|static + * @param string $userName + * @return User|Builder|Model|object|null */ public static function getByUsername(string $userName) { @@ -381,9 +358,9 @@ class User extends Authenticatable } /** - * @return \Illuminate\Database\Eloquent\Model|static + * @return Model|static * - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @throws ModelNotFoundException */ public static function getByEmail(string $email) { @@ -393,7 +370,7 @@ class User extends Authenticatable /** * @return bool */ - public static function updateUserRole(int $uid, int $role) + public static function updateUserRole(int $uid, int $role): bool { $roleQuery = Role::query()->where('id', $role)->first(); $roleName = $roleQuery->name; @@ -405,10 +382,10 @@ class User extends Authenticatable } /** - * @param int $uid - * @param int $addYear + * @param int $uid + * @param int $addYear */ - public static function updateUserRoleChangeDate($uid, $date = '', $addYear = 0): void + public static function updateUserRoleChangeDate(int $uid, $date = '', int $addYear = 0): void { $user = self::find($uid); $currRoleExp = $user->rolechangedate ?? now()->toDateTimeString(); @@ -444,16 +421,16 @@ class User extends Authenticatable } /** - * @param string $userName - * @param string $email - * @param string $host - * @param string $role - * @param bool $apiRequests + * @param string $userName + * @param string $email + * @param string $host + * @param string $role + * @param bool $apiRequests * @return \Illuminate\Database\Eloquent\Collection * * @throws \Throwable */ - public static function getRange($start, $offset, $orderBy, $userName = '', $email = '', $host = '', $role = '', $apiRequests = false) + public static function getRange($start, $offset, $orderBy, string $userName = '', string $email = '', string $host = '', string $role = '', bool $apiRequests = false) { if ($apiRequests) { UserRequest::clearApiRequests(false); @@ -499,38 +476,18 @@ class User extends Authenticatable { $order = (empty($orderBy) ? 'username_desc' : $orderBy); $orderArr = explode('_', $order); - switch ($orderArr[0]) { - case 'email': - $orderField = 'email'; - break; - case 'host': - $orderField = 'host'; - break; - case 'createdat': - $orderField = 'created_at'; - break; - case 'lastlogin': - $orderField = 'lastlogin'; - break; - case 'apiaccess': - $orderField = 'apiaccess'; - break; - case 'grabs': - $orderField = 'grabs'; - break; - case 'role': - $orderField = 'rolename'; - break; - case 'rolechangedate': - $orderField = 'rolechangedate'; - break; - case 'verification': - $orderField = 'verified'; - break; - default: - $orderField = 'username'; - break; - } + $orderField = match ($orderArr[0]) { + 'email' => 'email', + 'host' => 'host', + 'createdat' => 'created_at', + 'lastlogin' => 'lastlogin', + 'apiaccess' => 'apiaccess', + 'grabs' => 'grabs', + 'role' => 'rolename', + 'rolechangedate' => 'rolechangedate', + 'verification' => 'verified', + default => 'username', + }; $orderSort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc'; return [$orderField, $orderSort]; @@ -541,11 +498,11 @@ class User extends Authenticatable * * Automatically update the hash if it needs to be. * - * @param string $password Password to check against hash. - * @param string|bool $hash Hash to check against password. - * @param int $userID ID of the user. + * @param string $password Password to check against hash. + * @param bool|string $hash Hash to check against password. + * @param int $userID ID of the user. */ - public static function checkPassword($password, $hash, $userID = -1): bool + public static function checkPassword(string $password, bool|string $hash, int $userID = -1): bool { if (Hash::check($password, $hash) === false) { return false; @@ -585,17 +542,18 @@ class User extends Authenticatable } /** - * @return mixed + * @param $password + * @return string */ - public static function hashPassword($password) + public static function hashPassword($password): string { return Hash::make($password); } /** - * @return \Illuminate\Database\Eloquent\Model|static + * @return Model|static * - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + * @throws ModelNotFoundException */ public static function getByPassResetGuid(string $guid) { @@ -603,31 +561,15 @@ class User extends Authenticatable } /** - * @param int $num + * @param int $num */ - public static function incrementGrabs(int $id, $num = 1): void + public static function incrementGrabs(int $id, int $num = 1): void { self::find($id)->increment('grabs', $num); } /** - * Check if the user is in the database, and if their API key is good, return user data if so. - * - * - * @return bool|\Illuminate\Database\Eloquent\Model|null|static - */ - public static function getByIdAndRssToken($userID, $rssToken) - { - $user = self::query()->where(['id' => $userID, 'api_token' => $rssToken])->first(); - if ($user === null) { - return false; - } - - return $user; - } - - /** - * @return \Illuminate\Database\Eloquent\Model|null|static + * @return Model|null|static */ public static function getByRssToken(string $rssToken) { @@ -640,36 +582,30 @@ class User extends Authenticatable } /** - * Generate a random username. - */ - public static function generateUsername(): string - { - return Str::random(); - } - - /** - * @param int $length + * @param int $length * * @throws \Exception */ - public static function generatePassword($length = 15): string + public static function generatePassword(int $length = 15): string { return Token::random($length, true); } /** - * Register a new user. - * - * @param int $invites - * @param string $inviteCode - * @param bool $forceInviteMode - * @param int $role - * @param bool $validate + * @param $userName + * @param $password + * @param $email + * @param $host + * @param $notes + * @param int $invites + * @param string $inviteCode + * @param bool $forceInviteMode + * @param int $role + * @param bool $validate * @return bool|int|string - * * @throws \Exception */ - public static function signUp($userName, $password, $email, $host, $notes, $invites = Invitation::DEFAULT_INVITES, $inviteCode = '', $forceInviteMode = false, $role = self::ROLE_USER, $validate = true) + public static function signUp($userName, $password, $email, $host, $notes, int $invites = Invitation::DEFAULT_INVITES, string $inviteCode = '', bool $forceInviteMode = false, int $role = self::ROLE_USER, bool $validate = true): bool|int|string { $user = [ 'username' => trim($userName), @@ -685,9 +621,7 @@ class User extends Authenticatable ]); if ($validator->fails()) { - $error = implode('', Arr::collapse($validator->errors()->toArray())); - - return $error; + return implode('', Arr::collapse($validator->errors()->toArray())); } } @@ -726,19 +660,19 @@ class User extends Authenticatable /** * Add a new user. * - * @param string $userName - * @param string $password - * @param string $email - * @param int $role - * @param string $notes - * @param string $host - * @param int $invites - * @param int $invitedBy + * @param string $userName + * @param string $password + * @param string $email + * @param int $role + * @param string $notes + * @param string $host + * @param int $invites + * @param int $invitedBy * @return bool|int * * @throws \Exception */ - public static function add($userName, $password, $email, $role, $notes = '', $host = '', $invites = Invitation::DEFAULT_INVITES, $invitedBy = 0) + public static function add(string $userName, string $password, string $email, int $role, string $notes = '', string $host = '', int $invites = Invitation::DEFAULT_INVITES, int $invitedBy = 0) { $password = self::hashPassword($password); if (! $password) { @@ -766,11 +700,11 @@ class User extends Authenticatable /** * Get the list of categories the user has excluded. * - * @param int $userID ID of the user. + * @param int $userID ID of the user. * * @throws \Exception */ - public static function getCategoryExclusionById($userID): array + public static function getCategoryExclusionById(int $userID): array { $ret = []; @@ -822,9 +756,7 @@ class User extends Authenticatable } } - $exclusion = Category::query()->whereIn('root_categories_id', $ret)->pluck('id')->toArray(); - - return $exclusion; + return Category::query()->whereIn('root_categories_id', $ret)->pluck('id')->toArray(); } /** @@ -869,27 +801,6 @@ class User extends Authenticatable return $url; } - /** - * Deletes old rows FROM the user_requests and user_downloads tables. - * if site->userdownloadpurgedays SET to 0 then all release history is removed but - * the download/request rows must remain for at least one day to allow the role based - * limits to apply. - * - * @param int $days - * - * @throws \Exception - */ - public static function pruneRequestHistory($days = 0): void - { - if ($days === 0) { - $days = 1; - UserDownload::query()->update(['releases_id' => null]); - } - - UserRequest::query()->where('timestamp', '<', now()->subDays($days))->delete(); - UserDownload::query()->where('timestamp', '<', now()->subDays($days))->delete(); - } - /** * Deletes users that have not verified their accounts for 3 or more days. */ @@ -898,7 +809,7 @@ class User extends Authenticatable static::whereVerified(0)->where('created_at', '<', now()->subDays(3))->delete(); } - public function passwordSecurity(): \Illuminate\Database\Eloquent\Relations\HasOne + public function passwordSecurity(): HasOne { return $this->hasOne(PasswordSecurity::class); } diff --git a/database/migrations/2014_01_16_195548_create_users_table.php b/database/migrations/2014_01_16_195548_create_users_table.php index b6b693752..0d1e578b0 100644 --- a/database/migrations/2014_01_16_195548_create_users_table.php +++ b/database/migrations/2014_01_16_195548_create_users_table.php @@ -38,20 +38,8 @@ class CreateUsersTable extends Migration $table->integer('bookview')->default(1); $table->integer('gameview')->default(1); $table->integer('rate_limit')->default(60); - $table->string('saburl')->nullable(); - $table->string('sabapikey')->nullable(); - $table->boolean('sabapikeytype')->nullable(); - $table->boolean('sabpriority')->nullable(); - $table->boolean('queuetype')->default(1)->comment('Type of queue, Sab or NZBGet'); - $table->string('nzbgeturl')->nullable(); - $table->string('nzbgetusername')->nullable(); - $table->string('nzbgetpassword')->nullable(); - $table->string('nzbvortex_api_key', 10)->nullable(); - $table->string('nzbvortex_server_url')->nullable(); $table->string('userseed', 50); $table->string('notes')->nullable(); - $table->string('cp_url')->nullable(); - $table->string('cp_api')->nullable(); $table->string('style')->nullable(); $table->dateTime('rolechangedate')->nullable()->comment('When does the role expire'); $table->timestamp('email_verified_at')->nullable(); diff --git a/resources/assets/js/functions.js b/resources/assets/js/functions.js index 1d9b65233..63930241c 100755 --- a/resources/assets/js/functions.js +++ b/resources/assets/js/functions.js @@ -40,145 +40,6 @@ jQuery(function($) { return false; }); - $('.sabsend').click(function(e) { - if ($(this).hasClass('icon_sab_clicked')) return false; - - let guid = $('.guid') - .attr('id') - .substring(4); - let nzburl = base_url + '/sendtoqueue/' + guid; - - $.post(nzburl, function(resp) { - $(e.target) - .addClass('icon_sab_clicked') - .attr('title', 'Added to Queue'); - PNotify.defaults.icons = 'fontawesome5'; - PNotify.success({ - title: 'Release added to your download queue!', - type: 'success', - icon: 'fa fa-info fa-3x', - Animate: { - animate: true, - in_class: 'bounceInLeft', - out_class: 'bounceOutRight', - }, - desktop: { - desktop: true, - fallback: true, - }, - }); - }); - return false; - }); - - $('.getsend').click(function(e) { - if ($(this).hasClass('icon_nzbget_clicked')) return false; - - let guid = $('.guid') - .attr('id') - .substring(4); - let nzburl = base_url + '/sendtoqueue/' + guid; - - $.post(nzburl, function(resp) { - $(e.target) - .addClass('icon_nzbget_clicked') - .attr('title', 'Added to Queue'); - PNotify.defaults.icons = 'fontawesome5'; - PNotify.success({ - title: 'Release added to your download queue!', - type: 'success', - icon: 'fa fa-info fa-3x', - Animate: { - animate: true, - in_class: 'bounceInLeft', - out_class: 'bounceOutRight', - }, - desktop: { - desktop: true, - fallback: true, - }, - }); - }); - return false; - }); - - $('.sendtocouch').click(function(e) { - if ($(this).hasClass('icon_cp_clicked')) return false; - let id = $(this) - .attr('id') - .substring(4); - let cpurl = base_url + 'sendtocouch/' + id; - - $.post(cpurl, function(resp) { - $(e.target) - .addClass('icon_cp_clicked') - .attr('title', 'Added to CouchPotato'); - PNotify.defaults.icons = 'fontawesome5'; - PNotify.success({ - title: 'Movie added to CoucPotato wanted list!', - type: 'success', - icon: 'fa fa-info fa-3x', - Animate: { - animate: true, - in_class: 'bounceInLeft', - out_class: 'bounceOutRight', - }, - desktop: { - desktop: true, - fallback: true, - }, - }); - }); - return false; - }); - - $('.vortexsend').click(function(event) { - if ($(this).hasClass('icon_nzbvortex_clicked')) return false; - let guid = $('.guid') - .attr('id') - .substring(4); - - if (guid && guid.length > 0) { - $.ajax({ - url: base_url + 'nzbvortex?addQueue=' + guid + '&isAjax', - cache: false, - }) - .done(function(html) { - let message = 'Added ' + guid + ' to queue.'; - $(event.target) - .addClass('icon_nzbvortex_clicked') - .attr('title', message); - PNotify.defaults.icons = 'fontawesome5'; - PNotify.success({ - title: 'Release added to your download queue!', - type: 'success', - icon: 'fa fa-info fa-3x', - Animate: { - animate: true, - in_class: 'bounceInLeft', - out_class: 'bounceOutRight', - }, - desktop: { - desktop: true, - fallback: true, - }, - }); - }) - .fail(function(response) { - alert(response.responseText); - }); - } - return false; - }); - - let vortexStates = new Array(); - vortexStates[0] = 'Waiting'; - vortexStates[1] = 'Downloading'; - vortexStates[2] = 'Downloaded'; - vortexStates[3] = 'Saving'; - vortexStates[4] = 'Saved'; - vortexStates[5] = 'Skipped'; - // browse.tpl, search.tpl -- show icons on hover let orig_opac = $('table.data tr') .children('td.icons') @@ -289,195 +150,6 @@ jQuery(function($) { return false; }); - $('.icon_nzbvortex').click(function(event) { - if ($(this).hasClass('icon_nzbvortex_clicked')) return false; - let guid = $(this) - .parent() - .parent() - .attr('id') - .substring(4); - - if (guid && guid.length > 0) { - $.ajax({ - url: base_url + '/nzbvortex?addQueue=' + guid + '&isAjax', - cache: false, - }) - .done(function(html) { - let message = 'Added ' + guid + ' to queue.'; - $(event.target) - .addClass('icon_nzbvortex_clicked') - .attr('title', message); - PNotify.defaults.icons = 'fontawesome5'; - PNotify.success({ - title: 'ADDED TO NZBVORTEX!', - type: 'success', - icon: 'fa fa-info fa-3x', - Animate: { - animate: true, - in_class: 'bounceInLeft', - out_class: 'bounceOutRight', - }, - desktop: { - desktop: true, - fallback: true, - }, - }); - }) - .fail(function(response) { - alert(response.responseText); - }); - } - - return false; - }); - - $(document).on('click', 'a.vortex-resume', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?resume=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-pause', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?pause=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-moveup', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?moveup=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-movedown', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?movedown=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-movetop', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?movetop=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-movebottom', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?movebottom=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-trash', function(event) { - event.preventDefault(); - $('#vortex-overlay-' + $(this).attr('href')).show(); - $.get(base_url + 'nzbvortex?delete=' + $(this).attr('href') + '&isAjax'); - $(this).removeAttr('href'); - return false; - }); - - $(document).on('click', 'a.vortex-filelist', function(event) { - event.preventDefault(); - let id = $(this).attr('href'); - $('#vortex-overlay-' + id).show(); - - $.colorbox({}); - - $.ajax({ - url: base_url + '/nzbvortex?filelist=' + id + '&isAjax', - cache: false, - }) - .done(function(response) { - $('#cboxLoadingGraphic').hide(); - let json = $.parseJSON(response); - console.log(json); - $.each(json.files, function(k, v) { - $('#cboxContent').append( - '' + v.fileName + ' (' + vortexStates[v.state] + ')Make sure you've entered API key and server URL under profile settings.
-{/if} diff --git a/resources/views/themes/Gentele/profile.tpl b/resources/views/themes/Gentele/profile.tpl index c0c127617..01dad2082 100755 --- a/resources/views/themes/Gentele/profile.tpl +++ b/resources/views/themes/Gentele/profile.tpl @@ -119,22 +119,6 @@| Queue - type - (NZBGet or SABnzbd) - | -|
| Select type | -- {html_options id="queuetypeids" name='queuetypeids' values=$queuetypeids output=$queuetypes selected=$user.queuetype} - Pick the type of queue you wish to use, once you save your profile, the page will reload, the box will appear and you can fill out the details. - | -
|---|---|
| - SABnzbd - | -|
| URL | -- |
|---|---|
| API Key | -- |
| API Key Type | -
- {html_radios id="sabapikeytype" name='sabapikeytype' values=$sabapikeytype_ids output=$sabapikeytype_names selected=$sabapikeytype_selected separator=' '} -
- Select the type of api key you entered in the
- above setting. Using your full SAB api key will
- allow you access to the SAB queue from within
- this site.
-
- |
-
| Priority Level | -
- {html_options id="sabpriority" class="form-inline" name='sabpriority' values=$sabpriority_ids output=$sabpriority_names selected=$sabpriority_selected}
- Set the priority level for NZBs that
- are added to your queue
-
- |
-
| Setting Storage | -
- {html_radios id="sabsetting" name='sabsetting' values=$sabsetting_ids output=$sabsetting_names selected=$sabsetting_selected separator=' '}{if $sabsetting_selected == 2} [
- Clear Cookies
- ]{/if}
- Where to store the SAB setting.
- • - Cookie will store the setting in your - browsers coookies and will only work when using your - current browser. • Site will store - the setting in your user account enabling it to work - no matter where you are logged in from. Please Note: - You should only store your full SAB api key with - sites you trust. - |
-
| - NZBget - | -|
| URL | -- |
|---|---|
| Username / Password | -
-
-
- /
-
-
- |
-
- The following queue is pulled from
- {$serverURL|escape:"htmlall"}.
-
- {if {{App\Models\Settings::settingValue('apps.sabnzbplus.integrationtype')}} == 2 || $user.queuetype == 2}Edit your queue settings in
- your profile
- .{/if}
-
The {$queueType} queue has been disabled by the administrator.
- {/if} - {else} -{$error}
- {/if} -