index 146372120e882eb291efb5b398471ecb50238185..d14308bcb45988897ccb484c7606655a47c14ebe 100644 (file)
/*! \file
* Common functions and named definitions. */
+/* Define globals for revision comparing */
+$svn_path = '$HeadURL$';
+$svn_revision = '$Revision$';
+
/* Configuration file location */
if(!isset($_SERVER['CONFIG_DIR'])){
define ("CONFIG_DIR", "/etc/gosa");
define('DES3_CBC_MD5',5);
define('DES3_CBC_SHA1',16);
-/* Define globals for revision comparing */
-$svn_path = '$HeadURL$';
-$svn_revision = '$Revision$';
-
/* Include required files */
-require_once("class_location.inc");
+include_once("class_location.inc");
require_once ("functions_debug.inc");
require_once ("accept-to-gettext.inc");
// Fetch required attributes
foreach(array('shadowExpire','shadowLastChange','shadowMax','shadowMin',
- 'shadowInactive','shadowWarning') as $attr){
+ 'shadowInactive','shadowWarning','sambaKickoffTime') as $attr){
$$attr = (isset($attrs[$attr][0]))? $attrs[$attr][0] : null;
}
+ // Check if the account has reached its kick off limitations.
+ // ---------------------------------------------------------
+ // Once the accout reaches the kick off limit it has expired.
+ if($sambaKickoffTime !== null){
+ if(time() >= $sambaKickoffTime){
+ return(POSIX_ACCOUNT_EXPIRED);
+ }
+ }
+
+
// Check if the account has expired.
// ---------------------------------
// An account is locked/expired once its expiration date has reached (shadowExpire).
// If the optional attribute (shadowInactive) is set, we've to postpone
// the account expiration by the amount of days specified in (shadowInactive).
- if($shadowExpire != null && $shadowExpire >= $current){
+ if($shadowExpire != null && $shadowExpire <= $current){
// The account seems to be expired, but we've to check 'shadowInactive' additionally.
// ShadowInactive specifies an amount of days we've to reprieve the user.
global $config;
if(!$config->configRegistry->propertyExists($class,$name)){
- trigger_error("No department mapping found for type ".$name);
+ if($config->boolValueIsTrue("core","developmentMode")){
+ trigger_error("No department mapping found for type ".$name);
+ }
return "";
}
@@ -2878,9 +2890,14 @@ function change_password ($dn, $password, $mode=FALSE, $hash= "", $old_password
$attrs= array();
if (!$mode && !empty($tmp)){
$attrs= generate_smb_nt_hash($password);
- $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0;
- if ($shadow != 0){
- $attrs['shadowLastChange']= $shadow;
+ if(!count($attrs) || !is_array($attrs)){
+ msg_dialog::display(tr("Error"),tr("Cannot generate SAMBA hash!"),ERROR_DIALOG);
+ return(FALSE);
+ }else{
+ $shadow = (isset($attrs["shadowLastChange"][0]))?(int)(date("U") / 86400):0;
+ if ($shadow != 0){
+ $attrs['shadowLastChange']= $shadow;
+ }
}
}
$hash = $rpc->mksmbhash($password);
if(!$rpc->success()){
msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
- return("");
+ return(array());
}
}elseif ($config->get_cfg_value("core","gosaSupportURI") != ""){
if ($hash == "") {
msg_dialog::display(_("Configuration error"), sprintf(_("Generating SAMBA hash by running %s failed: check %s!"), bold($config->get_cfg_value("core",'sambaHashHook'), bold("sambaHashHook"))), ERROR_DIALOG);
- return ("");
+ return(array());
}
}
$label= null;
// Bail out, if there's no style file
+ if(!class_exists('session')){
+ return "";
+ }
if(!session::global_is_set("img-styles")){
// Get theme
// In the DN we've to use escaped characters, but the object name (o)
// has the be un-escaped.
- $name = 'GOsaLdapEncoding_,_"_(_)_+';
- $dnName = 'GOsaLdapEncoding_\,_\"_(_)_\+';
+ $name = 'GOsaLdapEncoding_,_"_(_)_+_/';
+ $dnName = 'GOsaLdapEncoding_\,_\"_(_)_\+_/';
// Prapare name to be useable in filters
$fixed= normalizeLdap(str_replace('\\\\', '\\\\\\', $name));
}
krsort($hits);
+ // Add lower case placeholders to avoid errors
+ foreach($attrs as $key => $attr) $attrs[strtolower($key)] = $attr;
+
// Replace the placeholder in the given string now.
foreach($hits as $match){
// Avoid errors about undefined index.
- $name = $match[2];
+ $name = strtolower($match[2]);
if(!isset($attrs[$name])) $attrs[$name] = $default;
// Calculate the replacement
if(!isset($match[5])){
$replacements[$match[0]][] = $attributes[$match[2]];
- // Start given but no end, so just add a simple character
+ // Start given but no end, so just add a single character
}elseif(!isset($match[7])){
if(isset($attributes[$match[2]][$match[5]])){
- $replacements[$match[0]][] = $attributes[$match[2]][$match[5]];
+ $tmp = " ".$attributes[$match[2]];
+ $replacements[$match[0]][] = trim($tmp[$match[5]]);
}
// Add all values in range
$str = "";
for($i=$match[5]; $i<= $match[7]; $i++){
if(isset($attributes[$match[2]][$i])){
- $str .= $attributes[$match[2]][$i];
- $replacements[$match[0]][] = $str;
+ $tmp = " ".$attributes[$match[2]];
+ $str .= $tmp[$i];
+ $replacements[$match[0]][] = trim($str);
}
}
}
);
}
+function gosa_file_name($filename)
+{
+ $tempfile = tempnam(sys_get_temp_dir(), 'GOsa');
+ if(move_uploaded_file($filename, $tempfile)){
+ return( $tempfile);
+ }
+}
+
+function gosa_file($filename)
+{
+ $tempfile = tempnam(sys_get_temp_dir(), 'GOsa');
+ if(move_uploaded_file($filename, $tempfile)){
+ return file( $tempfile );
+ }
+}
+
+function gosa_fopen($filename, $mode)
+{
+ $tempfile = tempnam(sys_get_temp_dir(), 'GOsa');
+ if(move_uploaded_file($filename, $tempfile)){
+ return fopen( $tempfile, $mode );
+ }
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>