mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Fix more Users stuff
This commit is contained in:
+2
-2
@@ -385,7 +385,7 @@ class User extends Authenticatable
|
||||
* @return \Illuminate\Database\Eloquent\Collection|static[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getRange($start, $offset, $orderBy, $userName = '', $email = '', $host = '', $role = '')
|
||||
public static function getRange($start, $offset, $orderBy, $userName = '', $email = '', $host = '', $role = '')
|
||||
{
|
||||
UserRequest::clearApiRequests(false);
|
||||
|
||||
@@ -872,7 +872,7 @@ class User extends Authenticatable
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[]
|
||||
*/
|
||||
public function getUsersByMonth()
|
||||
public static function getUsersByMonth()
|
||||
{
|
||||
return self::query()->whereNotNull('created_at')->where('created_at', '!=', '0000-00-00 00:00:00')->selectRaw("DATE_FORMAT(created_at, '%M %Y') as mth, COUNT(id) as num")->groupBy(['mth'])->orderBy('created_at', 'desc')->get();
|
||||
}
|
||||
|
||||
+32
-11
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace nntmux;
|
||||
|
||||
use App\Models\User;
|
||||
use Page;
|
||||
|
||||
final class NZBVortex
|
||||
{
|
||||
protected $nonce = null;
|
||||
@@ -9,7 +12,7 @@ final class NZBVortex
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (is_null($this->session)) {
|
||||
if (null === $this->session) {
|
||||
$this->getNonce();
|
||||
$this->login();
|
||||
}
|
||||
@@ -72,17 +75,18 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* add NZB to queue.
|
||||
*
|
||||
* @param string $nzb
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addQueue($nzb = '')
|
||||
{
|
||||
if (! empty($nzb)) {
|
||||
$page = new Page;
|
||||
$user = new Users;
|
||||
|
||||
$host = $page->serverurl;
|
||||
$data = $user->getById($user->currentUserId());
|
||||
$data = User::getById(User::currentUserId());
|
||||
$url = sprintf('%sgetnzb/%s.nzb&i=%s&r=%s', $host, $nzb, $data['id'], $data['rsstoken']);
|
||||
|
||||
$params = [
|
||||
@@ -96,10 +100,12 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* resume NZB.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function resume($id = 0)
|
||||
public function resume($id = 0): void
|
||||
{
|
||||
if ($id > 0) {
|
||||
// /nzb/(id)/resume
|
||||
@@ -110,8 +116,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* pause NZB.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function pause($id = 0)
|
||||
{
|
||||
@@ -124,8 +132,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* move NZB up in queue.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function moveUp($id = 0)
|
||||
{
|
||||
@@ -138,8 +148,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* move NZB down in queue.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function moveDown($id = 0)
|
||||
{
|
||||
@@ -152,8 +164,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* move NZB to bottom of queue.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function moveBottom($id = 0)
|
||||
{
|
||||
@@ -166,8 +180,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* Remove a (finished/unfinished) NZB from queue and delete files.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete($id = 0)
|
||||
{
|
||||
@@ -180,8 +196,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* move NZB to top of queue.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function moveTop($id = 0)
|
||||
{
|
||||
@@ -194,8 +212,10 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* get filelist for nzb.
|
||||
*
|
||||
* @param int $id
|
||||
* @return array|bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getFilelist($id = 0)
|
||||
{
|
||||
@@ -212,7 +232,9 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* get /auth/nonce.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getNonce()
|
||||
{
|
||||
@@ -222,11 +244,11 @@ final class NZBVortex
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function login()
|
||||
{
|
||||
$user = new Users();
|
||||
$data = $user->getById($user->currentUserId());
|
||||
$data = User::getById(User::currentUserId());
|
||||
$cnonce = generateUuid();
|
||||
$hash = hash('sha256', sprintf('%s:%s:%s', $this->nonce, $cnonce, $data['nzbvortex_api_key']), true);
|
||||
$hash = base64_encode($hash);
|
||||
@@ -258,8 +280,7 @@ final class NZBVortex
|
||||
*/
|
||||
protected function sendRequest($path, $params = [])
|
||||
{
|
||||
$user = new Users;
|
||||
$data = $user->getById($user->currentUserId());
|
||||
$data = User::getById(User::currentUserId());
|
||||
|
||||
$url = sprintf('%s/api', $data['nzbvortex_server_url']);
|
||||
$params = http_build_query($params);
|
||||
@@ -283,7 +304,7 @@ final class NZBVortex
|
||||
|
||||
switch ($status) {
|
||||
case 0:
|
||||
throw new \Exception(sprintf('Unable to connect. Is NZBVortex running? Is your API key correct? Is something blocking ports? (Err: %s)', $error));
|
||||
throw new \RuntimeException(sprintf('Unable to connect. Is NZBVortex running? Is your API key correct? Is something blocking ports? (Err: %s)', $error));
|
||||
break;
|
||||
|
||||
case 200:
|
||||
@@ -291,11 +312,11 @@ final class NZBVortex
|
||||
break;
|
||||
|
||||
case 403:
|
||||
throw new \Exception('Unable to login. Is your API key correct?');
|
||||
throw new \RuntimeException('Unable to login. Is your API key correct?');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception(sprintf('%s (%s): %s', $path, $status, $response['result']));
|
||||
throw new \RuntimeException(sprintf('%s (%s): %s', $path, $status, $response['result']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
||||
|
||||
use App\Models\User;
|
||||
use nntmux\NZB;
|
||||
use nntmux\db\DB;
|
||||
use nntmux\Users;
|
||||
use nntmux\Releases;
|
||||
|
||||
$page = new AdminPage;
|
||||
$users = new Users;
|
||||
$releases = new Releases;
|
||||
$pdo = new DB();
|
||||
$nzb = new NZB($pdo);
|
||||
|
||||
if (! $users->isLoggedIn()) {
|
||||
if (! User::isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
||||
|
||||
use nntmux\Users;
|
||||
use App\Models\UserRole;
|
||||
|
||||
$page = new AdminPage();
|
||||
|
||||
$users = new Users();
|
||||
|
||||
$page->title = 'User Role List';
|
||||
|
||||
//get the user roles
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
||||
|
||||
use App\Models\User;
|
||||
use nntmux\Users;
|
||||
use nntmux\Releases;
|
||||
use App\Models\UserRole;
|
||||
|
||||
$page = new AdminPage();
|
||||
$users = new Users();
|
||||
$releases = new Releases();
|
||||
|
||||
$page->title = 'Site Stats';
|
||||
|
||||
$topgrabs = $users->getTopGrabbers();
|
||||
$topgrabs = User::getTopGrabbers();
|
||||
$page->smarty->assign('topgrabs', $topgrabs);
|
||||
|
||||
$topdownloads = $releases->getTopDownloads();
|
||||
@@ -24,7 +24,7 @@ $page->smarty->assign('topcomments', $topcomments);
|
||||
$recent = $releases->getRecentlyAdded();
|
||||
$page->smarty->assign('recent', $recent);
|
||||
|
||||
$usersbymonth = $users->getUsersByMonth();
|
||||
$usersbymonth = User::getUsersByMonth();
|
||||
$page->smarty->assign('usersbymonth', $usersbymonth);
|
||||
|
||||
$usersbyrole = UserRole::getUsersByRole();
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
||||
|
||||
use nntmux\Users;
|
||||
use App\Models\User;
|
||||
|
||||
$page = new AdminPage();
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$users = new Users();
|
||||
User::deleteUser($_GET['id']);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
use nntmux\Users;
|
||||
use App\Models\UserRequest;
|
||||
use App\Models\UserDownload;
|
||||
|
||||
$page = new AdminPage();
|
||||
$u = new Users();
|
||||
|
||||
$action = $_REQUEST['action'] ?? '';
|
||||
$id = $_REQUEST['id'] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user