diff --git a/Changelog b/Changelog index 149093deb..5c68dbbc5 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-04-05 DariusIII + * Chg: Update contact form * Chg: Update and improve registration page * Fix: Fix NOCAPTCHA on login pages * Chg: Add ConsoleController diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index e6372552e..e59b5a16d 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -92,7 +92,7 @@ class BasePageController extends Controller */ public function __construct(Request $request) { - $this->middleware('auth')->except('api', 'rss', 'contact-us'); + $this->middleware('auth')->except('api', 'rss', 'contact', 'showContactForm'); // Buffer settings/DB connection. $this->settings = new Settings(); $this->pdo = new DB(); @@ -121,6 +121,7 @@ class BasePageController extends Controller $this->smarty->assign('ismod', 'false'); $this->smarty->assign('loggedin', 'false'); } + if ($this->theme === 'None') { $this->theme = Settings::settingValue('site.main.style'); } @@ -141,8 +142,6 @@ class BasePageController extends Controller } /** - * @param \Illuminate\Http\Request $request - * * @return bool */ public function isPostBack() diff --git a/app/Http/Controllers/ContactUsController.php b/app/Http/Controllers/ContactUsController.php index f0a8a8158..db7dc0dc1 100644 --- a/app/Http/Controllers/ContactUsController.php +++ b/app/Http/Controllers/ContactUsController.php @@ -9,21 +9,17 @@ use Illuminate\Support\Facades\Mail; class ContactUsController extends BasePageController { - public function __construct(Request $request) - { - parent::__construct($request); - $this->middleware('guest'); - } - /** * @param \Illuminate\Http\Request $request * * @throws \Exception */ - public function showContactForm(Request $request) + public function contact(Request $request) { + $this->setPrefs(); $this->validate($request, [ 'useremail' => 'required', + 'username' => 'required' ]); if (env('NOCAPTCHA_ENABLED') === true) { @@ -37,11 +33,11 @@ class ContactUsController extends BasePageController if ($request->has('useremail')) { $email = $request->input('useremail'); $mailTo = Settings::settingValue('site.main.email'); - $mailBody = "Values submitted from contact form:\n"; + $mailBody = 'Values submitted from contact form: '; foreach ($request->all() as $key => $value) { - if ($key !== 'submit') { - $mailBody .= "$key : $value
\r\n"; + if ($key !== 'submit' && $key !== '_token') { + $mailBody .= "$key : $value" . PHP_EOL; } } @@ -51,12 +47,21 @@ class ContactUsController extends BasePageController $msg = "

Thank you for getting in touch with ".Settings::settingValue('site.main.title').'.

'; } $this->smarty->assign('msg', $msg); + + redirect('/'); + } + + /** + * @throws \Exception + */ + public function showContactForm() + { + $this->setPrefs(); $title = 'Contact '.Settings::settingValue('site.main.title'); $meta_title = 'Contact '.Settings::settingValue('site.main.title'); $meta_keywords = 'contact us,contact,get in touch,email'; $meta_description = 'Contact us at '.Settings::settingValue('site.main.title').' and submit your feedback'; - - $content = $this->smarty->fetch('contact.tpl'); + $content = $this->smarty->fetch($this->theme.'/contact.tpl'); $this->smarty->assign( [ @@ -65,9 +70,10 @@ class ContactUsController extends BasePageController 'meta_title' => $meta_title, 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description, + 'nocaptcha' => env('NOCAPTCHA_ENABLED'), ] ); - $this->pagerender(); + $this->smarty->display($this->theme.'/basepage.tpl'); } } diff --git a/resources/views/emails/contactUs.blade.php b/resources/views/emails/contactUs.blade.php index ec71d462f..cd318abfe 100644 --- a/resources/views/emails/contactUs.blade.php +++ b/resources/views/emails/contactUs.blade.php @@ -5,5 +5,5 @@ @endsection @section('content') - {{ $mailBody }} + {!! nl2br(e($mailBody)) !!} @endsection diff --git a/resources/views/themes/Gentele/contact.tpl b/resources/views/themes/Gentele/contact.tpl index 525517713..a65c766e6 100755 --- a/resources/views/themes/Gentele/contact.tpl +++ b/resources/views/themes/Gentele/contact.tpl @@ -54,7 +54,9 @@ + {if $nocaptcha != false} {NoCaptcha::display()}{NoCaptcha::renderJs()} + {/if} diff --git a/routes/web.php b/routes/web.php index 8b1231fa4..fe081b245 100644 --- a/routes/web.php +++ b/routes/web.php @@ -91,11 +91,7 @@ Route::get('/xxx', function () { })->middleware('auth'); Route::get('contact-us', 'ContactUsController@showContactForm'); -Route::post('contact-us', 'ContactUsController@showContactForm'); - -Route::post('/contact-us', function () { - redirect('/contact-us'); -})->middleware('guest'); +Route::post('contact-us', 'ContactUsController@contact'); Route::get('/forum', function () { redirect('/forum');