An error occurred while loading the file. Please try again.
-
Côme Chilliet authored
Basic fixes like identation issue #5955
e7a2d4d9
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2018 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* base class for passwordRecovery and such classes handling requests on their own */
class standAlonePage
{
protected $directories;
protected $directory;
protected $activated;
protected $interactive;
/* Constructor */
function __construct ($interactive = TRUE)
{
global $config, $ssl, $ui;
$this->interactive = $interactive;
/* Destroy old session if exists.
Else you will get your old session back, if you not logged out correctly. */
session::destroy();
session::start();
$config = $this->loadConfig();
session::global_set('config', $config);
/* Generate server list */
$this->directories = array();
foreach ($config->data['LOCATIONS'] as $key => $ignored) {
$this->directories[$key] = $key;
}
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
static::init();
}
function checkDirectoryChooser ()
{
global $config;
$olddirectory = $this->directory;
if (isset($_POST['server']) && isset($this->directories[$_POST['server']])) {
$this->directory = validate($_POST['server']);
} elseif (isset($_GET['directory']) && isset($this->directories[$_GET['directory']])) {
$this->directory = validate($_GET['directory']);
} elseif (empty($this->directory)) {
$this->directory = $config->data['MAIN']['DEFAULT'];
if (!isset($this->directories[$this->directory])) {
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
$this->directory = key($this->directories);
}
}
if ($this->directory != $olddirectory) {
/* Set config to selected one */
$config->set_current($this->directory);
$this->activated = $this->readLdapConfig();
}
}
function init ()
{
global $config, $ssl, $ui;
static::checkDirectoryChooser();
reset_errors();
static::securityHeaders();
CSRFProtection::check();
$ui = session::global_get('ui');
$config = session::global_get('config');
if ($this->interactive) {
timezone::setDefaultTimezoneFromConfig();
Language::init();
$this->setupSmarty();
}
$ssl = $this->checkForSSL();
/* Prepare plugin list */
pluglist::load();
}
function loadConfig ()
{
global $BASE_DIR;
/* Check if CONFIG_FILE is accessible */
if (!is_readable(CONFIG_DIR.'/'.CONFIG_FILE)) {
msg_dialog::display(_('Fatal error'),
sprintf(_('FusionDirectory configuration %s/%s is not readable. Aborted.'),
CONFIG_DIR, CONFIG_FILE), FATAL_ERROR_DIALOG);
exit();
}
/* Parse configuration file */
$config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
session::global_set('DEBUGLEVEL', $config->get_cfg_value('debuglevel'));
@DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
return $config;
}
function setupSmarty ()
{
global $config;
$smarty = get_smarty();
/* Set template compile directory */
$smarty->compile_dir = $config->get_cfg_value('templateCompileDirectory', SPOOL_DIR);
/* Check for compile directory */
if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))) {