FusionDirectory
 All Data Structures Files Functions Variables
Functions | Variables
functions.inc File Reference

Go to the source code of this file.

Functions

 __fusiondirectory_autoload ($class_name)
 Does autoloading for classes used in FusionDirectory. More...
 
 class_available ($name)
 Checks if a class is available. More...
 
 plugin_available ($plugin)
 Check if plugin is available. More...
 
 load_plist ($ldap_available=TRUE)
 Loads plist and load it in config object.
 
 make_seed ()
 Create seed with microseconds. More...
 
 DEBUG ($level, $line, $function, $file, $data, $info= '')
 Debug level action. More...
 
 get_browser_language ()
 Determine which language to show to the user. More...
 
 get_template_path ($filename= '', $plugin=FALSE, $path= '')
 Return themed path for specified base file. More...
 
 array_remove_entries (array $needles, array $haystack)
 Remove multiple entries from an array. More...
 
 array_remove_entries_ics (array $needles, array $haystack)
 Remove multiple entries from an array (case-insensitive) More...
 
 array_merge_unique ($ar1, $ar2)
 Merge to array but remove duplicate entries (case-insensitive) More...
 
 fusiondirectory_log ($message)
 Generate a system log info. More...
 
 ldap_init ($server, $base, $binddn= '', $pass= '')
 Initialize a LDAP connection. More...
 
 ldap_get_user ($username)
 Get user from LDAP directory. More...
 
 ldap_login_user ($username, $password)
 Verify user login against LDAP directory. More...
 
 add_lock ($object, $user)
 Add a lock for object(s) More...
 
 del_lock ($object)
 Remove a lock for object(s) More...
 
 del_user_locks ($userdn)
 Remove all locks owned by a specific userdn. More...
 
 get_lock ($object)
 Get a lock for a specific object. More...
 
 get_locks ($objects, $allow_readonly=FALSE)
 Get locks for objects. More...
 
 check_sizelimit ()
 Show sizelimit configuration dialog. More...
 
 print_sizelimit_warning ()
 Print a sizelimit warning. More...
 
 eval_sizelimit ()
 Handle sizelimit dialog related posts.
 
get_userinfo ()
 Return the current userinfo object. More...
 
