Custom error handling function. When a PHP error occurs, PHP will call this function rather than printing
the typical PHP error string. This provides the application the ability to
format an error message so that it looks better.
Optionally, it can present a link so that a user can search/submit bugs.
This function is not to be called directly. It is exclusively for the use of
PHP internally. If this function is called by PHP from within a context
where error handling has been disabled (ie, from within a function called
with "@" prepended), then this function does nothing.
Arguments
Name
Type
Description
Default
$errno
n/a
$errstr
n/a
$file
n/a
$lineno
n/a
Return value
Type
Description
n/a
n/a
Tags
Name
Description
see
app_name(
)
:
n/a
Description
Returns the application name.
Return value
Type
Description
n/a
n/a
app_version(
)
:
string
Description
Returns the application version currently running. The version
is read from the file named VERSION.
Return value
Type
Description
string
The current version as read from the VERSION file.
auto_lang(
$lang,
)
:
n/a
Description
This function will convert the browser two character language into the
default 5 character language, where the country portion should NOT be
assumed to be upper case characters of the first two characters.
Arguments
Name
Type
Description
Default
$lang
n/a
Return value
Type
Description
n/a
n/a
check_config(
$config_file,
)
:
n/a
Description
Makes sure that the config file is properly setup.
Arguments
Name
Type
Description
Default
$config_file
n/a
Return value
Type
Description
n/a
n/a
cmd_control_pane(
$type,
)
:
array
Description
Commands available in the control_panel of the page
Debug Logging The global debug level is turned on in your configuration file by setting:
$config->custom->debug['level'] = 255;
together with atleast one output direction (currently file and syslog are supported).
$config->custom->debug['file'] = '/tmp/app_debug.log';
$config->custom->debug['syslog'] = true;
The debug level is turned into binary, then if the message levels bit is on
the message will be sent to the debug log. (Thus setting your debug level to 255,
all bits on, will results in all messages being printed.)
The message level bits are defined here.
0( 1) = Entry/Return results from function calls.
1( 2) = Configuration Processing
2( 4) = Template Processing
3( 8) = Schema Processing
4( 16) = LDAP Server Communication
5( 32) = Tree Processing
7( 64) = Other non generic messages
8(128) = Page Processing
9(256) = Hooks Processing
Returns the cached array of LDAP resources. Note that internally, this function utilizes a two-layer cache,
one in memory using a static variable for multiple calls within
the same page load, and one in a session for multiple calls within
the same user session (spanning multiple page loads).
Arguments
Name
Type
Description
Default
$index
n/a
$item
n/a
$subitem
n/a
'null'
Return value
Type
Description
\Returns
the cached attributed requested,
or null if there is nothing cached..
Utility wrapper for setting cookies, which takes into consideration
application configuration values. On success, true is returned. On
failure, false is returned.
Fetches whether the user has configured phpLDAPadmin to obfuscate passwords
with "*********" when displaying them. This is configured in config.php thus:
$config->custom->appearance['obfuscate_password_display'] = true;
Or if it is OK to show encrypted passwords but not clear text passwords
$config->custom->appearance['show_clear_password'] = false;
Arguments
Name
Type
Description
Default
$enc
n/a
null
Return value
Type
Description
boolean
pretty_print_dn(
$dn,
)
:
string
Description
Returns an HTML-beautified version of a DN. Internally, this function makes use of pla_explode_dn() to break the
the DN into its components. It then glues them back together with
"pretty" HTML. The returned HTML is NOT to be used as a real DN, but
simply displayed.
Arguments
Name
Type
Description
Default
$dn
n/a
Return value
Type
Description
string
is_dn_string(
$str,
)
:
boolean
Description
Given a string, this function returns true if the string has the format
of a DN (ie, looks like "cn=Foo,dc=example,dc=com"). Returns false otherwise. The purpose of this function is so that developers can examine a string and
know if it looks like a DN, and draw a hyperlink as needed.
(See unit_test.php for test cases)
Arguments
Name
Type
Description
Default
$str
n/a
Return value
Type
Description
boolean
is_mail_string(
$str,
)
:
boolean
Description
Get whether a string looks like an email address (user@example.com).
Arguments
Name
Type
Description
Default
$str
n/a
Return value
Type
Description
boolean
Returns true if the specified string looks like an email address or false otherwise.
is_url_string(
$str,
)
:
boolean
Description
Get whether a string looks like a web URL (http://www.example.com/)
Arguments
Name
Type
Description
Default
$str
n/a
Return value
Type
Description
boolean
Returns true if the specified string looks like a web URL or false otherwise.
pla_compare_dns(
$dn1,
$dn2,
)
:
int
Description
Compares 2 DNs. If they are equivelant, returns 0, otherwise,
returns their sorting order (similar to strcmp()):
Returns < 0 if dn1 is less than dn2. Returns > 0 if dn1 is greater than dn2.
The comparison is performed starting with the top-most element
of the DN. Thus, the following list:
ou=people,dc=example,dc=com
cn=Admin,ou=People,dc=example,dc=com
cn=Joe,ou=people,dc=example,dc=com
dc=example,dc=com
cn=Fred,ou=people,dc=example,dc=org
cn=Dave,ou=people,dc=example,dc=org
Will be sorted thus using usort( $list, "pla_compare_dns" ):
dc=com
dc=example,dc=com
ou=people,dc=example,dc=com
cn=Admin,ou=People,dc=example,dc=com
cn=Joe,ou=people,dc=example,dc=com
cn=Dave,ou=people,dc=example,dc=org
cn=Fred,ou=people,dc=example,dc=org
For LDAP servers with auto_number enabled, this function will get the next
available number using the host's preferred mechanism (pool or search). This is configured in config.php by server:
$servers->setValue('auto_number','enable',true|false);
The available mechanisms are:
pool:
The pool mechanism uses a user-configured entry in the LDAP server to
store the last used "number". This mechanism simply fetches and increments
and returns that value.
search:
The search mechanism will search the LDAP server that has the attribute
set. It will then find the smallest value and "fills in the gaps" by
incrementing the smallest attribute until an unused value is found.
NOTE: Both mechanisms do NOT prevent race conditions or toe-stomping, so
care must be taken when actually creating the entry to check that the number
returned here has not been used in the mean time. Note that the two different
mechanisms may (will!) return different values as they use different algorithms
to arrive at their result. Do not be alarmed if (when!) this is the case.
See config.php.example for more notes on the two mechanisms.
Given a DN and server ID, this function reads the DN's objectClasses and
determines which icon best represents the entry. The results of this query
are cached in a session variable so it is not run every time the tree
browser changes, just when exposing new DNs that were not displayed
previously. That means we can afford a little bit of inefficiency here
in favor of coolness. :) This function returns a string like "country.png". All icon files are assumed
to be contained in the /images/ directory of phpLDAPadmin.
Developers are encouraged to add new icons to the images directory and modify
this function as needed to suit their types of LDAP entries. If the modifications
are general to an LDAP audience, the phpLDAPadmin team will gladly accept them
as a patch.
Appends a servers base to a "sub" dn or returns the base.
Arguments
Name
Type
Description
Default
$base
n/a
$sub_dn
n/a
Return value
Type
Description
string|null
Returns null if both base is null and sub_dn is null or empty
random_salt(
$length,
)
:
string
Description
Used to generate a random salt for crypt-style passwords. Salt strings are used
to make pre-built hash cracking dictionaries difficult to use as the hash algorithm uses
not only the user's password but also a randomly generated string. The string is
stored as the first N characters of the hash for reference of hashing algorithms later.
Given a DN string, this returns the 'RDN' portion of the string. For example. given 'cn=Manager,dc=example,dc=com', this function returns
'cn=Manager' (it is really the exact opposite of ds_ldap::getContainer()).
Arguments
Name
Type
Description
Default
$dn
n/a
$include_attrs
n/a
0
$decode
n/a
false
Return value
Type
Description
string
The RDN
rdn_explode(
$rdn,
)
:
n/a
Description
Split an RDN into its attributes
Arguments
Name
Type
Description
Default
$rdn
n/a
Return value
Type
Description
n/a
n/a
pla_verbose_error(
$key,
)
:
array
Description
Given an LDAP error number, returns a verbose description of the error. This function parses ldap_error_codes.txt and looks up the specified
ldap error number, and returns the verbose message defined in that file.
Array (
[title] => "Invalid Credentials"
[description] => "An invalid username and/or password was supplied to the LDAP server."
)
Arguments
Name
Type
Description
Default
$key
n/a
Return value
Type
Description
array
An associative array contianing the error title and description like so:
support_oid_to_text(
$key,
)
:
array
Description
Given an LDAP OID number, returns a verbose description of the OID. This function parses ldap_supported_oids.txt and looks up the specified
OID, and returns the verbose message defined in that file.
Array (
[title] => All Operational Attribute
[ref] => RFC 3673
[desc] => An LDAP extension which clients may use to request the return of all operational attributes.
)
Arguments
Name
Type
Description
Default
$key
n/a
Return value
Type
Description
array
An associative array contianing the OID title and description like so:
Draw the jpegPhoto image(s) for an entry wrapped in HTML. Many options are available to
specify how the images are to be displayed. Usage Examples:
draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',"jpegPhoto",0,true,array('img_opts'=>"border: 1px; width: 150px"));
draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',null,1);
Arguments
Name
Type
Description
Default
$server
n/a
$dn
n/a
$attr_name
n/a
'jpegphoto'
$index
n/a
$draw_delete_buttons
n/a
false
$options
n/a
array()
Return value
Type
Description
n/a
n/a
password_types(
)
:
n/a
Description
Return the list of available password types
Return value
Type
Description
n/a
n/a
Tags
Name
Description
todo
Dynamically work this list out so we only present hashes that we can encrypt
Given a clear-text password and a hash, this function determines if the clear-text password
is the password that was used to generate the hash. This is handy to verify a user's password
when all that is given is the hash and a "guess".
Arguments
Name
Type
Description
Default
$cryptedpassword
n/a
$plainpassword
n/a
$attribute
n/a
'userpassword'
Return value
Type
Description
Boolean
True if the clear password matches the hash, and false otherwise.
get_enc_type(
$user_password,
)
:
string
Description
Detects password encryption type Returns crypto string listed in braces. If it is 'crypt' password,
returns crypto detected in password hash. Function should detect
md5crypt, blowfish and extended DES crypt. If function fails to detect
encryption type, it returns NULL.
Explode a DN into an array of its RDN parts. NOTE: When a multivalue RDN is passed to ldap_explode_dn, the results returns with 'value + value';
Array (
[0] => uid=ppratt
[1] => ou=People
[2] => dc=example
[3] => dc=com
)
Converts an array to a query-string with the option to exclude certain variables
from the returned query string. This is convenient if callers want to convert the
current GET query string or POST array into a string and replace certain
variables with their own.
Arguments
Name
Type
Description
Default
$array
n/a
$exclude_vars
n/a
array()
Return value
Type
Description
string
The string created from the array.
pla_reverse_dn(
$dn,
)
:
string
Description
Reverses a DN such that the top-level RDN is first and the bottom-level RDN is last
For example:
cn=Brigham,ou=People,dc=example,dc=com
Becomes:
dc=com,dc=example,ou=People,cn=Brigham
This makes it possible to sort lists of DNs such that they are grouped by container.
Arguments
Name
Type
Description
Default
$dn
n/a
Return value
Type
Description
string
The reversed DN
Tags
Name
Description
see
see
sortAttrs(
$a,
$b,
)
:
n/a
Description
Attribute sorting
Arguments
Name
Type
Description
Default
$a
n/a
$b
n/a
Return value
Type
Description
n/a
n/a
arrayLower(
array
$array,
)
:
n/a
Description
Reads an array and returns the array values back in lower case
Arguments
Name
Type
Description
Default
$array
array
The array to convert the values to lowercase.
Return value
Type
Description
n/a
n/a
Tags
Name
Description
returns
array Array with values converted to lowercase.
draw_formatted_dn(
$server,
$entry,
)
:
n/a
Description
Gets a DN string using the user-configured tree_display_format string to format it.
This function returns a string automatically generated
based on the criteria defined in the array $criteria in config.php
Return value
Type
Description
n/a
n/a
a_array_rand(
$input,
$num_req,
)
:
string
Description
This function returns an array of $num_req values
randomly picked from the $input array
Arguments
Name
Type
Description
Default
$input
n/a
$num_req
n/a
Return value
Type
Description
string
The padded string
random_junk(
)
:
n/a
Description
This is for Opera. By putting "random junk" in the query string, it thinks
that it does not have a cached version of the page, and will thus
fetch the page rather than display the cached version
Return value
Type
Description
n/a
n/a
htmlid(
$sid,
$dn,
)
:
string
Description
Returns a HTML id that can be used in the URL after the #.