X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Ffunctions.inc;h=9b3b4606062fe44eeb8a71f0331516789d854948;hb=2aeab3942abfef8c64c1377992d73082227be400;hp=3abd10ff027470995b14001ca5231f92010513c3;hpb=8f499de9ae42ee3fe80bb0d4f4d575d1e6807294;p=gosa.git
diff --git a/include/functions.inc b/include/functions.inc
index 3abd10ff0..9b3b46060 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -20,6 +20,7 @@
/* Configuration file location */
define ("CONFIG_DIR", "/etc/gosa");
+define ("CONFIG_FILE", "gosa.conf");
define ("CONFIG_TEMPLATE_DIR", "../contrib/");
define ("HELP_BASEDIR", "/var/www/doc/");
@@ -44,6 +45,7 @@ require_once ("class_mail-methods.inc");
require_once("class_password-methods.inc");
require_once ("functions_debug.inc");
require_once ("functions_dns.inc");
+require_once ("accept-to-gettext.inc");
require_once ("class_MultiSelectWindow.inc");
/* Define constants for debugging */
@@ -145,46 +147,35 @@ function DEBUG($level, $line, $function, $file, $data, $info="")
}
-/* Simple function to get browser language and convert it to
- xx_XY needed by locales. Ignores sublanguages and weights. */
function get_browser_language()
{
- global $BASE_DIR;
-
/* Try to use users primary language */
+ global $config;
$ui= get_userinfo();
if ($ui != NULL){
if ($ui->language != ""){
- return ($ui->language);
+ return ($ui->language.".UTF-8");
}
}
- /* Get list of languages */
- if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
- $lang= preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
- $languages= split (',', $lang);
- $languages[]= "C";
- } else {
- $languages= array("C");
+ /* Try to use users primary language */
+ if ($ui != NULL){
+ if ($ui->language != ""){
+ return ($ui->language.".UTF-8");
+ }
}
- /* Walk through languages and get first supported */
- foreach ($languages as $val){
-
- /* Strip off weight */
- $lang= preg_replace("/;q=.*$/i", "", $val);
+ /* Load supported languages */
+ $gosa_languages= get_languages();
- /* Simplify sub language handling */
- $lang= preg_replace("/-.*$/", "", $lang);
-
- /* Cancel loop if available in GOsa, or the last
- entry has been reached */
- if (is_dir("$BASE_DIR/locale/$lang")){
- break;
- }
+ /* Move supported languages to flat list */
+ $langs= array();
+ foreach($gosa_languages as $lang => $dummy){
+ $langs[]= $lang.'.UTF-8';
}
- return (strtolower($lang)."_".strtoupper($lang));
+ /* Return gettext based string */
+ return (al2gt($langs, 'text/html'));
}
@@ -290,7 +281,8 @@ function ldap_init ($server, $base, $binddn='', $pass='')
{
global $config;
- $ldap = new LDAP ($binddn, $pass, $server, isset($config->current['RECURSIVE']) && $config->current['RECURSIVE'] == "true",
+ $ldap = new LDAP ($binddn, $pass, $server,
+ isset($config->current['RECURSIVE']) && $config->current['RECURSIVE'] == "true",
isset($config->current['TLS']) && $config->current['TLS'] == "true");
/* Sadly we've no proper return values here. Use the error message instead. */
@@ -475,7 +467,7 @@ function add_lock ($object, $user)
$ldap->search("(&(objectClass=gosaLockEntry)(gosaUser=$user)(gosaObject=".base64_encode($object)."))",
array("gosaUser"));
if (!preg_match("/Success/i", $ldap->error)){
- print_red (sprintf(_("Can't set locking information in LDAP database. Please check the 'config' entry in gosa.conf! LDAP server says '%s'."), $ldap->get_error()));
+ print_red (sprintf(_("Can't set locking information in LDAP database. Please check the 'config' entry in %s! LDAP server says '%s'."),CONFIG_FILE, $ldap->get_error()));
return;
}
@@ -556,7 +548,7 @@ function get_lock ($object)
$ldap->cd ($config->current['CONFIG']);
$ldap->search("(&(objectClass=gosaLockEntry)(gosaObject=".base64_encode($object)."))", array("gosaUser"));
if (!preg_match("/Success/i", $ldap->error)){
- print_red (_("Can't get locking information in LDAP database. Please check the 'config' entry in gosa.conf!"));
+ print_red (sprintf(_("Can't get locking information in LDAP database. Please check the 'config' entry in %s!"),CONFIG_FILE));
return("");
}
@@ -973,7 +965,7 @@ function is_uid($uid)
/* STRICT adds spaces and case insenstivity to the uid check.
This is dangerous and should not be used. */
- if (isset($config->current['STRICT']) && preg_match('/^no$/i', $config->current['STRICT'])){
+ if (isset($config->current['STRICT']) && preg_match('/^(no|false)$/i', $config->current['STRICT'])){
return preg_match ("/^[a-z0-9 _.-]+$/i", $uid);
} else {
return preg_match ("/^[a-z0-9_-]+$/", $uid);
@@ -986,6 +978,13 @@ function is_ip($ip)
return preg_match("/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/", $ip);
}
+
+function is_mac($mac)
+{
+ return preg_match("/^[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]$/i", $mac);
+}
+
+
/* Checks if the given ip address doesn't match
"is_ip" because there is also a sub net mask given */
function is_ip_with_subnetmask($ip)
@@ -1118,15 +1117,62 @@ function print_red()
}
if(isset($_SESSION['errors']) && strlen($_SESSION['errors'])==0) {
- $_SESSION['errors'].= "