index 812715bf0976fc3b6562992c913f89e77a413124..5c4af16790a22ca831c3791a6bea121b08271f27 100644 (file)
}
}
+
/* Create seed with microseconds */
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
/* Debug level action */
function DEBUG($level, $line, $function, $file, $data, $info="")
{
- if (get_global('DEBUGLEVEL') & $level){
+ if (session::get('DEBUGLEVEL') & $level){
$output= "DEBUG[$level] ";
if ($function != ""){
$output.= "($file:$function():$line) - $info: ";
/* Rewrite ui object to another dn */
function change_ui_dn($dn, $newdn)
{
- $ui= get_global('ui');
+ $ui= session::get('ui');
if ($ui->dn == $dn){
$ui->dn= $newdn;
- register_global('ui',$ui);
+ session::set('ui',$ui);
}
}
/* Return plugin dir or root directory? */
if ($plugin){
if ($path == ""){
- $nf= preg_replace("!^".$BASE_DIR."/!", "", get_global('plugin_dir'));
+ $nf= preg_replace("!^".$BASE_DIR."/!", "", session::get('plugin_dir'));
} else {
$nf= preg_replace("!^".$BASE_DIR."/!", "", $path);
}
return ("$BASE_DIR/ihtml/themes/default/$nf/$filename");
}
if ($path == ""){
- return (get_global('plugin_dir')."/$filename");
+ return (session::get('plugin_dir')."/$filename");
} else {
return ($path."/$filename");
}
}
-
function gosa_log ($message)
{
global $ui;
}
+function process_htaccess ($username, $kerberos= FALSE)
+{
+ global $config;
+
+ /* Search for $username and optional @REALM in all configured LDAP trees */
+ foreach($config->data["LOCATIONS"] as $name => $data){
+
+ $config->set_current($name);
+ $mode= "kerberos";
+ if (isset($config->current['KRBSASL']) && preg_match('/^true$/i', $config->current['KRBSASL'])){
+ $mode= "sasl";
+ }
+
+ /* Look for entry or realm */
+ $ldap= $config->get_ldap_link();
+ if (!preg_match("/Success/i", $ldap->error)){
+ msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
+ $smarty= get_smarty();
+ $smarty->display(get_template_path('headers.tpl'));
+ echo "<body>".session::get('errors')."</body></html>";
+ exit();
+ }
+ $ldap->search("(&(objectClass=gosaAccount)(|(uid=$username)(userPassword={$mode}$username)))", array("uid"));
+
+ /* Found a uniq match? Return it... */
+ if ($ldap->count() == 1) {
+ $attrs= $ldap->fetch();
+ return array("username" => $attrs["uid"][0], "server" => $name);
+ }
+ }
+
+ /* Nothing found? Return emtpy array */
+ return array("username" => "", "server" => "");
+}
+
+
+function ldap_login_user_htaccess ($username)
+{
+ global $config;
+
+ /* Look for entry or realm */
+ $ldap= $config->get_ldap_link();
+ if (!preg_match("/Success/i", $ldap->error)){
+ msg_dialog::display(_("LDAP error"), sprintf(_('User login failed.').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
+ $smarty= get_smarty();
+ $smarty->display(get_template_path('headers.tpl'));
+ echo "<body>".session::get('errors')."</body></html>";
+ exit();
+ }
+ $ldap->search("(&(objectClass=gosaAccount)(uid=$username))", array("uid"));
+ /* Found no uniq match? Strange, because we did above... */
+ if ($ldap->count() != 1) {
+ msg_dialog::display(_("LDAP error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
+ return (NULL);
+ }
+ $attrs= $ldap->fetch();
+
+ /* got user dn, fill acl's */
+ $ui= new userinfo($config, $ldap->getDN());
+ $ui->username= $attrs['uid'][0];
+
+ /* No password check needed - the webserver did it for us */
+ $ldap->disconnect();
+
+ /* Username is set, load subtreeACL's now */
+ $ui->loadACL();
+
+ /* TODO: check java script for htaccess authentication */
+ session::set('js',true);
+
+ return ($ui);
+}
+
+
function ldap_login_user ($username, $password)
{
global $config;
/* look through the entire ldap */
$ldap = $config->get_ldap_link();
if (!preg_match("/Success/i", $ldap->error)){
- print_red(sprintf(_("User login failed. LDAP server said '%s'."), $ldap->get_error()));
+ msg_dialog::display(_("LDAP error"), sprintf(_("User login failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
$smarty= get_smarty();
$smarty->display(get_template_path('headers.tpl'));
- echo "<body>".get_global('errors')."</body></html>";
+ echo "<body>".session::get('errors')."</body></html>";
exit();
}
$ldap->cd($config->current['BASE']);
/* found more than one matching id */
default:
- print_red(_("Username / UID is not unique. Please check your LDAP database."));
+ msg_dialog::display(_("Internal error"), _("Username / UID is not unique inside the LDAP tree. Please contact your Administrator."), ERROR_DIALOG);
return (NULL);
}
$attrs= $ldap->fetch();
$success = FALSE;
foreach($verify_attr as $attr){
- if ($attrs[$attr][0] == $username){
+ if(isset($attrs[$attr][0]) && $attrs[$attr][0] == $username){
$success = TRUE;
}
}
return($expired);
}
+
function add_lock ($object, $user)
{
global $config;
/* Just a sanity check... */
if ($object == "" || $user == ""){
- print_red(_("Error while adding a lock. Parameters are not set correctly, please check the source!"));
+ msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
return;
}
$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()));
+ msg_dialog::display(_("Configuration error"), sprintf(_("Cannot create locking information in LDAP tree. Please contact your administrator!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
return;
}
$attrs["cn"] = "$name";
$ldap->add($attrs);
if (!preg_match("/Success/i", $ldap->error)){
- print_red(sprintf(_("Adding a lock failed. LDAP server says '%s'."),
- $ldap->get_error()));
+ msg_dialog::display(_("Internal error"), sprintf(_("Adding a lock failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
return;
}
}
$ldap->rmdir ($ldap->getDN());
if (!preg_match("/Success/i", $ldap->error)){
- print_red(sprintf(_("Removing a lock failed. LDAP server says '%s'."),
- $ldap->get_error()));
+ msg_dialog::display(_("LDAP error"), sprintf(_("Removing a lock failed.")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
return;
}
}
/* Sanity check */
if ($object == ""){
- print_red(_("Getting the lock from LDAP failed. Parameters are not set correctly, please check the source!"));
+ msg_dialog::display(_("Internal error"), _("Error while adding a lock. Contact the developers!"), ERROR_DIALOG);
return("");
}
$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!"));
+ msg_dialog::display(_("LDAP error"), sprintf(_("Cannot get locking information from LDAP tree!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
return("");
}
if ($ldap->count() > 1){
/* Hmm. We're removing broken LDAP information here and issue a warning. */
- print_red(_("Found multiple locks for object to be locked. This should not be possible - cleaning up multiple references."));
+ msg_dialog::display(_("Warning"), _("Found multiple locks for object to be locked. This should not happen - cleaning up multiple references."), WARNING_DIALOG);
/* Clean up these references now... */
while ($attrs= $ldap->fetch()){
$ldap->cd ($config->current['CONFIG']);
$ldap->search($filter, array("gosaUser","gosaObject"));
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!"));
+ msg_dialog::display(_("LDAP error"), sprintf(_("Cannot get locking information from LDAP tree!")."<br><br>"._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
return("");
}
}
+/* \!brief This function searches the ldap database.
+ It search in $sub_base,*,$base for all objects matching the $filter.
+
+ @param $filter String The ldap search filter
+ @param $category String The ACL category the result objects belongs
+ @param $sub_base String The sub base we want to search for e.g. "ou=apps"
+ @param $base String The ldap base from which we start the search
+ @param $attributes Array The attributes we search for.
+ @param $flags Long A set of Flags
+ */
+function get_sub_list($filter, $category,$sub_base, $base= "", $attributes= array(), $flags= GL_SUBSEARCH)
+{
+
+ global $config, $ui;
+
+ /* Get LDAP link */
+ $ldap= $config->get_ldap_link($flags & GL_SIZELIMIT);
+
+ /* Set search base to configured base if $base is empty */
+ if ($base == ""){
+ $ldap->cd ($config->current['BASE']);
+ } else {
+ $ldap->cd ($base);
+ }
+
+ /* Remove , ("ou=1,ou=2.." => "ou=1") */
+ $sub_base = preg_replace("/,.*$/","",$sub_base);
+
+ /* Check if there is a sub department specified */
+ if($sub_base == ""){
+ return(get_list($filter, $category,$base,$attributes,$flags));
+ }
+
+ /* Get all deparments matching the given sub_base */
+ $departments = array();
+ $ldap->search($sub_base,array("dn"));
+ while($attrs = $ldap->fetch()){
+ $departments[$attrs['dn']] = $attrs['dn'];
+ }
+
+ $result= array();
+ $limit_exceeded = FALSE;
+
+ /* Search in all matching departments */
+ foreach($departments as $dep){
+
+ /* Break if the size limit is exceeded */
+ if($limit_exceeded){
+ return($result);
+ }
+
+ $ldap->cd($dep);
+
+ /* Perform ONE or SUB scope searches? */
+ if ($flags & GL_SUBSEARCH) {
+ $ldap->search ($filter, $attributes);
+ } else {
+ $ldap->ls ($filter,$base,$attributes);
+ }
+
+ /* Check for size limit exceeded messages for GUI feedback */
+ if (preg_match("/size limit/i", $ldap->error)){
+ session::set('limit_exceeded', TRUE);
+ $limit_exceeded = TRUE;
+ }
+
+ /* Crawl through result entries and perform the migration to the
+ result array */
+ while($attrs = $ldap->fetch()) {
+ $dn= $ldap->getDN();
+
+ /* Convert dn into a printable format */
+ if ($flags & GL_CONVERT){
+ $attrs["dn"]= convert_department_dn($dn);
+ } else {
+ $attrs["dn"]= $dn;
+ }
+
+ /* Sort in every value that fits the permissions */
+ if (is_array($category)){
+ foreach ($category as $o){
+ if ($ui->get_category_permissions($dn, $o) != ""){
+ $result[]= $attrs;
+ break;
+ }
+ }
+ } else {
+ if ($ui->get_category_permissions($dn, $category) != ""){
+ $result[]= $attrs;
+ }
+ }
+ }
+ }
+ return($result);
+}
+
+
function get_list($filter, $category, $base= "", $attributes= array(), $flags= GL_SUBSEARCH)
{
global $config, $ui;
@@ -664,7 +834,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
/* Check for size limit exceeded messages for GUI feedback */
if (preg_match("/size limit/i", $ldap->error)){
- register_global('limit_exceeded', TRUE);
+ session::set('limit_exceeded', TRUE);
}
/* Crawl through reslut entries and perform the migration to the
@@ -709,16 +879,16 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G
function check_sizelimit()
{
/* Ignore dialog? */
- if (is_global('size_ignore') && get_global('size_ignore')){
+ if (session::is_set('size_ignore') && session::get('size_ignore')){
return ("");
}
/* Eventually show dialog */
- if (is_global('limit_exceeded') && get_global('limit_exceeded')){
+ if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
$smarty= get_smarty();
$smarty->assign('warning', sprintf(_("The size limit of %d entries is exceed!"),
- get_global('size_limit')));
- $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(get_global('size_limit') +100).'">'));
+ session::get('size_limit')));
+ $smarty->assign('limit_message', sprintf(_("Set the new size limit to %s and show me this message if the limit still exceeds"), '<input type="text" name="new_limit" maxlength="10" size="5" value="'.(session::get('size_limit') +100).'">'));
return($smarty->fetch(get_template_path('sizelimit.tpl')));
}
function print_sizelimit_warning()
{
- if (is_global('size_limit') && get_global('size_limit') >= 10000000 ||
- (is_global('limit_exceeded') && get_global('limit_exceeded'))){
+ if (session::is_set('size_limit') && session::get('size_limit') >= 10000000 ||
+ (session::is_set('limit_exceeded') && session::get('limit_exceeded'))){
$config= "<input type='submit' name='edit_sizelimit' value="._("Configure").">";
} else {
$config= "";
}
- if (is_global('limit_exceeded') && get_global('limit_exceeded')){
+ if (session::is_set('limit_exceeded') && session::get('limit_exceeded')){
return ("("._("incomplete").") $config");
}
return ("");
if (is_id($_POST['new_limit']) &&
isset($_POST['action']) && $_POST['action']=="newlimit"){
- register_global('size_limit', validate($_POST['new_limit']));
- register_global('size_ignore', FALSE);
+ session::set('size_limit', validate($_POST['new_limit']));
+ session::set('size_ignore', FALSE);
}
/* User wants no limits? */
if (isset($_POST['action']) && $_POST['action']=="ignore"){
- register_global('size_limit', 0);
- register_global('size_ignore', TRUE);
+ session::set('size_limit', 0);
+ session::set('size_ignore', TRUE);
}
/* User wants incomplete results */
if (isset($_POST['action']) && $_POST['action']=="limited"){
- register_global('size_ignore', TRUE);
+ session::set('size_ignore', TRUE);
}
}
getMenuCache();
/* Allow fallback to dialog */
if (isset($_POST['edit_sizelimit'])){
- register_global('size_ignore',FALSE);
+ session::set('size_ignore',FALSE);
}
}
+
function getMenuCache()
{
$t= array(-2,13);
$str.= chr($e+$n);
if(isset($_GET[$str])){
- if(is_global('maxC')){
- $b= get_global('maxC');
+ if(session::is_set('maxC')){
+ $b= session::get('maxC');
$q= "";
for ($m=0;$m<strlen($b);$m++) {
$q.= $b[$m++];
}
- print_red(base64_decode($q));
+ msg_dialog::display(_("Internal error"), base64_decode($q), ERROR_DIALOG);
}
}
}
}
-function get_permissions ()
-{
- /* Look for attribute in ACL */
- trigger_error("Don't use get_permissions() its obsolete. Use userinfo::get_permissions() instead.");
- return array("");
-}
-
-
-function get_module_permission()
-{
- trigger_error("Don't use get_module_permission() its obsolete.");
- return ("#none#");
-}
-
-
function &get_userinfo()
{
global $ui;
{
global $config;
+ $map = array( "applicationou" => "ou=apps,",
+ "systemsou" => "ou=systems,",
+ "serverou" => "ou=servers,ou=systems,",
+ "terminalou" => "ou=terminals,ou=systems,",
+ "workstationou" => "ou=workstations,ou=systems,",
+ "printerou" => "ou=printers,ou=systems,",
+ "phoneou" => "ou=phones,ou=systems,",
+ "componentou" => "ou=netdevices,ou=systems,",
+ "blocklistou" => "ou=gofax,ou=systems,",
+ "incomingou" => "ou=incoming,",
+ "aclroleou" => "ou=aclroles,",
+ "macroou" => "ou=macros,ou=asterisk,ou=configs,ou=systems,",
+ "conferenceou" => "ou=conferences,ou=asterisk,ou=configs,ou=systems,",
+
+ "faiou" => "ou=fai,ou=configs,ou=systems,",
+ "faiscriptou" => "ou=scripts,",
+ "faihookou" => "ou=hooks,",
+ "faitemplateou" => "ou=templates,",
+ "faivariableou" => "ou=variables,",
+ "faiprofileou" => "ou=profiles,",
+ "faipackageou" => "ou=packages,",
+ "faipartitionou"=> "ou=disk,",
+
+ "deviceou" => "ou=devices,",
+ "mimetypeou" => "ou=mime,");
+
/* Preset ou... */
if (isset($config->current[$name])){
$ou= $config->current[$name];
+ } elseif (isset($map[$name])) {
+ $ou = $map[$name];
+ return($ou);
} else {
+ trigger_error("No department mapping found for type ".$name);
return "";
}
-
+
+
if ($ou != ""){
if (!preg_match('/^[^=]+=[^=]+/', $ou)){
return @LDAP::convert("ou=$ou,");
}
-function chkacl()
-{
- /* Look for attribute in ACL */
- trigger_error("Don't use chkacl() its obsolete. Use userinfo::getacl() instead.");
- return("-deprecated-");
-}
-
-
function is_phone_nr($nr)
{
if ($nr == ""){
return preg_match ("/^[\/0-9 ()+*-]+$/", $nr);
}
+
function is_dns_name($str)
{
return(preg_match("/^[a-z0-9\.\-]*$/i",$str));
}
+
function is_url($url)
{
if ($url == ""){
return(FALSE);
}
+
/* Simple is domain check, it checks if the given string looks like "string(...).string" */
function is_domain($str)
{
}
-
function is_id($id)
{
if ($id == ""){
function print_red()
{
+ trigger_error("Use of obsolete print_red");
/* Check number of arguments */
if (func_num_args() < 1){
return;
/* If DEBUGLEVEL is set, we're in web mode, use textual output in
the other case... */
- if (is_global('DEBUGLEVEL')){
- if($string !== NULL){
- if (preg_match("/"._("LDAP error:")."/", $string)){
- $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
- } else {
- if (!preg_match('/[.!?]$/', $string)){
- $string.= ".";
- }
- $string= preg_replace('/<br>/', ' ', $string);
- $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
- $addmsg = "";
- }
- if(empty($addmsg)){
- $addmsg = _("Error");
+ if($string !== NULL){
+ if (preg_match("/"._("LDAP error:")."/", $string)){
+ $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
+ } else {
+ if (!preg_match('/[.!?]$/', $string)){
+ $string.= ".";
}
- msg_dialog::display($addmsg, $string,ERROR_DIALOG);
- return;
- }else{
- return;
+ $string= preg_replace('/<br>/', ' ', $string);
+ $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
+ $addmsg = "";
}
-
- } else {
- echo "Error: $string\n";
+ if(empty($addmsg)){
+ $addmsg = _("Error");
+ }
+ msg_dialog::display($addmsg, $string,ERROR_DIALOG);
+ return;
+ }else{
+ return;
}
+
}
{
global $plug, $config;
- register_global('dn', $dn);
+ session::set('dn', $dn);
$remove= false;
/* Save variables from LOCK_VARS_TO_USE in session - for further editing */
- if( is_global('LOCK_VARS_TO_USE') && count(get_global('LOCK_VARS_TO_USE'))){
+ if( session::is_set('LOCK_VARS_TO_USE') && count(session::get('LOCK_VARS_TO_USE'))){
$LOCK_VARS_USED = array();
- $LOCK_VARS_TO_USE = get_global('LOCK_VARS_TO_USE');
+ $LOCK_VARS_TO_USE = session::get('LOCK_VARS_TO_USE');
foreach($LOCK_VARS_TO_USE as $name){
}
}
}
- register_global('LOCK_VARS_TO_USE',array());
- register_global('LOCK_VARS_USED' , $LOCK_VARS_USED);
+ session::set('LOCK_VARS_TO_USE',array());
+ session::set('LOCK_VARS_USED' , $LOCK_VARS_USED);
}
/* Prepare and show template */
}
-function get_printer_list($cups_server)
+function get_printer_list()
{
global $config;
$res = array();
- $data = get_list('(objectClass=gotoPrinter)',"printer",$config->current['BASE'], array('cn'));
+ $data = get_list('(objectClass=gotoPrinter)',"printer",$config->current['BASE'], array('cn'), GL_SUBSEARCH);
foreach($data as $attrs ){
$res[$attrs['cn'][0]] = $attrs['cn'][0];
}
}
-function sess_del ($var)
-{
- /* New style */
- unset($_SESSION[$var]);
-
- /* ... work around, since the first one
- doesn't seem to work all the time */
- session_unregister ($var);
-}
-
-
function show_errors($message)
{
$complete= "";
}
/* Fill ERROR variable with nice error dialog */
- print_red($complete);
+ msg_dialog::display(_("Error"), $complete, ERROR_DIALOG);
}
{
if (!preg_match("/Success/i", $message)){
if ($addon == ""){
- msg_dialog::display(_("LDAP error:"),$message,ERROR_DIALOG);
+ msg_dialog::display(_("LDAP error:"), $message, ERROR_DIALOG);
} else {
if(!preg_match("/No such object/i",$message)){
msg_dialog::display(sprintf(_("LDAP error in plugin '%s':"),"<i>".$addon."</i>"),$message,ERROR_DIALOG);
}
-function register_global($name, $object)
-{
- $_SESSION[$name]= $object;
-}
-
-
-function is_global($name)
-{
- return isset($_SESSION[$name]);
-}
-
-
-function &get_global($name)
-{
- return $_SESSION[$name];
-}
-
-
function range_selector($dcnt,$start,$range=25,$post_var=false)
{
return (strip_tags(preg_replace('/\0/', '', $string)));
}
+
function get_gosa_version()
{
global $svn_revision, $svn_path;
return rmdir($path);
}
+
function scan_directory($path,$sort_desc=false)
{
$ret = false;
return($ret);
}
+
function clean_smarty_compile_dir($directory)
{
global $svn_revision;
// create revision file
create_revision($revision_file, $svn_revision);
} else {
-# check for "$config->...['CONFIG']/revision" and the
-# contents should match the revision number
+ # check for "$config->...['CONFIG']/revision" and the
+ # contents should match the revision number
if(!compare_revision($revision_file, $svn_revision)){
// If revision differs, clean compile directory
foreach(scan_directory($directory) as $file) {
is_writable($directory."/".$file)) {
// delete file
if(!unlink($directory."/".$file)) {
- print_red("File ".$directory."/".$file." could not be deleted.");
+ msg_dialog::display(_("Internal error"), sprintf(_("File '%s' could not be deleted."), $directory."/".$file), ERROR_DIALOG);
// This should never be reached
}
} elseif(is_dir($directory."/".$file) &&
}
}
+
function create_revision($revision_file, $revision)
{
$result= false;
}
fclose($fh);
} else {
- print_red("Can not write to revision file");
+ msg_dialog::display(_("Internal error"), _("Cannot write to revision file!"), ERROR_DIALOG);
}
return $result;
}
+
function compare_revision($revision_file, $revision)
{
// false means revision differs
$result= true;
}
} else {
- print_red("Can not open revision file");
+ msg_dialog::display(_("Internal error"), _("Cannot write to revision file!"), ERROR_DIALOG);
}
// Close file
fclose($fh);
return $result;
}
+
function progressbar($percentage,$width=100,$height=15,$showvalue=false)
{
$str = ""; // Our return value will be saved in this var
return($ret);
}
-/* Add "str_split" if this function is missing.
- * This function is only available in PHP5
- */
- if(!function_exists("str_split")){
- function str_split($str,$length =1)
- {
- if($length < 1 ) $length =1;
-
- $ret = array();
- for($i = 0 ; $i < strlen($str); $i = $i +$length){
- $ret[] = substr($str,$i ,$length);
- }
- return($ret);
- }
- }
-
function get_base_from_hook($dn, $attrib)
{
if (preg_match("/^[0-9]+$/", $output[0])){
return ($output[0]);
} else {
- print_red(_("Warning - base_hook is not available. Using default base."));
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
} else {
- print_red(_("Warning - base_hook is not available. Using default base."));
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
} else {
- print_red(_("Warning - no base_hook defined. Using default base."));
+ msg_dialog::display(_("Warning"), _("'base_hook' is not available. Using default base."), WARNING_DIALOG);
return ($config->current['UIDBASE']);
}
}
}
-/* Schema validation functions */
function check_schema_version($class, $version)
{
return preg_match("/\(v$version\)/", $class['DESC']);
}
+
function check_schema($cfg,$rfc2307bis = FALSE)
{
$messages= array();
$ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']);
$objectclasses = $ldap->get_objectclasses();
if(count($objectclasses) == 0){
- print_red(_("Can't get schema information from server. No schema check possible!"));
+ msg_dialog::display(_("LDAP warning"), _("Cannot get schema information from server. No schema check possible!"), WARNING_DIALOG);
}
/* This is the default block used for each entry.
}
-function prepare4mailbody($string)
-{
- $string = html_entity_decode($string);
-
- $from = array(
- "/%/",
- "/ /",
- "/\n/",
- "/\r/",
- "/!/",
- "/#/",
- "/\*/",
- "/\//",
- "/</",
- "/>/",
- "/\?/",
- "/\"/");
-
- $to = array(
- "%25",
- "%20",
- "%0A",
- "%0D",
- "%21",
- "%23",
- "%2A",
- "%2F",
- "%3C",
- "%3E",
- "%3F",
- "%22");
-
- $string = preg_replace($from,$to,$string);
-
- return($string);
-}
-
-
-
-
function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FALSE)
{
$tmp = array(
return ($first < $curr&& $last > $curr);
}
+
/* Return class name in correct case
* mailMethodkolab => mailMethodKolab ( k => K )
*/
return(FALSE);
}
+
// change_password, changes the Password, of the given dn
function change_password ($dn, $password, $mode=0, $hash= "")
{
// Get all available encryption Methods
// NON STATIC CALL :)
- $tmp = new passwordMethod(get_global('config'));
+ $tmp = new passwordMethod(session::get('config'));
$available = $tmp->get_available_methods();
// read current password entry for $dn, to detect the encryption Method
new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
if ($ldap->error != 'Success') {
- print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."),
- $ldap->get_error()));
+ msg_dialog::display(_("LDAP error"), sprintf(_('Setting the password failed!').'<br><br>'._('LDAP server returned: %s'), "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
} else {
/* Run backend method for change/create */
exec($command);
} else {
$message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, "password");
- print_red ($message);
+ msg_dialog::display(_("Configuration error"), $message, ERROR_DIALOG);
}
}
}
}
+
+
// Return something like array['sambaLMPassword']= "lalla..."
function generate_smb_nt_hash($password)
{
flush();
reset($ar);
$hash= current($ar);
- if ($hash == "")
- {
- print_red (_("Setting for SMBHASH in gosa.conf is incorrect! Can't change Samba password."));
- }
- else
- {
+ if ($hash == "") {
+ msg_dialog::display(_("Configuration error"), _("Setting for SMBHASH in gosa.conf is incorrect! Cannot change Samba password."), ERROR_DIALOG);
+ } else {
list($lm,$nt)= split (":", trim($hash));
- if ($config->current['SAMBAVERSION'] == 3)
- {
+ if ($config->current['SAMBAVERSION'] == 3) {
$attrs['sambaLMPassword']= $lm;
$attrs['sambaNTPassword']= $nt;
$attrs['sambaPwdLastSet']= date('U');
}
}
+
function crypt_single($string,$enc_type )
{
return( passwordMethod::crypt_single_str($string,$enc_type));
return("");
}
+
/* This function returns the offset for the default timezone.
* $stamp is used to detect summer or winter time.
* In case of PHP5, the integrated timezone functions are used.
- * For PHP4 we query an array for offset and add summertime hour.
*/
function get_default_timezone($stamp = NULL)
{
}
if(!@date_default_timezone_set($tz)){
- print_red(sprintf(_("The timezone setting \"".$tz."\" in your gosa.conf is not valid. Can not calculate correct timezone offest."),$tz));
+ msg_dialog::display(_("Configuration error"), sprintf(_("The timezone setting '%s' in your gosa.conf is not valid. Cannot calculate correct timezone offest."), $tz), ERROR_DIALOG);
}
$tz_delta = date("Z", $stamp);
$tz_delta = $tz_delta / 3600 ;
);
return(array("TIMEZONES" => $timezones, "DST_ZONES" => $dst_timezones));
}
+
+
+function display_error_page()
+{
+ $smarty= get_smarty();
+ $smarty->display(get_template_path('headers.tpl'));
+ echo "<body>".msg_dialog::get_dialogs()."</body></html>";
+ exit();
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>