added comments, removed double checks, removed session related bug

This commit is contained in:
Roland Gruber 2003-10-11 12:17:28 +00:00
parent 9e8d184b66
commit c535a42f27
3 changed files with 220 additions and 190 deletions

View File

@ -30,16 +30,16 @@ include_once("status.inc");
function setlanguage() {
if ($_SESSION['language']) {
$language = explode(":", $_SESSION['language']);
putenv("LANG=" . $language[0]);
setlocale(LC_ALL, $language[0]);
$locdir = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/locale";
putenv("LANG=" . $language[0]); // e.g. LANG=de_DE
setlocale(LC_ALL, $language[0]); // set LC_ALL to de_DE
$locdir = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/locale"; // set path to translations
bindtextdomain("messages", $locdir);
textdomain("messages");
}
else echo _("Language not defined in session!");
}
// returns an array of String with all available configuration profiles (without .conf)
// returns an array of string with all available configuration profiles (without .conf)
function getConfigProfiles() {
$dir = dir(substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config");
$ret = array();
@ -47,6 +47,7 @@ function getConfigProfiles() {
while ($entry = $dir->read()){
$ext = substr($entry, strlen($entry)-5, 5);
$name = substr($entry, 0, strlen($entry)-5);
// check if extension is right, add to profile list
if ($ext == ".conf") {
$ret[$pos] = $name;
$pos ++;
@ -57,7 +58,7 @@ function getConfigProfiles() {
}
// print meta refresh
// $page is the target page
// $page is the URL of the target page
function metaRefresh($page) {
echo $_SESSION['header'];
echo "<html>\n";
@ -122,6 +123,7 @@ class Config {
var $defaultLanguage;
// Path to external script and server where it is executed
// used for managing quota and home directories
// optional settings, may not be defined
var $scriptPath;
var $scriptServer;
@ -147,6 +149,7 @@ class Config {
// constructor, loads preferences from config file
function Config($file=0) {
// load first profile if none is given
if (!is_string($file)) {
$profiles = getConfigProfiles();
$file = $profiles[0];
@ -162,13 +165,14 @@ class Config {
$file = fopen($conffile, "r");
while (!feof($file)) {
$line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
$line = trim($line); // remove spaces at the beginning and end
if (($line == "")||($line[0] == "#")) continue; // ignore comments and empty lines
// search keywords
for ($i = 0; $i < sizeof($this->settings); $i++) {
$keyword = $this->settings[$i];
$keylen = strlen($keyword);
if (strtolower(substr($line, 0, $keylen + 2)) == strtolower($keyword . ": ")) {
$this->$keyword = chop(substr($line, $keylen + 2, strlen($line) - $keylen -2));
$this->$keyword = substr($line, $keylen + 2, strlen($line) - $keylen -2);
break;
}
}
@ -195,7 +199,7 @@ class Config {
$saved = array(); // includes all settings which have been saved
for ($i = 0; $i < sizeof($file_array); $i++) {
$line = trim($file_array[$i]);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
if (($line == "")||($line[0] == "#")) continue; // ignore comments and empty lines
// search for keywords
for ($k = 0; $k < sizeof($this->settings); $k++) {
$keyword = $this->settings[$k];
@ -287,6 +291,8 @@ class Config {
}
// sets the server address
// $value: new server address
// returns true if $value has correct format
function set_ServerURL($value) {
if (is_string($value)) $this->ServerURL = $value;
else return false;
@ -304,6 +310,8 @@ class Config {
}
// needs a string that contains all admin users seperated by semicolons
// $value: new admin string
// returns true if $value has correct format
function set_Adminstring($value) {
if (is_string($value) &&
eregi("^([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+(;([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+)*$", $value)) {
@ -319,6 +327,8 @@ class Config {
}
// sets the preferences wizard password
// $value: new password
// returns true if $value has correct format
function set_Passwd($value) {
if (is_string($value)) $this->Passwd = $value;
else return false;
@ -331,6 +341,8 @@ class Config {
}
// sets the LDAP suffix where users are saved
// $value: new user suffix
// returns true if $value has correct format
function set_UserSuffix($value) {
if (is_string($value) && (eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $value))) {
$this->usersuffix = $value;
@ -345,6 +357,8 @@ class Config {
}
// sets the LDAP suffix where groups are saved
// $value: new group suffix
// returns true if $value has correct format
function set_GroupSuffix($value) {
if (is_string($value) && (eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $value))) {
$this->groupsuffix = $value;
@ -359,6 +373,8 @@ class Config {
}
// sets the LDAP suffix where hosts are saved
// $value: new host suffix
// returns true if $value has correct format
function set_HostSuffix($value) {
if (is_string($value) && (eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $value))) {
$this->hostsuffix = $value;
@ -373,6 +389,8 @@ class Config {
}
// sets the LDAP suffix where domains are saved
// $value: new domain suffix
// returns true if $value has correct format
function set_DomainSuffix($value) {
if (!$value && ($this->get_Samba3() == "no")) $this->domainsuffix = "";
elseif (is_string($value) && (eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $value))) {
@ -388,6 +406,8 @@ class Config {
}
// sets the minimum UID to use when creating new users
// $value: new minimum UID number
// returns true if $value has correct format
function set_minUID($value) {
if (is_numeric($value)) $this->MinUID = $value;
else return false;
@ -400,6 +420,8 @@ class Config {
}
// sets the maximum UID to use when creating new users
// $value: new maximum UID number
// returns true if $value has correct format
function set_maxUID($value) {
if (is_numeric($value)) $this->MaxUID = $value;
else return false;
@ -412,6 +434,8 @@ class Config {
}
// sets the minimum GID to use when creating new groups
// $value: new minimum GID number
// returns true if $value has correct format
function set_minGID($value) {
if (is_numeric($value)) $this->MinGID = $value;
else return false;
@ -424,6 +448,8 @@ class Config {
}
// sets the maximum GID to use when creating new groups
// $value: new maximum GID number
// returns true if $value has correct format
function set_maxGID($value) {
if (is_numeric($value)) $this->MaxGID = $value;
else return false;
@ -436,6 +462,8 @@ class Config {
}
// sets the minimum UID to use when creating new Samba hosts
// $value: new minimum machine number
// returns true if $value has correct format
function set_minMachine($value) {
if (is_numeric($value)) $this->MinMachine = $value;
else return false;
@ -448,6 +476,8 @@ class Config {
}
// sets the maximum UID to use when creating new Samba hosts
// $value: new maximum machine number
// returns true if $value has correct format
function set_maxMachine($value) {
if (is_numeric($value)) $this->MaxMachine = $value;
else return false;
@ -460,8 +490,10 @@ class Config {
}
// sets the list of attributes to show in user list
// $value: new attribute string
// returns true if $value has correct format
function set_userlistAttributes($value) {
if (is_string($value) && eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $value)) {
if (is_string($value) && eregi("^((#[a-z]+)|([a-z]*:[a-z_\\-]+))(;((#[a-z]+)|([a-z]*:[a-z_\\-]+)))*$", $value)) {
$this->userlistAttributes = $value;
}
else return false;
@ -474,8 +506,10 @@ class Config {
}
// sets the list of attributes to show in group list
// $value: new attribute string
// returns true if $value has correct format
function set_grouplistAttributes($value) {
if (is_string($value) && eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $value)) {
if (is_string($value) && eregi("^((#[a-z]+)|([a-z]*:[a-z_\\-]+))(;((#[a-z]+)|([a-z]*:[a-z_\\-]+)))*$", $value)) {
$this->grouplistAttributes = $value;
}
else return false;
@ -488,8 +522,10 @@ class Config {
}
// sets the list of attributes to show in host list
// $value: new attribute string
// returns true if $value has correct format
function set_hostlistAttributes($value) {
if (is_string($value) && eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $value)) {
if (is_string($value) && eregi("^((#[a-z]+)|([a-z]*:[a-z_\\-]+))(;((#[a-z]+)|([a-z]*:[a-z_\\-]+)))*$", $value)) {
$this->hostlistAttributes = $value;
}
else return false;
@ -502,6 +538,8 @@ class Config {
}
// sets the maximum number of rows in user/group/host lists
// $value: new attribute string
// returns true if $value has correct format
function set_MaxListEntries ($value) {
if (is_numeric($value)) $this->maxlistentries = $value;
else return false;
@ -514,6 +552,8 @@ class Config {
}
// sets the default language string
// $value: new default language
// returns true if $value has correct format
function set_defaultLanguage($value) {
if (is_string($value)) $this->defaultLanguage = $value;
else return false;
@ -526,6 +566,8 @@ class Config {
}
// sets the path to the external script
// $value: new script path
// returns true if $value has correct format
function set_scriptPath($value) {
if (!$value) $this->scriptPath = ""; // optional parameter
elseif (is_string($value) && eregi("^/([a-z0-9_\\-])+(/([a-z0-9_\\.\\-])+)+$", $value)) $this->scriptPath = $value;
@ -539,9 +581,11 @@ class Config {
}
// sets the server of the external script
// $value: new script server
// returns true if $value has correct format
function set_scriptServer($value) {
if (!$value) $value = ""; // optional parameter
if (is_string($value)) {
if (!$value) $this->scriptServer = ""; // optional parameter
elseif (is_string($value) && eregi("^[a-z0-9\\-]+(\\.[a-z0-9\\-]+)*$", $value)) {
$this->scriptServer = $value;
}
else return false;
@ -560,6 +604,8 @@ class Config {
}
// set Samba version: "yes" means 3.x schema, "no" means 2.2.x schema
// $value: "yes"/"no"
// returns true if $value has correct format
function set_samba3($value) {
if (is_string($value) && eregi("^(yes|no)$", $value)) {
$this->samba3 = $value;
@ -570,7 +616,7 @@ class Config {
// returns the LDAP cache timeout in minutes
function get_cacheTimeout() {
if ($this->cachetimeout) return $this->cachetimeout;
if (isset($this->cachetimeout)) return $this->cachetimeout;
else return 5;
}
@ -580,6 +626,8 @@ class Config {
}
// sets the LDAP cache timeout in minutes (0,1,2,5,10,15)
// $value: new cache timeout
// returns true if $value has correct format
function set_cacheTimeout($value) {
if (is_numeric($value) && ($value > -1)) {
$this->cachetimeout = $value;
@ -595,6 +643,8 @@ class Config {
}
// set the password hash type (CRYPT/SHA/SSHA/MD5/SMD5)
// $value: new password hash algorithm
// returns true if $value has correct format
function set_pwdhash($value) {
if (is_string($value) && eregi("^(crypt|sha|ssha|md5|smd5|plain)$", $value)) {
$this->pwdhash = $value;
@ -629,14 +679,15 @@ class CfgMain {
$file = fopen($conffile, "r");
while (!feof($file)) {
$line = fgets($file, 1024);
if (($line == "\n")||($line[0] == "#")) continue; // ignore comments
$line = trim($line); // remove spaces at the beginning and end
if (($line == "")||($line[0] == "#")) continue; // ignore comments
// search keywords
if (substr($line, 0, 10) == "password: ") {
$this->password = chop(substr($line, 10, strlen($line)-10));
$this->password = substr($line, 10, strlen($line)-10);
continue;
}
if (substr($line, 0, 9) == "default: ") {
$this->default = chop(substr($line, 9, strlen($line)-9));
$this->default = substr($line, 9, strlen($line)-9);
continue;
}
}

View File

@ -37,35 +37,32 @@ if ($_POST['back'] || $_POST['submitconf']){
// save settings
if ($_POST['submitconf']){
// save HTTP-POST variables in session
// get data if register_globals is off
if ($_POST['passwd']) $_SESSION['conf_passwd'] = $_POST['passwd'];
if ($_POST['passwd1']) $_SESSION['conf_passwd1'] = $_POST['passwd1'];
if ($_POST['passwd2']) $_SESSION['conf_passwd2'] = $_POST['passwd2'];
if ($_POST['serverurl']) $_SESSION['conf_serverurl'] = $_POST['serverurl'];
if (isset($_POST['cachetimeout'])) $_SESSION['conf_cachetimeout'] = $_POST['cachetimeout'];
if ($_POST['admins']) $_SESSION['conf_admins'] = $_POST['admins'];
if ($_POST['suffusers']) $_SESSION['conf_suffusers'] = $_POST['suffusers'];
if ($_POST['suffgroups']) $_SESSION['conf_suffgroups'] = $_POST['suffgroups'];
if ($_POST['suffhosts']) $_SESSION['conf_suffhosts'] = $_POST['suffhosts'];
if ($_POST['suffdomains']) $_SESSION['conf_suffdomains'] = $_POST['suffdomains'];
if (isset($_POST['minUID'])) $_SESSION['conf_minUID'] = $_POST['minUID'];
if ($_POST['maxUID']) $_SESSION['conf_maxUID'] = $_POST['maxUID'];
if (isset($_POST['minGID'])) $_SESSION['conf_minGID'] = $_POST['minGID'];
if ($_POST['maxGID']) $_SESSION['conf_maxGID'] = $_POST['maxGID'];
if (isset($_POST['minMach'])) $_SESSION['conf_minMach'] = $_POST['minMach'];
if ($_POST['maxMach']) $_SESSION['conf_maxMach'] = $_POST['maxMach'];
if ($_POST['usrlstattr']) $_SESSION['conf_usrlstattr'] = $_POST['usrlstattr'];
if ($_POST['grplstattr']) $_SESSION['conf_grplstattr'] = $_POST['grplstattr'];
if ($_POST['hstlstattr']) $_SESSION['conf_hstlstattr'] = $_POST['hstlstattr'];
if ($_POST['maxlistentries']) $_SESSION['conf_maxlistentries'] = $_POST['maxlistentries'];
if ($_POST['lang']) $_SESSION['conf_lang'] = $_POST['lang'];
if ($_POST['samba3']) $_SESSION['conf_samba3'] = $_POST['samba3'];
if ($_POST['pwdhash']) $_SESSION['conf_pwdhash'] = $_POST['pwdhash'];
if ($_POST['scriptpath']) $_SESSION['conf_scriptpath'] = $_POST['scriptpath'];
else $_SESSION['conf_scriptpath'] = "";
if ($_POST['scriptserver']) $_SESSION['conf_scriptserver'] = $_POST['scriptserver'];
else $_SESSION['conf_scriptserver'] = "";
if ($_POST['filename']) $_SESSION['conf_filename'] = $_POST['filename'];
$_SESSION['conf_passwd'] = $_POST['passwd'];
$_SESSION['conf_passwd1'] = $_POST['passwd1'];
$_SESSION['conf_passwd2'] = $_POST['passwd2'];
$_SESSION['conf_serverurl'] = $_POST['serverurl'];
$_SESSION['conf_cachetimeout'] = $_POST['cachetimeout'];
$_SESSION['conf_admins'] = $_POST['admins'];
$_SESSION['conf_suffusers'] = $_POST['suffusers'];
$_SESSION['conf_suffgroups'] = $_POST['suffgroups'];
$_SESSION['conf_suffhosts'] = $_POST['suffhosts'];
$_SESSION['conf_suffdomains'] = $_POST['suffdomains'];
$_SESSION['conf_minUID'] = $_POST['minUID'];
$_SESSION['conf_maxUID'] = $_POST['maxUID'];
$_SESSION['conf_minGID'] = $_POST['minGID'];
$_SESSION['conf_maxGID'] = $_POST['maxGID'];
$_SESSION['conf_minMach'] = $_POST['minMach'];
$_SESSION['conf_maxMach'] = $_POST['maxMach'];
$_SESSION['conf_usrlstattr'] = $_POST['usrlstattr'];
$_SESSION['conf_grplstattr'] = $_POST['grplstattr'];
$_SESSION['conf_hstlstattr'] = $_POST['hstlstattr'];
$_SESSION['conf_maxlistentries'] = $_POST['maxlistentries'];
$_SESSION['conf_lang'] = $_POST['lang'];
$_SESSION['conf_samba3'] = $_POST['samba3'];
$_SESSION['conf_pwdhash'] = $_POST['pwdhash'];
$_SESSION['conf_scriptpath'] = $_POST['scriptpath'];
$_SESSION['conf_scriptserver'] = $_POST['scriptserver'];
$_SESSION['conf_filename'] = $_POST['filename'];
metaRefresh("confsave.php");
}
// back to login

View File

@ -34,32 +34,32 @@ setlanguage();
$conf = new Config($_SESSION['conf_filename']);
// get data from session
if ($_SESSION['conf_passwd']) $passwd = $_SESSION['conf_passwd'];
if ($_SESSION['conf_passwd1']) $passwd1 = $_SESSION['conf_passwd1'];
if ($_SESSION['conf_passwd2']) $passwd2 = $_SESSION['conf_passwd2'];
if ($_SESSION['conf_serverurl']) $serverurl = $_SESSION['conf_serverurl'];
if (isset($_SESSION['conf_cachetimeout'])) $cachetimeout = $_SESSION['conf_cachetimeout'];
if ($_SESSION['conf_admins']) $admins = $_SESSION['conf_admins'];
if ($_SESSION['conf_suffusers']) $suffusers = $_SESSION['conf_suffusers'];
if ($_SESSION['conf_suffgroups']) $suffgroups = $_SESSION['conf_suffgroups'];
if ($_SESSION['conf_suffhosts']) $suffhosts = $_SESSION['conf_suffhosts'];
if ($_SESSION['conf_suffdomains']) $suffdomains = $_SESSION['conf_suffdomains'];
if (isset($_SESSION['conf_minUID'])) $minUID = $_SESSION['conf_minUID'];
if ($_SESSION['conf_maxUID']) $maxUID = $_SESSION['conf_maxUID'];
if (isset($_SESSION['conf_minGID'])) $minGID = $_SESSION['conf_minGID'];
if ($_SESSION['conf_maxGID']) $maxGID = $_SESSION['conf_maxGID'];
if (isset($_SESSION['conf_minMach'])) $minMach = $_SESSION['conf_minMach'];
if ($_SESSION['conf_maxMach']) $maxMach = $_SESSION['conf_maxMach'];
if ($_SESSION['conf_usrlstattr']) $usrlstattr = $_SESSION['conf_usrlstattr'];
if ($_SESSION['conf_grplstattr']) $grplstattr = $_SESSION['conf_grplstattr'];
if ($_SESSION['conf_hstlstattr']) $hstlstattr = $_SESSION['conf_hstlstattr'];
if ($_SESSION['conf_maxlistentries']) $maxlistentries = $_SESSION['conf_maxlistentries'];
if ($_SESSION['conf_lang']) $lang = $_SESSION['conf_lang'];
if ($_SESSION['conf_scriptpath']) $scriptpath = $_SESSION['conf_scriptpath'];
if ($_SESSION['conf_scriptserver']) $scriptserver = $_SESSION['conf_scriptserver'];
if ($_SESSION['conf_samba3']) $samba3 = $_SESSION['conf_samba3'];
if ($_SESSION['conf_pwdhash']) $pwdhash = $_SESSION['conf_pwdhash'];
if ($_SESSION['conf_filename']) $filename = $_SESSION['conf_filename'];
$passwd = $_SESSION['conf_passwd'];
$passwd1 = $_SESSION['conf_passwd1'];
$passwd2 = $_SESSION['conf_passwd2'];
$serverurl = $_SESSION['conf_serverurl'];
$cachetimeout = $_SESSION['conf_cachetimeout'];
$admins = $_SESSION['conf_admins'];
$suffusers = $_SESSION['conf_suffusers'];
$suffgroups = $_SESSION['conf_suffgroups'];
$suffhosts = $_SESSION['conf_suffhosts'];
$suffdomains = $_SESSION['conf_suffdomains'];
$minUID = $_SESSION['conf_minUID'];
$maxUID = $_SESSION['conf_maxUID'];
$minGID = $_SESSION['conf_minGID'];
$maxGID = $_SESSION['conf_maxGID'];
$minMach = $_SESSION['conf_minMach'];
$maxMach = $_SESSION['conf_maxMach'];
$usrlstattr = $_SESSION['conf_usrlstattr'];
$grplstattr = $_SESSION['conf_grplstattr'];
$hstlstattr = $_SESSION['conf_hstlstattr'];
$maxlistentries = $_SESSION['conf_maxlistentries'];
$lang = $_SESSION['conf_lang'];
$scriptpath = $_SESSION['conf_scriptpath'];
$scriptserver = $_SESSION['conf_scriptserver'];
$samba3 = $_SESSION['conf_samba3'];
$pwdhash = $_SESSION['conf_pwdhash'];
$filename = $_SESSION['conf_filename'];
// check if password is correct
// if not: load login page
@ -78,139 +78,121 @@ echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\">"
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>");
// check new preferences
if (!$serverurl) {
echo ("<font color=\"red\"><b>" . _("Server Address is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!isset($cachetimeout) || !(is_numeric($cachetimeout)) || !($cachetimeout > -1)) {
echo ("<font color=\"red\"><b>" . _("Cache timeout is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$admins || !eregi("^([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+(;([a-z0-9]|-)+=([a-z0-9]|-)+(,([a-z0-9]|-)+=([a-z0-9]|-)+)+)*$", $admins)) {
echo ("<font color=\"red\"><b>" . _("List of admin users is empty or invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffusers || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffusers)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffgroups || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffgroups)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$suffhosts || !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffhosts)) {
echo ("<font color=\"red\"><b>" . _("HostSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (($samba3 == "yes") && !eregi("^(([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)(,([a-z]|-|[0-9])*=([a-z]|-|[0-9])*)*$", $suffdomains)) {
echo ("<font color=\"red\"><b>" . _("DomainSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!isset($minUID) || !is_numeric($minUID)) {
echo ("<font color=\"red\"><b>" . _("MinUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxUID || !is_numeric($maxUID)) {
echo ("<font color=\"red\"><b>" . _("MaxUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!isset($minGID) || !is_numeric($minGID)) {
echo ("<font color=\"red\"><b>" . _("MinGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxGID || !is_numeric($maxGID)) {
echo ("<font color=\"red\"><b>" . _("MaxGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!isset($minMach) || !is_numeric($minMach)) {
echo ("<font color=\"red\"><b>" . _("MinMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxMach || !is_numeric($maxMach)) {
echo ("<font color=\"red\"><b>" . _("MaxMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$usrlstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $usrlstattr)) {
echo ("<font color=\"red\"><b>" . _("User list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$grplstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $grplstattr)) {
echo ("<font color=\"red\"><b>" . _("Group list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$hstlstattr || !eregi("^((#[a-z]*)|([a-z]*:[a-z*]))(;((#[a-z]*)|([a-z]*:[a-z]*)))*$", $hstlstattr)) {
echo ("<font color=\"red\"><b>" . _("Host list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$maxlistentries || !is_numeric($maxlistentries)) {
echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$lang) {
echo ("<font color=\"red\"><b>" . _("Language is not defined!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$samba3) {
if (!$conf->set_samba3($samba3)) {
echo ("<font color=\"red\"><b>" . _("Samba version is not defined!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if ($scriptpath && !eregi("^/[a-z0-9_\\-]+(/[a-z0-9_\\.\\-]+)+$", $scriptpath)) {
if (!$conf->set_ServerURL($serverurl)) {
echo ("<font color=\"red\"><b>" . _("Server Address is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_cacheTimeout($cachetimeout)) {
echo ("<font color=\"red\"><b>" . _("Cache timeout is empty!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Adminstring($admins)) {
echo ("<font color=\"red\"><b>" . _("List of admin users is empty or invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_UserSuffix($suffusers)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_GroupSuffix($suffgroups)) {
echo ("<font color=\"red\"><b>" . _("GroupSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_HostSuffix($suffhosts)) {
echo ("<font color=\"red\"><b>" . _("HostSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_DomainSuffix($suffdomains)) {
echo ("<font color=\"red\"><b>" . _("DomainSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minUID($minUID)) {
echo ("<font color=\"red\"><b>" . _("MinUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxUID($maxUID)) {
echo ("<font color=\"red\"><b>" . _("MaxUID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minGID($minGID)) {
echo ("<font color=\"red\"><b>" . _("MinGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxGID($maxGID)) {
echo ("<font color=\"red\"><b>" . _("MaxGID is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_minMachine($minMach)) {
echo ("<font color=\"red\"><b>" . _("MinMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_maxMachine($maxMach)) {
echo ("<font color=\"red\"><b>" . _("MaxMachine is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_userlistAttributes($usrlstattr)) {
echo ("<font color=\"red\"><b>" . _("User list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_grouplistAttributes($grplstattr)) {
echo ("<font color=\"red\"><b>" . _("Group list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_hostlistAttributes($hstlstattr)) {
echo ("<font color=\"red\"><b>" . _("Host list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_MaxListEntries($maxlistentries)) {
echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_defaultLanguage($lang)) {
echo ("<font color=\"red\"><b>" . _("Language is not defined!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_scriptpath($scriptpath)) {
echo ("<font color=\"red\"><b>" . _("Script path is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if ($scriptserver && !is_string($scriptserver)) {
if (!$conf->set_scriptserver($scriptserver)) {
echo ("<font color=\"red\"><b>" . _("Script server is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
// set new preferences
$conf->set_ServerURL($serverurl);
$conf->set_cacheTimeout($cachetimeout);
$conf->set_Adminstring($admins);
$conf->set_UserSuffix($suffusers);
$conf->set_GroupSuffix($suffgroups);
$conf->set_HostSuffix($suffhosts);
$conf->set_DomainSuffix($suffdomains);
$conf->set_minUID($minUID);
$conf->set_maxUID($maxUID);
$conf->set_minGID($minGID);
$conf->set_maxGID($maxGID);
$conf->set_minMachine($minMach);
$conf->set_maxMachine($maxMach);
$conf->set_userlistAttributes($usrlstattr);
$conf->set_grouplistAttributes($grplstattr);
$conf->set_hostlistAttributes($hstlstattr);
$conf->set_MaxListEntries($maxlistentries);
$conf->set_defaultLanguage($lang);
$conf->set_samba3($samba3);
$conf->set_scriptpath($scriptpath);
$conf->set_scriptserver($scriptserver);
$conf->set_pwdhash($pwdhash);
if (!$conf->set_pwdhash($pwdhash)) {
echo ("<font color=\"red\"><b>" . _("Password hash is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}