get_smarty ()
 Get global smarty object. More...
 
 convert_department_dn ($dn, $base=NULL)
 Convert a department DN to a sub-directory style list. More...
 
 get_ou ($name)
 Get the OU of a certain RDN. More...
 
 get_people_ou ()
 Get the OU for users. More...
 
 get_base_from_people ($dn)
 Return a base from a given user DN. More...
 
 strict_uid_mode ()
 Check if strict naming rules are configured. More...
 
 gen_locked_message ($locks, $dn, $allow_readonly=FALSE)
 Generate a lock message. More...
 
 to_string ($value)
 Return a string/HTML representation of an array. More...
 
 rewrite ($s)
 Function to rewrite some problematic characters. More...
 
 dn2base ($dn, $ou=NULL)
 Return the base of a given DN. More...
 
 check_command ($cmdline)
 Check if a given command exists and is executable. More...
 
 print_header ($image, $headline, $info= '')
 Print plugin HTML header. More...
 
 back_to_main ()
 Generate HTML for the 'Back' button. More...
 
 normalize_netmask ($netmask)
 Put netmask in n.n.n.n format. More...
 
 netmask_to_bits ($netmask)
 Return the number of set bits in the netmask. More...
 
 _recurse_gen_uids ($rule, $variables)
 Recursion helper for gen_uids()
 
 gen_uids ($rule, $attributes)
 Generate a list of uid proposals based on a rule. More...
 
 to_byte ($value)
 Convert various data sizes to bytes. More...
 
 humanReadableSize ($bytes, $precision=2)
 Convert a size in bytes to a human readable version. More...
 
 in_array_ics ($value, array $items)
 Check if a value exists in an array (case-insensitive) More...
 
 generate_alphabet ($count=10)
 Generate a clickable alphabet.
 
 validate ($string)
 Removes malicious characters from a (POST) string. More...
 
 rmdirRecursive ($path, $followLinks=FALSE)
 Recursively delete a path in the file system. More...
 
 scan_directory ($path, $sort_desc=FALSE)
 Get directory content information. More...
 
 clean_smarty_compile_dir ($directory)
 Clean the smarty compile dir. More...
 
 create_revision ($revision_file, $revision)
 Create the revision file. More...
 
 compare_revision ($revision_file, $revision)
 Compare the revision file. More...
 
 array_key_ics ($ikey, array $items)
 Lookup a key in an array case-insensitive. More...
 
 array_differs ($src, $dst)
 Determine if two arrays are different. More...
 
 array_differs_recursive ($src, $dst)
 Determine if two arrays are different using recursion for sublevels. More...
 
 normalizeLdap ($input)
 Escape all LDAP filter relevant characters. More...
 
 check_schema ($cfg)
 Check if LDAP schema matches the requirements. More...
 
 get_languages ($languages_in_own_language=FALSE, $strip_region_tag=FALSE)
 Get the language for the user connecting. More...
 
 language_is_rtl ($lang)
 Returns TRUE if $lang is a right to left language ($lang should match /.._..(.UTF-8)?/)
 
 get_post ($name)
 Returns contents of the given POST variable and check magic quotes settings. More...
 
 get_correct_class_name ($cls)
 Return class name in correct case.
 
 change_password ($dn, $password, $hash="")
 Change the password of a given DN. More...
 
 getEntryCSN ($dn)
 Get the Change Sequence Number of a certain DN. More...
 
 send_binary_content ($data, $name, $type="application/octet-stream")
 Initialize a file download with given content, name and data type. More...
 
 xmlentities ($str)
 Encode special string characters. More...
 
 get_random_char ()
 Returns a random char.
 
 cred_decrypt ($input, $password)
 Decrypt a string with RIJNDAEL_128. More...
 
 isIpInNet ($ip, $net, $mask)
 Test if an ip is the network range. More...
 
 expandIPv6 ($ip)
 Expands an IP v6.
 
 initLanguage ($lang=NULL)
 

Variables

const DEBUG_LDAP 2
 
const DEBUG_DB 4
 
const DEBUG_SHELL 8
 
const DEBUG_POST 16
 
const DEBUG_SESSION 32
 
const DEBUG_CONFIG 64
 
const DEBUG_ACL 128
 
const DEBUG_SI 256
 
const DEBUG_MAIL 512
 
const DEBUG_FAI 1024
 

Detailed Description

Common functions and named definitions.

Definition in file functions.inc.

Function Documentation

__fusiondirectory_autoload (   $class_name)

Does autoloading for classes used in FusionDirectory.

Takes the list generated by 'fusiondirectory-setup' and loads the file containing the requested class.

Parameters
array$class_namelist of class name

Definition at line 86 of file functions.inc.

References DEBUG().

add_lock (   $object,
  $user 
)

Add a lock for object(s)

Adds a lock by the specified user for one ore multiple objects. If the lock for that object already exists, an error is triggered.

Parameters
array$objectThe object or array of objects to lock
string$userThe user who shall own the lock

Definition at line 619 of file functions.inc.

References msg_dialog\display(), get_ou(), session\global_get_ref(), session\global_is_set(), session\global_set(), msgPool\ldaperror(), and LdapGeneralizedTime\toString().

Referenced by simpleManagement\editEntry(), simplePlugin\mainInc(), and simpleManagement\removeEntryRequested().

array_differs (   $src,
  $dst 
)

Determine if two arrays are different.

Parameters
array$srcThe source
array$dstThe destination
Returns
boolean TRUE or FALSE

Definition at line 1941 of file functions.inc.

Referenced by simplePlugin\cleanup().

array_differs_recursive (   $src,
  $dst 
)

Determine if two arrays are different using recursion for sublevels.

