diff --git a/lam/config/lam.conf_sample b/lam/config/lam.conf_sample index 86e7bad2..8f86b9f9 100644 --- a/lam/config/lam.conf_sample +++ b/lam/config/lam.conf_sample @@ -64,3 +64,9 @@ maxlistentries: 30 # default language (a line from language.conf) defaultLanguage: de_DE:iso639_de:Deutsch (Deutschland) + +# Path to external Script +scriptPath: + +# Server of external Script +scriptServer: diff --git a/lam/config/language.conf b/lam/config/language.conf index 7365cce1..2080bbc6 100644 --- a/lam/config/language.conf +++ b/lam/config/language.conf @@ -7,4 +7,8 @@ en_GB:iso639_en:English (Britain) # German Language -de_DE:iso639_de:Deutsch (Deutschland) \ No newline at end of file +de_DE:iso639_de:Deutsch (Deutschland) + +# German Language +fr_FR:iso639_fr:Francais (France) + diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 6c687882..21be449b 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -80,6 +80,11 @@ class Config { // default language var $defaultLanguage; + // Path to external script and server where it is executed + // optional settings, may not be defined + var $scriptPath; + var $scriptServer; + // constructor, loads preferences from ../config/lam.conf function Config() { $this->reload(); @@ -164,6 +169,14 @@ class Config { $this->defaultLanguage = chop(substr($line, 17, strlen($line)-17)); continue; } + 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; + } } fclose($file); } @@ -186,7 +199,8 @@ class Config { // 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 = - $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $save_maxlstent = $save_deflang = False; + $save_usrlstatrr = $save_grplstatrr = $save_hstlstatrr = $save_maxlstent = $save_deflang = + $save_scriptPath = $save_scriptServer = False; $file = fopen($conffile, "r"); $file_array = array(); while (!feof($file)) { @@ -281,18 +295,28 @@ class Config { $save_deflang = True; continue; } + 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; + } } // 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" . - "# names have to be seperated by semicolons\n" . + "# names have to be seperated by semicolons\n" . "# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins); - if (!$save_suffusr == True) array_push($file_array, "\n\n# suffix of users\n" . + if (!$save_suffusr == True) array_push($file_array, "\n\n# suffix of users\n" . "# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->Suff_users); - if (!$save_suffgrp == True) array_push($file_array, "\n\n# suffix of groups\n" . + if (!$save_suffgrp == True) array_push($file_array, "\n\n# suffix of groups\n" . "# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->Suff_groups); - if (!$save_suffhst == True) array_push($file_array, "\n\n# suffix of Samba hosts\n" . + if (!$save_suffhst == True) array_push($file_array, "\n\n# suffix of Samba hosts\n" . "# 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); @@ -308,6 +332,8 @@ class Config { "\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes); 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); if (!$save_deflang == True) array_push($file_array, "\n\n# default language (a line from language.conf)\n" . "defaultLanguage: " . $this->defaultLanguage); + 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); $file = fopen($conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -337,7 +363,9 @@ class Config { echo _("grouplistAttributes: ") . $this->grouplistAttributes . "
"; echo _("hostlistAttributes: ") . $this->hostlistAttributes . "
"; echo _("maxlistentries: ") . $this->maxlistentries . "
"; - echo _("defaultLanguage: ") . $this->defaultLanguage; + echo _("defaultLanguage: ") . $this->defaultLanguage . "
"; + echo _("scriptPath: ") . $this->scriptPath . "
"; + echo _("scriptServer: ") . $this->scriptServer; } // functions to read/write preferences @@ -350,7 +378,7 @@ class Config { // sets the server address function set_ServerURL($value) { if (is_string($value)) $this->ServerURL = $value; - else echo _("Config->set_ServerURL failed!"); + else echo _("Config->set_ServerURL failed!") . " " . $value . " " . $value; } // returns an array of string with all admin names @@ -370,7 +398,7 @@ class Config { } if ($b) $this->Admins = $value; } - else echo _("Config->set_Admins failed!"); + else echo _("Config->set_Admins failed!") . " " . $value; } // returns all admin users seperated by semicolons @@ -384,7 +412,7 @@ class Config { $this->Adminstring = $value; $this->Admins = explode(";", $value); } - else echo _("Config->set_Adminstring failed!"); + else echo _("Config->set_Adminstring failed!") . " " . $value; } // returns the password to access the preferences wizard @@ -395,7 +423,7 @@ class Config { // sets the preferences wizard password function set_Passwd($value) { if (is_string($value)) $this->Passwd = $value; - else echo _("Config->set_Passwd failed!"); + else echo _("Config->set_Passwd failed!") . " " . $value; } // returns the LDAP suffix where users are saved @@ -406,7 +434,7 @@ class Config { // sets the LDAP suffix where users are saved function set_UserSuffix($value) { if (is_string($value)) $this->Suff_users = $value; - else echo _("Config->set_UserSuffix failed!"); + else echo _("Config->set_UserSuffix failed!") . " " . $value; } // returns the LDAP suffix where groups are saved @@ -417,7 +445,7 @@ class Config { // sets the LDAP suffix where groups are saved function set_GroupSuffix($value) { if (is_string($value)) $this->Suff_groups = $value; - else echo _("Config->set_GroupSuffix failed!"); + else echo _("Config->set_GroupSuffix failed!") . " " . $value; } // returns the LDAP suffix where hosts are saved @@ -428,7 +456,7 @@ class Config { // sets the LDAP suffix where hosts are saved function set_HostSuffix($value) { if (is_string($value)) $this->Suff_hosts = $value; - else echo _("Config->set_HostSuffix failed!"); + else echo _("Config->set_HostSuffix failed!") . " " . $value; } // returns the minimum UID to use when creating new users @@ -439,7 +467,7 @@ class Config { // sets the minimum UID to use when creating new users function set_minUID($value) { if (is_numeric($value)) $this->MinUID = $value; - else echo _("Config->set_minUID failed!"); + else echo _("Config->set_minUID failed!") . " " . $value; } // returns the maximum UID to use when creating new users @@ -450,7 +478,7 @@ class Config { // sets the maximum UID to use when creating new users function set_maxUID($value) { if (is_numeric($value)) $this->MaxUID = $value; - else echo _("Config->set_maxUID failed!"); + else echo _("Config->set_maxUID failed!") . " " . $value; } // returns the minimum GID to use when creating new groups @@ -461,7 +489,7 @@ class Config { // sets the minimum GID to use when creating new groups function set_minGID($value) { if (is_numeric($value)) $this->MinGID = $value; - else echo _("Config->set_minGID failed!"); + else echo _("Config->set_minGID failed!") . " " . $value; } // returns the maximum GID to use when creating new groups @@ -472,7 +500,7 @@ class Config { // sets the maximum GID to use when creating new groups function set_maxGID($value) { if (is_numeric($value)) $this->MaxGID = $value; - else echo _("Config->set_maxGID failed!"); + else echo _("Config->set_maxGID failed!") . " " . $value; } // returns the minimum UID to use when creating new Samba hosts @@ -483,7 +511,7 @@ class Config { // sets the minimum UID to use when creating new Samba hosts function set_minMachine($value) { if (is_numeric($value)) $this->MinMachine = $value; - else echo _("Config->set_minMachine failed!"); + else echo _("Config->set_minMachine failed!") . " " . $value; } // returns the maximum UID to use when creating new Samba hosts @@ -494,7 +522,7 @@ class Config { // sets the maximum UID to use when creating new Samba hosts function set_maxMachine($value) { if (is_numeric($value)) $this->MaxMachine = $value; - else echo _("Config->set_maxMachine failed!"); + else echo _("Config->set_maxMachine failed!") . " " . $value; } // returns the list of attributes to show in user list @@ -505,7 +533,7 @@ class Config { // sets the list of attributes to show in user list function set_userlistAttributes($value) { if (is_string($value)) $this->userlistAttributes = $value; - else echo _("Config->set_userlistAttributes failed!"); + else echo _("Config->set_userlistAttributes failed!") . " " . $value; } // returns the list of attributes to show in group list @@ -516,7 +544,7 @@ class Config { // sets the list of attributes to show in group list function set_grouplistAttributes($value) { if (is_string($value)) $this->grouplistAttributes = $value; - else echo _("Config->set_grouplistAttributes failed!"); + else echo _("Config->set_grouplistAttributes failed!") . " " . $value; } // returns the list of attributes to show in host list @@ -527,7 +555,7 @@ class Config { // sets the list of attributes to show in host list function set_hostlistAttributes($value) { if (is_string($value)) $this->hostlistAttributes = $value; - else echo _("Config->set_hostlistAttributes failed!"); + else echo _("Config->set_hostlistAttributes failed!") . " " . $value; } /** @@ -560,7 +588,31 @@ class Config { // sets the default language string function set_defaultLanguage($value) { if (is_string($value)) $this->defaultLanguage = $value; - else echo _("Config->set_defaultLanguage failed!"); + else echo _("Config->set_defaultLanguage failed!") . " " . $value; + } + + // 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; + else echo _("Config->set_scriptPath failed!") . " " . $value; + } + + // 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 + if (is_string($value)) $this->scriptServer = $value; + else echo _("Config->set_scriptServer failed!") . " " . $value; } diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 6fb33df3..261fa5c6 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -55,9 +55,12 @@ if ($_POST['back'] || $_POST['submitconf']){ if ($_POST['hstlstattr']) $hstlstattr = $_POST['hstlstattr']; if ($_POST['maxlistentries']) $maxlistentries = $_POST['maxlistentries']; if ($_POST['language']) $language = $_POST['language']; + if ($_POST['scriptpath']) $scriptpath = $_POST['scriptpath']; + if ($_POST['scriptserver']) $scriptserver = $_POST['scriptserver']; session_register('passwd', 'passwd1', 'passwd2', 'serverurl', 'admins', 'suffusers', 'suffgroups', 'suffhosts', 'minUID', 'maxUID', 'minGID', 'maxGID', 'minMach', - 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries', 'language'); + 'maxMach', 'usrlstattr', 'grplstattr', 'hstlstattr', 'maxlistentries', 'language', + 'scriptpath', 'scriptserver'); echo(""); } // back to login @@ -226,15 +229,16 @@ echo ("

