whitespace and braces fixing
This commit is contained in:
parent
c1b8105c0e
commit
3a113899ed
|
@ -21,26 +21,23 @@
|
||||||
error_reporting( E_ALL );
|
error_reporting( E_ALL );
|
||||||
|
|
||||||
$debug = false;
|
$debug = false;
|
||||||
if ( $debug )
|
if ( $debug ) {
|
||||||
{
|
|
||||||
// Use these for debugging, though not both at once!
|
// Use these for debugging, though not both at once!
|
||||||
phpinfo( INFO_VARIABLES );
|
phpinfo( INFO_VARIABLES );
|
||||||
//error_reporting( E_ALL );
|
//error_reporting( E_ALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use new style autoglobals where possible
|
// Use new style autoglobals where possible
|
||||||
if ( version_compare( phpversion(), "4.1.0", "<") )
|
if ( version_compare( phpversion(), '4.1.0', '<') ) {
|
||||||
{
|
|
||||||
$_SESSION = &$HTTP_SESSION_VARS;
|
$_SESSION = &$HTTP_SESSION_VARS;
|
||||||
$_SERVER = &$HTTP_SERVER_VARS;
|
$_SERVER = &$HTTP_SERVER_VARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Useful debugging lines for mobile devices
|
// Useful debugging lines for mobile devices
|
||||||
if ( false )
|
if ( false ) {
|
||||||
{
|
|
||||||
ob_start();
|
ob_start();
|
||||||
phpinfo( INFO_VARIABLES );
|
phpinfo( INFO_VARIABLES );
|
||||||
$fp = fopen( "/tmp/env.html", "w" );
|
$fp = fopen( '/tmp/env.html', 'w' );
|
||||||
fwrite( $fp, ob_get_contents() );
|
fwrite( $fp, ob_get_contents() );
|
||||||
fclose( $fp );
|
fclose( $fp );
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
@ -53,21 +50,18 @@ require_once( 'includes/Storage.php' );
|
||||||
require_once( 'includes/Event.php' );
|
require_once( 'includes/Event.php' );
|
||||||
require_once( 'includes/Monitor.php' );
|
require_once( 'includes/Monitor.php' );
|
||||||
|
|
||||||
if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' )
|
if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) {
|
||||||
{
|
|
||||||
$protocol = 'https';
|
$protocol = 'https';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$protocol = 'http';
|
$protocol = 'http';
|
||||||
}
|
}
|
||||||
define( "ZM_BASE_PROTOCOL", $protocol );
|
define( 'ZM_BASE_PROTOCOL', $protocol );
|
||||||
|
|
||||||
// Absolute URL's are unnecessary and break compatibility with reverse proxies
|
// Absolute URL's are unnecessary and break compatibility with reverse proxies
|
||||||
// define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
|
// define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
|
||||||
|
|
||||||
// Use relative URL's instead
|
// Use relative URL's instead
|
||||||
define( "ZM_BASE_URL", "" );
|
define( 'ZM_BASE_URL', '' );
|
||||||
|
|
||||||
// Check time zone is set
|
// Check time zone is set
|
||||||
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) {
|
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) {
|
||||||
|
@ -82,7 +76,7 @@ elseif ( isset($_COOKIE['zmSkin']) )
|
||||||
elseif ( defined('ZM_SKIN_DEFAULT') )
|
elseif ( defined('ZM_SKIN_DEFAULT') )
|
||||||
$skin = ZM_SKIN_DEFAULT;
|
$skin = ZM_SKIN_DEFAULT;
|
||||||
else
|
else
|
||||||
$skin = "classic";
|
$skin = 'classic';
|
||||||
|
|
||||||
$skins = array_map( 'basename', glob('skins/*',GLOB_ONLYDIR) );
|
$skins = array_map( 'basename', glob('skins/*',GLOB_ONLYDIR) );
|
||||||
if ( ! in_array( $skin, $skins ) ) {
|
if ( ! in_array( $skin, $skins ) ) {
|
||||||
|
@ -97,7 +91,7 @@ elseif ( isset($_COOKIE['zmCSS']) )
|
||||||
elseif (defined('ZM_CSS_DEFAULT'))
|
elseif (defined('ZM_CSS_DEFAULT'))
|
||||||
$css = ZM_CSS_DEFAULT;
|
$css = ZM_CSS_DEFAULT;
|
||||||
else
|
else
|
||||||
$css = "classic";
|
$css = 'classic';
|
||||||
|
|
||||||
$css_skins = array_map( 'basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR) );
|
$css_skins = array_map( 'basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR) );
|
||||||
if ( ! in_array( $css, $css_skins ) ) {
|
if ( ! in_array( $css, $css_skins ) ) {
|
||||||
|
@ -105,9 +99,9 @@ if ( ! in_array( $css, $css_skins ) ) {
|
||||||
$css = $css_skins[0];
|
$css = $css_skins[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
define( "ZM_BASE_PATH", dirname( $_SERVER['REQUEST_URI'] ) );
|
define( 'ZM_BASE_PATH', dirname( $_SERVER['REQUEST_URI'] ) );
|
||||||
define( "ZM_SKIN_NAME", $skin );
|
define( 'ZM_SKIN_NAME', $skin );
|
||||||
define( "ZM_SKIN_PATH", "skins/$skin" );
|
define( 'ZM_SKIN_PATH', "skins/$skin" );
|
||||||
|
|
||||||
$skinBase = array(); // To allow for inheritance of skins
|
$skinBase = array(); // To allow for inheritance of skins
|
||||||
if ( !file_exists( ZM_SKIN_PATH ) )
|
if ( !file_exists( ZM_SKIN_PATH ) )
|
||||||
|
@ -117,26 +111,25 @@ $skinBase[] = $skin;
|
||||||
$currentCookieParams = session_get_cookie_params();
|
$currentCookieParams = session_get_cookie_params();
|
||||||
Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
|
||||||
session_set_cookie_params(
|
session_set_cookie_params(
|
||||||
$currentCookieParams["lifetime"],
|
$currentCookieParams['lifetime'],
|
||||||
$currentCookieParams["path"],
|
$currentCookieParams['path'],
|
||||||
$currentCookieParams["domain"],
|
$currentCookieParams['domain'],
|
||||||
$currentCookieParams["secure"],
|
$currentCookieParams['secure'],
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
ini_set( "session.name", "ZMSESSID" );
|
ini_set( 'session.name', 'ZMSESSID' );
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if ( !isset($_SESSION['skin']) || isset($_REQUEST['skin']) || !isset($_COOKIE['zmSkin']) || $_COOKIE['zmSkin'] != $skin )
|
if ( !isset($_SESSION['skin']) || isset($_REQUEST['skin']) || !isset($_COOKIE['zmSkin']) || $_COOKIE['zmSkin'] != $skin ) {
|
||||||
{
|
|
||||||
$_SESSION['skin'] = $skin;
|
$_SESSION['skin'] = $skin;
|
||||||
setcookie( "zmSkin", $skin, time()+3600*24*30*12*10 );
|
setcookie( 'zmSkin', $skin, time()+3600*24*30*12*10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isset($_SESSION['css']) || isset($_REQUEST['css']) || !isset($_COOKIE['zmCSS']) || $_COOKIE['zmCSS'] != $css ) {
|
if ( !isset($_SESSION['css']) || isset($_REQUEST['css']) || !isset($_COOKIE['zmCSS']) || $_COOKIE['zmCSS'] != $css ) {
|
||||||
$_SESSION['css'] = $css;
|
$_SESSION['css'] = $css;
|
||||||
setcookie( "zmCSS", $css, time()+3600*24*30*12*10 );
|
setcookie( 'zmCSS', $css, time()+3600*24*30*12*10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ZM_OPT_USE_AUTH )
|
if ( ZM_OPT_USE_AUTH )
|
||||||
|
@ -154,8 +147,7 @@ require_once( 'includes/functions.php' );
|
||||||
CORSHeaders();
|
CORSHeaders();
|
||||||
|
|
||||||
// Check for valid content dirs
|
// Check for valid content dirs
|
||||||
if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) )
|
if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) ) {
|
||||||
{
|
|
||||||
Error( "Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."'). Check that these exist and are owned by the web account user");
|
Error( "Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."'). Check that these exist and are owned by the web account user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,22 +185,16 @@ if ( ZM_OPT_USE_AUTH && ! isset($user) && $view != 'login' ) {
|
||||||
# Any file/page that uses the session must re-open it.
|
# Any file/page that uses the session must re-open it.
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
if ( isset( $_REQUEST['request'] ) )
|
if ( isset( $_REQUEST['request'] ) ) {
|
||||||
{
|
foreach ( getSkinIncludes( 'ajax/'.$request.'.php', true, true ) as $includeFile ) {
|
||||||
foreach ( getSkinIncludes( 'ajax/'.$request.'.php', true, true ) as $includeFile )
|
|
||||||
{
|
|
||||||
if ( !file_exists( $includeFile ) )
|
if ( !file_exists( $includeFile ) )
|
||||||
Fatal( "Request '$request' does not exist" );
|
Fatal( "Request '$request' does not exist" );
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
if ( $includeFiles = getSkinIncludes( 'views/'.$view.'.php', true, true ) ) {
|
||||||
{
|
foreach ( $includeFiles as $includeFile ) {
|
||||||
if ( $includeFiles = getSkinIncludes( 'views/'.$view.'.php', true, true ) )
|
|
||||||
{
|
|
||||||
foreach ( $includeFiles as $includeFile )
|
|
||||||
{
|
|
||||||
if ( !file_exists( $includeFile ) )
|
if ( !file_exists( $includeFile ) )
|
||||||
Fatal( "View '$view' does not exist" );
|
Fatal( "View '$view' does not exist" );
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
|
@ -216,8 +202,7 @@ else
|
||||||
// If the view overrides $view to 'error', and the user is not logged in, then the
|
// If the view overrides $view to 'error', and the user is not logged in, then the
|
||||||
// issue is probably resolvable by logging in, so provide the opportunity to do so.
|
// issue is probably resolvable by logging in, so provide the opportunity to do so.
|
||||||
// The login view should handle redirecting to the correct location afterward.
|
// The login view should handle redirecting to the correct location afterward.
|
||||||
if ( $view == 'error' && !isset($user) )
|
if ( $view == 'error' && !isset($user) ) {
|
||||||
{
|
|
||||||
$view = 'login';
|
$view = 'login';
|
||||||
foreach ( getSkinIncludes( 'views/login.php', true, true ) as $includeFile )
|
foreach ( getSkinIncludes( 'views/login.php', true, true ) as $includeFile )
|
||||||
require_once $includeFile;
|
require_once $includeFile;
|
||||||
|
@ -225,8 +210,7 @@ else
|
||||||
}
|
}
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue