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

View File

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

View File

@ -110,7 +110,7 @@ echo $_SESSION['header'];
<?php
if (sizeof($files) > 0) {
echo "<select size=1 name=\"filename\">\n";
$conf = new CfgMain();
$conf = new LAMCfgMain();
$defaultprofile = $conf->default;
for ($i = 0; $i < sizeof($files); $i++) {
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'])) {
$_SESSION['conf_config'] = new Config($_POST['filename']);
$_SESSION['conf_config'] = new LAMConfig($_POST['filename']);
}
$conf = &$_SESSION['conf_config'];
@ -102,7 +102,7 @@ if (isset($_GET["typesback"])) {
// check if a new account type was added
if (isset($_GET["typeschanged"])) {
metaRefresh("confmodules.php");
exit;
exit;
}
}
@ -411,7 +411,7 @@ echo ("</html>\n");
function saveSettings() {
$conf = &$_SESSION['conf_config'];
$types = $conf->get_ActiveTypes();
// remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) {
$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>");
$conf->set_moduleSettings($options);
$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>");
// remove settings from 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
if (isset($_POST['passwd'])) {
$cfgMain = new CfgMain();
$cfgMain = new LAMCfgMain();
if (isset($_POST['passwd']) && ($_POST['passwd'] == $cfgMain->password)) {
$_SESSION["mainconf_password"] = $_POST['passwd'];
metaRefresh("mainmanage.php");

View File

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

View File

@ -21,7 +21,7 @@ $Id$
*/
/**
* Configuration profile management.
*
@ -60,7 +60,7 @@ echo $_SESSION['header'];
<?php
$cfg = new CfgMain();
$cfg = new LAMCfgMain();
// check if submit button was pressed
if ($_POST['submit']) {
// check master password
@ -78,7 +78,7 @@ if ($_POST['submit']) {
$file = is_file("../../config/" . $_POST['addprofile'] . ".conf");
if ($file) {
// load as config and write new password
$conf = new Config($_POST['addprofile']);
$conf = new LAMConfig($_POST['addprofile']);
$conf->Passwd = $_POST['addpassword'];
$conf->save();
$msg = _("Created new profile.");
@ -110,7 +110,7 @@ if ($_POST['submit']) {
// set new profile password
elseif ($_POST['action'] == "setpass") {
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->save();
$msg = _("New password set successfully.");
@ -119,7 +119,7 @@ if ($_POST['submit']) {
}
// set default profile
elseif ($_POST['action'] == "setdefault") {
$config = new CfgMain();
$config = new LAMCfgMain();
$config->default = $_POST['defaultfilename'];
$config->save();
$msg = _("New default profile set successfully.");
@ -314,7 +314,7 @@ if (!isset($cfg->default) && !isset($cfg->password)) {
<select size=1 name="defaultfilename">
<?php
$files = getConfigProfiles();
$conf = new CfgMain();
$conf = new LAMCfgMain();
$defaultprofile = $conf->default;
for ($i = 0; $i < sizeof($files); $i++) {
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
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
}
// Load login page
else
{
$_SESSION['loggedIn'] = false;
$default_Config = new CfgMain();
$default_Config = new LAMCfgMain();
$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
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
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -32,7 +32,7 @@ $Id$
/** configuration interface */
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 ("<b> Current Values</b><br><br>");
echo "<b>Password: </b>" . $conf->password . "<br>\n";
@ -51,7 +51,7 @@ $conf->save();
echo ("done<br>");
// at last all preferences are read from config.cfg and compared
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->default != "lam") echo ("<br><font color=\"#FF0000\">Saving Default failed!</font><br>");
echo ("done<br>");

View File

@ -32,7 +32,7 @@ $Id$
/** access to configuration functions */
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 ("<br><br><big><b> Starting Test...</b></big><br><br>");
// now all preferences are loaded
@ -76,7 +76,7 @@ $conf->save();
echo ("done<br>");
// at last all preferences are read from lam.conf and compared
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_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>");