clean up and reduce depth of some logic

This commit is contained in:
Isaac Connor 2019-01-23 11:18:30 -05:00
parent 124be4eee6
commit 58d3583722
1 changed files with 28 additions and 28 deletions

View File

@ -51,7 +51,6 @@ require_once('includes/Event.php');
require_once('includes/Group.php'); require_once('includes/Group.php');
require_once('includes/Monitor.php'); require_once('includes/Monitor.php');
if ( if (
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
or or
@ -166,6 +165,7 @@ if ( !is_writable(ZM_DIR_EVENTS) ) {
} }
# Globals # Globals
$action = null;
$error_message = null; $error_message = null;
$redirect = null; $redirect = null;
$view = null; $view = null;
@ -185,9 +185,9 @@ foreach ( getSkinIncludes('skin.php') as $includeFile )
# User Login will be performed in auth.php # User Login will be performed in auth.php
require_once('includes/auth.php'); require_once('includes/auth.php');
if ( isset($_REQUEST['action']) ) { if ( isset($_REQUEST['action']) )
$action = detaintPath($_REQUEST['action']); $action = detaintPath($_REQUEST['action']);
}
# The only variable we really need to set is action. The others are informal. # The only variable we really need to set is action. The others are informal.
isset($view) || $view = NULL; isset($view) || $view = NULL;
@ -244,8 +244,9 @@ if ( $request ) {
require_once $includeFile; require_once $includeFile;
} }
return; return;
} else { }
if ( $includeFiles = getSkinIncludes('views/'.$view.'.php', true, true) ) {
if ( $includeFiles = getSkinIncludes('views/'.$view.'.php', true, true) ) {
foreach ( $includeFiles as $includeFile ) { foreach ( $includeFiles as $includeFile ) {
if ( !file_exists($includeFile) ) if ( !file_exists($includeFile) )
Fatal("View '$view' does not exist"); Fatal("View '$view' does not exist");
@ -259,12 +260,11 @@ if ( $request ) {
foreach ( getSkinIncludes('views/login.php', true, true) as $includeFile ) foreach ( getSkinIncludes('views/login.php', true, true) as $includeFile )
require_once $includeFile; require_once $includeFile;
} }
} }
// If the view is missing or the view still returned error with the user logged in, // If the view is missing or the view still returned error with the user logged in,
// then it is not recoverable. // then it is not recoverable.
if ( !$includeFiles || $view == 'error' ) { if ( !$includeFiles || $view == 'error' ) {
foreach ( getSkinIncludes('views/error.php', true, true) as $includeFile ) foreach ( getSkinIncludes('views/error.php', true, true) as $includeFile )
require_once $includeFile; require_once $includeFile;
}
} }
?> ?>