Parameters
array$srcThe source
array$dstThe destination
Returns
boolean TRUE or FALSE

Definition at line 1960 of file functions.inc.

array_key_ics (   $ikey,
array  $items 
)

Lookup a key in an array case-insensitive.

Given an associative array this can lookup the value of a certain key, regardless of the case.

1 $items = array ('FOO' => 'blub', 'bar' => 'blub');
2 array_key_ics('foo', $items); # Returns 'blub'
3 array_key_ics('BAR', $items); # Returns 'blub'
Parameters
string$ikeyneedle
array$itemshaystack
Returns
return key or empty result

Definition at line 1920 of file functions.inc.

array_merge_unique (   $ar1,
  $ar2 
)

Merge to array but remove duplicate entries (case-insensitive)

Merges two arrays and removes duplicate entries. Triggers an error if first or second parametre is not an array.

Parameters
array$ar1first array
array$ar2second array
Returns
array

Definition at line 412 of file functions.inc.

array_remove_entries ( array  $needles,
array  $haystack 
)

Remove multiple entries from an array.

Removes every element that is in $needles from the array given as $haystack

Parameters
array$needlesarray of the entries to remove
array$haystackoriginal array to remove the entries from

Definition at line 378 of file functions.inc.

array_remove_entries_ics ( array  $needles,
array  $haystack 
)

Remove multiple entries from an array (case-insensitive)

Removes every element that is in $needles from the array given as $haystack but case insensitive

Parameters
array$needlesarray of the entries to remove
array$haystackoriginal array to remove the entries from

Definition at line 394 of file functions.inc.

back_to_main ( )

Generate HTML for the 'Back' button.

Returns
the back button html code

Definition at line 1389 of file functions.inc.

References msgPool\backButton().

Referenced by simplePlugin\execute().

change_password (   $dn,
  $password,
  $hash = "" 
)

Change the password of a given DN.

Change the password of a given DN with the specified hash.

Parameters
string$dnthe DN whose password shall be changed
string$passwordthe password
string$hashwhich hash to use to encrypt it, default is empty for reusing existing hash method for this password (or use the default one).
Returns
boolean TRUE on success and an error strings array on failure.

Definition at line 2252 of file functions.inc.

References objects\open().

check_command (   $cmdline)

Check if a given command exists and is executable.

Test if a given cmdline contains an executable command. Strips arguments from the given cmdline.

Parameters
string$cmdlinethe cmdline to check
Returns
TRUE if command exists and is executable, otherwise FALSE.

Definition at line 1340 of file functions.inc.

check_schema (   $cfg)

Check if LDAP schema matches the requirements.

Parameters
string$cfgA config object

Definition at line 1999 of file functions.inc.

References class_available(), and msg_dialog\display().

check_sizelimit ( )

Show sizelimit configuration dialog.

Show sizelimit configuration dialog when number of entries exceeded the sizelimit

Definition at line 865 of file functions.inc.

References session\get(), get_smarty(), get_template_path(), session\global_get(), session\global_is_set(), and session\is_set().

Referenced by listing\render().

class_available (   $name)

Checks if a class is available.

Parameters
string$nameThe subject of the test
Returns
boolean Return TRUE if successfull FALSE otherwise

Definition at line 130 of file functions.inc.

Referenced by check_schema(), LDAP\get_objectclasses(), ldap_login_user(), config\load_servers(), and config\set_current().

clean_smarty_compile_dir (   $directory)

Clean the smarty compile dir.

Parameters
string$directorysmarty compile dir

Definition at line 1805 of file functions.inc.

References compare_revision(), create_revision(), msg_dialog\display(), FD_VERSION, and scan_directory().

compare_revision (   $revision_file,
  $revision 
)

Compare the revision file.

Create the revision file in FusionDirectory spool dir

Parameters
string$revision_filethe name of the revision file
string$revisionthe version of FusionDirectory
Returns
TRUE if revision match FALSE otherwise