". _("This is the maximum count of entries which are displayed on one page of the user/host/group lists."). "

\n"); -echo (""); -echo (""); -echo ("
"); +echo ("\n"); +echo ("\n"); +echo ("
\n"); -echo ("
" . _("Language settings") . ""); -echo (""); +echo ("
" . _("Language settings") . "\n"); +echo ("
\n"); // language -echo (""); +echo ("\n"); +echo ("\n"); echo ("
"); +echo ("
" . _("Default Language") . ""); // read available languages $languagefile = "../../config/language.conf"; if(is_file($languagefile)) @@ -244,8 +248,8 @@ if(is_file($languagefile)) while(!feof($file)) { $line = fgets($file, 1024); - if($line == "\n" || $line[0] == "#") continue; // ignore comment and empty lines - $languages[$i] = $line; + if($line == "\n" || $line[0] == "#" || $line == "") continue; // ignore comment and empty lines + $languages[$i] = chop($line); $i++; } fclose($file); @@ -253,29 +257,43 @@ if(is_file($languagefile)) echo (""); +echo ("\n"); } else { - echo _("Unable to load available languages. For further instructions please contact the Admin of this site."); + echo _("Unable to load available languages. For further instructions please contact the Admin of this site.\n"); } - - -echo ("
\n"); -echo ("
"); -echo ("
"); +echo ("\n"); +echo ("
\n"); -echo ("
" . _("Security settings") . ""); -echo (""); +echo ("
" . _("Script settings") . "\n"); +echo ("
\n"); + +// script settings +echo ("". + "\n"); +echo ("". + "\n"); + +echo ("

