2003-02-17 18:21:44 +00:00
< ? php
2003-02-21 22:01:01 +00:00
/*
$Id $
2003-02-21 22:09:59 +00:00
This code is part of LDAP Account Manager ( http :// www . sourceforge . net / projects / lam )
2003-02-21 22:01:01 +00:00
Copyright ( C ) 2003 Roland Gruber
This program is free software ; you can redistribute it and / or modify
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 .
2003-03-30 19:51:47 +00:00
2003-02-21 22:01:01 +00:00
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 .
2003-05-14 13:45:52 +00:00
2003-02-21 22:01:01 +00:00
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
2003-05-14 13:45:52 +00:00
2003-03-15 11:42:08 +00:00
Config supplies access to the configuration data .
2003-02-21 22:01:01 +00:00
*/
2003-05-14 13:45:52 +00:00
include_once ( " status.inc " );
2003-05-09 16:22:46 +00:00
// sets language settings for automatic translation
2003-05-06 15:17:09 +00:00
function setlanguage () {
if ( $_SESSION [ 'language' ]) {
$language = explode ( " : " , $_SESSION [ 'language' ]);
putenv ( " LANG= " . $language [ 1 ]);
setlocale ( LC_ALL , $language [ 0 ]);
$locdir = substr ( __FILE__ , 0 , strlen ( __FILE__ ) - 15 ) . " /locale " ;
2003-05-10 11:17:28 +00:00
bindtextdomain ( " messages " , $locdir );
textdomain ( " messages " );
2003-05-06 15:17:09 +00:00
}
else echo _ ( " Language not defined in session! " );
}
2003-02-21 22:01:01 +00:00
2003-02-17 18:21:44 +00:00
class Config {
2003-03-05 18:38:19 +00:00
2003-05-06 23:52:00 +00:00
// server address (e.g. ldap://127.0.0.1:389)
var $ServerURL ;
2003-04-18 15:50:01 +00:00
2003-05-06 23:52:00 +00:00
// array of strings: users with admin rights
var $Admins ;
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// string: password to edit preferences
var $Passwd ;
2003-02-17 18:21:44 +00:00
2003-05-06 23:52:00 +00:00
// single line with the names of all admin users
var $Adminstring ;
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// suffix for users
var $Suff_users ;
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// suffix for groups
var $Suff_groups ;
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// suffix for Samba hosts
var $Suff_hosts ;
2003-03-05 18:38:19 +00:00
2003-05-06 23:52:00 +00:00
// minimum/maximum numbers for UID, GID and UID of Samba Hosts
var $MinUID ;
var $MaxUID ;
var $MinGID ;
var $MaxGID ;
var $MinMachine ;
var $MaxMachine ;
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// attributes that are shown in the user/group/host tables
var $userlistAttributes ;
var $grouplistAttributes ;
var $hostlistAttributes ;
2003-05-07 14:29:44 +00:00
// maximum number of rows shown in user/group/host list
2003-05-06 23:52:00 +00:00
var $maxlistentries ;
2003-03-30 19:51:47 +00:00
2003-05-09 16:22:46 +00:00
// default language
var $defaultLanguage ;
2003-05-12 17:52:54 +00:00
// Path to external script and server where it is executed
// optional settings, may not be defined
var $scriptPath ;
var $scriptServer ;
2003-05-28 15:37:48 +00:00
// if "yes" use the new LDAP schema for Samba 3.x
var $samba3 ;
2003-05-06 23:52:00 +00:00
// constructor, loads preferences from ../config/lam.conf
function Config () {
$this -> reload ();
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// reloads preferences from ../config/lam.conf
function reload () {
$conffile = substr ( __FILE__ , 0 , strlen ( __FILE__ ) - 15 ) . " /config/lam.conf " ;
if ( is_file ( $conffile ) == True ) {
$file = fopen ( $conffile , " r " );
while ( ! feof ( $file )) {
$line = fgets ( $file , 1024 );
if (( $line == " \n " ) || ( $line [ 0 ] == " # " )) continue ; // ignore comments
// search keywords
if ( substr ( $line , 0 , 11 ) == " serverURL: " ) {
$this -> ServerURL = chop ( substr ( $line , 11 , strlen ( $line ) - 11 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " passwd: " ) {
$this -> Passwd = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " admins: " ) {
$adminstr = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
$this -> Adminstring = $adminstr ;
$this -> Admins = explode ( " ; " , $adminstr );
continue ;
}
if ( substr ( $line , 0 , 12 ) == " usersuffix: " ) {
$this -> Suff_users = chop ( substr ( $line , 12 , strlen ( $line ) - 12 ));
continue ;
}
if ( substr ( $line , 0 , 13 ) == " groupsuffix: " ) {
$this -> Suff_groups = chop ( substr ( $line , 13 , strlen ( $line ) - 13 ));
continue ;
}
if ( substr ( $line , 0 , 12 ) == " hostsuffix: " ) {
$this -> Suff_hosts = chop ( substr ( $line , 12 , strlen ( $line ) - 12 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " minUID: " ) {
$this -> MinUID = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " maxUID: " ) {
$this -> MaxUID = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " minGID: " ) {
$this -> MinGID = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
if ( substr ( $line , 0 , 8 ) == " maxGID: " ) {
$this -> MaxGID = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
if ( substr ( $line , 0 , 12 ) == " minMachine: " ) {
$this -> MinMachine = chop ( substr ( $line , 12 , strlen ( $line ) - 12 ));
continue ;
}
if ( substr ( $line , 0 , 12 ) == " maxMachine: " ) {
$this -> MaxMachine = chop ( substr ( $line , 12 , strlen ( $line ) - 12 ));
continue ;
}
if ( substr ( $line , 0 , 20 ) == " userlistAttributes: " ) {
$this -> userlistAttributes = chop ( substr ( $line , 20 , strlen ( $line ) - 20 ));
continue ;
}
if ( substr ( $line , 0 , 21 ) == " grouplistAttributes: " ) {
$this -> grouplistAttributes = chop ( substr ( $line , 21 , strlen ( $line ) - 21 ));
continue ;
}
if ( substr ( $line , 0 , 20 ) == " hostlistAttributes: " ) {
$this -> hostlistAttributes = chop ( substr ( $line , 20 , strlen ( $line ) - 20 ));
continue ;
}
2003-05-07 14:29:44 +00:00
if ( substr ( $line , 0 , 16 ) == " maxlistentries: " ) {
$this -> maxlistentries = chop ( substr ( $line , 16 , strlen ( $line ) - 16 ));
continue ;
}
2003-05-09 16:22:46 +00:00
if ( substr ( $line , 0 , 17 ) == " defaultLanguage: " ) {
$this -> defaultLanguage = chop ( substr ( $line , 17 , strlen ( $line ) - 17 ));
continue ;
}
2003-05-12 17:52:54 +00:00
if ( substr ( $line , 0 , 12 ) == " scriptPath: " ) {
$this -> scriptPath = chop ( substr ( $line , 12 , strlen ( $line ) - 12 ));
continue ;
}
if ( substr ( $line , 0 , 14 ) == " scriptServer: " ) {
$this -> scriptServer = chop ( substr ( $line , 14 , strlen ( $line ) - 14 ));
continue ;
}
2003-05-28 15:37:48 +00:00
if ( substr ( $line , 0 , 8 ) == " samba3: " ) {
$this -> samba3 = chop ( substr ( $line , 8 , strlen ( $line ) - 8 ));
continue ;
}
2003-05-06 23:52:00 +00:00
}
fclose ( $file );
}
else {
2003-05-14 13:45:52 +00:00
StatusMessage ( " ERROR " , " " , _ ( " Unable to load lam.conf! " ) . $conffile );
2003-05-06 23:52:00 +00:00
}
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// saves preferences to ../config/lam.conf
function save () {
2003-05-15 17:31:18 +00:00
$conffile = substr ( __FILE__ , 0 , strlen ( __FILE__ ) - 15 ) . " /config/lam.conf " ;
2003-05-06 23:52:00 +00:00
if ( is_file ( $conffile ) == True ) {
// booleans to check if value was already saved
$save_serverURL = $save_passwd = $save_admins = $save_suffusr = $save_suffgrp = $save_suffhst =
$save_minUID = $save_maxUID = $save_minGID = $save_maxGID = $save_minMach = $save_maxMach =
2003-05-12 17:52:54 +00:00
$save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $save_maxlstent = $save_deflang =
2003-05-28 15:37:48 +00:00
$save_scriptPath = $save_scriptServer = $save_samba3 = False ;
2003-05-06 23:52:00 +00:00
$file = fopen ( $conffile , " r " );
$file_array = array ();
while ( ! feof ( $file )) {
array_push ( $file_array , fgets ( $file , 1024 ));
}
fclose ( $file );
for ( $i = 0 ; $i < sizeof ( $file_array ); $i ++ ) {
if (( $file_array [ $i ] == " \n " ) || ( $file_array [ $i ][ 0 ] == " # " )) continue ; // ignore comments
// search for keywords
if ( substr ( $file_array [ $i ], 0 , 11 ) == " serverURL: " ) {
$file_array [ $i ] = " serverURL: " . $this -> ServerURL . " \n " ;
$save_serverURL = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " passwd: " ) {
$file_array [ $i ] = " passwd: " . $this -> Passwd . " \n " ;
$save_passwd = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " admins: " ) {
$file_array [ $i ] = " admins: " . implode ( " ; " , $this -> Admins ) . " \n " ;
$save_admins = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 12 ) == " usersuffix: " ) {
$file_array [ $i ] = " usersuffix: " . $this -> Suff_users . " \n " ;
$save_suffusr = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 13 ) == " groupsuffix: " ) {
$file_array [ $i ] = " groupsuffix: " . $this -> Suff_groups . " \n " ;
$save_suffgrp = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 12 ) == " hostsuffix: " ) {
$file_array [ $i ] = " hostsuffix: " . $this -> Suff_hosts . " \n " ;
$save_suffhst = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " minUID: " ) {
$file_array [ $i ] = " minUID: " . $this -> MinUID . " \n " ;
$save_minUID = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " maxUID: " ) {
$file_array [ $i ] = " maxUID: " . $this -> MaxUID . " \n " ;
$save_maxUID = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " minGID: " ) {
$file_array [ $i ] = " minGID: " . $this -> MinGID . " \n " ;
$save_minGID = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 8 ) == " maxGID: " ) {
$file_array [ $i ] = " maxGID: " . $this -> MaxGID . " \n " ;
$save_maxGID = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 12 ) == " minMachine: " ) {
$file_array [ $i ] = " minMachine: " . $this -> MinMachine . " \n " ;
$save_minMach = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 12 ) == " maxMachine: " ) {
$file_array [ $i ] = " maxMachine: " . $this -> MaxMachine . " \n " ;
$save_maxMach = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 20 ) == " userlistAttributes: " ) {
$file_array [ $i ] = " userlistAttributes: " . $this -> userlistAttributes . " \n " ;
$save_usrlstattr = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 21 ) == " grouplistAttributes: " ) {
$file_array [ $i ] = " grouplistAttributes: " . $this -> grouplistAttributes . " \n " ;
$save_grplstattr = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 20 ) == " hostlistAttributes: " ) {
$file_array [ $i ] = " hostlistAttributes: " . $this -> hostlistAttributes . " \n " ;
$save_hstlstattr = True ;
continue ;
}
2003-05-07 14:29:44 +00:00
if ( substr ( $file_array [ $i ], 0 , 16 ) == " maxlistentries: " ) {
$file_array [ $i ] = " maxlistentries: " . $this -> maxlistentries . " \n " ;
$save_maxlstent = True ;
continue ;
}
2003-05-09 16:22:46 +00:00
if ( substr ( $file_array [ $i ], 0 , 17 ) == " defaultLanguage: " ) {
$file_array [ $i ] = " defaultLanguage: " . $this -> defaultLanguage . " \n " ;
$save_deflang = True ;
continue ;
}
2003-05-12 17:52:54 +00:00
if ( substr ( $file_array [ $i ], 0 , 12 ) == " scriptPath: " ) {
$file_array [ $i ] = " scriptPath: " . $this -> scriptPath . " \n " ;
$save_scriptPath = True ;
continue ;
}
if ( substr ( $file_array [ $i ], 0 , 14 ) == " scriptServer: " ) {
$file_array [ $i ] = " scriptServer: " . $this -> scriptServer . " \n " ;
$save_scriptServer = True ;
continue ;
}
2003-05-28 15:37:48 +00:00
if ( substr ( $file_array [ $i ], 0 , 8 ) == " samba3: " ) {
$file_array [ $i ] = " samba3: " . $this -> samba3 . " \n " ;
$save_samba3 = True ;
continue ;
}
2003-05-06 23:52:00 +00:00
}
// check if we have to add new entries (e.g. if user upgraded LAM and has an old lam.conf)
if ( ! $save_serverURL == True ) array_push ( $file_array , " \n \n # server address (e.g. ldap://localhost:389 or ldaps://localhost:636) \n " . " serverURL: " . $this -> ServerURL );
if ( ! $save_passwd == True ) array_push ( $file_array , " \n \n # password to change these preferences via webfrontend \n " . " passwd: " . $this -> Passwd );
if ( ! $save_admins == True ) array_push ( $file_array , " \n \n # list of users who are allowed to use LDAP Account Manager \n " .
2003-05-12 17:52:54 +00:00
" # names have to be seperated by semicolons \n " .
2003-05-06 23:52:00 +00:00
" # e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org \n " . " admins: " . $this -> Admins );
2003-05-12 17:52:54 +00:00
if ( ! $ save_suffusr == True ) array_push ( $file_array , " \n \n # suffix of users \n " .
2003-05-06 23:52:00 +00:00
" # e.g. ou=People,dc=yourdomain,dc=org \n " . " usersuffix: " . $this -> Suff_users );
2003-05-12 17:52:54 +00:00
if ( ! $save_suffgrp == True ) array_push ( $file_array , " \n \n # suffix of groups \n " .
2003-05-06 23:52:00 +00:00
" # e.g. ou=Groups,dc=yourdomain,dc=org \n " . " groupsuffix: " . $this -> Suff_groups );
2003-05-12 17:52:54 +00:00
if ( ! $save_suffhst == True ) array_push ( $file_array , " \n \n # suffix of Samba hosts \n " .
2003-05-06 23:52:00 +00:00
" # e.g. ou=machines,dc=yourdomain,dc=org \n " . " hostsuffix: " . $this -> Suff_hosts );
if ( ! $save_minUID == True ) array_push ( $file_array , " \n \n # minimum UID number \n " . " minUID: " . $this -> MinUID );
if ( ! $save_maxUID == True ) array_push ( $file_array , " \n \n # maximum UID number \n " . " maxUID: " . $this -> MaxUID );
if ( ! $save_minGID == True ) array_push ( $file_array , " \n \n # minimum GID number \n " . " minGID: " . $this -> MinGID );
if ( ! $save_maxGID == True ) array_push ( $file_array , " \n \n # maximum GID number \n " . " maxGID: " . $this -> MaxGID );
if ( ! $save_minMach == True ) array_push ( $file_array , " \n \n # minimum UID number for Samba hosts \n " . " minMachine: " . $this -> MinMachine );
if ( ! $save_maxMach == True ) array_push ( $file_array , " \n \n # maximum UID number for Samba hosts \n " . " maxMachine: " . $this -> MaxMachine );
if ( ! $save_usrlstattr == True ) array_push ( $file_array , " \n \n # list of attributes to show in user list \n # entries can either be predefined values (e.g. '#cn' or '#uid') " .
" \n # or individual ones (e.g. 'uid:User ID' or 'host:Host Name') \n # values have to be seperated by semicolons \n " . " userlistAttributes: " . $this -> userlistAttributes );
if ( ! $save_grplstattr == True ) array_push ( $file_array , " \n \n # list of attributes to show in group list \n # entries can either be predefined values (e.g. '#cn' or '#gidNumber') " .
" \n # or individual ones (e.g. 'cn:Group Name') \n # values have to be seperated by semicolons \n " . " grouplistAttributes: " . $this -> grouplistAttributes );
if ( ! $save_hstlstattr == True ) array_push ( $file_array , " \n \n # list of attributes to show in host list \n # entries can either be predefined values (e.g. '#cn' or '#uid') " .
" \n # or individual ones (e.g. 'cn:Host Name') \n # values have to be seperated by semicolons \n " . " hostlistAttributes: " . $this -> hostlistAttributes );
2003-05-07 14:29:44 +00:00
if ( ! $save_maxlstent == True ) array_push ( $file_array , " \n \n # maximum number of rows to show in user/group/host lists \n " . " maxlistentries: " . $this -> maxlistentries );
2003-05-09 16:22:46 +00:00
if ( ! $save_deflang == True ) array_push ( $file_array , " \n \n # default language (a line from language.conf) \n " . " defaultLanguage: " . $this -> defaultLanguage );
2003-05-12 17:52:54 +00:00
if ( ! $save_scriptPath == True ) array_push ( $file_array , " \n \n # Path to external Script \n " . " scriptPath: " . $this -> scriptPath );
if ( ! $save_scriptServer == True ) array_push ( $file_array , " \n \n # Server of external Script \n " . " scriptServer: " . $this -> scriptServer );
2003-05-28 15:37:48 +00:00
if ( ! $save_samba3 == True ) array_push ( $file_array , " \n \n # Set to \" yes \" only if you use the new Samba 3.x schema. \n " . " samba3: " . $this -> samba3 );
2003-05-06 23:52:00 +00:00
$file = fopen ( $conffile , " w " );
if ( $file ) {
for ( $i = 0 ; $i < sizeof ( $file_array ); $i ++ ) fputs ( $file , $file_array [ $i ]);
fclose ( $file );
}
2003-05-14 13:45:52 +00:00
else {
StatusMessage ( " ERROR " , " " , _ ( " Cannot open config file! " ));
exit ;
}
2003-05-06 23:52:00 +00:00
}
}
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// prints current preferences
function printconf () {
echo _ ( " <b>ServerURL: </b> " ) . $this -> ServerURL . " <br> " ;
2003-05-28 15:37:48 +00:00
echo _ ( " <b>Samba3: </b> " ) . $this -> samba3 . " <br> " ;
2003-05-06 23:52:00 +00:00
echo _ ( " <b>UserSuffix: </b> " ) . $this -> Suff_users . " <br> " ;
echo _ ( " <b>GroupSuffix: </b> " ) . $this -> Suff_groups . " <br> " ;
echo _ ( " <b>HostSuffix: </b> " ) . $this -> Suff_hosts . " <br> " ;
echo _ ( " <b>minUID: </b> " ) . $this -> MinUID . " <br> " ;
echo _ ( " <b>maxUID: </b> " ) . $this -> MaxUID . " <br> " ;
echo _ ( " <b>minGID: </b> " ) . $this -> MinGID . " <br> " ;
echo _ ( " <b>maxGID: </b> " ) . $this -> MaxGID . " <br> " ;
echo _ ( " <b>minMachine: </b> " ) . $this -> MinMachine . " <br> " ;
echo _ ( " <b>maxMachine: </b> " ) . $this -> MaxMachine . " <br> " ;
echo _ ( " <b>userlistAttributes: </b> " ) . $this -> userlistAttributes . " <br> " ;
echo _ ( " <b>grouplistAttributes: </b> " ) . $this -> grouplistAttributes . " <br> " ;
2003-05-07 14:29:44 +00:00
echo _ ( " <b>hostlistAttributes: </b> " ) . $this -> hostlistAttributes . " <br> " ;
2003-05-09 16:22:46 +00:00
echo _ ( " <b>maxlistentries: </b> " ) . $this -> maxlistentries . " <br> " ;
2003-05-12 17:52:54 +00:00
echo _ ( " <b>defaultLanguage: </b> " ) . $this -> defaultLanguage . " <br> " ;
echo _ ( " <b>scriptPath: </b> " ) . $this -> scriptPath . " <br> " ;
2003-05-28 15:37:48 +00:00
echo _ ( " <b>scriptServer: </b> " ) . $this -> scriptServer . " <br> " ;
echo _ ( " <b>Admins: </b> " ) . $this -> Adminstring ;
2003-05-06 23:52:00 +00:00
}
2003-03-08 10:10:19 +00:00
2003-05-06 23:52:00 +00:00
// functions to read/write preferences
2003-05-09 16:22:46 +00:00
2003-05-06 23:52:00 +00:00
// returns the server address as string
function get_ServerURL () {
return $this -> ServerURL ;
}
2003-04-18 15:50:01 +00:00
2003-05-06 23:52:00 +00:00
// sets the server address
function set_ServerURL ( $value ) {
if ( is_string ( $value )) $this -> ServerURL = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_ServerURL failed! " ) . " " . $value . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-09 16:22:46 +00:00
2003-05-06 23:52:00 +00:00
// returns an array of string with all admin names
function get_Admins () {
return $this -> Admins ;
}
2003-05-09 16:22:46 +00:00
2003-05-06 23:52:00 +00:00
// needs an array of string containing all admin users
function set_Admins ( $value ) {
if ( is_array ( $value )) { // check if $value is array of strings
$b = true ;
for ( $i = 0 ; $i < sizeof ( $value ); $i ++ ){
if ( is_string ( $value [ $i ]) == false ) {
$b = false ;
break ;
}
}
if ( $b ) $this -> Admins = $value ;
}
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_Admins failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns all admin users seperated by semicolons
function get_Adminstring () {
return $this -> Adminstring ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// needs a string that contains all admin users seperated by semicolons
function set_Adminstring ( $value ) {
2003-05-28 15:37:48 +00:00
if ( is_string ( $value ) &&
ereg ( " ^([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+(,([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+)+(;([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+(,([a-zA-Z0-9]|-)+=([a-zA-Z0-9]|-)+)+)* $ " , $value )) {
2003-05-06 23:52:00 +00:00
$this -> Adminstring = $value ;
$this -> Admins = explode ( " ; " , $value );
}
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_Adminstring failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the password to access the preferences wizard
function get_Passwd () {
return $this -> Passwd ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the preferences wizard password
function set_Passwd ( $value ) {
if ( is_string ( $value )) $this -> Passwd = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_Passwd failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the LDAP suffix where users are saved
function get_UserSuffix () {
return $this -> Suff_users ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the LDAP suffix where users are saved
function set_UserSuffix ( $value ) {
2003-05-15 19:11:37 +00:00
if ( is_string ( $value ) && ( eregi ( " ^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)* $ " , $value ))) {
2003-05-14 13:45:52 +00:00
$this -> Suff_users = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_UserSuffix failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the LDAP suffix where groups are saved
function get_GroupSuffix () {
return $this -> Suff_groups ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the LDAP suffix where groups are saved
function set_GroupSuffix ( $value ) {
2003-05-15 19:11:37 +00:00
if ( is_string ( $value ) && ( eregi ( " ^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)* $ " , $value ))) {
2003-05-14 13:45:52 +00:00
$this -> Suff_groups = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_GroupSuffix failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the LDAP suffix where hosts are saved
function get_HostSuffix () {
return $this -> Suff_hosts ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the LDAP suffix where hosts are saved
function set_HostSuffix ( $value ) {
2003-05-15 19:11:37 +00:00
if ( is_string ( $value ) && ( eregi ( " ^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)* $ " , $value ))) {
2003-05-14 13:45:52 +00:00
$this -> Suff_hosts = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_HostSuffix failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the minimum UID to use when creating new users
function get_minUID () {
return $this -> MinUID ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the minimum UID to use when creating new users
function set_minUID ( $value ) {
if ( is_numeric ( $value )) $this -> MinUID = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_minUID failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-13 14:40:19 +00:00
2003-05-06 23:52:00 +00:00
// returns the maximum UID to use when creating new users
function get_maxUID () {
return $this -> MaxUID ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the maximum UID to use when creating new users
function set_maxUID ( $value ) {
if ( is_numeric ( $value )) $this -> MaxUID = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_maxUID failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-13 14:40:19 +00:00
2003-05-06 23:52:00 +00:00
// returns the minimum GID to use when creating new groups
function get_minGID () {
return $this -> MinGID ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the minimum GID to use when creating new groups
function set_minGID ( $value ) {
if ( is_numeric ( $value )) $this -> MinGID = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_minGID failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-13 14:40:19 +00:00
2003-05-06 23:52:00 +00:00
// returns the maximum GID to use when creating new groups
function get_maxGID () {
return $this -> MaxGID ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the maximum GID to use when creating new groups
function set_maxGID ( $value ) {
if ( is_numeric ( $value )) $this -> MaxGID = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_maxGID failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-13 14:40:19 +00:00
2003-05-06 23:52:00 +00:00
// returns the minimum UID to use when creating new Samba hosts
function get_minMachine () {
return $this -> MinMachine ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the minimum UID to use when creating new Samba hosts
function set_minMachine ( $value ) {
if ( is_numeric ( $value )) $this -> MinMachine = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_minMachine failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-13 14:40:19 +00:00
2003-05-06 23:52:00 +00:00
// returns the maximum UID to use when creating new Samba hosts
function get_maxMachine () {
return $this -> MaxMachine ;
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// sets the maximum UID to use when creating new Samba hosts
function set_maxMachine ( $value ) {
if ( is_numeric ( $value )) $this -> MaxMachine = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_maxMachine failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
2003-05-06 23:52:00 +00:00
// returns the list of attributes to show in user list
function get_userlistAttributes () {
return $this -> userlistAttributes ;
}
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// sets the list of attributes to show in user list
function set_userlistAttributes ( $value ) {
2003-05-14 13:45:52 +00:00
if ( is_string ( $value ) && eregi ( " ^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))* $ " , $value )) {
$this -> userlistAttributes = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_userlistAttributes failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// returns the list of attributes to show in group list
function get_grouplistAttributes () {
return $this -> grouplistAttributes ;
}
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// sets the list of attributes to show in group list
function set_grouplistAttributes ( $value ) {
2003-05-14 13:45:52 +00:00
if ( is_string ( $value ) && eregi ( " ^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))* $ " , $value )) {
$this -> grouplistAttributes = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_grouplistAttributes failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-30 19:51:47 +00:00
2003-05-06 23:52:00 +00:00
// returns the list of attributes to show in host list
function get_hostlistAttributes () {
return $this -> hostlistAttributes ;
}
// sets the list of attributes to show in host list
function set_hostlistAttributes ( $value ) {
2003-05-14 13:45:52 +00:00
if ( is_string ( $value ) && eregi ( " ^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))* $ " , $value )) {
$this -> hostlistAttributes = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_hostlistAttributes failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-05-14 13:45:52 +00:00
// returns the maximum number of rows in user/group/host lists
2003-05-06 23:52:00 +00:00
function get_MaxListEntries () {
return $this -> maxlistentries ;
}
2003-05-09 16:22:46 +00:00
2003-05-14 13:45:52 +00:00
// sets the maximum number of rows in user/group/host lists
2003-05-06 23:52:00 +00:00
function set_MaxListEntries ( $value ) {
if ( is_numeric ( $value )) $this -> maxlistentries = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_MaxListEntries failed! " ) . $value );
2003-05-09 16:22:46 +00:00
}
// returns the default language string
function get_defaultLanguage () {
return $this -> defaultLanguage ;
}
// sets the default language string
function set_defaultLanguage ( $value ) {
if ( is_string ( $value )) $this -> defaultLanguage = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_defaultLanguage failed! " ) . " " . $value );
2003-05-12 17:52:54 +00:00
}
// returns the path to the external script
function get_scriptPath () {
return $this -> scriptPath ;
}
// sets the path to the external script
function set_scriptPath ( $value ) {
if ( ! $value ) $value = " " ; // optional parameter
if ( is_string ( $value ) && eregi ( " ^()|(/([a-z]|[0-9]|-|_|/)*) $ " , $value )) $this -> scriptPath = $value ;
2003-05-14 13:45:52 +00:00
else StatusMessage ( " WARN " , " " , _ ( " Config->set_scriptPath failed! " ) . " " . $value );
2003-05-12 17:52:54 +00:00
}
// returns the server of the external script
function get_scriptServer () {
return $this -> scriptServer ;
}
// sets the server of the external script
function set_scriptServer ( $value ) {
if ( ! $value ) $value = " " ; // optional parameter
2003-05-28 15:37:48 +00:00
if ( is_string ( $value ) && ( eregi ( " ^[0-9] { 1,3} \\ .[0-9] { 1,3} \\ .[0-9] { 1,3} \\ .[0-9] { 1,3} $ " , $value ) || $value == " " )) {
2003-05-14 13:45:52 +00:00
$this -> scriptServer = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_scriptServer failed! " ) . " " . $value );
2003-05-06 23:52:00 +00:00
}
2003-03-30 19:51:47 +00:00
2003-05-28 15:37:48 +00:00
// returns "yes" if Samba 3.x schema is used, otherwise "no"
function get_samba3 () {
return $this -> samba3 ;
}
// set Samba version: "yes" means 3.x schema, "no" means 2.2.x schema
function set_samba3 ( $value ) {
if ( is_string ( $value ) && eregi ( " ^(yes|no) $ " , $value )) {
$this -> samba3 = $value ;
}
else StatusMessage ( " WARN " , " " , _ ( " Config->set_samba3 failed! " ) . " " . $value );
}
2003-03-30 19:51:47 +00:00
2003-02-17 21:38:54 +00:00
}
2003-03-05 16:05:23 +00:00
2003-03-05 18:38:19 +00:00
?>