Definition at line 1879 of file functions.inc.

References msg_dialog\display().

Referenced by clean_smarty_compile_dir().

convert_department_dn (   $dn,
  $base = NULL 
)

Convert a department DN to a sub-directory style list.

This function returns a DN in a sub-directory style list. Examples:

  • ou=1.1.1,ou=limux becomes limux/1.1.1
  • cn=bla,ou=foo,dc=local becomes foo/bla or foo/bla/local, depending on the value for $base.

If the specified DN contains a basedn which either matches the specified base or $config->current['BASE'] it is stripped.

Parameters
string$dnthe subject for the conversion
string$basethe base dn, default: $config->current['BASE']
Returns
a string in the form as described above

Definition at line 978 of file functions.inc.

Referenced by config\get_departments().

create_revision (   $revision_file,
  $revision 
)

Create the revision file.

Create the revision file in FusionDirectory spool dir

Parameters
string$revision_filethe name of the revision file
string$revisionthe version of FusionDirectory
Returns
TRUE if successfully created FALSE otherwise

Definition at line 1851 of file functions.inc.

References msg_dialog\display().

Referenced by clean_smarty_compile_dir().

cred_decrypt (   $input,
  $password 
)

Decrypt a string with RIJNDAEL_128.

Parameters
string$inputThe string to decrypt.
String$passwordThe password used

Definition at line 2443 of file functions.inc.

Referenced by config\get_credentials().

DEBUG (   $level,
  $line,
  $function,
  $file,
  $data,
  $info = '' 
)

Debug level action.

Print a DEBUG level if specified debug level of the level matches the the configured debug level.

