diff --git a/contrib/man/fusiondirectory.conf.5 b/contrib/man/fusiondirectory.conf.5 index 4ac3b639001f75f00581b44bccb41c05f5196078..247c73d8c53f3c9fcec56fc28f1bb5830ad1cd02 100644 --- a/contrib/man/fusiondirectory.conf.5 +++ b/contrib/man/fusiondirectory.conf.5 @@ -26,26 +26,26 @@ information about several locations. .nf <?xml version="1.0"?> - + <conf configVersion="...." > <!-- Menu definition --> <menu> ... </menu> - + <!-- Tabbed dialog definitions --> ... - + <!-- Global setup --> <main> - + <!-- Location specific setups --> <location name=""> ... </location> - + </main> - + </conf> .fi @@ -59,37 +59,37 @@ There are two types of entries inside of the menu: section and plugin .B Defining a section -Open a +Open a .I <section> -tag including a +tag including a .I name attribute. This will show up in the menu as a new section later on. -Own entries are not handled via I18N by default. Close the +Own entries are not handled via I18N by default. Close the .I </section> tag after your plugin definitions. .B Defining a plugin -Open a +Open a .I <plugin> -tag including a +tag including a +.I "class" +attribute. The .I "class" -attribute. The -.I "class" should be present inside your FusionDirectory setup - the entry will be ignored if it is not. -Plugins should have an +Plugins should have an .I "acl" entry, that allows FusionDirectory to decide wether a user is allowed to see a plugin or not. -The +The .I "acl" string matches with an ACL definition done inside of FusionDirectory. -You can override an icon by specifying the +You can override an icon by specifying the .I "icon" attribute. -For every plugin, you can provide at least four additional hooks: +For every plugin, you can provide at least four additional hooks: .I postcreate, .I postremove, .I postmodify @@ -144,7 +144,7 @@ need a primary plugin. .I "*tab" should be looked for by a defined plugin. This one will take -every +every .I "tab" defined .I "class" @@ -240,7 +240,7 @@ for Sun DS based systems. .PP The .I logging -statement enables event logging on FusionDirectory side. Setting it to +statement enables event logging on FusionDirectory side. Setting it to .I true, FusionDirectory will log every action a user performs via syslog. If you use rsyslog and configure it to mysql logging, you can browse all events @@ -289,7 +289,7 @@ the LDAP. .PP .B snapshotURI -.I uri +.I uri .PP The .I snapshotURI @@ -815,7 +815,7 @@ Default is .I ou=fai,ou=configs,ou=systems. .PP -.B faiScriptRDN, faiHookRDN, faiTemplateRDN, faiVariableRDN, faiProfileRDN, faiPackageRDN, faiPartitionRDN +.B faiScriptRDN, faiHookRDN, faiTemplateRDN, faiVariableRDN, faiProfileRDN, faiPackageRDN, faiPartitionRDN .I string .PP These statement define the location where FusionDirectory stores FAI classes. The complete base for the @@ -920,7 +920,7 @@ FusionDirectory will do create a lock and perform a search for the next free ID. removed after the procedure completes. .I pool will use the sambaUnixIdPool objectclass settings inside your LDAP. This one is unsafe, -because it does not check for concurrent LDAP access and already used IDs in this range. +because it does not check for concurrent LDAP access and already used IDs in this range. On the other hand it is much faster. .PP @@ -1160,18 +1160,18 @@ and .I uid. .B imapTimeout -.I Integer (default 10) +.I Integer (default 10) .PP The .I imapTimeout statement sets the connection timeout for imap actions. .B mailFolderCreation -Every mail method has its own way to create mail accounts like +Every mail method has its own way to create mail accounts like .I share/development -or +or .I shared.development@example.com -which is used to identify the accounts, set quotas or add acls. +which is used to identify the accounts, set quotas or add acls. To override the methods default account creation syntax, you can set the .I mailFolderCreation @@ -1201,7 +1201,7 @@ option. This attribute allows to override the user account creation syntax, see the .I mailFolderCreation -description for more details. +description for more details. .I Examples @@ -1274,7 +1274,7 @@ DEBUG_TRACE = 1 DEBUG_LDAP = 2 -DEBUG_MYSQL = 4 +DEBUG_DB = 4 DEBUG_SHELL = 8 @@ -1355,7 +1355,7 @@ repository. .B Example: .nf - <tab class="servrepository" + <tab class="servrepository" repositoryBranchHook="/opt/dak/bin/get_extra_repos" postcreate="/opt/dak/bin/handle_repository '%lock_dn' '%lock_name' '%lock_type' /> .fi @@ -1375,7 +1375,7 @@ FusionDirectory/FAI methods. If you have only one release, or want to define a default release to be shown by FusionDirectory, define the .I defaultFaiRelease="ou=sarge,ou=fai,ou=configs,ou=syst..." -within the +within the .I faiManagement class definition diff --git a/include/class_msgPool.inc b/include/class_msgPool.inc index a637fb6108aadbf19c032c965053ad155b03561c..17d08fe4804dc90c0de12f5e185b1c0e738bf035 100644 --- a/include/class_msgPool.inc +++ b/include/class_msgPool.inc @@ -28,9 +28,9 @@ define ("LDAP_DEL", 4); define ("LDAP_SEARCH", 5); define ("LDAP_AUTH", 6); -/*! \brief This class contains all the messages for the various actions - * - */ +/*! \brief This class contains all the messages for the various actions + * + */ class msgPool { @@ -53,7 +53,7 @@ class msgPool public static function deleteInfo($name= "",$type = "") { - if ($name == "") { + if ($name == "") { if($type == ""){ return (_("This object will be deleted!")); }else{ @@ -84,7 +84,7 @@ class msgPool public static function permDelete($name= "") { - if ($name == "") { + if ($name == "") { return (_("You have no permission to delete this object!")); } @@ -102,7 +102,7 @@ class msgPool public static function permCreate($name= "") { - if ($name == "") { + if ($name == "") { return (_("You have no permission to create this object!")); } @@ -120,7 +120,7 @@ class msgPool public static function permModify($name= "") { - if ($name == "") { + if ($name == "") { return (_("You have no permission to modify this object!")); } @@ -138,7 +138,7 @@ class msgPool public static function permView($name= "") { - if ($name == "") { + if ($name == "") { return (_("You have no permission to view this object!")); } @@ -156,7 +156,7 @@ class msgPool public static function permMove($name= "") { - if ($name == "") { + if ($name == "") { return (_("You have no permission to move this object!")); } @@ -474,10 +474,10 @@ class msgPool } - public static function mysqlerror($error, $plugin= "") + public static function dbError($error, $plugin= "") { /* Assign headline depending on type */ - $headline= _("MySQL operation failed!"); + $headline= _("Database operation failed!"); return $headline."<br><br><i>"._("Error").":</i> ".$error; } diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 2461c41150e6b2ea62f49f08a6c6b12f69ad43b1..8d189f4050617fd0f9d73f99f740de85324e7a82 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -21,13 +21,13 @@ */ /*! \brief This is the base class for all plugins. - * + * * \author Cajus Pollmeier <pollmeier@gonicus.de> * \version 2.00 * \date 24.07.2003 - * + * * This is the base class for all plugins. It can be used standalone or - * can be included by the tabs class. All management should be done + * can be included by the tabs class. All management should be done * within this class. Extend your plugins from this class. */ class plugin @@ -125,10 +125,10 @@ class plugin /* This variable indicates that this class can handle multiple dns at once. */ var $multiple_support = FALSE; var $multi_attrs = array(); - var $multi_attrs_all = array(); + var $multi_attrs_all = array(); /* This variable indicates, that we are currently in multiple edit handle */ - var $multiple_support_active = FALSE; + var $multiple_support_active = FALSE; var $selected_edit_values = array(); var $multi_boxes = array(); @@ -142,7 +142,7 @@ class plugin function plugin (&$config, $dn= NULL, $object= NULL) { /* Configuration is fine, allways */ - $this->config= &$config; + $this->config= &$config; $this->dn= $dn; // Ensure that we've a valid acl_category set. @@ -265,7 +265,7 @@ class plugin /*! \brief Generates the html output for this node - * + * */ function execute() { @@ -280,7 +280,7 @@ class plugin } /*! \brief Removes object from parent - * + * */ function remove_from_parent() { @@ -319,7 +319,7 @@ class plugin /*! \brief Save HTML posted data to object - * + * */ function save_object() { @@ -333,20 +333,20 @@ class plugin if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){ /* Check for modifications */ $data= $this->$val = $_POST["$val"]; - - if ($this->$val != $data){ + + if ($this->$val != $data) { $this->is_modified= TRUE; } - - /* Okay, how can I explain this fix ... - * In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds. - * So IE posts these 'unselectable' option, with value = chr(194) - * chr(194) seems to be the in between the ...option> </option.. because there is no value=".." specified in these option fields - * This was added for W3c compliance, but now causes these ... ldap errors ... + + /* Okay, how can I explain this fix ... + * In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds. + * So IE posts these 'unselectable' option, with value = chr(194) + * chr(194) seems to be the in between the ...option> </option.. because there is no value=".." specified in these option fields + * This was added for W3c compliance, but now causes these ... ldap errors ... * So we set these Fields to ""; a normal empty string, and we can check these values in plugin::check() again ... */ if(isset($data[0]) && $data[0] == chr(194)) { - $data = ""; + $data = ""; } $this->$val= $data; } @@ -355,7 +355,7 @@ class plugin /*! \brief Save data to LDAP, depending on is_account we save or delete - * + * */ function save() { @@ -370,7 +370,7 @@ class plugin /* Get current objectClasses in order to add the required ones */ $ldap->cat($this->dn); - + $tmp= $ldap->fetch (); $oc= array(); @@ -408,14 +408,14 @@ class plugin function cleanup() { foreach ($this->attrs as $index => $value){ - + /* Convert arrays with one element to non arrays, if the saved attributes are no array, too */ - if (is_array($this->attrs[$index]) && + if (is_array($this->attrs[$index]) && count ($this->attrs[$index]) == 1 && isset($this->saved_attributes[$index]) && !is_array($this->saved_attributes[$index])){ - + $tmp= $this->attrs[$index][0]; $this->attrs[$index]= $tmp; } @@ -424,7 +424,7 @@ class plugin if (is_array($this->attrs[$index]) && count($this->attrs[$index]) == 0 && !isset($this->saved_attributes[$index])){ - + unset ($this->attrs[$index]); continue; } @@ -440,10 +440,10 @@ class plugin } /* Remove arrays that do not differ */ - if (is_array($this->attrs[$index]) && + if (is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && is_array($this->saved_attributes[$index])){ - + if (!array_differs($this->attrs[$index],$this->saved_attributes[$index])){ unset ($this->attrs[$index]); continue; @@ -458,7 +458,7 @@ class plugin } /*! \brief Check formular input - * + * */ function check() { @@ -480,12 +480,12 @@ class plugin /* Generate "ldif" for check hook */ $ldif= "dn: $this->dn\n"; - + /* ... objectClasses */ foreach ($this->objectclasses as $oc){ $ldif.= "objectClass: $oc\n"; } - + /* ... attributes */ foreach ($this->attributes as $attr){ if ($this->$attr == ""){ @@ -509,12 +509,12 @@ class plugin if (is_resource($fh)) { fwrite ($pipes[0], $ldif); fclose($pipes[0]); - + $result= stream_get_contents($pipes[1]); if ($result != ""){ $message[]= $result; } - + fclose($pipes[1]); fclose($pipes[2]); proc_close($fh); @@ -554,7 +554,7 @@ class plugin if (isset($this->attrs["$val"][0])){ - /* If attribute is set, replace dynamic parts: + /* If attribute is set, replace dynamic parts: %sn, %givenName and %uid. Fill these in our local variables. */ $value= $this->attrs["$val"][0]; @@ -583,8 +583,8 @@ class plugin } } - /* \brief Indicate whether a password change is needed or not - * + /* \brief Indicate whether a password change is needed or not + * */ function password_change_needed() { @@ -593,7 +593,7 @@ class plugin /*! \brief Show header message for tab dialogs - * + * */ function show_enable_header($button_text, $text, $disabled= FALSE) { @@ -602,7 +602,7 @@ class plugin /*! \brief Show header message for tab dialogs - * + * */ function show_disable_header($button_text, $text, $disabled= FALSE) { @@ -610,8 +610,8 @@ class plugin } - /*! \brief Show header message for tab dialogs - * + /*! \brief Show header message for tab dialogs + * */ function show_header($button_text, $text, $plugin_enabled, $button_disabled= FALSE) { @@ -651,7 +651,7 @@ class plugin $tmp[$name] = strlen($name); } arsort($tmp); - + /* Additional attributes */ foreach ($tmp as $name => $len){ $value = $add_attrs[$name]; @@ -697,7 +697,7 @@ class plugin $tmp[$name] = strlen($name); } arsort($tmp); - + /* Additional attributes */ foreach ($tmp as $name => $len){ $value = $add_attrs[$name]; @@ -741,7 +741,7 @@ class plugin $tmp[$name] = strlen($name); } arsort($tmp); - + /* Additional attributes */ foreach ($tmp as $name => $len){ $value = $add_attrs[$name]; @@ -887,7 +887,7 @@ class plugin $new[$dst_name]= LDAP::fix($dst_val); /* Check if this is a department. - * If it is a dep. && there is a , override in his ou + * If it is a dep. && there is a , override in his ou * change \2C to , again, else this entry can't be saved ... */ if((isset($new['ou'])) &&( preg_match("/\\,/",$new['ou']))){ @@ -897,11 +897,11 @@ class plugin /* Save copy */ $ldap->connect(); $ldap->cd($this->config->current['BASE']); - + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dst_dn)); - /* FAIvariable=.../..., cn=.. - could not be saved, because the attribute FAIvariable was different to + /* FAIvariable=.../..., cn=.. + could not be saved, because the attribute FAIvariable was different to the dn FAIvariable=..., cn=... */ if(!is_array($new['objectClass'])) $new['objectClass'] = array($new['objectClass']); @@ -967,12 +967,12 @@ class plugin * given destination $dst_dn * * - Ensure that all references are updated (ogroups) - * - Update ACLs + * - Update ACLs * - Update accessTo * * \param string 'src_dn' the source DN. * \param string 'dst_dn' the destination DN. - * + * * \return boolean TRUE on success else FALSE. */ function rename($src_dn, $dst_dn) @@ -986,7 +986,7 @@ class plugin if (!$ldap->rename_dn($src_dn,$dst_dn)){ # msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $src_dn, "", get_class())); new log("debug","Ldap Protocol v3 implementation error, ldap_rename failed, falling back to manual copy.","FROM: $src_dn -- TO: $dst_dn",array(),$ldap->get_error()); - @DEBUG(DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,"Rename failed FROM: $src_dn -- TO: $dst_dn", + @DEBUG(DEBUG_LDAP,__LINE__,__FUNCTION__,__FILE__,"Rename failed FROM: $src_dn -- TO: $dst_dn", "Ldap Protocol v3 implementation error, falling back to maunal method."); return(FALSE); } @@ -999,7 +999,7 @@ class plugin foreach($leaf_objs as $obj){ $new_dn = $obj['dn']; $old_dn = preg_replace("/".preg_quote(LDAP::convert($dst_dn), '/')."$/i",$src_dn,LDAP::convert($new_dn)); - $this->update_acls($old_dn,$new_dn); + $this->update_acls($old_dn,$new_dn); } // Migrate objectgroups if needed @@ -1014,7 +1014,7 @@ class plugin unset($o_ogroup->member[$src_dn]); } $o_ogroup->member[$dst_dn]= $dst_dn; - + // Save object group $o_ogroup->save(); } @@ -1036,20 +1036,20 @@ class plugin // Walk through all roles foreach($roles as $role){ $role = new roleGeneric($this->config,$role['dn']); - $key= array_search($src_dn, $role->roleOccupant); + $key= array_search($src_dn, $role->roleOccupant); if($key !== FALSE){ $role->roleOccupant[$key] = $dst_dn; $role->save(); } } - // Update 'manager' attributes from gosaDepartment and inetOrgPerson + // Update 'manager' attributes from gosaDepartment and inetOrgPerson $filter = "(&(objectClass=inetOrgPerson)(manager=".LDAP::prepare4filter(LDAP::fix($src_dn))."))"; $ocs = $ldap->get_objectclasses(); if(isset($ocs['gosaDepartment']['MAY']) && in_array('manager', $ocs['gosaDepartment']['MAY'])){ $filter = "(|".$filter."(&(objectClass=gosaDepartment)(manager=".LDAP::prepare4filter(LDAP::fix($src_dn)).")))"; } - $leaf_deps= get_list($filter,array("all"),$this->config->current['BASE'], + $leaf_deps= get_list($filter,array("all"),$this->config->current['BASE'], array("manager","dn","objectClass"),GL_SUBSEARCH | GL_NO_ACL_CHECK); foreach($leaf_deps as $entry){ $update = array('manager' => $dst_dn); @@ -1059,13 +1059,13 @@ class plugin trigger_error(sprintf("Failed to update manager for '%s', error was '%s'", $entry['dn'], $ldap->get_error())); } } - - /* Check if there are gosa departments moved. + + /* Check if there are gosa departments moved. If there were deps moved, the force reload of config->deps. */ $leaf_deps= get_list("(objectClass=gosaDepartment)",array("all"),$dst_dn, array("dn","objectClass"),GL_SUBSEARCH | GL_NO_ACL_CHECK); - + if(count($leaf_deps)){ $this->config->get_departments(); $this->config->make_idepartments(); @@ -1074,7 +1074,7 @@ class plugin $ui->reset_acl_cache(); } - return(TRUE); + return(TRUE); } @@ -1086,13 +1086,13 @@ class plugin return(TRUE); } - + /* Try to move the entry instead of copy & delete */ if(TRUE){ /* Try to move with ldap routines, if this was not successfull - fall back to the old style copy & remove method + fall back to the old style copy & remove method */ if($this->rename($src_dn, $dst_dn)){ return(TRUE); @@ -1194,7 +1194,7 @@ class plugin /*! \brief Calls external hooks which are defined for this plugin (fusiondirectory.conf) * Replaces placeholder by class values of this plugin instance. - * + * * \param Allows to a add special replacements. */ static function callHook($plugin, $cmd, $addAttrs= array(), &$returnOutput = array(), &$returnCode = NULL) @@ -1314,8 +1314,8 @@ class plugin /*! \brief Get gosaUnitTag for the given DN * - * If this is called from departmentGeneric, we have to skip this - * tagging procedure. + * If this is called from departmentGeneric, we have to skip this + * tagging procedure. */ function tag_attrs(&$at, $dn= "", $tag= "", $show= false) { @@ -1361,7 +1361,7 @@ class plugin } } - /*! \brief Add unit tag */ + /*! \brief Add unit tag */ /* Remove tags that may already be here... */ remove_objectClass("gosaAdministrativeUnitTag", $at); if (isset($at['gosaUnitTag'])){ @@ -1374,8 +1374,8 @@ class plugin $at['gosaUnitTag']= $tag; } - /* Initially this object was tagged. - - But now, it is no longer inside a tagged department. + /* Initially this object was tagged. + - But now, it is no longer inside a tagged department. So force the remove of the tag. (objectClass was already removed obove) */ @@ -1435,7 +1435,7 @@ class plugin } - /* check if the dn exists */ + /* check if the dn exists */ if ($ldap->dn_exists($this->dn)){ /* Extract seconds & mysecs, they are used as entry index */ @@ -1460,10 +1460,10 @@ class plugin $target['description'] = $description; $target['gosaSnapshotTimestamp'] = $newName; - /* Insert the new snapshot + /* Insert the new snapshot But we have to check first, if the given gosaSnapshotTimestamp - is already used, in this case we should increment this value till there is - an unused value. */ + is already used, in this case we should increment this value till there is + an unused value. */ $new_dn = "gosaSnapshotTimestamp=".$newName.",".$new_base; $ldap_to->cat($new_dn); while($ldap_to->count()){ @@ -1471,7 +1471,7 @@ class plugin $newName = str_replace(".", "", $sec."-".($usec++)); $new_dn = "gosaSnapshotTimestamp=".$newName.",".$new_base; $target['gosaSnapshotTimestamp'] = $newName; - } + } /* Inset this new snapshot */ $ldap_to->cd($snapldapbase); @@ -1494,7 +1494,7 @@ class plugin function remove_snapshot($dn) { $ui = get_userinfo(); - $old_dn = $this->dn; + $old_dn = $this->dn; $this->dn = $dn; $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); @@ -1510,7 +1510,7 @@ class plugin * * Test weither snapshotting is enabled or not. There will also be some errors posted, * if the configuration failed - * + * * \return TRUE if snapshots are enabled, and FALSE if it is disabled */ function snapshotEnabled() @@ -1550,28 +1550,28 @@ class plugin $snap_base = $this->config->get_cfg_value("snapshotBase"); $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn); $new_base = preg_replace("/".preg_quote($base, '/')."$/","",$base_of_object).$snap_base; - $tmp = array(); + $tmp = array(); /* Fetch all objects with gosaSnapshotDN=$dn */ $ldap_to->cd($new_base); $ldap_to->ls("(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN=".$dn."))",$new_base, - array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description")); + array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description")); /* Put results into a list and add description if missing */ - while($entry = $ldap_to->fetch()){ + while($entry = $ldap_to->fetch()){ if(!isset($entry['description'][0])){ $entry['description'][0] = ""; } - $tmp[] = $entry; + $tmp[] = $entry; } /* Return the raw array, or format the result */ if($raw){ return($tmp); - }else{ + }else{ $tmp2 = array(); foreach($tmp as $entry){ - $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; + $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; } } return($tmp2); @@ -1603,7 +1603,7 @@ class plugin } } - /* Prepare bases */ + /* Prepare bases */ $base = $this->config->current['BASE']; $snap_base = $this->config->get_cfg_value("snapshotBase"); $new_base = preg_replace("/".preg_quote($base, '/')."$/","",$base_of_object).$snap_base; @@ -1621,7 +1621,7 @@ class plugin if(!isset($entry['description'][0])){ $entry['description'][0] = ""; } - $tmp[] = $entry; + $tmp[] = $entry; } /* Check if entry still exists */ @@ -1638,11 +1638,11 @@ class plugin }else{ $tmp2 = array(); foreach($tmp as $key => $entry){ - $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; + $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; } } return($tmp2); - } + } /* \brief Restore selected snapshot */ @@ -1669,7 +1669,7 @@ class plugin } } - /* Get the snapshot */ + /* Get the snapshot */ $ldap_to->cat($dn); $restoreObject = $ldap_to->fetch(); @@ -1705,8 +1705,8 @@ class plugin }else{ msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s."),$entry),ERROR_DIALOG); } - } - + } + /* Restore a snapshot, display a dialog with all snapshots of the current object */ if(preg_match("/^RestoreSnapShotDialog_/",$name) && $once){ $once = false; @@ -1720,7 +1720,7 @@ class plugin } /* Restore one of the already deleted objects */ - if(((isset($_POST['menu_action']) && $_POST['menu_action'] == "RestoreDeletedSnapShot") + if(((isset($_POST['menu_action']) && $_POST['menu_action'] == "RestoreDeletedSnapShot") || preg_match("/^RestoreDeletedSnapShot_/",$name)) && $once){ $once = false; @@ -1854,11 +1854,11 @@ class plugin /*! \brief Returns a list of all available departments for this object. - * + * * If this object is new, all departments we are allowed to create a new user in - * are returned. If this is an existing object, return all deps. + * are returned. If this is an existing object, return all deps. * We are allowed to move tis object too. - * + * * \return array [dn] => "..name" // All deps. we are allowed to act on. */ function get_allowed_bases() @@ -1881,7 +1881,7 @@ class plugin } } - /* Add current base */ + /* Add current base */ if(isset($this->base) && isset($this->config->idepartments[$this->base])){ $deps[$this->base] = $this->config->idepartments[$this->base]; }elseif(strtolower($this->dn) == strtolower($this->config->current['BASE'])){ @@ -1927,7 +1927,7 @@ class plugin for($i = 0 ; $i < $attrs['gosaAclEntry']['count'] ; $i ++ ){ $acl_parts = explode(":",$attrs['gosaAclEntry'][$i]); - /* Roles uses antoher data storage order, members are stored int the third part, + /* Roles uses antoher data storage order, members are stored int the third part, while the members in direct ACL assignments are stored in the second part. */ $id = ($acl_parts[1] == "role") ? 3 : 2; @@ -1941,7 +1941,7 @@ class plugin $members[$key] = base64_encode($new_dn); $found = TRUE; } - } + } /* Check if the selected role has to updated */ @@ -1950,7 +1950,7 @@ class plugin $found = TRUE; } - /* Build new acl string */ + /* Build new acl string */ $acl_parts[$id] = implode($members,","); $acls[] = implode($acl_parts,":"); } @@ -1977,14 +1977,14 @@ class plugin } } - + /*! \brief Enable the Serial ID check * * This function enables the entry Serial ID check. If an entry was edited while - * we have edited the entry too, an error message will be shown. + * we have edited the entry too, an error message will be shown. * To configure this check correctly read the FAQ. - */ + */ function enable_CSN_check() { $this->CSN_check_active =TRUE; @@ -2005,7 +2005,7 @@ class plugin /* Copy needed attributes */ foreach ($this->attributes as $val){ $found= array_key_ics($val, $this->multi_attrs); - + if ($found != ""){ if(isset($this->multi_attrs["$val"][0])){ $this->$val= $this->multi_attrs["$val"][0]; @@ -2014,9 +2014,9 @@ class plugin } } - + /*! \brief Enables multiple support for this plugin - * + * */ function enable_multiple_support() { @@ -2026,8 +2026,8 @@ class plugin /*! \brief Returns all values that have been modfied in multiple edit mode. - * - * \return array Containing all modified values. + * + * \return array Containing all modified values. */ function get_multi_edit_values() { @@ -2040,9 +2040,9 @@ class plugin return($ret); } - + /*! \brief Update class variables with values collected by multiple edit. - * + * */ function set_multi_edit_values($attrs) { @@ -2063,13 +2063,13 @@ class plugin session::set('LOCK_VARS_USED_GET',array()); session::set('LOCK_VARS_USED_POST',array()); session::set('LOCK_VARS_USED_REQUEST',array()); - + return("Multiple edit is currently not implemented for this plugin."); } /*! \brief Save HTML posted data to object for multiple edit - * + * */ function multiple_save_object() { @@ -2080,7 +2080,7 @@ class plugin /* Save values to object */ $this->multi_boxes = array(); foreach ($this->attributes as $val){ - + /* Get selected checkboxes from multiple edit */ if(isset($_POST["use_".$val])){ $this->multi_boxes[] = $val; @@ -2094,10 +2094,10 @@ class plugin if ($this->$val != $data){ $this->is_modified= TRUE; } - + /* IE post fix */ if(isset($data[0]) && $data[0] == chr(194)) { - $data = ""; + $data = ""; } $this->$val= $data; } @@ -2109,7 +2109,7 @@ class plugin * * To be able to detect multiple used attributes * in multi_plugg::detect_multiple_used_attributes(). - * + * * \return array Attributes required for intialization of multi_plug */ public function get_multi_init_values() @@ -2120,7 +2120,7 @@ class plugin /*! \brief Check given values in multiple edit - * + * * \return array Error messages */ function multiple_check() @@ -2131,9 +2131,9 @@ class plugin /*! \brief Returns the snapshot header part for "Actions" menu in management dialogs - * - * \param $layer_menu - */ + * + * \param $layer_menu + */ function get_snapshot_header($base,$category) { $str = ""; @@ -2158,7 +2158,7 @@ class plugin function get_snapshot_action($base,$category) { - $str= ""; + $str= ""; $ui = get_userinfo(); if($this->snapshotEnabled()){ if ($ui->allow_snapshot_restore($base,$category)){ @@ -2172,7 +2172,7 @@ class plugin } if($ui->allow_snapshot_create($base,$category)){ $str.= "<input class='center' type='image' src='images/snapshot.png' - alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($base)."' + alt='"._("Create snapshot")."' name='CreateSnapShotDialog_".base64_encode($base)."' title='"._("Create a new snapshot from this object")."'> "; }else{ $str = "<img class='center' src='images/empty.png' alt=' '> "; @@ -2206,7 +2206,7 @@ class plugin } } - return($action); + return($action); } @@ -2219,7 +2219,7 @@ class plugin $category = array($category); } - /* Check permissions for each category, if there is at least one category which + /* Check permissions for each category, if there is at least one category which support read or paste permissions for the given base, then display the specific actions. */ $readable = $pasteable = false; @@ -2227,7 +2227,7 @@ class plugin $readable= $readable || preg_match('/r/', $ui->get_category_permissions($base, $cat)); $pasteable= $pasteable || $ui->is_pasteable($base, $cat) == 1; } - + if(($cut || $copy) && isset($this->CopyPasteHandler) && is_object($this->CopyPasteHandler)){ if($readable){ $s.= "..|---|\n"; diff --git a/include/functions.inc b/include/functions.inc index faf56393389f55615e577c4c46722a56cc05d705..9dd99bc479aeac083c90c006db82eef974947eb3 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -59,7 +59,7 @@ define('DES3_CBC_SHA1',16); /* Define constants for debugging */ define ("DEBUG_TRACE", 1); /*! Debug level for tracing of common actions (save, check, etc.) */ define ("DEBUG_LDAP", 2); /*! Debug level for LDAP queries */ -define ("DEBUG_MYSQL", 4); /*! Debug level for mysql operations */ +define ("DEBUG_DB", 4); /*! Debug level for database operations */ define ("DEBUG_SHELL", 8); /*! Debug level for shell commands */ define ("DEBUG_POST", 16); /*! Debug level for POST content */ define ("DEBUG_SESSION",32); /*! Debug level for SESSION content */ @@ -71,10 +71,10 @@ define ("DEBUG_FAI", 1024); // FAI (incomplete) // Define shadow states -define ("POSIX_ACCOUNT_EXPIRED", 1); -define ("POSIX_WARN_ABOUT_EXPIRATION", 2); -define ("POSIX_FORCE_PASSWORD_CHANGE", 4); -define ("POSIX_DISALLOW_PASSWORD_CHANGE", 8); +define ("POSIX_ACCOUNT_EXPIRED", 1); +define ("POSIX_WARN_ABOUT_EXPIRATION", 2); +define ("POSIX_FORCE_PASSWORD_CHANGE", 4); +define ("POSIX_DISALLOW_PASSWORD_CHANGE", 8); /* Rewrite german 'umlauts' and spanish 'accents' to get better results */ @@ -125,10 +125,10 @@ function __fusiondirectory_autoload($class_name) { spl_autoload_register('__fusiondirectory_autoload'); -/*! \brief Checks if a class is available. - * +/*! \brief Checks if a class is available. + * * \param string 'name' The subject of the test - * + * * \return boolean Return TRUE if successfull FALSE otherwise */ function class_available($name) @@ -143,7 +143,7 @@ function class_available($name) * Checks if a given plugin is available and readable. * * \param string 'plugin' the subject of the check - * + * * \return boolean Return TRUE if successfull FALSE otherwise */ function plugin_available($plugin) @@ -158,7 +158,7 @@ function plugin_available($plugin) } -/*! \brief Create seed with microseconds +/*! \brief Create seed with microseconds * * Example: * \code @@ -174,25 +174,25 @@ function make_seed() { } -/*! \brief Debug level action +/*! \brief Debug level action * - * Print a DEBUG level if specified debug level of the level matches the + * Print a DEBUG level if specified debug level of the level matches the * the configured debug level. * * \param int 'level' The log level of the message (should use the constants, * defined in functions.in (DEBUG_TRACE, DEBUG_LDAP, etc.) - * + * * \param int 'line' Define the line of the logged action (using __LINE__ is common) - * + * * \param string 'function' Define the function where the logged action happened in * (using __FUNCTION__ is common) - * + * * \param string 'file' Define the file where the logged action happend in * (using __FILE__ is common) - * + * * \param mixed 'data' The data to log. Can be a message or an array, which is printed * with print_a - * + * * \param string 'info' Optional: Additional information * * */ @@ -247,7 +247,7 @@ function get_browser_language() } return($lang); } - + /* Load supported languages */ $gosa_languages= get_languages(); @@ -262,7 +262,7 @@ function get_browser_language() } -/*! \brief Rewrite ui object to another dn +/*! \brief Rewrite ui object to another dn * * Usually used when a user is renamed. In this case the dn * in the user object must be updated in order to point @@ -270,7 +270,7 @@ function get_browser_language() * * \param string 'dn' the old DN * \param string 'newdn' the new DN - * + * */ function change_ui_dn($dn, $newdn) { @@ -296,7 +296,7 @@ function change_ui_dn($dn, $newdn) * \param string 'filename' The base file name * \param boolean 'plugin' Flag to take the plugin directory as search base * \param string 'path' User specified path to take as search base - * + * * \return string Full path to the template file */ function get_template_path($filename= '', $plugin= FALSE, $path= "") @@ -387,7 +387,7 @@ function array_remove_entries_ics($needles, $haystack) * * \param array 'ar1' first array * \param array 'ar2' second array - * + * * \return array */ function fusiondirectory_array_merge($ar1,$ar2) @@ -428,7 +428,7 @@ function fusiondirectory_log ($message) /*! \brief Initialize a LDAP connection * - * Initializes a LDAP connection. + * Initializes a LDAP connection. * * \param string 'server' The server we are connecting to * \param string 'base' The base of our ldap tree @@ -460,7 +460,7 @@ function ldap_init ($server, $base, $binddn='', $pass='') /*! \brief Process htaccess authentication * - * Process htaccess authentication + * Process htaccess authentication * * \param string 'username' The username we ant to check * \param bool 'kerberos' TRUE to use kerberos FALSE otherwise @@ -474,7 +474,7 @@ function process_htaccess ($username, $kerberos= FALSE) /* 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 ($config->get_cfg_value("useSaslForKerberos") == "true"){ @@ -484,8 +484,8 @@ function process_htaccess ($username, $kerberos= FALSE) /* Look for entry or realm */ $ldap= $config->get_ldap_link(); if (!$ldap->success()){ - msg_dialog::display(_("LDAP error"), - msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), + msg_dialog::display(_("LDAP error"), + msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), FATAL_ERROR_DIALOG); exit(); } @@ -509,7 +509,7 @@ function process_htaccess ($username, $kerberos= FALSE) * to an LDAP user. The password has been checked by apache already. * * \param string 'username' The username to check. - * + * * \return * - TRUE on SUCCESS, NULL or FALSE on error */ @@ -520,8 +520,8 @@ function ldap_login_user_htaccess ($username) /* Look for entry or realm */ $ldap= $config->get_ldap_link(); if (!$ldap->success()){ - msg_dialog::display(_("LDAP error"), - msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), + msg_dialog::display(_("LDAP error"), + msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), FATAL_ERROR_DIALOG); exit(); } @@ -563,7 +563,7 @@ function ldap_login_user_htaccess ($username) * * \param string 'username' The username to check * \param string 'password' The password to check - * + * * \return * - TRUE on SUCCESS, NULL or FALSE on error */ @@ -574,8 +574,8 @@ function ldap_login_user ($username, $password) /* look through the entire ldap */ $ldap = $config->get_ldap_link(); if (!$ldap->success()){ - msg_dialog::display(_("LDAP error"), - msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), + msg_dialog::display(_("LDAP error"), + msgPool::ldaperror($ldap->get_error(), "", LDAP_AUTH)."<br><br>".session::get('errors'), FATAL_ERROR_DIALOG); exit(); } @@ -583,7 +583,7 @@ function ldap_login_user ($username, $password) $allowed_attributes = array("uid","mail"); $verify_attr = array(); if($config->get_cfg_value("loginAttribute") != ""){ - $tmp = explode(",", $config->get_cfg_value("loginAttribute")); + $tmp = explode(",", $config->get_cfg_value("loginAttribute")); foreach($tmp as $attr){ if(in_array($attr,$allowed_attributes)){ $verify_attr[] = $attr; @@ -609,7 +609,7 @@ function ldap_login_user ($username, $password) case 0: return (NULL); /* valid uniq user */ - case 1: + case 1: break; /* found more than one matching id */ @@ -663,23 +663,23 @@ function ldap_login_user ($username, $password) * \param object 'config' The FusionDirectory configuration object. * \param string 'userdn' The 'dn' of the user to test the account status for. * \param string 'uid' The 'uid' of the user we're going to test. - * \return const + * \return const * POSIX_ACCOUNT_EXPIRED - If the account is expired. * POSIX_WARN_ABOUT_EXPIRATION - If the account is going to expire. * POSIX_FORCE_PASSWORD_CHANGE - The password has to be changed. * POSIX_DISALLOW_PASSWORD_CHANGE - The password cannot be changed right now. - * - * - * - * shadowLastChange + * + * + * + * shadowLastChange * | * |---- shadowMin ---> | <-- shadowMax -- * | | | - * |------- shadowWarning -> | + * |------- shadowWarning -> | * |-- shadowInactive --> DEACTIVATED * | * EXPIRED - * + * */ function ldap_expired_account($config, $userdn, $uid) { @@ -693,7 +693,7 @@ function ldap_expired_account($config, $userdn, $uid) $attrs= $ldap->fetch(); $current= floor(date("U") /60 /60 /24); - // Fetch required attributes + // Fetch required attributes foreach(array('shadowExpire','shadowLastChange','shadowMax','shadowMin', 'shadowInactive','shadowWarning','sambaKickoffTime') as $attr){ $$attr = (isset($attrs[$attr][0]))? $attrs[$attr][0] : null; @@ -713,7 +713,7 @@ function ldap_expired_account($config, $userdn, $uid) // 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 + // 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){ @@ -722,7 +722,7 @@ function ldap_expired_account($config, $userdn, $uid) // It some kind of x days' grace. if($shadowInactive == null || $current > $shadowExpire + $shadowInactive){ - // Finally we've detect that the account is deactivated. + // Finally we've detect that the account is deactivated. return(POSIX_ACCOUNT_EXPIRED); } } @@ -731,16 +731,16 @@ function ldap_expired_account($config, $userdn, $uid) // -------------------------------------- // We've to warn the user in the case of an expiring account. // An account is going to expire when it reaches its expiration date (shadowExpire). - // The user has to be warned, if the days left till expiration, match the + // The user has to be warned, if the days left till expiration, match the // configured warning period (shadowWarning) // --> shadowWarning: Warn x days before account expiration. if($shadowExpire != null && $shadowWarning != null){ - // Check if the account is still active and not already expired. + // Check if the account is still active and not already expired. if($shadowExpire >= $current){ - // Check if we've to warn the user by comparing the remaining - // number of days till expiration with the configured amount + // Check if we've to warn the user by comparing the remaining + // number of days till expiration with the configured amount // of days in shadowWarning. if(($shadowExpire - $current) <= $shadowWarning){ return(POSIX_WARN_ABOUT_EXPIRATION); @@ -760,10 +760,10 @@ function ldap_expired_account($config, $userdn, $uid) // Check if we've to force the user to change his password. // -------------------------------------------------------- - // A password change is enforced when the password is older than + // A password change is enforced when the password is older than // the configured amount of days (shadowMax). - // The age of the current password (shadowLastChange) plus the maximum - // amount amount of days (shadowMax) has to be smaller than the + // The age of the current password (shadowLastChange) plus the maximum + // amount amount of days (shadowMax) has to be smaller than the // current timestamp. if($shadowLastChange != null && $shadowMax != null){ @@ -774,9 +774,9 @@ function ldap_expired_account($config, $userdn, $uid) } - // Check if we've to freeze the users password. + // Check if we've to freeze the users password. // -------------------------------------------- - // Once a user has changed his password, he cannot change it again + // Once a user has changed his password, he cannot change it again // for a given amount of days (shadowMin). // We should not allow to change the password within FusionDirectory too. if($shadowLastChange != null && $shadowMin != null){ @@ -785,7 +785,7 @@ function ldap_expired_account($config, $userdn, $uid) if(($shadowLastChange + $shadowMin) >= $current){ return(POSIX_DISALLOW_PASSWORD_CHANGE); } - } + } return(0); } @@ -794,7 +794,7 @@ function ldap_expired_account($config, $userdn, $uid) -/*! +/*! * \brief Add a lock for object(s) * * Adds a lock by the specified user for one ore multiple objects. @@ -807,7 +807,7 @@ function add_lock($object, $user) { global $config; - /* Remember which entries were opened as read only, because we + /* Remember which entries were opened as read only, because we don't need to remove any locks for them later. */ if(!session::global_is_set("LOCK_CACHE")){ @@ -886,7 +886,7 @@ function del_lock ($object) return; } - /* If this object was opened in read only mode then + /* If this object was opened in read only mode then skip removing the lock entry, there wasn't any lock created. */ if(session::global_is_set("LOCK_CACHE")){ @@ -924,7 +924,7 @@ function del_user_locks($userdn) { global $config; - /* Get LDAP ressources */ + /* Get LDAP ressources */ $ldap= $config->get_ldap_link(); $ldap->cd ($config->get_cfg_value("config")); @@ -941,9 +941,9 @@ function del_user_locks($userdn) * Searches for a lock on a given object. * * \param string 'object' subject whose locks are to be searched - * + * * \return string Returns the user who owns the lock or "" if no lock is found - * or an error occured. + * or an error occured. */ function get_lock ($object) { @@ -994,7 +994,7 @@ function get_lock ($object) * Similar as get_lock(), but for multiple objects. * * \param array 'objects' Array of Objects for which a lock will be searched - * + * * \return A numbered array containing all found locks as an array with key 'dn' * and key 'user' or "" if an error occured. */ @@ -1036,9 +1036,9 @@ function get_multiple_locks($objects) * * This function searches the ldap database. It searches in $sub_bases,*,$base * for all objects matching the $filter. - * + * * \param string 'filter' The ldap search filter - * \param string 'category' The ACL category the result objects belongs + * \param string 'category' The ACL category the result objects belongs * \param string 'sub_bases' The sub base we want to search for e.g. "ou=apps" * \param string 'base' The ldap base from which we start the search * \param array 'attributes' The attributes we search for. @@ -1072,15 +1072,15 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra /* Subsearch is activated and we got an empty sub_base. * (This may be the case if you have empty people/group ous). - * Fall back to old get_list(). + * Fall back to old get_list(). * A log entry will be written. */ if($flags & GL_SUBSEARCH){ $sub_bases = array(); break; }else{ - - /* Do NOT search within subtrees is requeste and the sub base is empty. + + /* Do NOT search within subtrees is requeste and the sub base is empty. * Append all known departments that matches the base. */ $departments[$base] = $base; @@ -1089,15 +1089,15 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra $sub_bases[$key] = preg_replace("/,.*$/","",$sub_base); } } - + /* If there is no sub_department specified, fall back to old method, get_list(). */ if(!count($sub_bases) && !count($departments)){ - + /* Log this fall back, it may be an unpredicted behaviour. */ if(!count($sub_bases) && !count($departments)){ - // log($action,$objecttype,$object,$changes_array = array(),$result = "") + // log($action,$objecttype,$object,$changes_array = array(),$result = "") new log("debug","all",__FILE__,$attributes, sprintf("get_sub_list(): Falling back to get_list(), due to empty sub_bases parameter.". " This may slow down FusionDirectory. Search was: '%s'",$filter)); @@ -1119,8 +1119,8 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra /* Only add those departments that match the reuested list of departments. * * e.g. sub_deps = array("ou=servers,ou=systems,"); - * - * In this case we have search for "ou=servers" and we may have also fetched + * + * In this case we have search for "ou=servers" and we may have also fetched * departments like this "ou=servers,ou=blafasel,..." * Here we filter out those blafasel departments. */ @@ -1196,12 +1196,12 @@ function get_sub_list($filter, $category,$sub_deps, $base= "", $attributes= arra /*! \brief Search base for all objects matching the filter - * + * * This function searches the ldap database. It search the $base * for all objects matching the $filter. - * + * * \param string 'filter' The ldap search filter - * \param string 'category' The ACL category the result objects belongs + * \param string 'category' The ACL category the result objects belongs * \param string 'base' The ldap base from which we start the search * \param array 'attributes' The attributes we search for. * \param long 'flags' A set of Flags @@ -1258,7 +1258,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G $category = array($category); } foreach ($category as $o){ - if((preg_match("/\//",$o) && preg_match("/r/",$ui->get_permissions($dn,$o))) || + if((preg_match("/\//",$o) && preg_match("/r/",$ui->get_permissions($dn,$o))) || (!preg_match("/\//",$o) && preg_match("/r/",$ui->get_category_permissions($dn, $o)))){ $result[]= $attrs; break; @@ -1266,7 +1266,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G } } } - + # if(microtime(TRUE) - $start > 0.1){ # echo sprintf("<pre>GET_LIST %s .| %f --- $base -----$filter ---- $flags</pre>",__LINE__,microtime(TRUE) - $start); # } @@ -1275,7 +1275,7 @@ function get_list($filter, $category, $base= "", $attributes= array(), $flags= G /*! \brief Show sizelimit configuration dialog - * + * * Show sizelimit configuration dialog when number * of entries exceeded the sizelimit */ @@ -1299,7 +1299,7 @@ function check_sizelimit() } /*! \brief Print a sizelimit warning - * + * * Print a sizelimit warning when number * of entries exceeded the sizelimit */ @@ -1374,7 +1374,7 @@ function getMenuCache() /*! \brief Return the current userinfo object - * + * * \return return the current userinfo object */ function &get_userinfo() @@ -1410,7 +1410,7 @@ function &get_smarty() * * \param string 'dn' the subject for the conversion * \param string 'base' the base dn, default: $this->config->current['BASE'] - * + * * \return a string in the form as described above */ function convert_department_dn($dn, $base = NULL) @@ -1470,17 +1470,17 @@ function get_sub_department($value) * $base = get_ou('systemRDN') . $this->config->current['BASE']; * $ldap->cd($base); * \endcode - * + * * \param 'name' the rdn of the ou you are trying to find - * + * * \return the ou associated the the RDN or nothing - * + * */ function get_ou($name) { global $config; - $map = array( + $map = array( "roleRDN" => "ou=roles,", "ogroupRDN" => "ou=groups,", "applicationRDN" => "ou=apps,", @@ -1523,7 +1523,7 @@ function get_ou($name) trigger_error("No department mapping found for type ".$name); return ""; } - + if ($ou != ""){ if (!preg_match('/^[^=]+=[^=]+/', $ou)){ $ou = @LDAP::convert("ou=$ou"); @@ -1536,17 +1536,17 @@ function get_ou($name) }else{ return("$ou,"); } - + } else { return ""; } } -/*! \brief Get the OU for users +/*! \brief Get the OU for users * * Function for getting the userRDN - * + * * \return the ou of the userRDN */ function get_people_ou() @@ -1558,7 +1558,7 @@ function get_people_ou() /*! \brief Get the OU for groups * * Function for getting the groupRDN - * + * * \return the ou of the groupRDN */ function get_groups_ou() @@ -1570,7 +1570,7 @@ function get_groups_ou() /*! \brief Get the OU for windows workstations * * Function for getting the sambaMachineAccountRDN - * + * * \return the ou of the sambaMachineAccountRDN */ function get_winstations_ou() @@ -1587,8 +1587,8 @@ function get_winstations_ou() * \endcode * * \param dn a string - * - * \return the base from the dn + * + * \return the base from the dn */ function get_base_from_people($dn) { @@ -1627,7 +1627,7 @@ function strict_uid_mode() /*! \brief Get regular expression for checking uids based on the naming * rules. - * + * * \return string Returns the desired regular expression */ function get_uid_regexp() @@ -1742,8 +1742,8 @@ function gen_locked_message($user, $dn, $allow_readonly = FALSE) * returned unchanged. * * \param mixed 'value' Whatever needs to be printed. - * - * \return string 'value' in html form. + * + * \return string 'value' in html form. */ function to_string ($value) { @@ -1771,7 +1771,7 @@ function to_string ($value) * $this->printerList = get_printer_list(); * \endcode * - * \return array an array with the CNs of the printers as key and value. + * \return array an array with the CNs of the printers as key and value. */ function get_printer_list() { @@ -1791,7 +1791,7 @@ function get_printer_list() * with less problematic characters, as defined in $REWRITE. * * \param string 's' the string to rewrite - * + * * \return string 's' the result of the rewrite */ function rewrite($s) @@ -1809,7 +1809,7 @@ function rewrite($s) /*! \brief Return the base of a given DN * * \param string 'dn' a DN - * + * * \return base of the given DN */ function dn2base($dn) @@ -1834,7 +1834,7 @@ function dn2base($dn) * arguments from the given cmdline. * * \param string 'cmdline' the cmdline to check - * + * * \return TRUE if command exists and is executable, otherwise FALSE. */ function check_command($cmdline) @@ -1860,7 +1860,7 @@ function check_command($cmdline) * \param string 'image' the path of the image to be used next to the headline * \param string 'headline' the headline * \param string 'info' additional information to print - * + * * \return the $display variable */ function print_header($image, $headline, $info= "") @@ -1980,7 +1980,7 @@ function range_selector($dcnt,$start,$range=25,$post_var=false) } if($var == $range){ $output.="\n<option selected='selected' value='".$var."'>".$num."</option>"; - }else{ + }else{ $output.="\n<option value='".$var."'>".$num."</option>"; } } @@ -1994,7 +1994,7 @@ function range_selector($dcnt,$start,$range=25,$post_var=false) /*! \brief Generate HTML for the 'Apply filter' button - * + * * \return the back button html code */ function apply_filter() @@ -2010,7 +2010,7 @@ function apply_filter() /*! \brief Generate HTML for the 'Back' button - * + * * \return the back button html code */ function back_to_main() @@ -2023,9 +2023,9 @@ function back_to_main() /*! \brief Put netmask in n.n.n.n format - * + * * \param string 'netmask' The netmask - * + * * \return string Converted netmask */ function normalize_netmask($netmask) @@ -2072,9 +2072,9 @@ function normalize_netmask($netmask) * $bits = netmask_to_bits('255.0.0.255') # Returns 16 * $bits = netmask_to_bits('255.255.0.255') # Returns 24 * \endcode - * + * * \param 'netmask' given netmask - * + * * \return the number of bits in the netmask */ function netmask_to_bits($netmask) @@ -2128,7 +2128,7 @@ function recurse($rule, $variables) * * \param string 'rule' The rule string from fusiondirectory.conf. * \param array 'attributes' A dictionary of attribute/value mappings - * + * * \return string Expanded string, still containing the id keyword. */ function expand_id($rule, $attributes) @@ -2173,21 +2173,21 @@ function expand_id($rule, $attributes) * * \param string 'rule' The rule string from fusiondirectory.conf. * \param array 'attributes' A dictionary of attribute/value mappings - * + * * \return array List of valid not used uids */ function gen_uids($rule, $attributes) { global $config; - // Strip out non ascii chars - foreach($attributes as $name => $value){ - $value = iconv('UTF-8', 'US-ASCII//TRANSLIT', $value); - $value = preg_replace('/[^(\x20-\x7F)]*/','',$value); - $attributes[$name] = $value; - } + // Strip out non ascii chars + foreach($attributes as $name => $value){ + $value = iconv('UTF-8', 'US-ASCII//TRANSLIT', $value); + $value = preg_replace('/[^(\x20-\x7F)]*/','',$value); + $attributes[$name] = $value; + } - /* Search for keys and fill the variables array with all + /* Search for keys and fill the variables array with all possible values for that key. */ $part= ""; $trigger= false; @@ -2288,7 +2288,7 @@ function gen_uids($rule, $attributes) * this function returns the byte value. * * \param string 'value' a value in the above specified format - * + * * \return a byte value or the original value if specified string is simply * a numeric value */ @@ -2317,15 +2317,15 @@ function to_byte($value) { /*! \brief Check if a value exists in an array (case-insensitive) - * + * * This is just as http://php.net/in_array except that the comparison * is case-insensitive. * * \param string 'value' needle * \param array 'items' haystack - * - * \return Return TRUE is value is found, FALSE if not. - */ + * + * \return Return TRUE is value is found, FALSE if not. + */ function in_array_ics($value, $items) { return preg_grep('/^'.preg_quote($value, '/').'$/i', $items); @@ -2365,9 +2365,9 @@ function generate_alphabet($count= 10) /*! \brief Removes malicious characters from a (POST) string. - * + * * \param string 'string' the string to check for malicious caracters - * + * * \return string with caracters removed */ function validate($string) @@ -2406,7 +2406,7 @@ function rmdirRecursive($path, $followLinks=false) { * * \param string 'path' * \param boolean weither to sort the content descending. - * + * * \return array content of directory in ascending sorted manner. */ function scan_directory($path,$sort_desc=false) @@ -2419,8 +2419,8 @@ function scan_directory($path,$sort_desc=false) /* is this path a readable one */ if(is_readable($path)){ - /* Get contents and write it into an array */ - $ret = array(); + /* Get contents and write it into an array */ + $ret = array(); $dir = opendir($path); @@ -2444,9 +2444,9 @@ function scan_directory($path,$sort_desc=false) /*! \brief Clean the smarty compile dir - * + * * \param string 'directory' smarty compile dir - * + * */ function clean_smarty_compile_dir($directory) { @@ -2487,12 +2487,12 @@ function clean_smarty_compile_dir($directory) } /*! \brief Create the revision file - * + * * Create the revision file in FusionDirectory spool dir - * + * * \param string 'revision file' the name of the revision file * \param string 'revision' the version of FusionDirectory - * + * * \return TRUE if successfully created FALSE otherwise */ function create_revision($revision_file, $revision) @@ -2514,12 +2514,12 @@ function create_revision($revision_file, $revision) } /*! \brief Compare the revision file - * + * * Create the revision file in FusionDirectory spool dir - * + * * \param string 'revision file' the name of the revision file * \param string 'revision' the version of FusionDirectory - * + * * \return TRUE if revision match FALSE otherwise */ function compare_revision($revision_file, $revision) @@ -2548,7 +2548,7 @@ function compare_revision($revision_file, $revision) /*! \brief Return HTML for a progressbar * * \code - * $smarty->assign("installprogress", progressbar($current_progress_in_percent),100,15,true); + * $smarty->assign("installprogress", progressbar($current_progress_in_percent),100,15,true); * \endcode * * \param int 'percentage' Value to display @@ -2575,7 +2575,7 @@ function progressbar($percentage,$width=100,$height=15,$showvalue=false) * * \param string 'key' needle * \param array 'items' haystack - * + * * \return return key or empty result */ function array_key_ics($ikey, $items) @@ -2594,7 +2594,7 @@ function array_key_ics($ikey, $items) * * \param array 'src' * \param array 'dst' - * + * * \return boolean TRUE or FALSE */ function array_differs($src, $dst) @@ -2609,9 +2609,9 @@ function array_differs($src, $dst) /*! \brief Escape all LDAP filter relevant characters - * + * * \param string input string wehre we should add \ before special caracters - * + * */ function normalizeLdap($input) { @@ -2619,11 +2619,11 @@ function normalizeLdap($input) } /*! \brief Test weither we are allowed to change the object - * + * * \param string 'dn' the DN of the object to check * \param string 'object' * \param string 'attribute' the attribute to check - * + * */ function obj_is_writable($dn, $object, $attribute) { @@ -2703,14 +2703,14 @@ function gosa_ldap_explode_dn($dn,$config = NULL,$verify_in_ldap=false) } /*! \brief Get base from external hook - * + * */ function get_base_from_hook($dn, $attrib) { global $config; if ($config->get_cfg_value("baseIdHook") != ""){ - + /* Call hook script - if present */ $command= $config->get_cfg_value("baseIdHook"); @@ -2741,10 +2741,10 @@ function get_base_from_hook($dn, $attrib) /*! \brief Check if schema version matches the requirements - * + * * \param string 'class' objectClass to check * \param string 'version' version to check for - * + * * \return TRUE if successfull FALSE otherwise */ function check_schema_version($class, $version) @@ -2754,7 +2754,7 @@ function check_schema_version($class, $version) /*! \brief Check if LDAP schema matches the requirements - * + * * \param string '$cfg' A config object * \param bool 'rfc2307bis' TRUE for checking for rfc2307bis FALSE otherwise * @@ -2908,7 +2908,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA "zh_CN" => "Chinese", "vi_VN" => "Vietnamese", "ru_RU" => "Russian"); - + $tmp2= array( "de_DE" => _("German"), "fr_FR" => _("French"), @@ -2928,14 +2928,14 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA $old_lang = setlocale(LC_ALL, 0); /* If the locale wasn't correclty set before, there may be an incorrect - locale returned. Something like this: + locale returned. Something like this: C_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC ... Extract the locale name from this string and use it to restore old locale. */ if(preg_match("/LC_CTYPE/",$old_lang)){ $old_lang = preg_replace("/^.*LC_CTYPE=([^;]*).*$/","\\1",$old_lang); } - + foreach($tmp as $key => $name){ $lang = $key.".UTF-8"; setlocale(LC_ALL, $lang); @@ -2965,7 +2965,7 @@ function get_languages($languages_in_own_language = FALSE,$strip_region_tag = FA * a certain POST variable. * * \param string 'name' the POST var to return ($_POST[$name]) - * + * * \return string * */ function get_post($name) @@ -2980,7 +2980,7 @@ function get_post($name) /*! \brief Return class name in correct case - * + * */ function get_correct_class_name($cls) { @@ -2997,7 +2997,7 @@ function get_correct_class_name($cls) /*! \brief Change the password of a given DN - * + * * Change the password of a given DN with the specified hash. * * \param string 'dn' the DN whose password shall be changed @@ -3005,7 +3005,7 @@ function get_correct_class_name($cls) * \param int mode if not 0 doesn't create the samba password hash * \param string 'hash' which hash to use to encrypt it, default is empty * for cleartext storage. - * + * * \return boolean TRUE on success FALSE on error */ function change_password ($dn, $password, $mode=0, $hash= "") @@ -3076,7 +3076,7 @@ function change_password ($dn, $password, $mode=0, $hash= "") if ($mode == 0){ // Create SMB Password - if ($config->get_cfg_value('sambaHashHook', NULL)) { + if ($config->get_cfg_value('sambaHashHook', NULL)) { $attrs= generate_smb_nt_hash($password); if ($shadow != 0){ @@ -3134,8 +3134,8 @@ function change_password ($dn, $password, $mode=0, $hash= "") * array['sambaLMPassword'] etc. * * \param string 'password' - * - * \return array contains several keys for lmPassword, ntPassword, pwdLastSet, etc. + * + * \return array contains several keys for lmPassword, ntPassword, pwdLastSet, etc. */ function generate_smb_nt_hash($password) { @@ -3197,7 +3197,7 @@ function getEntryCSN($dn) /*! \brief Add (a) given objectClass(es) to an attrs entry - * + * * The function adds the specified objectClass(es) to the given * attrs entry. * @@ -3221,14 +3221,14 @@ function add_objectClass($classes, &$attrs) /*! \brief Removes a given objectClass from the attrs entry - * + * * The function remove the specified objectClass(es) to the given * attrs entry. - * + * * \param mixed 'classes' Either a single objectClass or several objectClasses * as an array * \param array 'attrs' The attrs array to be removed. - * + * */ function remove_objectClass($classes, &$attrs) { @@ -3254,7 +3254,7 @@ function remove_objectClass($classes, &$attrs) /*! \brief Initialize a file download with given content, name and data type. - * + * * \param string data The content to send. * \param string name The name of the file. * \param string type The content identifier, default value is "application/octet-stream"; @@ -3274,7 +3274,7 @@ function send_binary_content($data,$name,$type = "application/octet-stream") if (preg_match ("/\//", $name)) { $name= basename($name); } - + /* force download dialog */ if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) || preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) { header('Content-Disposition: filename="'.$name.'"'); @@ -3301,16 +3301,16 @@ function reverse_html_entities($str,$type = ENT_QUOTES , $charset = "UTF-8") /*! \brief Encode special string characters - * + * * Encode the special caracters so we can use the string in * HTML output, without breaking quotes. - * + * * \param string 'str' The String we want to encode. - * + * * \return string The encoded String */ function xmlentities($str) -{ +{ if(is_string($str)){ static $asc2uni= array(); @@ -3338,10 +3338,10 @@ function xmlentities($str) /*! \brief Updates all accessTo attributes from a given value to a new one. - * + * * \param String $from The source accessTo name. * \param String $to The destination accessTo name. - * + * */ function update_accessTo($from,$to) { @@ -3361,7 +3361,7 @@ function update_accessTo($from,$to) $new_attrs['accessTo'][] = $to; } }else{ - $new_attrs['accessTo'][] = $attrs['accessTo'][$i]; + $new_attrs['accessTo'][] = $attrs['accessTo'][$i]; } } $ldap->cd($dn); @@ -3375,7 +3375,7 @@ function update_accessTo($from,$to) /*! \brief Returns a random char - * + * */ function get_random_char () { $randno = rand (0, 63); @@ -3389,10 +3389,10 @@ function get_random_char () { } /*! \brief Encrypt a string with RIJNDAEL_128 - * + * * \param string 'input' The string to encrypt. * \param String 'password' The password used - * + * */ function cred_encrypt($input, $password) { @@ -3404,10 +3404,10 @@ function cred_encrypt($input, $password) { } /*! \brief Decrypt a string with RIJNDAEL_128 - * + * * \param string 'input' The string to decrypt. * \param String 'password' The password used - * + * */ function cred_decrypt($input,$password) { $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); @@ -3429,11 +3429,11 @@ function set_object_info($str = "") } /*! \brief Test if an ip is the network range - * + * * \param string 'ip' The ip address to test. * \param string 'net' The network to test * \param string 'netmask' The netmask of the network - * + * */ function isIpInNet($ip, $net, $mask) { // Move to long ints @@ -3448,12 +3448,12 @@ function isIpInNet($ip, $net, $mask) { } /*! \brief Get next id - * + * * \param string 'attrib' attribute to use to find the next id. * \param String 'dn' Dn e want an id for. - * + * * \return Return the next id or NULL if failed - * + * */ function get_next_id($attrib, $dn) { @@ -3471,11 +3471,11 @@ function get_next_id($attrib, $dn) } /*! \brief Get next id from the sambaUnixIdPool - * + * * \param string 'attrib' attribute to use to find the next id. - * + * * \return Return the next id or NULL if failed - * + * */ function get_next_id_pool($attrib) { global $config; @@ -3571,12 +3571,12 @@ function get_next_id_pool($attrib) { } /*! \brief Get next id in a traditional unix way - * + * * \param string 'attrib' attribute to use to find the next id. * \param String 'dn' Dn e want an id for. - * + * * \return Return the next id - * + * */ function get_next_id_traditional($attrib, $dn) { @@ -3637,11 +3637,11 @@ function get_next_id_traditional($attrib, $dn) } /*! \brief Convert from date to seconds - * + * * \param string 'val' a date - * + * * \return Return the date converted into seconds - * + * */ function convertToSeconds($val) { @@ -3655,12 +3655,12 @@ function get_next_id_traditional($attrib, $dn) } /*! \brief Sort multidimensional arrays for key 'text' - * + * * \param string 'val1' * \param string 'val2' - * - * \return Return -1 if val2 > val1, 0 if equal, 1 if val1 > val2 - * + * + * \return Return -1 if val2 > val1, 0 if equal, 1 if val1 > val2 + * */ function sort_list($val1, $val2) { diff --git a/include/functions_debug.inc b/include/functions_debug.inc index 9c4cbfa1285ad574f70865e28d1115a3f53a495b..067e561b4c7f5d64edfdb48127f1352e66adaebe 100644 --- a/include/functions_debug.inc +++ b/include/functions_debug.inc @@ -1,39 +1,32 @@ <?php -/************************************************ +/************************************************ ** Title.........: Debug Lib ** Version.......: 0.5.4 -** Author........: Thomas Schüßler <tulpe@atomar.de> +** Author........: Thomas Schüßler <tulpe@atomar.de> ** Filename......: debuglib.php(s) ** Last changed..: 16. July 2003 ** License.......: Free to use. Postcardware ;) ** ************************************************* -** +** ** Functions in this library: -** +** ** print_a( array array [,int mode] ) ** prints arrays in a readable, understandable form. ** if mode is defined the function returns the output instead of ** printing it to the browser -** -** +** +** ** show_vars([int mode]) ** use this function on the bottom of your script to see all ** superglobals and global variables in your script in a nice ** formated way -** +** ** show_vars() without parameter shows $_GET, $_POST, $_SESSION, ** $_FILES and all global variables you've defined in your script ** ** show_vars(1) shows $_SERVER and $_ENV in addition ** -** -** -** print_result( result_handle ) -** prints a mysql_result set returned by mysql_query() as a table -** this function is work in progress! use at your own risk -** -** ** ** ** Happy debugging and feel free to email me your comments. @@ -55,8 +48,8 @@ $MICROTIME_START = microtime(); @$GLOBALS_initial_count = count($GLOBALS); } - -/************************************************ + +/************************************************ ** print_a class and helper function ** prints out an array in a more readable way ** than print_r() @@ -66,7 +59,7 @@ ************************************************/ class Print_a_class { - + # this can be changed to FALSE if you don't like the fancy string formatting var $look_for_leading_tabs = TRUE; @@ -82,25 +75,25 @@ class Print_a_class { var $export_dumper_path = 'http://tools.www.mdc.xmc.de/print_a_dumper/print_a_dumper.php'; # i'm still working on the dumper! don't use it now # put the next line into the print_a_dumper.php file (optional) - # print htmlspecialchars( stripslashes ( $_POST['array'] ) ); + # print htmlspecialchars( stripslashes ( $_POST['array'] ) ); var $export_hash; - + function Print_a_class() { $this->export_hash = uniqid(''); } - + # recursive function! function print_a($array, $iteration = FALSE, $key_bg_color = FALSE) { $key_bg_color or $key_bg_color = $this->key_bg_color; - + # if print_a() was called with a fourth parameter (1 or 2) # and you click on the table a window opens with only the output of print_a() in it # 1 = serialized array # 2 = normal print_a() display - + /* put the following code on the page defined with $export_dumper_path; --->%---- snip --->%---- - + if($_GET['mode'] == 1) { print htmlspecialchars( stripslashes ( $_POST['array'] ) ); } elseif($_GET['mode'] == 2) { @@ -109,11 +102,11 @@ class Print_a_class { ---%<---- snip ---%<---- */ - + if( !$iteration && isset($this->export_flag) ) { $this->output .= '<form id="pa_form_'.$this->export_hash.'" action="'.$this->export_dumper_path.'?mode='.$this->export_flag.'" method="post" target="_blank"><input name="array" type="hidden" value="'.htmlspecialchars( serialize( $array ) ).'"></form>'; } - + # lighten up the background color for the key td's =) if( $iteration ) { for($i=0; $i<6; $i+=2) { @@ -125,42 +118,42 @@ class Print_a_class { } $key_bg_color = $tmp_key_bg_color; } - + # build a single table ... may be nested $this->output .= '<table summary="" style="border:none;" cellspacing="1" '.( !$iteration && $this->export_flag ? 'onClick="document.getElementById(\'pa_form_'.$this->export_hash.'\').submit();" )' : '' ).'>'; foreach( $array as $key => $value ) { - + $value_style = 'color:black;'; $key_style = 'color:white;'; - + $type = gettype( $value ); # print $type.'<br />'; - + # change the color and format of the value switch( $type ) { case 'array': break; - + case 'object': $key_style = 'color:#FF9B2F;'; break; - + case 'integer': $value_style = 'color:green;'; break; - + case 'double': $value_style = 'color:red;'; break; - + case 'bool': $value_style = 'color:blue;'; break; - + case 'resource': $value_style = 'color:darkblue;'; break; - + case 'string': if( $this->look_for_leading_tabs && preg_match('/^\t/m', $value) ) { $search = array('/\t/', "/\n/"); @@ -180,7 +173,7 @@ class Print_a_class { $this->output .= '</td>'; $this->output .= '<td nowrap="nowrap" style="background-color:#'.$this->value_bg_color.';font: '.$this->fontsize.' '.$this->fontfamily.'; color:black;">'; - + # value output if($type == 'array') { if(count($value)){ @@ -197,7 +190,7 @@ class Print_a_class { } else { $this->output .= '<div style="'.$value_style.'" title="'.$type.'">'.$value.'</div>'; } - + $this->output .= '</td>'; $this->output .= '</tr>'; } @@ -207,21 +200,21 @@ class Print_a_class { # helper function.. calls print_a() inside the print_a_class function print_a( $array, $return_mode = FALSE, $show_object_vars = FALSE, $export_flag = FALSE ) { - $e= error_reporting (0); + $e= error_reporting (0); if( is_array( $array ) or is_object( $array ) ) { $pa = new Print_a_class; $show_object_vars and $pa->show_object_vars = TRUE; $export_flag and $pa->export_flag = $export_flag; - + $pa->print_a( $array ); - + # $output = $pa->output; unset($pa); $output = &$pa->output; } else { $output = '<span style="color:red;font-size:small;">print_a( '.gettype( $array ).' )</span>'; } - - error_reporting ($e); + + error_reporting ($e); if($return_mode) { return $output; } else { @@ -230,92 +223,6 @@ function print_a( $array, $return_mode = FALSE, $show_object_vars = FALSE, $expo } } - -// shows mysql-result as a table.. # not ready yet :( -function print_result($RESULT) { - - if(!$RESULT) return; - - $fieldcount = mysql_num_fields($RESULT); - - for($i=0; $i<$fieldcount; $i++) { - $tables[mysql_field_table($RESULT, $i)]++; - } - - print ' - <style type="text/css"> - .rs_tb_th { - font-family: Verdana; - font-size:9pt; - font-weight:bold; - color:white; - } - .rs_f_th { - font-family:Verdana; - font-size:7pt; - font-weight:bold; - color:white; - } - .rs_td { - font-family:Verdana; - font-size:7pt; - } - </style> - <script type="text/javascript" language="JavaScript"> - var lastID; - function highlight(id) { - if(lastID) { - lastID.style.color = "#000000"; - lastID.style.textDecoration = "none"; - } - tdToHighlight = document.getElementById(id); - tdToHighlight.style.color ="#FF0000"; - tdToHighlight.style.textDecoration = "underline"; - lastID = tdToHighlight; - } - </script> - '; - - print '<table summary="" border="0" bgcolor="#000000" cellspacing="1" cellpadding="1">'; - - print '<tr>'; - foreach($tables as $tableName => $tableCount) { - $col == '0054A6' ? $col = '003471' : $col = '0054A6'; - print '<th colspan="'.$tableCount.'" class="rs_tb_th" style="background-color:#'.$col.';">'.$tableName.'</th>'; - } - print '</tr>'; - - print '<tr>'; - for($i=0;$i < mysql_num_fields($RESULT);$i++) { - $FIELD = mysql_field_name($RESULT, $i); - $col == '0054A6' ? $col = '003471' : $col = '0054A6'; - print '<td align="center" bgcolor="#'.$col.'" class="rs_f_th">'.$FIELD.'</td>'; - } - print '</tr>'; - - mysql_data_seek($RESULT, 0); - - while($DB_ROW = mysql_fetch_array($RESULT, MYSQL_NUM)) { - $pointer++; - if($toggle) { - $col1 = "E6E6E6"; - $col2 = "DADADA"; - } else { - $col1 = "E1F0FF"; - $col2 = "DAE8F7"; - } - $toggle = !$toggle; - print '<tr id="ROW'.$pointer.'" onMouseDown="highlight(\'ROW'.$pointer.'\');">'; - foreach($DB_ROW as $value) { - $col == $col1 ? $col = $col2 : $col = $col1; - print '<td valign="top" bgcolor="#'.$col.'" class="rs_td" nowrap>'.nl2br($value).'</td>'; - } - print '</tr>'; - } - print '</table>'; - mysql_data_seek($RESULT, 0); -} - function _script_globals() { global $GLOBALS_initial_count; @@ -329,7 +236,7 @@ function _script_globals() { } } } - + unset($script_GLOBALS['GLOBALS_initial_count']); return $script_GLOBALS; } @@ -341,7 +248,7 @@ function show_runtime() { $GENERATIONSEC = $MICROTIME_END[1] - $MICROTIME_START[1]; $GENERATIONMSEC = $MICROTIME_END[0] - $MICROTIME_START[0]; $GENERATIONTIME = substr($GENERATIONSEC + $GENERATIONMSEC, 0, 8); - + return '<span style="color:red;font-weight:normal;font-size:9px;">(runtime: '.$GENERATIONTIME.' sec)</span>'; } @@ -354,7 +261,7 @@ function show_runtime() { # function show_vars($show_all_vars = FALSE, $show_object_vars = FALSE) { if(isset($GLOBALS['no_vars'])) return; - + $script_globals = _script_globals(); print ' <style type="text/css"> @@ -402,21 +309,21 @@ function show_vars($show_all_vars = FALSE, $show_object_vars = FALSE) { # function prints sql strings # function pre($sql_string, $simple_mode = FALSE) { - + if(!$simple_mode) { # erste leere Zeile im SQL löschen $sql_string = preg_replace('/\^s+/m','', $sql_string); # letze leere Zeile im SQL löschen $sql_string = preg_replace('/\s+$/m','', $sql_string); - + # kleinste Anzahl von führenden TABS zählen preg_match_all('/^\t+/m', $sql_string, $matches); $minTabCount = strlen(min($matches[0])); - + # und entfernen $sql_string = preg_replace('/^\t{'.$minTabCount.'}/m', '', $sql_string); } - + print '<pre>'.$sql_string.'</pre>'; } ?>