renamed config classes

This commit is contained in:
Roland Gruber 2006-09-24 14:19:50 +00:00
parent 47f66d2f81
commit bbd7272c0c
10 changed files with 41 additions and 41 deletions

View File

@ -120,7 +120,7 @@ function metaRefresh($page) {
* *
* @package configuration * @package configuration
*/ */
class Config { class LAMConfig {
/** Server address (e.g. ldap://127.0.0.1:389) */ /** Server address (e.g. ldap://127.0.0.1:389) */
var $ServerURL; var $ServerURL;
@ -182,7 +182,7 @@ class Config {
* *
* @param integer $file Index number in config file array * @param integer $file Index number in config file array
*/ */
function Config($file = 0) { function LAMConfig($file = 0) {
// load first profile if none is given // load first profile if none is given
if (!is_string($file)) { if (!is_string($file)) {
$profiles = getConfigProfiles(); $profiles = getConfigProfiles();
@ -672,7 +672,7 @@ class Config {
if (($this->activeTypes == '') || !isset($this->activeTypes)) return array(); if (($this->activeTypes == '') || !isset($this->activeTypes)) return array();
else return explode(",", $this->activeTypes); else return explode(",", $this->activeTypes);
} }
/** /**
* Sets the list of active types. * Sets the list of active types.
* *
@ -711,34 +711,34 @@ class Config {
* *
* @package configuration * @package configuration
*/ */
class CfgMain { class LAMCfgMain {
/** Default profile */ /** Default profile */
var $default; var $default;
/** Password to change config.cfg */ /** Password to change config.cfg */
var $password; var $password;
/** Time of inactivity before session times out (minutes) */ /** Time of inactivity before session times out (minutes) */
var $sessionTimeout; var $sessionTimeout;
/** log level */ /** log level */
var $logLevel; var $logLevel;
/** log destination ("SYSLOG":syslog, "/...":file, "NONE":none) */ /** log destination ("SYSLOG":syslog, "/...":file, "NONE":none) */
var $logDestination; var $logDestination;
/** list of hosts which may access LAM */ /** list of hosts which may access LAM */
var $allowedHosts; var $allowedHosts;
/** list of data fields to save in config file */ /** list of data fields to save in config file */
var $settings = array("password", "default", "sessionTimeout", var $settings = array("password", "default", "sessionTimeout",
"logLevel", "logDestination", "allowedHosts"); "logLevel", "logDestination", "allowedHosts");
/** /**
* Loads preferences from config file * Loads preferences from config file
*/ */
function CfgMain() { function LAMCfgMain() {
// set default values // set default values
$this->sessionTimeout = 30; $this->sessionTimeout = 30;
$this->logLevel = LOG_NOTICE; $this->logLevel = LOG_NOTICE;
@ -825,7 +825,7 @@ class CfgMain {
exit; exit;
} }
} }
} }
?> ?>

View File

@ -51,7 +51,7 @@ function startSecureSession() {
// check session id // check session id
if (! isset($_SESSION["sec_session_id"]) || ($_SESSION["sec_session_id"] != session_id())) { if (! isset($_SESSION["sec_session_id"]) || ($_SESSION["sec_session_id"] != session_id())) {
// session id is invalid // session id is invalid
die(); die();
} }
// check if client IP has not changed // check if client IP has not changed
if (!isset($_SESSION["sec_client_ip"]) || ($_SESSION["sec_client_ip"] != $_SERVER['REMOTE_ADDR'])) { if (!isset($_SESSION["sec_client_ip"]) || ($_SESSION["sec_client_ip"] != $_SERVER['REMOTE_ADDR'])) {
@ -75,7 +75,7 @@ function startSecureSession() {
* *
*/ */
function checkClientIP() { function checkClientIP() {
$cfg = new CfgMain(); $cfg = new LAMCfgMain();
$allowedHosts = $cfg->allowedHosts; $allowedHosts = $cfg->allowedHosts;
// skip test if no hosts are defined // skip test if no hosts are defined
if ($allowedHosts == "") return; if ($allowedHosts == "") return;
@ -152,13 +152,13 @@ function logNewMessage($level, $message) {
$possibleLevels = array(LOG_NOTICE => 'NOTICE', LOG_WARNING => 'WARNING', LOG_ERR => 'ERROR'); $possibleLevels = array(LOG_NOTICE => 'NOTICE', LOG_WARNING => 'WARNING', LOG_ERR => 'ERROR');
if (!in_array($level, array_keys($possibleLevels))) StatusMessage('ERROR', 'Invalid log level!', $level); if (!in_array($level, array_keys($possibleLevels))) StatusMessage('ERROR', 'Invalid log level!', $level);
if (isset($_SESSION['cfgMain'])) $cfg = $_SESSION['cfgMain']; if (isset($_SESSION['cfgMain'])) $cfg = $_SESSION['cfgMain'];
else $cfg = new CfgMain(); else $cfg = new LAMCfgMain();
// check if logging is disabled // check if logging is disabled
if ($cfg->logDestination == 'NONE') return; if ($cfg->logDestination == 'NONE') return;
// check if log level is high enough // check if log level is high enough
elseif ($cfg->logLevel < $level) return; elseif ($cfg->logLevel < $level) return;
// ok to log, build log message // ok to log, build log message
$prefix = "LDAP Account Manager - " . $possibleLevels[$level] . ": "; $prefix = "LDAP Account Manager - " . $possibleLevels[$level] . ": ";
$message = $prefix . $message; $message = $prefix . $message;
// Syslog logging // Syslog logging
if ($cfg->logDestination == 'SYSLOG') { if ($cfg->logDestination == 'SYSLOG') {

View File

@ -110,7 +110,7 @@ echo $_SESSION['header'];
<?php <?php
if (sizeof($files) > 0) { if (sizeof($files) > 0) {
echo "<select size=1 name=\"filename\">\n"; echo "<select size=1 name=\"filename\">\n";
$conf = new CfgMain(); $conf = new LAMCfgMain();
$defaultprofile = $conf->default; $defaultprofile = $conf->default;
for ($i = 0; $i < sizeof($files); $i++) { for ($i = 0; $i < sizeof($files); $i++) {
if ($files[$i] == $defaultprofile) echo ("<option selected>" . $files[$i] . "</option>\n"); if ($files[$i] == $defaultprofile) echo ("<option selected>" . $files[$i] . "</option>\n");

View File

@ -56,7 +56,7 @@ if (! $passwd) {
} }
if (!isset($_SESSION['conf_config']) && isset($_POST['filename'])) { if (!isset($_SESSION['conf_config']) && isset($_POST['filename'])) {
$_SESSION['conf_config'] = new Config($_POST['filename']); $_SESSION['conf_config'] = new LAMConfig($_POST['filename']);
} }
$conf = &$_SESSION['conf_config']; $conf = &$_SESSION['conf_config'];
@ -102,7 +102,7 @@ if (isset($_GET["typesback"])) {
// check if a new account type was added // check if a new account type was added
if (isset($_GET["typeschanged"])) { if (isset($_GET["typeschanged"])) {
metaRefresh("confmodules.php"); metaRefresh("confmodules.php");
exit; exit;
} }
} }
@ -411,7 +411,7 @@ echo ("</html>\n");
function saveSettings() { function saveSettings() {
$conf = &$_SESSION['conf_config']; $conf = &$_SESSION['conf_config'];
$types = $conf->get_ActiveTypes(); $types = $conf->get_ActiveTypes();
// remove double slashes if magic quotes are on // remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) { if (get_magic_quotes_gpc() == 1) {
$postKeys = array_keys($_POST); $postKeys = array_keys($_POST);
@ -505,7 +505,7 @@ function saveSettings() {
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>"); "<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>");
$conf->set_moduleSettings($options); $conf->set_moduleSettings($options);
$conf->save(); $conf->save();
echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>"); echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>");
echo("</body></html>"); echo("</body></html>");
// remove settings from session // remove settings from session
$sessionKeys = array_keys($_SESSION); $sessionKeys = array_keys($_SESSION);

View File

@ -46,7 +46,7 @@ if (isset($_SESSION["mainconf_password"])) unset($_SESSION["mainconf_password"])
// check if user entered a password // check if user entered a password
if (isset($_POST['passwd'])) { if (isset($_POST['passwd'])) {
$cfgMain = new CfgMain(); $cfgMain = new LAMCfgMain();
if (isset($_POST['passwd']) && ($_POST['passwd'] == $cfgMain->password)) { if (isset($_POST['passwd']) && ($_POST['passwd'] == $cfgMain->password)) {
$_SESSION["mainconf_password"] = $_POST['passwd']; $_SESSION["mainconf_password"] = $_POST['passwd'];
metaRefresh("mainmanage.php"); metaRefresh("mainmanage.php");

View File

@ -21,7 +21,7 @@ $Id$
*/ */
/** /**
* Manages the main configuration options. * Manages the main configuration options.
* *
@ -41,7 +41,7 @@ session_save_path("../../sess");
setlanguage(); setlanguage();
$cfg = new CfgMain(); $cfg = new LAMCfgMain();
// check if user is logged in // check if user is logged in
if (!isset($_SESSION["mainconf_password"]) || ($_SESSION["mainconf_password"] != $cfg->password)) { if (!isset($_SESSION["mainconf_password"]) || ($_SESSION["mainconf_password"] != $cfg->password)) {
@ -239,7 +239,7 @@ if ($_POST['submit']) {
echo "<a href=\"../help.php?HelpNumber=240\" target=\"lamhelp\">"; echo "<a href=\"../help.php?HelpNumber=240\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">"; echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n"; echo "</a>\n";
?> ?>
</TD> </TD>
</TR> </TR>
<TR> <TR>
@ -326,7 +326,7 @@ if ($_POST['submit']) {
</TD> </TD>
</TR> </TR>
</table> </table>
</form> </form>
<p><br></p> <p><br></p>

View File

@ -21,7 +21,7 @@ $Id$
*/ */
/** /**
* Configuration profile management. * Configuration profile management.
* *
@ -60,7 +60,7 @@ echo $_SESSION['header'];
<?php <?php
$cfg = new CfgMain(); $cfg = new LAMCfgMain();
// check if submit button was pressed // check if submit button was pressed
if ($_POST['submit']) { if ($_POST['submit']) {
// check master password // check master password
@ -78,7 +78,7 @@ if ($_POST['submit']) {
$file = is_file("../../config/" . $_POST['addprofile'] . ".conf"); $file = is_file("../../config/" . $_POST['addprofile'] . ".conf");
if ($file) { if ($file) {
// load as config and write new password // load as config and write new password
$conf = new Config($_POST['addprofile']); $conf = new LAMConfig($_POST['addprofile']);
$conf->Passwd = $_POST['addpassword']; $conf->Passwd = $_POST['addpassword'];
$conf->save(); $conf->save();
$msg = _("Created new profile."); $msg = _("Created new profile.");
@ -110,7 +110,7 @@ if ($_POST['submit']) {
// set new profile password // set new profile password
elseif ($_POST['action'] == "setpass") { elseif ($_POST['action'] == "setpass") {
if ($_POST['setpassword'] && $_POST['setpassword2'] && ($_POST['setpassword'] == $_POST['setpassword2'])) { if ($_POST['setpassword'] && $_POST['setpassword2'] && ($_POST['setpassword'] == $_POST['setpassword2'])) {
$config = new Config($_POST['setprofile']); $config = new LAMConfig($_POST['setprofile']);
$config->set_Passwd($_POST['setpassword']); $config->set_Passwd($_POST['setpassword']);
$config->save(); $config->save();
$msg = _("New password set successfully."); $msg = _("New password set successfully.");
@ -119,7 +119,7 @@ if ($_POST['submit']) {
} }
// set default profile // set default profile
elseif ($_POST['action'] == "setdefault") { elseif ($_POST['action'] == "setdefault") {
$config = new CfgMain(); $config = new LAMCfgMain();
$config->default = $_POST['defaultfilename']; $config->default = $_POST['defaultfilename'];
$config->save(); $config->save();
$msg = _("New default profile set successfully."); $msg = _("New default profile set successfully.");
@ -314,7 +314,7 @@ if (!isset($cfg->default) && !isset($cfg->password)) {
<select size=1 name="defaultfilename"> <select size=1 name="defaultfilename">
<?php <?php
$files = getConfigProfiles(); $files = getConfigProfiles();
$conf = new CfgMain(); $conf = new LAMCfgMain();
$defaultprofile = $conf->default; $defaultprofile = $conf->default;
for ($i = 0; $i < sizeof($files); $i++) { for ($i = 0; $i < sizeof($files); $i++) {
if ($files[$i] == $defaultprofile) echo ("<option selected>" . $files[$i] . "</option>\n"); if ($files[$i] == $defaultprofile) echo ("<option selected>" . $files[$i] . "</option>\n");

View File

@ -417,16 +417,16 @@ if(!empty($_POST['checklogin']))
} }
// Reload loginpage after a profile change // Reload loginpage after a profile change
elseif(!empty($_POST['profileChange'])) { elseif(!empty($_POST['profileChange'])) {
$_SESSION['config'] = new Config($_POST['profile']); // Recreate the config object with the submited $_SESSION['config'] = new LAMConfig($_POST['profile']); // Recreate the config object with the submited
display_LoginPage($_SESSION['config']); // Load login page display_LoginPage($_SESSION['config']); // Load login page
} }
// Load login page // Load login page
else else
{ {
$_SESSION['loggedIn'] = false; $_SESSION['loggedIn'] = false;
$default_Config = new CfgMain(); $default_Config = new LAMCfgMain();
$default_Profile = $default_Config->default; $default_Profile = $default_Config->default;
$_SESSION["config"] = new Config($default_Profile); // Create new Config object $_SESSION["config"] = new LAMConfig($default_Profile); // Create new Config object
$_SESSION["cfgMain"] = $default_Config; // Create new CfgMain object $_SESSION["cfgMain"] = $default_Config; // Create new CfgMain object
display_LoginPage($_SESSION["config"]); // Load Login page display_LoginPage($_SESSION["config"]); // Load Login page

View File

@ -9,12 +9,12 @@ $Id$
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -32,7 +32,7 @@ $Id$
/** configuration interface */ /** configuration interface */
include ("../lib/config.inc"); include ("../lib/config.inc");
$conf = new CfgMain(); $conf = new LAMCfgMain();
echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>"; echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>";
echo ("<b> Current Values</b><br><br>"); echo ("<b> Current Values</b><br><br>");
echo "<b>Password: </b>" . $conf->password . "<br>\n"; echo "<b>Password: </b>" . $conf->password . "<br>\n";
@ -51,7 +51,7 @@ $conf->save();
echo ("done<br>"); echo ("done<br>");
// at last all preferences are read from config.cfg and compared // at last all preferences are read from config.cfg and compared
echo ("Loading and comparing..."); echo ("Loading and comparing...");
$conf = new CfgMain(); $conf = new LAMCfgMain();
if ($conf->password != "123456") echo ("<br><font color=\"#FF0000\">Saving password failed!</font><br>"); if ($conf->password != "123456") echo ("<br><font color=\"#FF0000\">Saving password failed!</font><br>");
if ($conf->default != "lam") echo ("<br><font color=\"#FF0000\">Saving Default failed!</font><br>"); if ($conf->default != "lam") echo ("<br><font color=\"#FF0000\">Saving Default failed!</font><br>");
echo ("done<br>"); echo ("done<br>");

View File

@ -32,7 +32,7 @@ $Id$
/** access to configuration functions */ /** access to configuration functions */
include ("../lib/config.inc"); include ("../lib/config.inc");
$conf = new Config('test'); $conf = new LAMConfig('test');
echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>"; echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>";
echo ("<br><br><big><b> Starting Test...</b></big><br><br>"); echo ("<br><br><big><b> Starting Test...</b></big><br><br>");
// now all preferences are loaded // now all preferences are loaded
@ -76,7 +76,7 @@ $conf->save();
echo ("done<br>"); echo ("done<br>");
// at last all preferences are read from lam.conf and compared // at last all preferences are read from lam.conf and compared
echo ("Loading and comparing..."); echo ("Loading and comparing...");
$conf2 = new Config('test'); $conf2 = new LAMConfig('test');
if ($conf2->get_ServerURL() != "ldap://123.345.678.123:777") echo ("<br><font color=\"#FF0000\">Saving ServerURL failed!</font><br>"); if ($conf2->get_ServerURL() != "ldap://123.345.678.123:777") echo ("<br><font color=\"#FF0000\">Saving ServerURL failed!</font><br>");
if ($conf2->get_cacheTimeout() != "33") echo ("<br><font color=\"#FF0000\">Saving Cache timeout failed!</font><br>"); if ($conf2->get_cacheTimeout() != "33") echo ("<br><font color=\"#FF0000\">Saving Cache timeout failed!</font><br>");
if ($conf2->get_Passwd() != "123456abcde") echo ("<br><font color=\"#FF0000\">Saving password failed!</font><br>"); if ($conf2->get_Passwd() != "123456abcde") echo ("<br><font color=\"#FF0000\">Saving password failed!</font><br>");