Parameters
int$levelThe log level of the message (should use the constants, defined in functions.in (DEBUG_TRACE, DEBUG_LDAP, etc.)
int$lineDefine the line of the logged action (using LINE is common)
string$functionDefine the function where the logged action happened in (using FUNCTION is common)
string$fileDefine the file where the logged action happend in (using FILE is common)
mixed$dataThe data to log. Can be a message or an array, which is printed with print_a
string$infoOptional: Additional information

Definition at line 219 of file functions.inc.

References session\global_get().

Referenced by simplePlugin\__construct(), __fusiondirectory_autoload(), simpleTabs\adapt_from_template(), CopyPasteHandler\add_to_queue(), simpleManagement\applyChanges(), simplePlugin\callHook(), simpleTabs\check(), simplePlugin\check(), simpleManagement\copyPasteHandler(), SnapshotHandler\createSnapshot(), simpleManagement\createSnapshot(), simpleManagement\createSnapshotDialog(), simpleManagement\editEntry(), simplePlugin\execute(), initLanguage(), CopyPasteHandler\load_entry_from_ldap(), simplePlugin\move(), simpleManagement\newEntry(), objects\open(), simpleManagement\removeEntryRequested(), SnapshotHandler\restoreSnapshot(), simpleManagement\restoreSnapshot(), simpleManagement\restoreSnapshotDialog(), simplePlugin\save(), simpleTabs\save_object(), simplePlugin\save_object(), and simpleManagement\saveChanges().

del_lock (   $object)

Remove a lock for object(s)

Remove a lock for object(s)

Parameters
mixed$objectobject or array of objects for which a lock shall be removed

Definition at line 689 of file functions.inc.

References msg_dialog\display(), get_ou(), session\global_get_ref(), session\global_is_set(), and msgPool\ldaperror().

Referenced by simplePlugin\mainInc(), and simpleManagement\remove_lock().

del_user_locks (   $userdn)

Remove all locks owned by a specific userdn.

For a given userdn remove all existing locks. This is usually called on logout.

Parameters
string$userdnthe subject whose locks shall be deleted

Definition at line 738 of file functions.inc.

References get_ou().

dn2base (   $dn,
  $ou = NULL 
)

Return the base of a given DN.

Parameters
string$dna DN
string$ouan ou to remove from the base
Returns
base of the given DN

Definition at line 1314 of file functions.inc.

References get_ou(), and get_people_ou().

Referenced by Attribute\check().

fusiondirectory_log (   $message)

Generate a system log info.

Creates a syslog message, containing user information.

Parameters
string$messagethe message to log

Definition at line 429 of file functions.inc.

gen_locked_message (   $locks,
  $dn,
  $allow_readonly = FALSE 
)

Generate a lock message.

This message shows a warning to the user, that a certain object is locked and presents some choices how the user can proceed. By default this is 'Cancel' or 'Edit anyway', but depending on the function call its possible to allow readonly access, too.

Example usage:

1 if ($locks = get_locks($this->dn)) {
2  return gen_locked_message($locks, $this->dn, TRUE);
3 }
Parameters
string$userthe user who holds the lock
string$dnthe locked DN
boolean$allow_readonlyTRUE if readonly access should be permitted, FALSE if not (default).

Definition at line 1189 of file functions.inc.

References session\get(), get_smarty(), get_template_path(), session\is_set(), and session\set().

Referenced by simpleManagement\editEntry(), simplePlugin\mainInc(), and simpleManagement\removeEntryRequested().

gen_uids (   $rule,
  $attributes 
)

Generate a list of uid proposals based on a rule.

Unroll given rule string by filling in attributes and replacing all keywords.

Parameters
string$ruleThe rule string from fusiondirectory.conf.
array$attributesA dictionary of attribute/value mappings
Returns
array List of valid not used uids

Definition at line 1510 of file functions.inc.

References _recurse_gen_uids(), and templateHandling\parseMask().

get_base_from_people (   $dn)

Return a base from a given user DN.

1 get_base_from_people('cn=Max Muster,dc=local')
2 # Result is 'dc=local'
Parameters
string$dn
Returns
the base from the dn

Definition at line 1130 of file functions.inc.

References get_people_ou().

Referenced by listing\update().

get_browser_language ( )

Determine which language to show to the user.

Determines which language should be used to present fusiondirectory content to the user. It does so by looking at several possibilites and returning the first setting that can be found.

  1. Language configured by the user
  2. Global configured language
  3. Language as returned by al2gt (as configured in the browser)
Returns
string gettext locale string

Definition at line 265 of file functions.inc.

References get_languages(), and get_userinfo().

Referenced by initLanguage().

get_languages (   $languages_in_own_language = FALSE,
  $strip_region_tag = FALSE 
)

Get the language for the user connecting.

Parameters
boolean$languages_in_own_languageFALSE
boolean$strip_region_tagFALSE

Definition at line 2111 of file functions.inc.

Referenced by get_browser_language().

get_lock (   $object)

Get a lock for a specific object.

Searches for a lock on a given object.

Parameters
string$objectsubject whose locks are to be searched
Returns
string Returns the dn of the user who owns the lock or '' if no lock is found or FALSE if an error occured.

Definition at line 764 of file functions.inc.

References msg_dialog\display(), and get_locks().

get_locks (   $objects,
  $allow_readonly = FALSE 
)

Get locks for objects.

Similar as get_lock(), but for multiple objects.

Parameters
mixed$objectsArray of dns for which a lock will be searched or dn of a single object
boolean$allow_readonlyTRUE if readonly access should be permitted, FALSE if not (default).
Returns
A numbered array containing all found locks as an array with key 'object' and key 'user', or FALSE if an error occured.

Definition at line 801 of file functions.inc.

References msg_dialog\display(), LdapGeneralizedTime\fromString(), get_ou(), and msgPool\ldaperror().

Referenced by simpleManagement\editEntry(), get_lock(), simplePlugin\mainInc(), and simpleManagement\removeEntryRequested().

get_ou (   $name)

Get the OU of a certain RDN.

Given a certain RDN name (ogroupRDN, applicationRDN etc.) this function returns either a configured OU or the default for the given RDN.

Example:

1 # Determine LDAP base where systems are stored
2 $base = get_ou('systemRDN') . $config->current['BASE'];
3 $ldap->cd($base);
Parameters
$namethe rdn of the ou you are trying to find
Returns
the ou associated the the RDN or nothing

Definition at line 1020 of file functions.inc.

Referenced by add_lock(), del_lock(), del_user_locks(), dn2base(), get_locks(), and get_people_ou().

get_people_ou ( )

Get the OU for users.

Function for getting the userRDN

Returns
the ou of the userRDN

Definition at line 1114 of file functions.inc.

References get_ou().

Referenced by dn2base(), and get_base_from_people().

get_post (   $name)

Returns contents of the given POST variable and check magic quotes settings.

Depending on the magic quotes settings this returns a stripclashed'ed version of a certain POST variable.

Parameters
string$namethe POST var to return ($_POST[$name])
Returns
string

Definition at line 2211 of file functions.inc.

References validate().

& get_smarty ( )
get_template_path (   $filename = '',
  $plugin = FALSE,
  $path = '' 
)

Return themed path for specified base file.

Depending on its parameters, this function returns the full path of a template file. First match wins while searching in this order:

  • load theme depending file
  • load global theme depending file
  • load default theme file
  • load global default theme file
Parameters
string$filenameThe base file name
boolean$pluginFlag to take the plugin directory as search base
string$pathUser specified path to take as search base
Returns
string Full path to the template file

Definition at line 315 of file functions.inc.

References session\global_get().

Referenced by simplePlugin\__construct(), check_sizelimit(), msg_dialog\execute(), gen_locked_message(), msg_dialog\get_dialogs(), simpleManagement\getHeader(), simplePlugin\mainInc(), simpleManagement\removeEntryRequested(), listing\render(), filter\render(), and pluglist\show_iconmenu().

& get_userinfo ( )

Return the current userinfo object.

Returns
return the current userinfo object

Definition at line 941 of file functions.inc.

Referenced by simplePlugin\aclGetPermissions(), simplePlugin\callHook(), CopyPasteHandler\execute(), get_browser_language(), listing\getDepartments(), listing\refreshBasesList(), and listing\update().

getEntryCSN (   $dn)

Get the Change Sequence Number of a certain DN.

To verify if a given object has been changed outside of FusionDirectory in the meanwhile, this function can be used to get the entryCSN from the LDAP directory. It uses the attribute as configured in modificationDetectionAttribute

Parameters
string$dnThe dn you want to check
Returns
either the result or "" in any other case

Definition at line 2332 of file functions.inc.

Referenced by simplePlugin\__construct(), and simplePlugin\check().

humanReadableSize (   $bytes,
  $precision = 2 
)

Convert a size in bytes to a human readable version.

Parameters
float$bytessize in bytes
int$precisionnumber of digits after comma, default is 2
Returns
Returns something like '9.77KiB' for arguments (10000, 2)

Definition at line 1643 of file functions.inc.

in_array_ics (   $value,
array  $items 
)

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.

Parameters
string$valueneedle
array$itemshaystack
Returns
Return TRUE is value is found, FALSE if not.

Definition at line 1677 of file functions.inc.

Referenced by pluglist\__construct(), simplePlugin\__construct(), acl\extractMembers(), userinfo\loadACL(), and listing\refreshBasesList().

initLanguage (   $lang = NULL)
Parameters
string$subjectThe subject string
string$ignoreSet of characters to leave untouched
int$flagsAny combination of LDAP_ESCAPE_* flags to indicate the set(s) of characters to escape.
Returns
string

Definition at line 2550 of file functions.inc.

References DEBUG(), get_browser_language(), session\global_get(), session\global_is_set(), session\global_set(), session\global_un_set(), load_plist(), and LOCALE_DIR.

Referenced by config\set_current().

isIpInNet (   $ip,
  $net,
  $mask 
)

Test if an ip is the network range.

Parameters
string$ipThe ip address to test.
string$netThe network to test
string$maskThe netmask of the network

Definition at line 2489 of file functions.inc.

ldap_get_user (   $username)

Get user from LDAP directory.

Search the user by login or other fields authorized by the configuration

Parameters
string$usernameThe username or email to check
Returns
userinfo instance on SUCCESS, FALSE if not found, string error on error

Definition at line 494 of file functions.inc.

References msg_dialog\display(), session\get(), and msgPool\ldaperror().

Referenced by ldap_login_user().

ldap_init (   $server,
  $base,
  $binddn = '',
  $pass = '' 
)

Initialize a LDAP connection.

Initializes a LDAP connection.

Parameters
string$serverThe server we are connecting to
string$baseThe base of our ldap tree
string$binddnDefault: empty
string$passDefault: empty
Returns
LDAP object

Definition at line 464 of file functions.inc.

References msg_dialog\display().

Referenced by config\get_ldap_link().

ldap_login_user (   $username,
  $password 
)

Verify user login against LDAP directory.

Checks if the specified username is in the LDAP and verifies if the password is correct by binding to the LDAP with the given credentials.

Parameters
string$usernameThe username to check
string$passwordThe password to check
Returns
TRUE on SUCCESS, NULL or FALSE on error

Definition at line 566 of file functions.inc.

References class_available(), msg_dialog\display(), and ldap_get_user().

make_seed ( )

Create seed with microseconds.

Example:

1 srand(make_seed());
2 $random = rand();
Returns
float a floating point number which can be used to feed srand() with it

Definition at line 190 of file functions.inc.

netmask_to_bits (   $netmask)

Return the number of set bits in the netmask.

For a given subnetmask (for example 255.255.255.0) this returns the number of set bits.

Example:

1 $bits = netmask_to_bits('255.255.255.0') # Returns 24
2 $bits = netmask_to_bits('255.255.254.0') # Returns 23

Be aware of the fact that the function does not check if the given subnet mask is actually valid. For example: Bad examples:

1 $bits = netmask_to_bits('255.0.0.255') # Returns 16
2 $bits = netmask_to_bits('255.255.0.255') # Returns 24
Parameters
$netmaskgiven netmask
Returns
the number of bits in the netmask

Definition at line 1452 of file functions.inc.

normalize_netmask (   $netmask)

Put netmask in n.n.n.n format.

Parameters
string$netmaskThe netmask
Returns
string Converted netmask

Definition at line 1402 of file functions.inc.

normalizeLdap (   $input)

Escape all LDAP filter relevant characters.

Parameters
string$inputstring where we should add \ before special caracters

Definition at line 1988 of file functions.inc.

plugin_available (   $plugin)

Check if plugin is available.

Checks if a given plugin is available and readable.

Parameters
string$pluginthe subject of the check
Returns
boolean Return TRUE if successfull FALSE otherwise

Definition at line 146 of file functions.inc.

Referenced by simpleTabs\__construct(), simpleTabs\addSpecialTabs(), pluglist\gen_menu(), and pluglist\show_iconmenu().

print_header (   $image,
  $headline,
  $info = '' 
)

Print plugin HTML header.

Parameters
string$imagethe path of the image to be used next to the headline
string$headlinethe headline
string$infoadditional information to print
Returns
the $display variable

Definition at line 1368 of file functions.inc.

References get_smarty().

Referenced by simpleManagement\getHeader(), and simplePlugin\mainInc().

print_sizelimit_warning ( )

Print a sizelimit warning.

Print a sizelimit warning when number of entries exceeded the sizelimit

Definition at line 890 of file functions.inc.

References session\get(), session\global_get(), session\global_is_set(), and session\is_set().

Referenced by listing\render().

rewrite (   $s)

Function to rewrite some problematic characters.

This function takes a string and replaces all possibly characters in it with less problematic characters, as defined in $REWRITE.

Parameters
string$sthe string to rewrite
Returns
string $s the result of the rewrite

Definition at line 1294 of file functions.inc.

rmdirRecursive (   $path,
  $followLinks = FALSE 
)

Recursively delete a path in the file system.

Will delete the given path and all its files recursively. Can also follow links if told so.

Parameters
string$path
boolean$followLinksTRUE to follow links, FALSE (default) for not following links

Definition at line 1738 of file functions.inc.

scan_directory (   $path,
  $sort_desc = FALSE 
)

Get directory content information.

Returns the content of a directory as an array in an ascending sorted manner.

Parameters
string$path
boolean$sort_descweither to sort the content descending.
Returns
array content of directory in ascending sorted manner.

Definition at line 1765 of file functions.inc.

Referenced by clean_smarty_compile_dir().

send_binary_content (   $data,
  $name,
  $type = "application/octet-stream" 
)

Initialize a file download with given content, name and data type.

Parameters
string$dataThe content to send.
string$nameThe name of the file.
string$typeThe content identifier, default value is "application/octet-stream";

Definition at line 2361 of file functions.inc.

Referenced by listing\update().

strict_uid_mode ( )

Check if strict naming rules are configured.

Return TRUE or FALSE depending on weither strictNamingRules are configured or not.

Returns
Returns TRUE if strictNamingRules is set to TRUE or if the config object is not available, otherwise FALSE.

Definition at line 1155 of file functions.inc.

Referenced by tests\is_uid().

to_byte (   $value)

Convert various data sizes to bytes.

Given a certain value in the format n(g|m|k), where n is a value and (g|m|k) stands for Gigabyte, Megabyte and Kilobyte this function returns the byte value.

Parameters
string$valuea value in the above specified format
Returns
a byte value or the original value if specified string is simply a numeric value

Definition at line 1610 of file functions.inc.

to_string (   $value)

Return a string/HTML representation of an array.

This returns a string representation of a given value. It can be used to dump arrays, where every value is printed on its own line. The output is targetted at HTML output, it uses '
' for line breaks. If the value is already a string its returned unchanged.

Parameters
mixed$valueWhatever needs to be printed.
Returns
string $value in html form.

Definition at line 1271 of file functions.inc.

validate (   $string)

Removes malicious characters from a (POST) string.

Parameters
string$stringthe string to check for malicious caracters
Returns
string with caracters removed

Definition at line 1722 of file functions.inc.

Referenced by eval_sizelimit(), generate_alphabet(), get_post(), listing\getAction(), filter\renderAlphabet(), filter\update(), and listing\update().

xmlentities (   $str)

Encode special string characters.

Encode the special caracters so we can use the string in HTML output, without breaking quotes.

Parameters
string$strThe String we want to encode.
Returns
string The encoded String

Definition at line 2406 of file functions.inc.

Variable Documentation

const DEBUG_ACL 128

Debug level for CONFIG information

Definition at line 43 of file functions.inc.

const DEBUG_CONFIG 64

Debug level for SESSION content

Definition at line 42 of file functions.inc.

Referenced by config\set_current().

const DEBUG_DB 4

Debug level for LDAP queries

Definition at line 38 of file functions.inc.

const DEBUG_FAI 1024

Debug level for all about mail (mailAccounts, imap, sieve etc.)

Definition at line 46 of file functions.inc.

const DEBUG_LDAP 2

Debug level for tracing of common actions (save, check, etc.)

Definition at line 37 of file functions.inc.

Referenced by simplePlugin\move().

const DEBUG_MAIL 512

Debug level for communication with Argonaut

Definition at line 45 of file functions.inc.

const DEBUG_POST 16

Debug level for shell commands

Definition at line 40 of file functions.inc.

const DEBUG_SESSION 32

Debug level for POST content

Definition at line 41 of file functions.inc.

const DEBUG_SHELL 8

Debug level for database operations

Definition at line 39 of file functions.inc.

Referenced by simplePlugin\callHook().

const DEBUG_SI 256

Debug level for ACL infos

Definition at line 44 of file functions.inc.