From 4bb25a5c1779a6c873cfe9f42256daae81d4c0bd Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 29 Dec 2007 18:59:09 +0000 Subject: [PATCH] made members of config class private --- lam/lib/config.inc | 33 +++++++++++++++++---------- lam/lib/lamdaemon.inc | 4 ++-- lam/lib/modules/posixAccount.inc | 8 +++---- lam/templates/config/confmain.php | 4 ++-- lam/templates/login.php | 2 +- lam/templates/tests/lamdaemonTest.php | 4 ++-- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index c6a2c708..41027b71 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -164,25 +164,25 @@ function metaRefresh($page) { class LAMConfig { /** Server address (e.g. ldap://127.0.0.1:389) */ - var $ServerURL; + private $ServerURL; /** Array of string: users with admin rights */ - var $Admins; + private $Admins; /** Password to edit preferences */ private $Passwd; /** LDAP suffix for tree view */ - var $treesuffix; + private $treesuffix; /** Default language */ - var $defaultLanguage; + private $defaultLanguage; /** module settings */ - var $moduleSettings = array(); + private $moduleSettings = array(); /** type settings */ - var $typeSettings = array(); + private $typeSettings = array(); /** * Path to external lamdaemon script on server where it is executed @@ -190,12 +190,12 @@ class LAMConfig { * This is used for managing quota and home directories. * optional setting, may not be defined */ - var $scriptPath; + private $scriptPath; /** * The rights for the home directory */ - var $scriptRights = '750'; + private $scriptRights = '750'; /** * Servers where lamdaemon script is executed @@ -203,16 +203,16 @@ class LAMConfig { * This is used for managing quota and home directories. * optional setting, may not be defined */ - var $scriptServer; + private $scriptServer; /** LDAP cache timeout */ - var $cachetimeout; + private $cachetimeout; /** Active account types */ - var $activeTypes = "user,group,host,smbDomain"; + private $activeTypes = "user,group,host,smbDomain"; /** Name of configuration file */ - var $file; + private $file; /** List of all settings in config file */ private $settings = array("ServerURL", "Passwd", "Admins", "treesuffix", @@ -388,6 +388,15 @@ class LAMConfig { } } + /** + * Returns the name of the config file + * + * @return String name + */ + public function getName() { + return $this->file; + } + /** * Returns if the file can be written on the filesystem. * diff --git a/lam/lib/lamdaemon.inc b/lam/lib/lamdaemon.inc index ee55fbe6..7ba84a91 100644 --- a/lam/lib/lamdaemon.inc +++ b/lam/lib/lamdaemon.inc @@ -50,7 +50,7 @@ function lamdaemon($commands, $server) { $userstring = implode ("\n", $commands); $output_array = array(); - $towrite = escapeshellarg($server)." ".escapeshellarg($_SESSION['config']->scriptPath)." - -"; + $towrite = escapeshellarg($server)." ".escapeshellarg($_SESSION['config']->get_scriptPath())." - -"; $descriptorspec = array( 0 => array("pipe", "r"), // stdin 1 => array("pipe", "w"), // stout @@ -112,7 +112,7 @@ function lamdaemonSSH($commands, $server) { return $return; } if (@ssh2_auth_password($handle, $userName, $credentials[1])) { - $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath); + $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->get_scriptPath()); fwrite($shell, $commands); $return = array(); $time = time() + (sizeof($commands) * 30); diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 5856962f..d02b6c2b 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -553,7 +553,7 @@ class posixAccount extends baseModule { break; } } - $result = lamdaemon(array($this->attributes['uid'][0] . " home add 0".$_SESSION['config']->scriptRights), $server); + $result = lamdaemon(array($this->attributes['uid'][0] . " home add 0".$_SESSION['config']->get_scriptRights()), $server); // lamdaemon results if (is_array($result)) { foreach ($result as $singleresult) { @@ -974,7 +974,7 @@ class posixAccount extends baseModule { array('kind' => 'text', 'text' => _('Home directory').'*'), array('kind' => 'input', 'name' => 'homeDirectory', 'type' => 'text', 'size' => '30', 'maxlength' => '255', 'value' => $this->attributes['homeDirectory'][0]), array('kind' => 'help', 'value' => 'homeDirectory')); - if ($this->getAccountContainer()->isNewAccount && isset($_SESSION['config']->scriptPath) && ($_SESSION['config']->scriptPath != '')) { + if ($this->getAccountContainer()->isNewAccount && ($_SESSION['config']->get_scriptPath() != null) && ($_SESSION['config']->get_scriptPath() != '')) { // get list of lamdaemon servers $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { @@ -1030,7 +1030,7 @@ class posixAccount extends baseModule { * @return meta HTML code */ function display_html_delete() { - if ($this->get_scope() == 'user' && isset($_SESSION['config']->scriptPath)) { + if ($this->get_scope() == 'user' && ($_SESSION['config']->get_scriptPath() != null)) { $return[] = array ( array('kind' => 'text', 'text' => _('Delete home directory')), array('kind' => 'input', 'name' => 'deletehomedir', 'type' => 'checkbox'), @@ -1593,7 +1593,7 @@ class posixAccount extends baseModule { // create home directories elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) { $pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])]; - $result = lamdaemon(array($data[$pos][$ids['posixAccount_userName']] . " home add 0".$_SESSION['config']->scriptRights), + $result = lamdaemon(array($data[$pos][$ids['posixAccount_userName']] . " home add 0".$_SESSION['config']->get_scriptRights()), $data[$pos][$ids['posixAccount_createHomeDir']]); $errors = array(); if (($result != false) && (sizeof($result) == 1)) { diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 33f796dd..b4f9a9df 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -62,7 +62,7 @@ $conf = &$_SESSION['conf_config']; // check if password is valid // if not: load login page -if (!$conf->check_Passwd($passwd) && !($_SESSION['conf_isAuthenticated'] === $conf->file)) { +if (!$conf->check_Passwd($passwd) && !($_SESSION['conf_isAuthenticated'] === $conf->getName())) { $sessionKeys = array_keys($_SESSION); for ($i = 0; $i < sizeof($sessionKeys); $i++) { if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]); @@ -72,7 +72,7 @@ if (!$conf->check_Passwd($passwd) && !($_SESSION['conf_isAuthenticated'] === $co require('conflogin.php'); exit; } -$_SESSION['conf_isAuthenticated'] = $conf->file; +$_SESSION['conf_isAuthenticated'] = $conf->getName(); // check if button was pressed and if we have to save the setting or go back to login if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules']) || isset($_POST['edittypes'])){ diff --git a/lam/templates/login.php b/lam/templates/login.php index a18a600b..e0b183c8 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -323,7 +323,7 @@ function display_LoginPage($config_object) { file; + $_POST['profile'] = $_SESSION['config']->getName(); } ?> diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php index 0ac4c988..12ff7c59 100644 --- a/lam/templates/tests/lamdaemonTest.php +++ b/lam/templates/tests/lamdaemonTest.php @@ -67,7 +67,7 @@ function lamTestLamdaemon($command, $stopTest, $handle, $testText) { flush(); $lamdaemonOk = false; $errorMessage = ""; - $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath); + $shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->get_scriptPath()); $stderr = ssh2_fetch_stream($shell, SSH2_STREAM_STDERR); fwrite($shell, $command); $return = array(); @@ -138,7 +138,7 @@ for ($i = 0; $i < sizeof($servers); $i++) { echo "" . _("Error") . "\n"; echo "" . _("No lamdaemon server set, please update your LAM configuration settings.") . ""; } - elseif (!isset($_SESSION['config']->scriptPath) || (strlen($_SESSION['config']->scriptPath) < 10)) { + elseif (($_SESSION['config']->get_scriptPath() == null) || (strlen($_SESSION['config']->get_scriptPath()) < 10)) { echo "" . _("Error") . "  \n"; echo "" . _("No lamdaemon path set, please update your LAM configuration settings.") . ""; $stopTest = true;