mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Add ContentController and route
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
2018-04-08 DariusIII
|
||||
* Chg: Add ContentController and route
|
||||
2018-04-07 DariusIII
|
||||
* Chg: Add BtcPaymentController
|
||||
* Chg: Update libraries to their latest versions
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Blacklight\Contents;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ContentController extends BasePageController
|
||||
{
|
||||
public function show(Request $request)
|
||||
{
|
||||
$contents = new Contents();
|
||||
|
||||
$role = 0;
|
||||
if (! empty($this->userdata) && Auth::check()) {
|
||||
$role = $this->userdata['role'];
|
||||
}
|
||||
|
||||
/* The role column in the content table values are :
|
||||
* 1 = logged in users
|
||||
* 2 = admins
|
||||
*
|
||||
* The user role values are:
|
||||
* 1 = user
|
||||
* 2 = admin
|
||||
* 3 = disabled
|
||||
* 4 = moderator
|
||||
*
|
||||
* Admins and mods should be the only ones to see admin content.
|
||||
*/
|
||||
$this->smarty->assign('admin', (($role === 2 || $role === 4) ? 'true' : 'false'));
|
||||
|
||||
$contentId = 0;
|
||||
if ($request->has('id')) {
|
||||
$contentId = $request->input('id');
|
||||
}
|
||||
|
||||
$contentPage = false;
|
||||
if ($request->has('page')) {
|
||||
$contentPage = $request->input('page');
|
||||
}
|
||||
|
||||
if ($contentId === 0 && $contentPage === 'content') {
|
||||
$content = $contents->getAllButFront();
|
||||
$this->smarty->assign('front', false);
|
||||
$meta_title = 'Contents page';
|
||||
$meta_keywords = 'contents';
|
||||
$meta_description = 'This is the contents page.';
|
||||
} elseif ($contentId !== 0 && $contentPage !== false) {
|
||||
$content = [$contents->getByID($contentId, $role)];
|
||||
$this->smarty->assign('front', false);
|
||||
$meta_title = 'Contents page';
|
||||
$meta_keywords = 'contents';
|
||||
$meta_description = 'This is the contents page.';
|
||||
} else {
|
||||
$content = $contents->getFrontPage();
|
||||
$index = $contents->getIndex();
|
||||
$this->smarty->assign('front', true);
|
||||
$meta_title = $index->title;
|
||||
$meta_keywords = $index->metakeywords;
|
||||
$meta_description = $index->metadescription;
|
||||
}
|
||||
|
||||
if (empty($content)) {
|
||||
$this->show404();
|
||||
}
|
||||
|
||||
$this->smarty->assign('content', $content);
|
||||
|
||||
$content = $this->smarty->fetch('content.tpl');
|
||||
$this->smarty->assign(
|
||||
[
|
||||
'content' => $content,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'meta_description' => $meta_description,
|
||||
]
|
||||
);
|
||||
$this->pagerender();
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Mail\ContactUs;
|
||||
use Blacklight\Captcha;
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
$captcha = new Captcha($page);
|
||||
$msg = '';
|
||||
|
||||
if ($captcha->getError() === false && request()->has('useremail')) {
|
||||
$email = request()->input('useremail');
|
||||
$mailTo = Settings::settingValue('site.main.email');
|
||||
$mailBody = "Values submitted from contact form:\n";
|
||||
$request = request()->all();
|
||||
|
||||
foreach ($request as $key => $value) {
|
||||
if ($key !== 'submit') {
|
||||
$mailBody .= "$key : $value<br />\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (! preg_match("/\n/i", request()->input('useremail'))) {
|
||||
Mail::to($mailTo)->send(new ContactUs($email, $mailBody));
|
||||
}
|
||||
$msg = "<h2 style='text-align:center;'>Thank you for getting in touch with ".Settings::settingValue('site.main.title').'.</h2>';
|
||||
}
|
||||
$page->smarty->assign('msg', $msg);
|
||||
$page->title = 'Contact '.Settings::settingValue('site.main.title');
|
||||
$page->meta_title = 'Contact '.Settings::settingValue('site.main.title');
|
||||
$page->meta_keywords = 'contact us,contact,get in touch,email';
|
||||
$page->meta_description = 'Contact us at '.Settings::settingValue('site.main.title').' and submit your feedback';
|
||||
|
||||
$page->content = $page->smarty->fetch('contact.tpl');
|
||||
|
||||
$page->pagerender();
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Mail\PasswordReset;
|
||||
use App\Mail\ForgottenPassword;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
if (Auth::check()) {
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$action = request()->input('action') ?? 'view';
|
||||
|
||||
$email = $rssToken = $sent = $confirmed = '';
|
||||
|
||||
switch ($action) {
|
||||
case 'reset':
|
||||
if (! request()->has('guid')) {
|
||||
$page->smarty->assign('error', 'No reset code provided.');
|
||||
break;
|
||||
}
|
||||
|
||||
$ret = User::getByPassResetGuid(request()->input('guid'));
|
||||
if (! $ret) {
|
||||
$page->smarty->assign('error', 'Bad reset code provided.');
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// reset the password, inform the user, send out the email
|
||||
//
|
||||
User::updatePassResetGuid($ret['id'], '');
|
||||
$newpass = User::generatePassword();
|
||||
User::updatePassword($ret['id'], $newpass);
|
||||
|
||||
$to = $ret['email'];
|
||||
$onscreen = 'Your password has been reset to <strong>'.$newpass.'</strong> and sent to your e-mail address.';
|
||||
Mail::to($to)->send(new PasswordReset($ret['id'], $newpass));
|
||||
$page->smarty->assign('notice', $onscreen);
|
||||
$confirmed = true;
|
||||
break;
|
||||
|
||||
break;
|
||||
case 'submit':
|
||||
$email = request()->input('email') ?? '';
|
||||
$rssToken = request()->input('apikey') ?? '';
|
||||
if (empty($email) && empty($rssToken)) {
|
||||
$page->smarty->assign('error', 'Missing parameter(email and/or apikey to send password reset');
|
||||
} else {
|
||||
//
|
||||
// Check users exists and send an email
|
||||
//
|
||||
$ret = ! empty($rssToken) ? User::getByRssToken($rssToken) : User::getByEmail($email);
|
||||
if ($ret === null) {
|
||||
$page->smarty->assign('error', 'The email or apikey are not recognised.');
|
||||
$sent = true;
|
||||
break;
|
||||
}
|
||||
//
|
||||
// Generate a forgottenpassword guid, store it in the user table
|
||||
//
|
||||
$guid = md5(uniqid('', false));
|
||||
User::updatePassResetGuid($ret['id'], $guid);
|
||||
//
|
||||
// Send the email
|
||||
//
|
||||
$resetLink = $page->serverurl.'forgottenpassword?action=reset&guid='.$guid;
|
||||
Mail::to($ret['email'])->send(new ForgottenPassword($resetLink));
|
||||
$sent = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$page->smarty->assign(
|
||||
[
|
||||
'email' => $email,
|
||||
'apikey' => $rssToken,
|
||||
'confirmed' => $confirmed,
|
||||
'sent' => $sent,
|
||||
]
|
||||
);
|
||||
|
||||
$page->title = 'Forgotten Password';
|
||||
$page->meta_title = 'Forgotten Password';
|
||||
$page->meta_keywords = 'forgotten,password,signup,registration';
|
||||
$page->meta_description = 'Forgotten Password';
|
||||
|
||||
$page->content = $page->smarty->fetch('forgottenpassword.tpl');
|
||||
$page->pagerender();
|
||||
@@ -72,6 +72,10 @@ Route::get('console', 'ConsoleController@show');
|
||||
|
||||
Route::get('browsegroup', 'BrowseGroupController@show');
|
||||
|
||||
Route::get('content', 'ContentController@show');
|
||||
|
||||
Route::post('content', 'ContentController@show');
|
||||
|
||||
Route::get('/games', function () {
|
||||
redirect('/games');
|
||||
})->middleware('auth');
|
||||
|
||||
Reference in New Issue
Block a user