better config check

This commit is contained in:
Roland Gruber 2013-01-12 11:28:43 +00:00
parent a1724bb79e
commit 63ab02f5b5
4 changed files with 34 additions and 2 deletions

View File

@ -33,6 +33,9 @@ $Id$
/** status messages */
include_once("../lib/status.inc");
/** config */
include_once("../lib/config.inc");
// check if PHP >= 5.2.4
if (version_compare(phpversion(), '5.2.4') < 0) {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\n";
@ -107,6 +110,11 @@ if (!@preg_match('/^\p{L}+$/u', "abc")) {
if (!extension_loaded('zip')) {
$criticalErrors[] = array("ERROR", "Your PHP has no ZIP support.", "Please install the ZIP extension for PHP.");
}
// check for main config
$mainConfig = new LAMCfgMain();
if (!$mainConfig->isConfigFileExisting()) {
$criticalErrors[] = array("ERROR", "The main config file (config.cfg) does not exist.", "Please see the manual for installation instructions.");
}
// stop login if critical errors occured
if (sizeof($criticalErrors) > 0) {
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n\n";

View File

@ -1521,6 +1521,15 @@ class LAMCfgMain {
return is_writeable($this->conffile);
}
/**
* Returns if the configuration file is existing.
*
* @return boolean exists
*/
public function isConfigFileExisting() {
return file_exists($this->conffile);
}
}
?>

View File

@ -45,6 +45,8 @@ setlanguage();
$cfg = new LAMCfgMain();
$files = getConfigProfiles();
// check if submit button was pressed
if (isset($_POST['action'])) {
// check master password
@ -108,6 +110,15 @@ if (isset($_POST['action'])) {
elseif ($_POST['action'] == "delete") {
if (deleteConfigProfile($_POST['delfilename']) == null) {
$msg = _("Profile deleted.");
// update default profile setting if needed
if ($cfg->default == $_POST['delfilename']) {
$filesNew = array_delete(array($_POST['delfilename']), $files);
if (sizeof($filesNew) > 0) {
sort($filesNew);
$cfg->default = $filesNew[0];
$cfg->save();
}
}
}
else $error = _("Unable to delete profile!");
}
@ -226,8 +237,6 @@ if (!isset($cfg->default)) {
</div>
<div class="filled ui-corner-all">
<?php
$files = getConfigProfiles();
$topicSpacer = new htmlSpacer(null, '20px');
$tabindex = 1;

View File

@ -89,6 +89,9 @@ else if (sizeof($profiles) > 0) {
// use first profile as fallback
$_SESSION["config"] = new LAMConfig($profiles[0]);
}
else {
$_SESSION["config"] = null;
}
if (!isset($default_Config->default) || !in_array($default_Config->default, $profiles)) {
$error_message = _('No default profile set. Please set it in the server profile configuration.');
@ -278,6 +281,9 @@ function display_LoginPage($config_object) {
}
}
}
else {
StatusMessage('WARN', _('Please enter the configuration and create a server profile.'));
}
// check if session expired
if (isset($_GET['expired'])) {
StatusMessage("ERROR", _("Your session expired, please log in again."));