". + _("Path to external script") . ":

get_scriptPath() . "\">

". + _("Server of external script") . ":

get_scriptServer() . "\">
\n"); +echo ("
\n"); +echo ("
\n"); + + +echo ("
" . _("Security settings") . "\n"); +echo ("\n"); // new password echo ("". - ""); + "\n"); // reenter password echo ("". @@ -291,7 +309,7 @@ echo ("
". _("New Password") . ":
". _("Reenter Password") . ":
"); echo ("\n"); diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index 5494e113..5faf44fc 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -51,6 +51,8 @@ if ($_SESSION['grplstattr']) $grplstattr = $_SESSION['grplstattr']; if ($_SESSION['hstlstattr']) $hstlstattr = $_SESSION['hstlstattr']; if ($_SESSION['maxlistentries']) $maxlistentries = $_SESSION['maxlistentries']; if ($_SESSION['language']) $language = $_SESSION['language']; +if ($_SESSION['scriptpath']) $scriptpath = $_SESSION['scriptpath']; +if ($_SESSION['scriptserver']) $scriptserver = $_SESSION['scriptserver']; // check if password is correct // if not: load login page @@ -139,6 +141,12 @@ if (chop($maxlistentries) == "") { exit; } +if (chop($language) == "") { + echo _("" . _("Language is not defined!") . ""); + echo ("\n


