Cleaned up some old code.

Still had some <br />'s in there and updated some of the redirects to use the Browser class.
This commit is contained in:
Josh Sherman 2013-09-09 16:08:10 -04:00
parent 1a0f66cc9c
commit 2ac7790385

View file

@ -52,7 +52,7 @@ class Controller extends Object
// Generate a generic "site down" message if the site is set to be disabled // Generate a generic "site down" message if the site is set to be disabled
if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true) if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true)
{ {
Error::fatal($_SERVER['SERVER_NAME'] . ' is currently<br />down for maintenance'); Error::fatal($_SERVER['SERVER_NAME'] . ' is currently<br>down for maintenance');
} }
// Checks for attributes passed in the URI // Checks for attributes passed in the URI
@ -136,20 +136,17 @@ class Controller extends Object
// Determines if the module is private and should be, well, private // Determines if the module is private and should be, well, private
if ($module->private == true) if ($module->private == true)
{ {
header('Location: /'); Browser::goHome();
exit;
} }
// Determines if we need to serve over HTTP or HTTPS // Determines if we need to serve over HTTP or HTTPS
if ($module->secure == false && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) if ($module->secure == false && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'])
{ {
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); Browser::redirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit;
} }
elseif ($module->secure == true && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == false)) elseif ($module->secure == true && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == false))
{ {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); Browser::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit;
} }
// Validates security level // Validates security level
@ -241,9 +238,7 @@ class Controller extends Object
$_SESSION['__pickles']['login']['destination'] = $_REQUEST['request'] ? $_REQUEST['request'] : '/'; $_SESSION['__pickles']['login']['destination'] = $_REQUEST['request'] ? $_REQUEST['request'] : '/';
// Redirect to login page, potentially configured in the config, else /login // Redirect to login page, potentially configured in the config, else /login
header('Location: /' . (isset($this->config->security['login']) ? $this->config->security['login'] : 'login')); Browser::redirect('/' . (isset($this->config->security['login']) ? $this->config->security['login'] : 'login'));
exit;
} }
} }
} }
@ -282,7 +277,7 @@ class Controller extends Object
{ {
if (!$_REQUEST['request']) if (!$_REQUEST['request'])
{ {
Error::fatal('Way to go, you\'ve successfully created an infinite redirect loop. Good thing I was here or you would have been served with a pretty ugly browser error.<br /><br />So here\'s the deal, no templates were able to be loaded. Make sure your parent and child templates actually exist and if you\'re using non-default values, make sure they\'re defined correctly in your config.'); Error::fatal('Way to go, you\'ve successfully created an infinite redirect loop. Good thing I was here or you would have been served with a pretty ugly browser error.<br><br>So here\'s the deal, no templates were able to be loaded. Make sure your parent and child templates actually exist and if you\'re using non-default values, make sure they\'re defined correctly in your config.');
} }
else else
{ {