mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Add ForumController and routes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
2018-04-09 DariusIII
|
||||
* Chg: Add ForumController and routes
|
||||
2018-04-08 DariusIII
|
||||
* Chg: Add FileListController and routes
|
||||
* Chg: Add FailedReleasesController and routes
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Forumpost;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ForumController extends BasePageController
|
||||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function forum(Request $request)
|
||||
{
|
||||
$this->setPrefs();
|
||||
if ($this->isPostBack() && $request->has('addMessage') && $request->has('addSubject')) {
|
||||
Forumpost::add(0, Auth::id(), $request->input('addSubject'), $request->input('addMessage'));
|
||||
header('/forum');
|
||||
}
|
||||
|
||||
$lock = $unlock = null;
|
||||
|
||||
if ($request->has('lock')) {
|
||||
$lock = $request->input('lock');
|
||||
}
|
||||
|
||||
if ($request->has('unlock')) {
|
||||
$unlock = $request->input('unlock');
|
||||
}
|
||||
|
||||
if ($lock !== null) {
|
||||
Forumpost::lockUnlockTopic($lock, 1);
|
||||
header('/forum');
|
||||
die();
|
||||
}
|
||||
|
||||
if ($unlock !== null) {
|
||||
Forumpost::lockUnlockTopic($unlock, 0);
|
||||
header('/forum');
|
||||
die();
|
||||
}
|
||||
|
||||
$results = Forumpost::getBrowseRange();
|
||||
|
||||
$this->smarty->assign('privateprofiles', (int) Settings::settingValue('..privateprofiles') === 1);
|
||||
|
||||
$this->smarty->assign('results', $results);
|
||||
|
||||
$meta_title = 'Forum';
|
||||
$meta_keywords = 'forum,chat,posts';
|
||||
$meta_description = 'Forum';
|
||||
|
||||
$content = $this->smarty->fetch('forum.tpl');
|
||||
|
||||
$this->smarty->assign(
|
||||
[
|
||||
'content' => $content,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_description' => $meta_description,
|
||||
]
|
||||
);
|
||||
$this->pagerender();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getPosts(Request $request)
|
||||
{
|
||||
$this->setPrefs();
|
||||
$id = $request->input('id') + 0;
|
||||
|
||||
if (! empty($request->input('addMessage')) && $this->isPostBack()) {
|
||||
Forumpost::add($id, Auth::id(), '', $request->input('addMessage'));
|
||||
header('/forumpost/'.$id.'#last');
|
||||
}
|
||||
|
||||
$results = Forumpost::getPosts($id);
|
||||
if (\count($results) === 0) {
|
||||
header('/forum');
|
||||
}
|
||||
|
||||
$meta_title = 'Forum Post';
|
||||
$meta_keywords = 'view,forum,post,thread';
|
||||
$meta_description = 'View forum post';
|
||||
|
||||
$this->smarty->assign('results', $results);
|
||||
$this->smarty->assign('privateprofiles', (int) Settings::settingValue('..privateprofiles') === 1);
|
||||
|
||||
$content = $this->smarty->fetch('forumpost.tpl');
|
||||
|
||||
$this->smarty->assign(
|
||||
[
|
||||
'content' => $content,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_description' => $meta_description,
|
||||
]
|
||||
);
|
||||
$this->pagerender();
|
||||
}
|
||||
}
|
||||
@@ -109,27 +109,15 @@ class Forumpost extends Model
|
||||
return self::query()->where('id', $id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count of posts for parent forum.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getBrowseCount(): int
|
||||
{
|
||||
$res = self::query()->count('id');
|
||||
|
||||
return $res ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get browse range for forum.
|
||||
*
|
||||
*
|
||||
* @param $start
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|static[]
|
||||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
*/
|
||||
public static function getBrowseRange($start)
|
||||
public static function getBrowseRange()
|
||||
{
|
||||
return self::query()
|
||||
->where('forumpost.parentid', '=', 0)
|
||||
@@ -137,8 +125,7 @@ class Forumpost extends Model
|
||||
->leftJoin('user_roles', 'user_roles.id', '=', 'users.user_roles_id')
|
||||
->select(['forumpost.*', 'users.username', 'user_roles.name as rolename'])
|
||||
->orderBy('forumpost.updated_at', 'desc')
|
||||
->limit(config('nntmux.items_per_page'))->offset($start)
|
||||
->get();
|
||||
->paginate(config('nntmux.items_per_page'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Blacklight\ReleaseExtra;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$re = new ReleaseExtra($page->settings);
|
||||
$redata = $re->getBriefByGuid(request()->input('id'));
|
||||
|
||||
if (! $redata) {
|
||||
echo 'No media info';
|
||||
} else {
|
||||
echo "<table>\n";
|
||||
if ($redata['videocodec'] !== '' && $redata['containerformat'] !== '') {
|
||||
$redata['videocodec'] = $re->makeCodecPretty($redata['videocodec']);
|
||||
echo '<tr><th>Format:</th><td>'.htmlentities($redata['videocodec'], ENT_QUOTES).' - '.htmlentities($redata['containerformat'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['videoduration'] !== '') {
|
||||
echo '<tr><th>Duration:</th><td>'.htmlentities($redata['videoduration'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['size'] !== '') {
|
||||
echo '<tr><th>Resolution:</th><td>'.htmlentities($redata['size'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['videoaspect'] !== '') {
|
||||
echo '<tr><th>Aspect Ratio:</th><td>'.htmlentities($redata['videoaspect'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['audio'] !== '' && $redata['audio'] !== ', ') {
|
||||
echo '<tr><th>Audio Languages:</th><td>'.htmlentities($redata['audio'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['audioformat'] !== '' && $redata['audioformat'] !== ', ') {
|
||||
echo '<tr><th>Audio Format:</th><td>'.htmlentities($redata['audioformat'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
if ($redata['subs'] !== '') {
|
||||
echo '<tr><th>Subtitles:</th><td>'.htmlentities($redata['subs'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Predb;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$predata = Predb::getOne(request()->input('id'));
|
||||
|
||||
if (! $predata) {
|
||||
echo 'No pre info';
|
||||
} else {
|
||||
echo "<table>\n";
|
||||
if (isset($predata['nuked'])) {
|
||||
$nuked = '';
|
||||
switch ($predata['nuked']) {
|
||||
case Predb::PRE_NUKED:
|
||||
$nuked = 'NUKED';
|
||||
break;
|
||||
case Predb::PRE_MODNUKE:
|
||||
$nuked = 'MODNUKED';
|
||||
break;
|
||||
case Predb::PRE_OLDNUKE:
|
||||
$nuked = 'OLDNUKE';
|
||||
break;
|
||||
case Predb::PRE_RENUKED:
|
||||
$nuked = 'RENUKE';
|
||||
break;
|
||||
case Predb::PRE_UNNUKED:
|
||||
$nuked = 'UNNUKED';
|
||||
break;
|
||||
}
|
||||
if ($nuked !== '') {
|
||||
echo '<tr><th>'.$nuked.':</th><td>'.htmlentities($predata['nukereason'] ?? '', ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
echo '<tr><th>Title:</th><td>'.htmlentities($predata['title'], ENT_QUOTES)."</td></tr>\n";
|
||||
if (isset($predata['category']) && $predata['category'] !== '') {
|
||||
echo '<tr><th>Cat:</th><td>'.htmlentities($predata['category'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
echo '<tr><th>Source:</th><td>'.htmlentities($predata['source'], ENT_QUOTES)."</td></tr>\n";
|
||||
if (isset($predata['size'])) {
|
||||
if (isset($predata['size'][0]) && $predata['size'][0] > 0) {
|
||||
echo '<tr><th>Size:</th><td>'.htmlentities($predata['size'], ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
if (isset($predata['files'])) {
|
||||
echo '<tr><th>Files:</th><td>'.htmlentities((preg_match('/F|B/', $predata['files'], $match) ? $predata['files'] : ($predata['files'].'MB')), ENT_QUOTES)."</td></tr>\n";
|
||||
}
|
||||
echo '<tr><th>Pred:</th><td>'.htmlentities($predata['predate'], ENT_QUOTES)."</td></tr>\n";
|
||||
echo '</table>';
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (request()->has('action') && request()->has('emailto') && (int) request()->input('action') === 1) {
|
||||
$emailto = request()->input('emalto');
|
||||
$ret = User::sendInvite($page->serverurl, Auth::id(), $emailto);
|
||||
if (! $ret) {
|
||||
echo 'Invite not sent.';
|
||||
} else {
|
||||
echo 'Invite sent. Alternatively paste them following link to register - '.$ret;
|
||||
}
|
||||
} else {
|
||||
echo 'Invite not sent.';
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\ReleaseFile;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$files = ReleaseFile::getByGuid(request()->input('id'));
|
||||
|
||||
if (count($files) === 0) {
|
||||
echo 'No files';
|
||||
} else {
|
||||
echo "<ul>\n";
|
||||
foreach ($files as $f) {
|
||||
echo '<li>'.htmlentities($f['name'], ENT_QUOTES).' '.($f['passworded'] === 1 ? '<img width="12" src="'.WWW_TOP.'/assets/images/icons/lock.gif" />' : '')."</li>\n";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Release;
|
||||
use App\Models\Category;
|
||||
use Blacklight\Releases;
|
||||
use Blacklight\http\BasePage;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
$page = new BasePage();
|
||||
$releases = new Releases(['Settings' => $page->settings]);
|
||||
|
||||
// Set the current action.
|
||||
$action = request()->input('action') ?? '';
|
||||
|
||||
// Request is for id, but guid is actually being provided
|
||||
if (request()->has('id') && is_array(request()->input('id'))) {
|
||||
$id = request()->input('id');
|
||||
//Get info for first guid to populate form
|
||||
$rel = Release::getByGuid(request()->input('id')[0]);
|
||||
} else {
|
||||
$id = $rel = '';
|
||||
}
|
||||
|
||||
$page->smarty->assign('action', $action);
|
||||
$page->smarty->assign('idArr', $id);
|
||||
|
||||
switch ($action) {
|
||||
case 'doedit':
|
||||
case 'edit':
|
||||
$success = false;
|
||||
if ($action === 'doedit') {
|
||||
$success = $releases->updateMulti(
|
||||
request()->input('id'),
|
||||
request()->input('category'),
|
||||
request()->input('grabs'),
|
||||
request()->input('videosid'),
|
||||
request()->input('episodesid'),
|
||||
request()->input('anidbid'),
|
||||
request()->input('imdbid')
|
||||
);
|
||||
}
|
||||
$page->smarty->assign('release', $rel);
|
||||
$page->smarty->assign('success', $success);
|
||||
$page->smarty->assign('from', request()->input('from') ?? '');
|
||||
$page->smarty->assign('catlist', Category::getForSelect(false));
|
||||
$page->content = $page->smarty->fetch('ajax_release-edit.tpl');
|
||||
echo $page->content;
|
||||
|
||||
break;
|
||||
case 'dodelete':
|
||||
$releases->deleteMultiple(request()->input('id'));
|
||||
break;
|
||||
default:
|
||||
$page->show404();
|
||||
break;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\UserRequest;
|
||||
use App\Models\UserDownload;
|
||||
use Blacklight\http\BasePage;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$page = new BasePage();
|
||||
|
||||
$action = request()->input('action') ?? '';
|
||||
$id = request()->input('id') ?? '';
|
||||
|
||||
switch ($action) {
|
||||
case 'grabs':
|
||||
UserDownload::delDownloadRequests($id);
|
||||
break;
|
||||
case 'api':
|
||||
UserRequest::delApiRequests($id);
|
||||
break;
|
||||
default:
|
||||
$page->show404();
|
||||
break;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Video;
|
||||
use App\Models\Release;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
if (! Auth::check()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
if (! request()->has('id')) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
|
||||
if (! $rel) {
|
||||
echo 'No tv info';
|
||||
} else {
|
||||
echo "<ul class=\"ui-tooltip-nntmux\">\n";
|
||||
echo '<li>'.htmlentities($rel['title'], ENT_QUOTES)."</li>\n";
|
||||
echo '<li>Aired on '.date('F j, Y', strtotime($rel['firstaired']))."</li>\n";
|
||||
echo '</ul>';
|
||||
|
||||
if (isset($rel['videos_id']) && $rel['videos_id'] > 0) {
|
||||
$show = Video::getByVideoID($rel['videos_id']);
|
||||
if (count($show) > 0 && (int) $show['image'] !== 0) {
|
||||
echo '<img class="shadow" src="/covers/tvshows/'.$show['id'].'.jpg" width="180"/>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Blacklight\NZB;
|
||||
use Blacklight\db\DB;
|
||||
use App\Models\Release;
|
||||
|
||||
$pdo = new DB();
|
||||
$nzb = new NZB();
|
||||
|
||||
if (request()->has('id')) {
|
||||
$rel = Release::getByGuid(request()->input('id'));
|
||||
if (! $rel) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
$nzbpath = $nzb->NZBPath(request()->input('id'));
|
||||
|
||||
if (! file_exists($nzbpath)) {
|
||||
$page->show404();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
@readgzfile($nzbpath);
|
||||
$nzbfile = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$ret = $nzb->nzbFileList($nzbfile);
|
||||
|
||||
$page->smarty->assign('rel', $rel);
|
||||
$page->smarty->assign('files', $ret);
|
||||
|
||||
$page->title = 'File List';
|
||||
$page->meta_title = 'View Nzb file list';
|
||||
$page->meta_keywords = 'view,nzb,file,list,description,details';
|
||||
$page->meta_description = 'View Nzb File List';
|
||||
|
||||
$modal = false;
|
||||
if (request()->has('modal')) {
|
||||
$modal = true;
|
||||
$page->smarty->assign('modal', true);
|
||||
}
|
||||
|
||||
$page->content = $page->smarty->fetch('viewfilelist.tpl');
|
||||
|
||||
if ($modal) {
|
||||
echo $page->content;
|
||||
} else {
|
||||
$page->pagerender();
|
||||
}
|
||||
}
|
||||
+4
-12
@@ -103,21 +103,13 @@ Route::get('/xxx', function () {
|
||||
Route::get('contact-us', 'ContactUsController@showContactForm');
|
||||
Route::post('contact-us', 'ContactUsController@contact');
|
||||
|
||||
Route::get('/forum', function () {
|
||||
redirect('/forum');
|
||||
})->middleware('auth');
|
||||
Route::get('forum', 'ForumController@forum');
|
||||
|
||||
Route::post('/forum', function () {
|
||||
redirect('/forum');
|
||||
})->middleware('auth');
|
||||
Route::post('forum', 'ForumController@forum');
|
||||
|
||||
Route::get('/forumpost/{id}', function () {
|
||||
redirect('/forumpost');
|
||||
})->middleware('auth');
|
||||
Route::get('forumpost/{id}', 'ForumController@getPosts');
|
||||
|
||||
Route::post('/forumpost/{id}', function () {
|
||||
redirect('/forumpost');
|
||||
})->middleware('auth');
|
||||
Route::post('forumpost/{id}', 'ForumController@getPosts');
|
||||
|
||||
Route::get('/profileedit', function () {
|
||||
redirect('/profileedit');
|
||||
|
||||
Reference in New Issue
Block a user