" . _("Back to preferences...") . ""); + exit; +} + // set new preferences $conf->set_ServerURL($serverurl); $conf->set_Adminstring($admins); @@ -156,6 +164,11 @@ $conf->set_grouplistAttributes($grplstattr); $conf->set_hostlistAttributes($hstlstattr); $conf->set_MaxListEntries($maxlistentries); $conf->set_defaultLanguage($language); +// optional +if ($_SESSION['scriptpath']) $conf->set_scriptpath($scriptpath); +else $conf->set_scriptpath(""); +if ($_SESSION['scriptserver']) $conf->set_scriptserver($scriptserver); +else $conf->set_scriptserver(""); @@ -194,4 +207,7 @@ unset($_SESSION['grplstattr']); unset($_SESSION['hstlstattr']); unset($_SESSION['maxlistentries']); unset($_SESSION['language']); +unset($_SESSION['scriptpath']); +unset($_SESSION['scriptserver']); + ?> diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index 3239637d..69b466a4 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -48,6 +48,8 @@ $grouplistAttributes = $conf->get_grouplistAttributes(); $hostlistAttributes = $conf->get_hostlistAttributes(); $maxlistentries = $conf->get_maxlistentries(); $defaultlanguage = $conf->get_defaultlanguage(); +$scriptpath = $conf->get_scriptPath(); +$scriptServer = $conf->get_scriptServer(); echo ("done
"); // next we modify them and save lam.conf echo ("Changing preferences..."); @@ -69,6 +71,8 @@ $conf->set_grouplistAttributes("#gidNumber;#cn;#memberUID"); $conf->set_hostlistAttributes("#cn;#uid;#description"); $conf->set_maxlistentries("54"); $conf->set_defaultlanguage("de_AT:iso639_de:Deutsch (Oesterreich)"); +$conf->set_scriptPath("/var/www/lam/lib/script"); +$conf->set_scriptServer("127.0.0.1"); $conf->save(); echo ("done
"); // at last all preferences are read from lam.conf and compared @@ -94,6 +98,8 @@ if ($conf->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("
if ($conf->get_hostlistAttributes() != "#cn;#uid;#description") echo ("
Saving hostlistAttributes failed!
"); if ($conf->get_maxlistentries() != "54") echo ("
Saving maxlistentries failed!
"); if ($conf->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") echo ("
Saving default language failed!
"); +if ($conf->get_scriptPath() != "/var/www/lam/lib/script") echo ("
Saving script path failed!
"); +if ($conf->get_scriptServer() != "127.0.0.1") echo ("
Saving script server failed!
"); echo ("done
"); // restore old values echo ("Restoring old preferences..."); @@ -115,6 +121,8 @@ $conf->set_grouplistAttributes($grouplistAttributes); $conf->set_hostlistAttributes($hostlistAttributes); $conf->set_maxlistentries($maxlistentries); $conf->set_defaultLanguage($defaultlanguage); +$conf->set_scriptPath($scriptpath); +$conf->set_scriptServer($scriptserver); $conf->save(); echo ("done
"); // finished
".
 	"".
 	"".
-	"