made members of config class private

This commit is contained in:
Roland Gruber 2007-12-29 18:59:09 +00:00
parent bf323b807c
commit 4bb25a5c17
6 changed files with 32 additions and 23 deletions

View File

@ -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.
*

View File

@ -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);

View File

@ -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)) {

View File

@ -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'])){

View File

@ -323,7 +323,7 @@ function display_LoginPage($config_object) {
<?php
echo _("Server profile") . ": ";
if(empty($_POST['profileChange'])) {
$_POST['profile'] = $_SESSION['config']->file;
$_POST['profile'] = $_SESSION['config']->getName();
}
?></b>
<?php echo $_POST['profile']; ?>

View File

@ -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 "<td>" . _("Error") . "</td>\n";
echo "<td bgcolor=\"red\">" . _("No lamdaemon server set, please update your LAM configuration settings.") . "</td>";
}
elseif (!isset($_SESSION['config']->scriptPath) || (strlen($_SESSION['config']->scriptPath) < 10)) {
elseif (($_SESSION['config']->get_scriptPath() == null) || (strlen($_SESSION['config']->get_scriptPath()) < 10)) {
echo "<td bgcolor=\"red\">" . _("Error") . "&nbsp;&nbsp;</td>\n";
echo "<td bgcolor=\"red\">" . _("No lamdaemon path set, please update your LAM configuration settings.") . "</td>";
$stopTest = true;