RELEASE 0.9.8

This commit is contained in:
Deon George
2009-06-30 20:26:08 +10:00
parent 1f7f96122f
commit fdee1bdbd1
242 changed files with 34529 additions and 34446 deletions

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.68.2.6 2005/10/22 04:42:40 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.76.2.6 2005/12/30 02:32:41 wurley Exp $
/**
* Contains code to be executed at the top of each phpLDAPadmin page.
@@ -16,13 +16,15 @@
* @package phpLDAPadmin
*/
$timer = stopwatch();
@define('LIBDIR','../lib/');
# For PHP5 backward/forward compatibility
if (! defined('E_STRICT'))
define('E_STRICT',2048);
# General functions needed to proceed (pla_ldap_search(), pla_error(), get_object_attrs(), etc.)
# General functions needed to proceed.
ob_start();
require_once realpath(LIBDIR.'functions.php');
ob_end_clean();
@@ -33,10 +35,6 @@ set_error_handler('pla_error_handler');
# Disable error reporting until all our required functions are loaded.
error_reporting(0);
/* Creates the language array which will be populated with localized strings
based on the user-configured language. */
$lang = array();
/*
* functions.php should have defined our pla_function_files array, listing all our
* required functions (order IS important).
@@ -54,15 +52,15 @@ ob_end_clean();
# We are now ready for error reporting.
# Turn on all notices and warnings. This helps us write cleaner code (we hope at least)
if (phpversion() >= "5") {
if (phpversion() >= '5') {
# Work-around to get PLA to work in PHP5
ini_set( "zend.ze1_compatibility_mode", 1 );
ini_set('zend.ze1_compatibility_mode',1);
# E_DEBUG is PHP5 specific and prevents warnings about using 'var' to declare class members
error_reporting( E_DEBUG );
error_reporting(E_DEBUG);
} else
# For PHP4
error_reporting( E_ALL );
error_reporting(E_ALL);
/**
* At this point we have read all our additional function PHP files and our configuration.
@@ -80,53 +78,63 @@ if (pla_session_start())
*/
$language = $config->GetValue('appearance','language');
# Get english by default, in case there are tags that are missing.
ob_start();
include LANGDIR."recoded/en.php";
ob_end_clean();
if ($language == "auto") {
if ($language == 'auto') {
# Make sure their browser correctly reports language. If not, skip this.
if( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
# get the languages which are spetcified in the HTTP header
$HTTP_LANGS1 = preg_split ("/[;,]+/", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
$HTTP_LANGS2 = preg_split ("/[;,]+/", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
foreach( $HTTP_LANGS2 as $key => $value ) {
$value=preg_split ("/[-]+/", $value );
$HTTP_LANGS2[$key]=$value[0];
# Get the languages which are spetcified in the HTTP header
$HTTP_LANGS = preg_split ('/[;,]+/',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($HTTP_LANGS as $key => $value) {
if (substr($value,0,2) == 'q=') {
unset($HTTP_LANGS[$key]);
continue;
}
$value = preg_split('/[-]+/',$value);
if (sizeof($value) == 2)
$HTTP_LANGS[$key] = strtolower($value[0]).'_'.strtoupper($value[1]);
else
$HTTP_LANGS[$key] = auto_lang(strtolower($value[0]));
}
$HTTP_LANGS = array_merge ($HTTP_LANGS1, $HTTP_LANGS2);
foreach( $HTTP_LANGS as $HTTP_LANG) {
# try to grab one after the other the language file
$language_file = LANGDIR."recoded/$HTTP_LANG.php";
if( file_exists($language_file) &&
is_readable($language_file)) {
ob_start();
include $language_file;
ob_end_clean();
$HTTP_LANGS = array_unique($HTTP_LANGS);
foreach ($HTTP_LANGS as $HTTP_LANG) {
# Try to grab one after the other the language file
$language_file = LANGDIR.$HTTP_LANG;
if ((substr($HTTP_LANG,0,2) == 'en') ||
(file_exists($language_file) && is_readable($language_file))) {
# Set language
putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE
setlocale(LC_ALL,$HTTP_LANG); # set LC_ALL to de_DE
bindtextdomain('messages',LANGDIR);
bind_textdomain_codeset('messages','UTF-8');
textdomain('messages');
header('Content-type: text/html; charset=UTF-8',true);
break;
}
}
}
} else {
# grab the language file configured in config.php
if( $language != null ) {
if( 0 == strcmp( $language, 'english' ) )
$language = 'en';
# Grab the language file configured in config.php
if ($language != null) {
if (strcmp($language,'english') == 0)
$language = 'en_GB';
$language_file = LANGDIR."recoded/$language.php";
if( file_exists($language_file) &&
is_readable($language_file)) {
ob_start();
include $language_file;
ob_end_clean();
} else {
pla_error(sprintf('Could not read language file "%s". Either the file does not exist, or its permissions do not allow phpLDAPadmin to read it.',$language_file));
}
$language_file = LANGDIR.$language;
# Set language
putenv('LANG='.$language); # e.g. LANG=de_DE
setlocale(LC_ALL,$language); # set LC_ALL to de_DE
bindtextdomain('messages',LANGDIR);
bind_textdomain_codeset('messages','UTF-8');
textdomain('messages');
header('Content-type: text/html; charset=UTF-8', true);
}
}
@@ -138,7 +146,7 @@ if (! isset($templates) || ! is_array($templates))
$templates['custom'] =
array('desc' => 'Custom',
'icon' => 'images/object.png',
'handler' => 'custom.php' );
'handler' => 'custom.php');
/*
* Strip slashes from GET, POST, and COOKIE variables if this
@@ -149,7 +157,6 @@ if (get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped
array_stripslashes($_GET);
array_stripslashes($_POST);
array_stripslashes($_COOKIE);
array_stripslashes($_FILES);
$slashes_stripped = true;
}
@@ -162,4 +169,36 @@ if (isset($_REQUEST['server_id'])) {
if ($ldapserver->haveAuthInfo())
set_lastactivity($ldapserver);
}
/**
* Timer stopwatch, used to instrument PLA
*/
function stopwatch() {
static $mt_previous = 0;
list($usec, $sec) = explode(' ',microtime());
$mt_current = (float)$usec + (float)$sec;
if (! $mt_previous) {
$mt_previous = $mt_current;
return 0;
} else {
$mt_diff = ($mt_current - $mt_previous);
$mt_previous = $mt_current;
return sprintf('%.5f',$mt_diff);
}
}
/**
* 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.
*/
function auto_lang($lang) {
switch ($lang) {
case 'ja': return 'ja_JP';
default: return sprintf('%s_%s',$lang,strtoupper($lang));
}
}
?>

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.11.2.5 2005/10/22 11:34:07 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.16.2.5 2005/12/08 19:54:38 wurley Exp $
/**
* Configuration processing and defaults.
@@ -28,7 +28,6 @@ class Config {
$this->default->appearance['anonymous_bind_implies_read_only'] = array(
'desc'=>'Display as read only if user logs in with anonymous bind',
'default'=>true);
//$anonymous_bind_implies_read_only = true;
/* Anonymous redirect
* Set to true if you want phpLDAPadmin to redirect anonymous
@@ -38,21 +37,18 @@ class Config {
$this->default->appearance['anonymous_bind_redirect_no_tree'] = array(
'desc'=>'Redirect user to search form if anonymous',
'default'=>false);
//$anonymous_bind_redirect_no_tree = false;
$this->default->appearance['date'] = array(
'desc'=>'Date format whenever dates are shown',
'default'=>'%A %e %B %Y');
//$date_format = "%A %e %B %Y";
$this->default->appearance['date_attrs'] = array(
'desc'=>'Array of attributes that should show a jscalendar',
'default'=>array('shadowExpire'=>'%es','shadowInactive'=>'%es','shadowLastChange'=>'%es'));
'default'=>array('shadowExpire'=>'%es','shadowLastChange'=>'%es'));
$this->default->appearance['hide_configuration_management'] = array(
'desc'=>'Hide the Sourceforge related links',
'default'=>false);
//$hide_configuration_management = false;
/** Language
* The language setting. If you set this to 'auto', phpLDAPadmin will
@@ -64,7 +60,6 @@ class Config {
$this->default->appearance['language'] = array(
'desc'=>'Language',
'default'=>'auto');
//$language = 'auto';
/** Mass Delete
* Set to true if you want to draw a checkbox next to each entry in the tree viewer
@@ -73,7 +68,6 @@ class Config {
$this->default->appearance['mass_delete'] = array(
'desc'=>'Enable mass delete in tree viewer',
'default'=>false);
//$enable_mass_delete = false;
/**
* If you want certain attributes to be editable as multi-line, include them in this list
@@ -82,7 +76,6 @@ class Config {
$this->default->appearance['multi_line_attributes'] = array(
'desc'=>'Attributes to show as multiline attributes',
'default'=>array("postalAddress","homePostalAddress","personalSignature"));
//$multi_line_attributes = array( "postalAddress", "homePostalAddress", "personalSignature" );
/**
* A list of syntax OIDs which support multi-line attribute values:
@@ -94,7 +87,6 @@ class Config {
"1.3.6.1.4.1.1466.115.121.1.40",
// postal address syntax OID:
"1.3.6.1.4.1.1466.115.121.1.41"));
//$multi_line_syntax_oids ...
/** Obfuscate Password
* If true, display all password hash values as "******". Note that clear-text
@@ -103,7 +95,6 @@ class Config {
$this->default->appearance['obfuscate_password_display'] = array(
'desc'=>'Obfuscate the display of passwords',
'default'=>false);
//$obfuscate_password_display = false;
$this->default->appearance['show_clear_password'] = array(
'desc'=>'Whether to show clear passwords if we dont obfuscate them',
@@ -116,7 +107,6 @@ class Config {
$this->default->appearance['show_hints'] = array(
'desc'=>'Show helpful hints',
'default'=>true);
//$show_hints = true; // set to false to disable hints
/** Tree display
* A format string used to display enties in the tree viewer (left-hand side)
@@ -142,12 +132,14 @@ class Config {
$this->default->appearance['tree_display_format'] = array(
'desc'=>'LDAP attribute to show in the tree',
'default'=>'%rdn');
//$tree_display_format = '%rdn';
$this->default->appearance['tree_width'] = array(
'desc'=>'Pixel width of the left frame view (tree browser)',
'default'=>320);
//$tree_width = 320; // pixels
$this->default->appearance['tree_plm'] = array(
'desc'=>'Whether to enable the PHPLayersMenu for the tree',
'default'=>false);
/** Caching
*/
@@ -159,6 +151,10 @@ class Config {
'desc'=>'Cache Template configuration',
'default'=>true);
$this->default->cache['tree'] = array(
'desc'=>'Cache Browser Tree',
'default'=>true);
/** Aliases and Referrrals
* Similar to ldapsearch's -a option, the following options allow you to configure
* how phpLDAPadmin will treat aliases and referrals in the LDAP tree.
@@ -173,31 +169,26 @@ class Config {
* LDAP_DEREF_ALWAYS - aliases should be dereferenced always (eg, the contents
* of the referenced entry is shown and not the aliasing entry)
*/
$this->default->deref['export'] = array(
@$this->default->deref['export'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$export_deref = LDAP_DEREF_NEVER;
$this->default->deref['search'] = array(
@$this->default->deref['search'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_ALWAYS);
//$search_deref = LDAP_DEREF_ALWAYS;
$this->default->deref['tree'] = array(
@$this->default->deref['tree'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$tree_deref = LDAP_DEREF_NEVER;
$this->default->deref['view'] = array(
@$this->default->deref['view'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$view_deref = LDAP_DEREF_NEVER;
## Debug Attributes
$this->default->debug['level'] = array(
'desc'=>'Debug level verbosity',
'default'=>0);
//$debug_level
$this->default->debug['syslog'] = array(
'desc'=>'Whether to send debug messages to syslog',
@@ -206,7 +197,6 @@ class Config {
$this->default->debug['file'] = array(
'desc'=>'Name of file to send debug output to',
'default'=>null);
//$use_syslog
/** Temp Directories
* This directory must be readable and writable by your web server
@@ -214,12 +204,10 @@ class Config {
$this->default->jpeg['tmpdir'] = array(
'desc'=>'Temporary directory for jpegPhoto data',
'default'=>'/tmp');
//$jpeg_temp_dir = "/tmp";
$this->default->jpeg['tmp_keep_time'] = array(
'desc'=>'Time in seconds to keep jpegPhoto temporary files in the temp directory',
'default'=>120);
//$jpeg_tmp_keep_time = 120; // seconds
## Session Attributes
/** Cookie Encryption
@@ -228,7 +216,6 @@ class Config {
$this->default->session['blowfish'] = array(
'desc'=>'Blowfish key to encrypt cookie details',
'default'=>null);
//$blowfish_secret = '';
/** Cookie Time
* If you used auth_type 'form' in the servers list, you can adjust how long the cookie will last
@@ -237,7 +224,6 @@ class Config {
$this->default->session['cookie_time'] = array(
'desc'=>'Time in seconds for the life of cookies',
'default'=>0);
//$cookie_time = 0;
## Password Generation
$this->default->password['length'] = array(
@@ -264,15 +250,6 @@ class Config {
'desc'=>'Whether to use similiar characters',
'default'=>true);
## Template Engine Configuration
$this->default->template_engine['enable'] = array(
'desc'=>'Use templates from parsed by the template engine',
'default'=>true);
$this->default->template_engine['disable_old'] = array(
'desc'=>'Disable access to old templates',
'default'=>true);
/** Search display
* By default, when searching you may display a list or a table of results.
* Set this to 'table' to see table formatted results.
@@ -281,12 +258,10 @@ class Config {
$this->default->search['display'] = array(
'desc'=>'Display a list or table of search results',
'default'=>'list');
//$default_search_display = 'list';
$this->default->search['size_limit'] = array(
'desc'=>'Limit the size of searchs on the search page',
'default'=>50);
//$search_result_size_limit = 50;
/**
* Which attributes to include in the drop-down menu of the simple search form (comma-separated)
@@ -296,7 +271,6 @@ class Config {
$this->default->search['attributes'] = array(
'desc'=>'Attributes to include in the drop down menu of the simple search form (comma separated)',
'default'=>array('uid','cn','gidNumber','objectClass','telephoneNumber','mail','street'));
//$search_attributes ...
/**
* You can re-arrange the order of the search criteria on the simple search form by modifying this array
@@ -304,8 +278,7 @@ class Config {
*/
$this->default->search['criteria_options'] = array(
'desc'=>'Rearrange the order of the search criteria',
'default'=>array("equals","starts with","contains","ends with","sounds like"));
//$search_criteria_options ...
'default'=>array('equals','starts with','contains','ends with','sounds like'));
/**
* The list of attributes to display in each search result entry.
@@ -314,7 +287,6 @@ class Config {
$this->default->search['result_attributes'] = array(
'desc'=>'List of attributes to display in each search result entry',
'default'=>array('cn','sn','uid','postalAddress','telephoneNumber'));
//$search_result_attributes ...
}
function GetValue($key,$index) {

View File

@@ -1,6 +1,6 @@
<?php
/*
$Id: createlm.php,v 1.1.2.1 2005/10/22 14:22:48 wurley Exp $
$Id: createlm.php,v 1.2 2005/10/23 01:05:41 wurley Exp $
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2004 Roland Gruber

View File

@@ -1,200 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/custom_functions.php,v 1.8 2005/03/05 06:27:06 wurley Exp $
/**
* CUSTOM_FUCTIONS has been DEPRECIATED, please use the hooks functions now.
* Let the phpLDAPadmin developers know if you REALLY need this - it will be removed
* in future releases.
*
* custom_functions.php:
*
* This file is full of functions (callbacks really) that are
* meant to be filled in by users of phpLDAPadmin (you). These functions
* are called as the result of a phpLDAPadmin event, like adding
* a new entry, deleting an entry, changing an attribute value, etc.
* Consider this concept an attempt to provide something like SQL
* triggers for LDAP users.
*
* This can be very handy, for example, for system administrators
* who want to execute custom code after a user is created or deleted.
*
* These functions generally have 2 parameters, $server_id and $dn:
*
* 1. $server_id.
* The $server_id can be used to connect to the server using
* pla_ldap_connect( $server_id ) to fetch additional information about
* the entry being deleted. It can also be used to call
* get_object_attrs( $server_id, $dn ) to fetch the entry's attributes.
*
* 2. $dn
* The dn is provided so users can determine where in the LDAP tree
* this entry resides and act accordingly. For example, if the DN
* contains "ou=development", you may want to act differently than
* if it contains "ou=accounting".
*
* Types of callback functions:
*
* These callbacks generally fall into two categories: "pre" and "post",
* "pre" callbacks run before an event has occurred and their return
* value (true or false) is used to decide whether to allow the event
* to proceed. "post" callbacks run after an event has occurred and
* their return value (void) is ignored.
*
* NOTE: These custom callbacks are NOT executed for LDIF imports.
*
* ALSO NOTE: These callbacks are responsible for printing out error
* messages. The calling code will die silently without notifying
* the user why. YOU are responsible for creating output here.
*
* TODO: This section outlines events that phpLDAPadmin does not yet
* support. This list includes:
* - ldap_mod_add (ie, adding a new value to a multi-valued attribute)
* - ldap_mod_del (ie, deleting a value from a multi-valued attribute
* or deleting an attribute from an entry)
* - ldap_rename (ie, renaming an entry's RDN)
*
* DONE: This section lists events that phpLDAPadmin *does* support.
* This list includes:
* - ldap_add (ie, creating new entries)
* - ldap_delete (ie, removing entries)
* - ldap_modify (ie, changing the value of an attribute, for both
* multi- and single-valued attributes)
* @deprecated
* @see hooks.php
* @package phpLDAPadmin
*/
/*
* This function is executed before modifying an entry's
* attribute. Unlike preAttrModify, this function's
* return value is ignored. In addition to the standard
* $server_id and $dn paramaters, this function also
* gives you the attribute name ($attr_name), and the new
* value that the attribute will have ($new_value). $new_value
* may be a string or an array of strings.
*/
function postAttrModify( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
//
// A very simple (and lame) example:
// if( 0 == strcasecmp( $attr_name, "userPassword" ) ) {
// mail( "user@example.com", "Password change notification",
// "User '$dn' has changed their password." );
// }
}
/*
* This function is executed before modifying an entry's
* attribute. If it returns true, the entry is modified.
* If it returns false, the entry is not modified.
* In addition to the standard $server_id and $dn params,
* this function also gives you the attribute name ($attr_name)
* and the new value that the attribute will have ($new_value).
* $new_value may be a string or an array of strings.
* @deprecated
*/
function preAttrModify( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
return true;
}
/*
* This function is executed before adding an entry's
* attribute. If it returns true, the entry is added.
* If it returns false, the entry is not added.
* In addition to the standard $server_id and $dn params,
* this function also gives you the attribute name ($attr_name)
* and the new value that the attribute will have ($new_value).
* $new_value may be a string or an array of strings.
* @deprecated
*/
function preAttrAdd( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
return true;
}
/*
* This function is executed after an entry is created.
* Unlike preEntryCreate(), this function's return
* value is ignored. This is very handy for executing
* custom code after creating a user account. For example,
* one may wish to create the user's home directory.
* See the documentation for preEntryCreate() below for
* the description of the $attrs parameter.
* @deprecated
*/
function postEntryCreate( $server_id, $dn, $attrs )
{
// Fill me in
//
// A very simple example:
// if( preg_match( "/^uid=(\w+),/", $dn, $user_name ) ) {
// $user_name = $user_name[1];
// mkdir( "/home/$user_name" );
// } else {
// // not a user account
// }
}
/*
* This function is executed before an entry is created.
* If it returns true, the entry is created, if false is
* returned, the entry is not created. This function has
* the additional parameters, $attrs, which is an assoc-
* iative array of attribute/vale pairs of the same form
* expected by ldap_add(), example:
*
* Array (
* [objectClass] => Array (
* [0] => top
* [1] => person
* [2] => inetOrgPerson
* )
* [cn] => John
* [sn] => Doe
* ...
* )
*
* @deprecated
*/
function preEntryCreate( $server_id, $dn, $attrs )
{
// Fill me in
return true;
}
/*
* This function is executed before an entry is deleted.
* If it returns true, the entry is deleted, if false
* is returned, the entry is not deleted.
* @deprecated
*/
function preEntryDelete( $server_id, $dn )
{
// Fill me in
return true;
}
/*
* This function is executed after an entry is deleted.
* Unlike preEntryDelete(), this function's return
* value is ignored.
* @deprecated
*/
function postEntryDelete( $server_id, $dn )
{
// Fill me in
}
/**
* This function is called, after a new session is initilaized
* @deprecated
*/
function postSessionInit()
{
// Fill me in
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/schema_functions.php,v 1.85.2.3 2005/10/22 02:09:21 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/schema_functions.php,v 1.88.2.5 2006/01/02 08:35:39 wurley Exp $
/**
* Classes and functions for fetching and parsing schema from an LDAP server.
@@ -29,11 +29,6 @@ class SchemaItem {
$this->description = null;
}
/** Default constructor. */
#function SchemaItem() {
# $this->initVars();
#}
function setOID( $new_oid ) {
$this->oid = $new_oid;
}
@@ -72,14 +67,14 @@ class ObjectClass extends SchemaItem {
var $children_objectclasses;
/** Initialize the class' member variables */
function initVars() {
function initVars($ldapserver) {
parent::initVars();
$this->oid = null;
$this->name = null;
$this->description = null;
$this->sup_classes = array();
$this->type = null;
$this->type = $ldapserver->schema_oclass_default;
$this->must_attrs = array();
$this->may_attrs = array();
$this->is_obsolete = false;
@@ -94,62 +89,70 @@ class ObjectClass extends SchemaItem {
** The last token may be terminate by more than one bracket
*/
if (DEBUG_ENABLED)
debug_log('%s::_parse_list(): Entered with (%d,%s,%s)',2,
get_class($this),$i,serialize($strings),serialize($attrs));
debug_log('%s::_parse_list(): Entered with (%d,%s,%s)',9,
get_class($this),$i,$strings,$attrs);
$string = $strings[$i];
if (!preg_match('/^\(/',$string)) {
// A bareword only - can be terminated by a ) if the last item
if (preg_match('/\)+$/',$string))
$string = preg_replace('/\)+$/',"",$string);
$string = preg_replace('/\)+$/','',$string);
array_push($attrs, $string);
} elseif (preg_match('/^\(.*\)$/',$string)) {
$string = preg_replace('/^\(/',"",$string);
$string = preg_replace('/\)+$/',"",$string);
$string = preg_replace('/^\(/','',$string);
$string = preg_replace('/\)+$/','',$string);
array_push($attrs, $string);
} else {
// Handle the opening cases first
if ($string == "(") {
if ($string == '(') {
$i++;
} elseif (preg_match("/^\(./",$string)) {
$string = preg_replace('/^\(/',"",$string);
} elseif (preg_match('/^\(./',$string)) {
$string = preg_replace('/^\(/','',$string);
array_push ($attrs, $string);
$i++;
}
// Token is either a name, a $ or a ')'
// NAME can be terminated by one or more ')'
while (! preg_match('/\)+$/',$strings[$i])) {
$string = $strings[$i];
if ($string == "$") {
if ($string == '$') {
$i++;
continue;
}
if (preg_match('/\)$/',$string)) {
$string = preg_replace('/\)+$/',"",$string);
$string = preg_replace('/\)+$/','',$string);
} else {
$i++;
}
array_push ($attrs, $string);
}
}
sort($attrs);
if (DEBUG_ENABLED)
debug_log('%s::_parse_list(): Returning (%d,[%s],[%s])',9,
get_class($this),$i,serialize($strings),serialize($attrs));
get_class($this),$i,$strings,$attrs);
return $i;
}
/**
* Creates a new ObjectClass object given a raw LDAP objectClass string.
*/
function ObjectClass( $raw_ldap_schema_string ) {
function ObjectClass($raw_ldap_schema_string,$ldapserver) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with (%s)',2,get_class($this),$raw_ldap_schema_string);
debug_log('%s::__construct(): Entered with (%s)',9,get_class($this),$raw_ldap_schema_string);
$this->initVars();
$this->initVars($ldapserver);
$class = $raw_ldap_schema_string;
$strings = preg_split("/[\s,]+/",$class,-1,PREG_SPLIT_DELIM_CAPTURE);
$strings = preg_split('/[\s,]+/',$class,-1,PREG_SPLIT_DELIM_CAPTURE);
$str_count = count($strings);
@@ -160,15 +163,15 @@ class ObjectClass extends SchemaItem {
break;
case 'NAME':
if ($strings[$i+1]!="(") {
if ($strings[$i+1]!='(') {
do {
$i++;
if(strlen($this->name)==0)
$this->name = $strings[$i];
else
$this->name .= " ".$strings[$i];
$this->name .= ' '.$strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
} while (!preg_match('/\'$/s', $strings[$i]));
} else {
$i++;
@@ -178,20 +181,20 @@ class ObjectClass extends SchemaItem {
if(strlen($this->name) == 0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
} while (!preg_match('/\'$/s', $strings[$i]));
do {
$i++;
} while (! preg_match('/\)+\)?/',$strings[$i]));
}
$this->name = preg_replace("/^\'/", "", $this->name);
$this->name = preg_replace("/\'$/", "", $this->name);
$this->name = preg_replace('/^\'/', '', $this->name);
$this->name = preg_replace('/\'$/', '', $this->name);
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case NAME returned (%s)',9,
debug_log('%s::__construct(): Case NAME returned (%s)',8,
get_class($this),$this->name);
break;
@@ -201,12 +204,12 @@ class ObjectClass extends SchemaItem {
if (strlen($this->description)==0)
$this->description=$this->description . $strings[$i];
else
$this->description=$this->description . " " . $strings[$i];
$this->description=$this->description . ' ' . $strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
} while (!preg_match('/\'$/s', $strings[$i]));
if (DEBUG_ENABLED)
debug_log('%s::__construc(): Case DESC returned (%s)',9,
debug_log('%s::__construc(): Case DESC returned (%s)',8,
get_class($this),$this->description);
break;
@@ -215,29 +218,29 @@ class ObjectClass extends SchemaItem {
$this->is_obsolete = TRUE;
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case OBSOLETE returned (%s)',9,
debug_log('%s::__construct(): Case OBSOLETE returned (%s)',8,
get_class($this),$this->is_obsolete);
break;
case 'SUP':
if ($strings[$i+1]!="(") {
if ($strings[$i+1]!='(') {
$i++;
array_push($this->sup_classes, preg_replace("/'/","",$strings[$i]));
array_push($this->sup_classes,preg_replace("/'/",'',$strings[$i]));
} else {
$i++;
do {
$i++;
if ($strings[$i]!="$")
array_push($this->sup_classes,preg_replace("/'/","",$strings[$i]));
if ($strings[$i]!='$')
array_push($this->sup_classes,preg_replace("/'/",'',$strings[$i]));
} while (! preg_match('/\)+\)?/',$strings[$i+1]));
}
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case SUP returned (%s)',9,
get_class($this),serialize($this->sup_classes));
debug_log('%s::__construct(): Case SUP returned (%s)',8,
get_class($this),$this->sup_classes);
break;
@@ -245,16 +248,16 @@ class ObjectClass extends SchemaItem {
$this->type='abstract';
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case ABSTRACT returned (%s)',9,
debug_log('%s::__construct(): Case ABSTRACT returned (%s)',8,
get_class($this),$this->type);
break;
case 'STRUCTURAL':
$this->type='structural';
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case STRUCTURAL returned (%s)',9,
debug_log('%s::__construct(): Case STRUCTURAL returned (%s)',8,
get_class($this),$this->type);
break;
@@ -262,7 +265,7 @@ class ObjectClass extends SchemaItem {
$this->type='auxiliary';
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case AUXILIARY returned (%s)',9,
debug_log('%s::__construct(): Case AUXILIARY returned (%s)',8,
get_class($this),$this->type);
break;
@@ -272,8 +275,8 @@ class ObjectClass extends SchemaItem {
$i = $this->_parse_list(++$i, $strings, $attrs);
if (DEBUG_ENABLED)
debug_log('%s::__construct(): _parse_list returned %d (%s)',9,
get_class($this),$i,serialize($attrs));
debug_log('%s::__construct(): _parse_list returned %d (%s)',8,
get_class($this),$i,$attrs);
foreach ($attrs as $string) {
$attr = new ObjectClassAttribute($string, $this->name);
@@ -281,8 +284,8 @@ class ObjectClass extends SchemaItem {
}
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case MUST returned (%s)',9,
get_class($this),serialize($this->must_attrs));
debug_log('%s::__construct(): Case MUST returned (%s)',8,
get_class($this),$this->must_attrs);
break;
case 'MAY':
@@ -291,8 +294,8 @@ class ObjectClass extends SchemaItem {
$i = $this->_parse_list(++$i, $strings, $attrs);
if (DEBUG_ENABLED)
debug_log('%s::__construct(): _parse_list returned %d (%s)',9,
get_class($this),$i,serialize($attrs));
debug_log('%s::__construct(): _parse_list returned %d (%s)',8,
get_class($this),$i,$attrs);
foreach ($attrs as $string) {
$attr = new ObjectClassAttribute($string, $this->name);
@@ -300,29 +303,28 @@ class ObjectClass extends SchemaItem {
}
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case MAY returned (%s)',9,
get_class($this),serialize($this->may_attrs));
debug_log('%s::__construct(): Case MAY returned (%s)',8,
get_class($this),$this->may_attrs);
break;
default:
if(preg_match ("/[\d\.]+/i",$strings[$i]) && $i == 1) {
if(preg_match ('/[\d\.]+/i',$strings[$i]) && $i == 1) {
$this->oid = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Case default returned (%s)',9,
debug_log('%s::__construct(): Case default returned (%s)',8,
get_class($this),$this->oid);
}
break;
}
}
$this->description = preg_replace("/^\'/", "", $this->description);
$this->description = preg_replace("/\'$/", "", $this->description);
$this->description = preg_replace("/^\'/", '', $this->description);
$this->description = preg_replace("/\'$/", '', $this->description);
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s)',9,
get_class($this),$this->name,$this->description,serialize($this->must_attrs),
serialize($this->may_attrs));
get_class($this),$this->name,$this->description,$this->must_attrs,$this->may_attrs);
}
/**
@@ -341,22 +343,28 @@ class ObjectClass extends SchemaItem {
*/
function getMustAttrs($oclasses = NULL) {
if (DEBUG_ENABLED)
debug_log('%s::getMustAttrs(): Entered with (%s)',2,get_class($this),serialize($oclasses));
debug_log('%s::getMustAttrs(): Entered with (%s)',9,get_class($this),$oclasses);
$all_must_attrs = array();
$all_must_attrs = $this->must_attrs;
foreach( $this->sup_classes as $sup_class)
{
if( $oclasses != null
&& $sup_class != "top"
&& isset( $oclasses[ strtolower($sup_class) ] ) ) {
$sup_class = $oclasses[ strtolower($sup_class) ];
$sup_class_must_attrs = $sup_class->getMustAttrs( $oclasses );
$all_must_attrs = array_merge( $sup_class_must_attrs, $all_must_attrs );
foreach ($this->sup_classes as $sup_class) {
if (! is_null($oclasses) && $sup_class != 'top'
&& isset($oclasses[strtolower($sup_class)])) {
$sup_class = $oclasses[ strtolower($sup_class)];
$sup_class_must_attrs = $sup_class->getMustAttrs($oclasses);
$all_must_attrs = array_merge($sup_class_must_attrs,$all_must_attrs);
}
}
ksort($all_must_attrs);
masort($all_must_attrs,'name,source',1);
# Remove any duplicates
foreach ($all_must_attrs as $index => $attr)
if (isset($allattr[$attr->name]))
unset($all_must_attrs[$index]);
else
$allattr[$attr->name] = 1;
return $all_must_attrs;
}
@@ -375,24 +383,31 @@ class ObjectClass extends SchemaItem {
* @see getMayAttrNames
* @see AttributeType
*/
function getMayAttrs($oclasses = NULL) {
function getMayAttrs($oclasses=null) {
if (DEBUG_ENABLED)
debug_log('%s::getMayAttrs(): Entered with (%s)',2,get_class($this),serialize($oclasses));
debug_log('%s::getMayAttrs(): Entered with (%s)',9,get_class($this),$oclasses);
$all_may_attrs = array();
$all_may_attrs = $this->may_attrs;
foreach( $this->sup_classes as $sup_class_name )
{
if( $oclasses != null
&& $sup_class_name != "top"
&& isset( $oclasses[ strtolower($sup_class_name) ] ) ) {
$sup_class = $oclasses[ strtolower($sup_class_name) ];
$sup_class_may_attrs = $sup_class->getMayAttrs( $oclasses );
$all_may_attrs = array_merge( $sup_class_may_attrs, $all_may_attrs );
foreach ($this->sup_classes as $sup_class_name) {
if (! is_null($oclasses) && $sup_class_name != 'top'
&& isset($oclasses[strtolower($sup_class_name)])) {
$sup_class = $oclasses[strtolower($sup_class_name)];
$sup_class_may_attrs = $sup_class->getMayAttrs($oclasses);
$all_may_attrs = array_merge($sup_class_may_attrs,$all_may_attrs);
}
}
ksort($all_may_attrs);
masort($all_may_attrs,'name,source',1);
# Remove any duplicates
foreach ($all_may_attrs as $index => $attr)
if (isset($allattr[$attr->name]))
unset($all_may_attrs[$index]);
else
$allattr[$attr->name] = 1;
return $all_may_attrs;
}
@@ -413,7 +428,7 @@ class ObjectClass extends SchemaItem {
*/
function getMustAttrNames( $oclasses = null ) {
if (DEBUG_ENABLED)
debug_log('%s::getMustAttrNames(): Entered with (%s)',2,get_class($this),serialize($oclasses));
debug_log('%s::getMustAttrNames(): Entered with (%s)',9,get_class($this),$oclasses);
$attrs = $this->getMustAttrs( $oclasses );
$attr_names = array();
@@ -441,7 +456,7 @@ class ObjectClass extends SchemaItem {
*/
function getMayAttrNames( $oclasses = null ) {
if (DEBUG_ENABLED)
debug_log('%s::getMayAttrNames(): Entered with (%s)',2,get_class($this),serialize($oclasses));
debug_log('%s::getMayAttrNames(): Entered with (%s)',9,get_class($this),$oclasses);
$attrs = $this->getMayAttrs( $oclasses );
$attr_names = array();
@@ -460,7 +475,7 @@ class ObjectClass extends SchemaItem {
*/
function addChildObjectClass( $object_class_name ) {
if (DEBUG_ENABLED)
debug_log('%s::addChildObjectClass(): Entered with (%s)',2,get_class($this),$object_class_name);
debug_log('%s::addChildObjectClass(): Entered with (%s)',9,get_class($this),$object_class_name);
$object_class_name = trim( $object_class_name );
if( ! is_array( $this->children_objectclasses ) )
@@ -522,7 +537,7 @@ class ObjectClass extends SchemaItem {
*/
function addMustAttrs( $new_must_attrs ) {
if (DEBUG_ENABLED)
debug_log('%s::addMustAttrs(): Entered with (%s)',2,get_class($this),$new_must_attrs);
debug_log('%s::addMustAttrs(): Entered with (%s)',9,get_class($this),$new_must_attrs);
if( ! is_array( $new_must_attrs ) )
return;
@@ -539,7 +554,7 @@ class ObjectClass extends SchemaItem {
*/
function addMayAttrs( $new_may_attrs ) {
if (DEBUG_ENABLED)
debug_log('%s::addMayAttrs(): Entered with (%s)',2,get_class($this),$new_may_attrs);
debug_log('%s::addMayAttrs(): Entered with (%s)',9,get_class($this),$new_may_attrs);
if( ! is_array( $new_may_attrs ) )
return;
@@ -573,11 +588,11 @@ class ObjectClassAttribute {
* @param string $source the name of the ObjectClass which
* specifies this attribute.
*/
function ObjectClassAttribute($name, $source) {
function ObjectClassAttribute($name,$source) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with name (%s), source (%s)',9,get_class($this),$name,$source);
$this->name=$name;
$this->source=$source;
$this->name = $name;
$this->source = $source;
}
/** Gets this attribute's name */
@@ -661,11 +676,11 @@ class AttributeType extends SchemaItem {
*/
function AttributeType( $raw_ldap_attr_string ) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with (%s)',2,get_class($this),$raw_ldap_attr_string);
debug_log('%s::__construct(): Entered with (%s)',9,get_class($this),$raw_ldap_attr_string);
$this->initVars();
$attr = $raw_ldap_attr_string;
$strings = preg_split("/[\s,]+/",$attr,-1,PREG_SPLIT_DELIM_CAPTURE);
$strings = preg_split('/[\s,]+/',$attr,-1,PREG_SPLIT_DELIM_CAPTURE);
for($i=0; $i<count($strings); $i++) {
@@ -674,13 +689,13 @@ class AttributeType extends SchemaItem {
break;
case 'NAME':
if ($strings[$i+1]!="(") {
if ($strings[$i+1]!='(') {
do {
$i++;
if (strlen($this->name)==0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
// this attribute has no aliases
@@ -693,22 +708,22 @@ class AttributeType extends SchemaItem {
if (strlen($this->name) == 0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
// add alias names for this attribute
while ($strings[++$i]!=")") {
while ($strings[++$i]!=')') {
$alias = $strings[$i];
$alias = preg_replace("/^\'/", "", $alias );
$alias = preg_replace("/\'$/", "", $alias );
$alias = preg_replace("/^\'/", '', $alias );
$alias = preg_replace("/\'$/", '', $alias );
$this->aliases[] = $alias;
}
}
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case NAME returned (%s) (%s)',9,
get_class($this),$this->name,serialize($this->aliases));
debug_log('%s::AttributeType(): Case NAME returned (%s) (%s)',8,
get_class($this),$this->name,$this->aliases);
break;
case 'DESC':
@@ -717,11 +732,11 @@ class AttributeType extends SchemaItem {
if (strlen($this->description)==0)
$this->description=$this->description . $strings[$i];
else
$this->description=$this->description . " " . $strings[$i];
$this->description=$this->description . ' ' . $strings[$i];
} while (!preg_match("/\'$/s", $strings[$i]));
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case DESC returned (%s)',9,
debug_log('%s::AttributeType(): Case DESC returned (%s)',8,
get_class($this),$this->description);
break;
@@ -729,7 +744,7 @@ class AttributeType extends SchemaItem {
$this->is_obsolete = TRUE;
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case OBSOLETE returned (%s)',9,
debug_log('%s::AttributeType(): Case OBSOLETE returned (%s)',8,
get_class($this),$this->is_obsolete);
break;
@@ -738,7 +753,7 @@ class AttributeType extends SchemaItem {
$this->sup_attribute = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case SUP returned (%s)',9,
debug_log('%s::AttributeType(): Case SUP returned (%s)',8,
get_class($this),$this->sup_attribute);
break;
@@ -747,7 +762,7 @@ class AttributeType extends SchemaItem {
$this->equality = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case EQUALITY returned (%s)',9,
debug_log('%s::AttributeType(): Case EQUALITY returned (%s)',8,
get_class($this),$this->equality);
break;
@@ -756,7 +771,7 @@ class AttributeType extends SchemaItem {
$this->ordering = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case ORDERING returned (%s)',9,
debug_log('%s::AttributeType(): Case ORDERING returned (%s)',8,
get_class($this),$this->ordering);
break;
@@ -765,37 +780,37 @@ class AttributeType extends SchemaItem {
$this->sub_str = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case SUBSTR returned (%s)',9,
debug_log('%s::AttributeType(): Case SUBSTR returned (%s)',8,
get_class($this),$this->sub_str);
break;
case 'SYNTAX':
$i++;
$this->syntax = $strings[$i];
$this->syntax_oid = preg_replace("/{\d+}$/", "", $this->syntax);
$this->syntax_oid = preg_replace('/{\d+}$/', '', $this->syntax);
// does this SYNTAX string specify a max length (ie, 1.2.3.4{16})
if (preg_match( "/{(\d+)}$/", $this->syntax, $this->max_length))
if (preg_match( '/{(\d+)}$/', $this->syntax, $this->max_length))
$this->max_length = $this->max_length[1];
else
$this->max_length = null;
if ($i < count($strings) - 1 && $strings[$i+1]=="{") {
if ($i < count($strings) - 1 && $strings[$i+1]=='{') {
do {
$i++;
$this->name .= " " . $strings[$i];
} while ($strings[$i]!="}");
$this->name .= ' ' . $strings[$i];
} while ($strings[$i]!='}');
}
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case SYNTAX returned (%s) (%s) (%s)',9,
debug_log('%s::AttributeType(): Case SYNTAX returned (%s) (%s) (%s)',8,
get_class($this),$this->syntax,$this->syntax_oid,$this->max_length);
break;
case 'SINGLE-VALUE':
$this->is_single_value = TRUE;
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case SINGLE-VALUE returned (%s)',9,
debug_log('%s::AttributeType(): Case SINGLE-VALUE returned (%s)',8,
get_class($this),$this->is_single_value);
break;
@@ -803,7 +818,7 @@ class AttributeType extends SchemaItem {
$this->is_collective = TRUE;
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case COLLECTIVE returned (%s)',9,
debug_log('%s::AttributeType(): Case COLLECTIVE returned (%s)',8,
get_class($this),$this->is_collective);
break;
@@ -811,7 +826,7 @@ class AttributeType extends SchemaItem {
$this->is_no_user_modification = TRUE;
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case NO-USER-MODIFICATION returned (%s)',9,
debug_log('%s::AttributeType(): Case NO-USER-MODIFICATION returned (%s)',8,
get_class($this),$this->is_no_user_modification);
break;
@@ -820,33 +835,33 @@ class AttributeType extends SchemaItem {
$this->usage = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case USAGE returned (%s)',9,
debug_log('%s::AttributeType(): Case USAGE returned (%s)',8,
get_class($this),$this->usage);
break;
default:
if(preg_match ("/[\d\.]+/i",$strings[$i]) && $i == 1) {
if(preg_match ('/[\d\.]+/i',$strings[$i]) && $i == 1) {
$this->oid = $strings[$i];
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Case default returned (%s)',9,
debug_log('%s::AttributeType(): Case default returned (%s)',8,
get_class($this),$this->oid);
}
}
}
$this->name = preg_replace("/^\'/", "", $this->name);
$this->name = preg_replace("/\'$/", "", $this->name);
$this->description = preg_replace("/^\'/", "", $this->description);
$this->description = preg_replace("/\'$/", "", $this->description);
$this->syntax = preg_replace("/^\'/", "", $this->syntax );
$this->syntax = preg_replace("/\'$/", "", $this->syntax );
$this->syntax_oid = preg_replace("/^\'/", "", $this->syntax_oid );
$this->syntax_oid = preg_replace("/\'$/", "", $this->syntax_oid );
$this->sup_attribute = preg_replace("/^\'/", "", $this->sup_attribute );
$this->sup_attribute = preg_replace("/\'$/", "", $this->sup_attribute );
$this->name = preg_replace("/^\'/", '', $this->name);
$this->name = preg_replace("/\'$/", '', $this->name);
$this->description = preg_replace("/^\'/", '', $this->description);
$this->description = preg_replace("/\'$/", '', $this->description);
$this->syntax = preg_replace("/^\'/", '', $this->syntax );
$this->syntax = preg_replace("/\'$/", '', $this->syntax );
$this->syntax_oid = preg_replace("/^\'/", '', $this->syntax_oid );
$this->syntax_oid = preg_replace("/\'$/", '', $this->syntax_oid );
$this->sup_attribute = preg_replace("/^\'/", '', $this->sup_attribute );
$this->sup_attribute = preg_replace("/\'$/", '', $this->sup_attribute );
if (DEBUG_ENABLED)
debug_log('%s::AttributeType(): Returning ()',1,get_class($this));
debug_log('%s::AttributeType(): Returning ()',9,get_class($this));
}
/**
@@ -922,7 +937,7 @@ class AttributeType extends SchemaItem {
*/
function isAliasFor( $attr_name ) {
if (DEBUG_ENABLED)
debug_log('%s::isAliasFor(): Entered with (%s)',2,get_class($this),$attr_name);
debug_log('%s::isAliasFor(): Entered with (%s)',9,get_class($this),$attr_name);
foreach( $this->aliases as $alias_attr_name )
if( 0 == strcasecmp( $alias_attr_name, $attr_name ) )
@@ -1006,7 +1021,7 @@ class AttributeType extends SchemaItem {
*/
function removeAlias( $remove_alias_name ) {
if (DEBUG_ENABLED)
debug_log('%s::removeAlias(): Entered with (%s)',2,get_class($this),$remove_alias_name);
debug_log('%s::removeAlias(): Entered with (%s)',9,get_class($this),$remove_alias_name);
foreach( $this->aliases as $i => $alias_name ) {
@@ -1067,7 +1082,7 @@ class AttributeType extends SchemaItem {
*/
function addUsedInObjectClass( $object_class_name ) {
if (DEBUG_ENABLED)
debug_log('%s::addUsedInObjectClass(): Entered with (%s)',2,get_class($this),$object_class_name);
debug_log('%s::addUsedInObjectClass(): Entered with (%s)',9,get_class($this),$object_class_name);
foreach( $this->used_in_object_classes as $used_in_object_class )
if( 0 == strcasecmp( $used_in_object_class, $object_class_name ) )
@@ -1092,7 +1107,7 @@ class AttributeType extends SchemaItem {
*/
function addRequiredByObjectClass( $object_class_name ) {
if (DEBUG_ENABLED)
debug_log('%s::addRequiredByObjectClass(): Entered with (%s)',2,get_class($this),$object_class_name);
debug_log('%s::addRequiredByObjectClass(): Entered with (%s)',9,get_class($this),$object_class_name);
foreach( $this->required_by_object_classes as $required_by_object_class )
if( 0 == strcasecmp( $required_by_object_class, $object_class_name ) )
@@ -1129,12 +1144,12 @@ class Syntax extends SchemaItem {
*/
function Syntax ( $raw_ldap_syntax_string ) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with (%s)',2,get_class($this),$raw_ldap_syntax_string);
debug_log('%s::__construct(): Entered with (%s)',9,get_class($this),$raw_ldap_syntax_string);
$this->initVars();
$class = $raw_ldap_syntax_string;
$strings = preg_split ("/[\s,]+/", $class, -1,PREG_SPLIT_DELIM_CAPTURE);
$strings = preg_split ('/[\s,]+/', $class, -1,PREG_SPLIT_DELIM_CAPTURE);
for($i=0; $i<count($strings); $i++) {
switch($strings[$i]) {
case '(':
@@ -1145,16 +1160,16 @@ class Syntax extends SchemaItem {
if(strlen($this->description)==0)
$this->description=$this->description . $strings[$i];
else
$this->description=$this->description . " " . $strings[$i];
$this->description=$this->description . ' ' . $strings[$i];
}while(!preg_match("/\'$/s", $strings[$i]));
break;
default:
if(preg_match ("/[\d\.]+/i",$strings[$i]) && $i == 1)
if(preg_match ('/[\d\.]+/i',$strings[$i]) && $i == 1)
$this->oid = $strings[$i];
}
}
$this->description = preg_replace("/^\'/", "", $this->description);
$this->description = preg_replace("/\'$/", "", $this->description);
$this->description = preg_replace("/^\'/", '', $this->description);
$this->description = preg_replace("/\'$/", '', $this->description);
}
}
@@ -1189,10 +1204,10 @@ class MatchingRule extends SchemaItem {
*/
function MatchingRule( $raw_ldap_matching_rule_string ) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with (%s)',2,get_class($this),$raw_ldap_matching_rule_string);
debug_log('%s::__construct(): Entered with (%s)',9,get_class($this),$raw_ldap_matching_rule_string);
$this->initVars();
$strings = preg_split ("/[\s,]+/", $raw_ldap_matching_rule_string, -1,PREG_SPLIT_DELIM_CAPTURE);
$strings = preg_split ('/[\s,]+/', $raw_ldap_matching_rule_string, -1,PREG_SPLIT_DELIM_CAPTURE);
for($i=0; $i<count($strings); $i++) {
switch($strings[$i]) {
@@ -1200,13 +1215,13 @@ class MatchingRule extends SchemaItem {
break;
case 'NAME':
if($strings[$i+1]!="(") {
if($strings[$i+1]!='(') {
do {
$i++;
if(strlen($this->name)==0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
}while(!preg_match("/\'$/s", $strings[$i]));
} else {
$i++;
@@ -1215,14 +1230,14 @@ class MatchingRule extends SchemaItem {
if(strlen($this->name) == 0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
} while(!preg_match("/\'$/s", $strings[$i]));
do {
$i++;
} while (! preg_match('/\)+\)?/',$strings[$i]));
}
$this->name = preg_replace("/^\'/", "", $this->name);
$this->name = preg_replace("/\'$/", "", $this->name);
$this->name = preg_replace("/^\'/", '', $this->name);
$this->name = preg_replace("/\'$/", '', $this->name);
break;
case 'DESC':
@@ -1231,7 +1246,7 @@ class MatchingRule extends SchemaItem {
if(strlen($this->description)==0)
$this->description=$this->description . $strings[$i];
else
$this->description=$this->description . " " . $strings[$i];
$this->description=$this->description . ' ' . $strings[$i];
}while(!preg_match("/\'$/s", $strings[$i]));
break;
@@ -1244,12 +1259,12 @@ class MatchingRule extends SchemaItem {
break;
default:
if(preg_match ("/[\d\.]+/i",$strings[$i]) && $i == 1)
if(preg_match ('/[\d\.]+/i',$strings[$i]) && $i == 1)
$this->oid = $strings[$i];
}
}
$this->description = preg_replace("/^\'/", "", $this->description);
$this->description = preg_replace("/\'$/", "", $this->description);
$this->description = preg_replace("/^\'/", '', $this->description);
$this->description = preg_replace("/\'$/", '', $this->description);
}
/**
@@ -1266,7 +1281,7 @@ class MatchingRule extends SchemaItem {
*/
function addUsedByAttr( $new_attr_name ) {
if (DEBUG_ENABLED)
debug_log('%s::addUsedByAttr(): Entered with (%s)',2,get_class($this),$new_attr_name);
debug_log('%s::addUsedByAttr(): Entered with (%s)',9,get_class($this),$new_attr_name);
foreach( $this->used_by_attrs as $attr_name )
if( 0 == strcasecmp( $attr_name, $new_attr_name ) )
@@ -1331,11 +1346,11 @@ class MatchingRuleUse extends SchemaItem {
function MatchingRuleUse( $raw_matching_rule_use_string ) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with (%s)',2,get_class($this),$raw_matching_rule_use_string);
debug_log('%s::__construct(): Entered with (%s)',9,get_class($this),$raw_matching_rule_use_string);
$this->initVars();
$strings = preg_split ("/[\s,]+/", $raw_matching_rule_use_string, -1,PREG_SPLIT_DELIM_CAPTURE);
$strings = preg_split ('/[\s,]+/', $raw_matching_rule_use_string, -1,PREG_SPLIT_DELIM_CAPTURE);
for($i=0; $i<count($strings); $i++) {
switch($strings[$i]) {
@@ -1343,13 +1358,13 @@ class MatchingRuleUse extends SchemaItem {
break;
case 'NAME':
if($strings[$i+1]!="(") {
if($strings[$i+1]!='(') {
do {
$i++;
if( ! isset( $this->name ) || strlen( $this->name ) ==0 )
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
}while(!preg_match("/\'$/s", $strings[$i]));
} else {
$i++;
@@ -1358,19 +1373,19 @@ class MatchingRuleUse extends SchemaItem {
if(strlen($this->name) == 0)
$this->name = $strings[$i];
else
$this->name .= " " . $strings[$i];
$this->name .= ' ' . $strings[$i];
} while(!preg_match("/\'$/s", $strings[$i]));
do {
$i++;
} while (! preg_match('/\)+\)?/',$strings[$i]));
}
$this->name = preg_replace("/^\'/", "", $this->name);
$this->name = preg_replace("/\'$/", "", $this->name);
$this->name = preg_replace("/^\'/", '', $this->name);
$this->name = preg_replace("/\'$/", '', $this->name);
break;
case 'APPLIES':
// TODO
if($strings[$i+1]!="(") {
if($strings[$i+1]!='(') {
// has a single attribute name
$i++;
$this->used_by_attrs = array( $strings[$i] );
@@ -1378,11 +1393,11 @@ class MatchingRuleUse extends SchemaItem {
} else {
// has multiple attribute names
$i++;
while($strings[$i]!=")") {
while($strings[$i]!=')') {
$i++;
$new_attr = $strings[$i];
$new_attr = preg_replace("/^\'/", "", $new_attr );
$new_attr = preg_replace("/\'$/", "", $new_attr );
$new_attr = preg_replace("/^\'/", '', $new_attr );
$new_attr = preg_replace("/\'$/", '', $new_attr );
$this->used_by_attrs[] = $new_attr;
//echo "Adding $new_attr<br />";
$i++;
@@ -1391,7 +1406,7 @@ class MatchingRuleUse extends SchemaItem {
break;
default:
if(preg_match ("/[\d\.]+/i",$strings[$i]) && $i == 1)
if(preg_match ('/[\d\.]+/i',$strings[$i]) && $i == 1)
$this->oid = $strings[$i];
}
}

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_advanced.php,v 1.22.2.1 2005/10/09 09:07:22 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_advanced.php,v 1.23.2.2 2005/12/08 12:06:58 wurley Exp $
/**
* @package phpLDAPadmin
@@ -7,9 +7,9 @@
?>
<script>
<script type="text/javascript" language="javascript">
<?php foreach ($server_info_list as $i => $ignore) {
<?php foreach ($server_info_list as $i => $ignore) {
foreach ($server_info_list[$i]['base_dns'] as $base_dn) { ?>
addToServersList(new server(<?php echo $i; ?>,"<?php echo $server_info_list[$i]['name']; ?>","<?php echo $base_dn; ?>"));
@@ -26,44 +26,44 @@ function focus_filter() {
<input type="hidden" name="form" value="advanced" />
<input type="hidden" name="format" value="<?php echo $format; ?>" />
<center><b><?php echo $lang['advanced_search_form_str']; ?></b></center>
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=simple"><?php echo $lang['simple_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo $lang['predefined_searches']; ?></a>)</small><br />
<center><b><?php echo _('Advanced Search Form'); ?></b></center>
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=simple"><?php echo _('Simple Search Form'); ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo _('Predefined Searches'); ?></a>)</small><br />
<br />
<table>
<tr>
<td><small><?php echo $lang['server']; ?></small></td>
<td><small><?php echo _('Server'); ?></small></td>
<td><?php echo $server_menu_html; ?></td>
</tr>
<tr>
<td><small><?php echo $lang['base_dn']; ?></small></td>
<td><small><?php echo _('Base DN'); ?></small></td>
<td><input type="text" name="base_dn" value="<?php echo count($base_dns) == 1 ? $base_dns[0] : '' ?>" style="width: 200px" id="base_dn" />
<?php draw_chooser_link( 'advanced_search_form.base_dn' );
if( isset( $base_dn_is_invalid ) && $base_dn_is_invalid )
echo "<small style=\"color:red; white-space: nowrap\">" . $lang['this_base_dn_is_not_valid'] . "</small>";
echo "<small style=\"color:red; white-space: nowrap\">" . _('This is not a valid DN.') . "</small>";
if( isset( $base_dn_does_not_exist ) && $base_dn_does_not_exist )
echo "<small style=\"color:red; white-space: nowrap\">" . $lang['this_base_dn_does_not_exist'] . "</small>"; ?>
echo "<small style=\"color:red; white-space: nowrap\">" . _('This entry does not exist.') . "</small>"; ?>
</td>
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['scope_in_which_to_search']; ?>"><?php echo $lang['search_scope']; ?></acronym></small></td>
<td><small><acronym title="<?php echo _('The scope in which to search'); ?>"><?php echo _('Search Scope'); ?></acronym></small></td>
<td>
<select name="scope" style="width: 200px">
<option<?php echo $scope=='sub'?' selected':''; ?> value="sub">
<?php echo $lang['scope_sub']; ?>
<?php echo _('Sub (entire subtree)'); ?>
</option>
<option<?php echo $scope=='one'?' selected':''; ?> value="one">
<?php echo $lang['scope_one']; ?>
<?php echo _('One (one level beneath base)'); ?>
</option>
<option<?php echo $scope=='base'?' selected':''; ?> value="base">
<?php echo $lang['scope_base']; ?>
<?php echo _('Base (base dn only)'); ?>
</option>
</select>
</td>
@@ -71,15 +71,15 @@ if( isset( $base_dn_does_not_exist ) && $base_dn_does_not_exist )
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['standard_ldap_search_filter']; ?>">
<?php echo $lang['search_filter']; ?></acronym></small></td>
<td><small><acronym title="<?php echo htmlspecialchars(_('Standard LDAP search filter. Example: (&(sn=Smith)(givenname=David))')); ?>">
<?php echo _('Search Filter'); ?></acronym></small></td>
<td><input type="text" name="filter" id="filter" style="width: 200px" value="<?php echo $filter ? htmlspecialchars($filter) : 'objectClass=*'; ?>" /></td>
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['list_of_attrs_to_display_in_results']; ?>">
<?php echo $lang['show_attributes']; ?></acronym></small></td>
<td><small><acronym title="<?php echo _('A list of attributes to display in the results (comma-separated)'); ?>">
<?php echo _('Show Attributtes'); ?></acronym></small></td>
<td><input type="text" name="display_attrs" style="width: 200px" value="<?php
echo isset( $_GET['display_attrs'] ) ?
@@ -88,12 +88,12 @@ if( isset( $base_dn_does_not_exist ) && $base_dn_does_not_exist )
</tr>
<tr>
<td colspan="2"><br /><center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center></td>
<td colspan="2"><br /><center><input type="submit" value="<?php echo _('Search'); ?>" /></center></td>
</tr>
</table>
</form>
<script language="javascript">
<script type="text/javascript" language="javascript">
// Move the cursor to the filter field
focus_filter();
</script>

View File

@@ -1,69 +1,60 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_predefined.php,v 1.8 2005/07/16 03:13:54 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_predefined.php,v 1.8.4.2 2005/12/08 12:06:58 wurley Exp $
/**
* @package phpLDAPadmin
*/
?>
echo '<form action="search.php" method="get" class="search">';
echo '<input type="hidden" name="search" value="true" />';
echo '<input type="hidden" name="form" value="predefined" />';
printf('<input type="hidden" name="format" value="%s" />',$format);
<form action="search.php" method="get" class="search">
<input type="hidden" name="search" value="true" />
<input type="hidden" name="form" value="predefined" />
<input type="hidden" name="format" value="<?php echo $format; ?>" />
<table>
<tr>
<td>
<?php if( isset( $_GET['predefined'] ) )
$selected_q_number = intval( $_GET['predefined'] );
echo '<table><tr><td>';
if (isset($_GET['predefined']))
$selected_q_number = intval($_GET['predefined']);
else
$selected_q_number = null; ?>
$selected_q_number = null;
<center><b><?php echo $lang['predefined_searches']; ?></b><br />
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=simple"><?php echo $lang['simple_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=advanced"><?php echo $lang['advanced_search_form_str']; ?></a>)</small><br />
<br />
printf('<center><b>%s</b><br />',_('Predefined Searches'));
printf('<small>(<a href="search.php?server_id=%s&amp;form=simple">%s</a> | <a href="search.php?server_id=%s&amp;form=advanced">%s</a>)</small>',
$ldapserver->server_id,_('Simple Search Form'),
$ldapserver->server_id,_('Advanced Search Form'));
<?php if( ! isset( $queries ) || ! is_array( $queries ) || 0 == count( $queries ) ) {
echo "<br />\n";
echo $lang['no_predefined_queries'];
echo "<br />\n";
echo "<br />\n";
echo "<br />\n";
echo "</td></tr></table>\n";
echo "</body>\n";
echo "</html>\n";
die();
echo '<br /><br />';
} else { ?>
if (! isset($queries) || ! is_array($queries) || count($queries) == 0) {
echo '<br />';
echo _('No queries have been defined in config.php.');
echo '<br /><br /><br />';
echo '</center>';
echo '</td></tr></table>';
echo '</body></html>';
die();
<small><?php echo $lang['predefined_search_str']; ?>: </small>
<select name="predefined">
} else {
<?php foreach( $queries as $q_number => $q ) {
printf('<small>%s: </small>',_('Select a predefined search'));
echo '<select name="predefined">';
if ($selected_q_number === $q_number)
$selected = " selected";
foreach ($queries as $q_number => $q) {
else
$selected = "";
if ($selected_q_number === $q_number)
$selected = ' selected';
else
$selected = '';
print("\t<option value=\"" . $q_number . "\"" . $selected . ">\n");
print("\t" . htmlspecialchars( $q['name'] ) . "\n");
print("\t</option>\n");
} ?>
printf('<option value="%s"%s>%s</option>',$q_number,$selected,htmlspecialchars($q['name']));
}
</select>
echo '</select>';
<?php } ?>
}
<br />
<br />
<center><input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" /></center>
<center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center>
</td>
</table>
</form>
echo '<br /><br />';
printf('<center><input type="hidden" name="server_id" value="%s" /></center>',$ldapserver->server_id);
printf('<center><input type="submit" value="%s" /></center>',_('Search'));
echo '</center>';
echo '</td></tr></table></form>';
?>

View File

@@ -1,12 +1,12 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_simple.php,v 1.14 2005/07/16 03:13:54 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_simple.php,v 1.14.4.4 2005/12/09 14:31:27 wurley Exp $
/**
* @package phpLDAPadmin
*/
?>
<script language="javascript">
<script type="text/javascript" language="javascript">
function focus_filter() {
document.simple_search_form.filter.focus();
}
@@ -21,31 +21,32 @@
<table>
<tr>
<td>
<center><b><?php echo $lang['simple_search_form_str']; ?></b><br />
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=advanced"><?php echo $lang['advanced_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo $lang['predefined_searches']; ?></a>)</small><br />
<center><b><?php echo _('Simple Search Form'); ?></b><br />
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=advanced"><?php echo _('Advanced Search Form'); ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo _('Predefined Searches'); ?></a>)</small><br />
</center>
<br />
<small><?php echo $lang['server']; ?></small><br /> <?php echo $server_menu_html; ?><br />
<small><?php echo _('Server'); ?></small><br /> <?php echo $server_menu_html; ?><br />
<br />
<small><?php echo $lang['search_for_entries_whose']; ?></small><br />
<small><?php echo _('Search for entries whose'); ?></small><br />
<nobr>
<select name="attribute">
<?php foreach( $config->GetValue('search','attributes') as $id => $attribute ) { ?>
<option value="<?php echo rawurlencode( $attribute ); ?>"<?php echo $attribute==$attr?' selected="true"':''; ?>>
<?php echo htmlspecialchars(show_friendly_attribute($attribute)); ?>
<?php echo htmlspecialchars($ldapserver->showFriendlyAttr($attribute)); ?>
</option>
<?php } ?>
</select>
</nobr>
<select name="criterion">
<?php
<?php
foreach( $config->GetValue('search','criteria_options') as $c ) { ?>
<option value="<?php echo $c; ?>"<?php echo $c==$criterion?' selected="true"':''; ?>>
<?php echo htmlspecialchars( $lang[$c] ); ?>
<?php echo htmlspecialchars(_($c)); ?>
</option>
<?php } ?>
</select>
@@ -53,14 +54,13 @@ foreach( $config->GetValue('search','criteria_options') as $c ) { ?>
<input type="text" name="filter" id="filter" size="20" value="<?php echo htmlspecialchars($filter); ?>" /><br />
<br />
<center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center>
</nobr>
<center><input type="submit" value="<?php echo _('Search'); ?>" /></center>
</td>
</tr>
</table>
</form>
<script language="javascript">
<script type="text/javascript" language="javascript">
// Move the cursor to the filter field
focus_filter();
</script>

View File

@@ -1,92 +1,73 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_list.php,v 1.5 2005/04/29 11:24:15 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_list.php,v 1.5.4.4 2005/12/09 14:31:27 wurley Exp $
/**
* @package phpLDAPadmin
*/
$friendly_attrs = process_friendly_attr_table();
$entry_id = ldap_first_entry( $ldapserver->connect(), $results );
// Iterate over each entry
# Iterate over each entry
$i = 0;
while( $entry_id ) {
foreach ($results as $dn => $dndetails) {
$i++;
if( $i <= $start_entry ) {
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
if ($i <= $start_entry)
continue;
}
if( $i >= $end_entry )
if ($i >= $end_entry)
break;
$dn = ldap_get_dn( $ldapserver->connect(), $entry_id );
$encoded_dn = rawurlencode( $dn );
$rdn = get_rdn( $dn ); ?>
echo '<div class="search_result">';
echo '<table><tr>';
printf('<td><img src="images/%s" /></td>',get_icon($ldapserver,$dn));
printf('<td><a href="template_engine.php?server_id=%s&amp;dn=%s">%s</a></td>',
$ldapserver->server_id,rawurlencode(dn_unescape($dn)),htmlspecialchars(get_rdn($dn)));
echo '</tr></table>';
echo '</div>';
<div class="search_result">
<table>
<tr>
<td><img src="images/<?php echo get_icon_use_cache( $ldapserver, $dn ); ?>" /></td>
<td><a href="edit.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>"><?php echo htmlspecialchars($rdn); ?></a></td>
</tr>
</table>
</div>
echo '<table class="attrs">';
printf('<tr><td class="attr" valign="top">dn</td><td>%s</td></tr>',htmlspecialchars(dn_unescape($dn)));
<table class="attrs">
# Iterate over each attribute for this entry
foreach ($dndetails as $attr => $values) {
# Ignore DN, we've already displayed it.
if ($attr == 'dn')
continue;
<?php $attrs = ldap_get_attributes( $ldapserver->connect(), $entry_id );
$attr = ldap_first_attribute( $ldapserver->connect(), $entry_id, $attrs );
if ($ldapserver->isAttrBinary($attr))
$values = array('(binary)');
// Always print out the DN in the attribute list
echo "<tr><td class=\"attr\" valign=\"top\">dn</td>";
echo "<td>" . htmlspecialchars($dn) . "</td></tr>\n";
if (isset($friendly_attrs[strtolower($attr)]))
$attr = sprintf('<acronym title="Alias for $attr">%s</acronym>',
htmlspecialchars($friendly_attrs[strtolower($attr)]));
else
$attr = htmlspecialchars($attr);
// Iterate over each attribute for this entry
while( $attr ) {
echo '<tr>';
printf('<td class="attr" valign="top">%s</td>',$attr);
echo '<td class="val">';
if( is_attr_binary( $ldapserver, $attr ) )
$values = array( "(binary)" );
if ($ldapserver->isJpegPhoto($attr))
draw_jpeg_photos($ldapserver,$dn,$attr,false,false,'align="left"');
else
$values = ldap_get_values( $ldapserver->connect(), $entry_id, $attr );
if (is_array($values))
foreach ($values as $value)
echo str_replace(' ','&nbsp;',htmlspecialchars($value)).'<br />';
if( isset( $values['count'] ) )
unset( $values['count'] );
else
echo str_replace(' ','&nbsp;',htmlspecialchars($values)).'<br />';
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) )
$attr = "<acronym title=\"Alias for $attr\">".htmlspecialchars( $friendly_attrs[ strtolower($attr) ] ) .
"</acronym>";
echo '</td>';
echo '</tr>';
}
else
$attr = htmlspecialchars( $attr ); ?>
echo '</table>';
<tr>
<td class="attr" valign="top"><?php echo $attr; ?></td>
<td class="val">
<?php if( is_jpeg_photo( $ldapserver, $attr ) )
draw_jpeg_photos( $ldapserver, $dn, $attr, false, false, 'align="left"' );
else
foreach( $values as $value )
echo str_replace( ' ', '&nbsp;', htmlspecialchars( $value ) ) . "<br />\n"; ?>
</td>
</tr>
<?php $attr = ldap_next_attribute( $ldapserver->connect(), $entry_id, $attrs );
} // end while( $attr ) ?>
</table>
<?php $entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
// flush every 5th entry (speeds things up a bit)
if( 0 == $i % 5 )
# Flush every 5th entry (speeds things up a bit)
if ($i % 5 == 0)
flush();
} // end while( $entry_id )
}
?>

View File

@@ -1,9 +1,9 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_table.php,v 1.7 2005/04/29 11:24:15 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_results_table.php,v 1.7.4.5 2005/12/09 14:31:27 wurley Exp $
/**
* Incoming variables (among others)
* $results: The result of ldap_search(), ldap_list(), or ldap_read().
* $results: The result from the ldapsearch.
* $ldapserver: LDAP Server Object.
* $start_entry: The index of the entry at which to begin displaying
* $end_entry: The index of the entry at which to end displaying
@@ -11,123 +11,105 @@
*/
$friendly_attrs = process_friendly_attr_table();
$entry_id = ldap_first_entry( $ldapserver->connect(), $results );
$all_attrs = array( '' => 1, 'dn' => 1 );
// Iterate over each entry and store the whole dang thing in memory (necessary to extract
// all attribute names and display in table format in a single pass)
$i = 0;
$entries = array();
$all_attrs = array('' =>1,'dn'=>1);
$entries_display = array();
while( $entry_id ) {
$i++;
if( $i <= $start_entry ) {
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
continue;
}
if( $i >= $end_entry )
break;
$dn = ldap_get_dn( $ldapserver->connect(), $entry_id );
$dn_display = strlen( $dn ) > 40 ? "<acronym title=\"" . htmlspecialchars( $dn ) . "\">" .
htmlspecialchars( substr( $dn, 0, 40 ) . '...' ) .
"</acronym>"
: htmlspecialchars( $dn );
$encoded_dn = rawurlencode( $dn );
$rdn = get_rdn( $dn );
$icon = get_icon_use_cache( $ldapserver, $dn );
$attrs = ldap_get_attributes( $ldapserver->connect(), $entry_id );
$attr = ldap_first_attribute( $ldapserver->connect(), $entry_id, $attrs );
$attrs_display = array();
$edit_url = sprintf("edit.php?server_id=%s&amp;dn=%s",$ldapserver->server_id,$encoded_dn);
$attrs_display[''] = "<center><a href=\"$edit_url\"><img src=\"images/$icon\" /></a><center>";
$attrs_display['dn'] = "<a href=\"$edit_url\">$dn_display</a>";
// Iterate over each attribute for this entry and store in associative array $attrs_display
while( $attr ) {
//echo "getting values for dn $dn, attr $attr\n";
/* Iterate over each entry and store the whole dang thing in memory (necessary to extract
all attribute names and display in table format in a single pass) */
$i=0;
// Clean up the attr name
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) )
$attr_display = "<acronym title=\"Alias for $attr\">" .
htmlspecialchars( $friendly_attrs[ strtolower($attr) ] ) .
"</acronym>";
else
$attr_display = htmlspecialchars( $attr );
foreach ($results as $dn => $dndetails) {
$i++;
if ($i <= $start_entry)
continue;
if( ! isset( $all_attrs[ $attr_display ] ) )
$all_attrs[ $attr_display ] = 1;
if ($i >= $end_entry)
break;
// Get the values
$display = '';
if( is_jpeg_photo( $ldapserver, $attr ) ) {
ob_start();
draw_jpeg_photos( $ldapserver, $dn, $attr, false, false, 'align="center"' );
$display = ob_get_contents();
ob_end_clean();
} elseif( is_attr_binary( $ldapserver, $attr ) ) {
$display = array( "(binary)" );
} else {
$values = @ldap_get_values( $ldapserver->connect(), $entry_id, $attr );
if( ! is_array( $values ) ) {
$display = 'Error';
} else {
if( isset( $values['count'] ) )
unset( $values['count'] );
foreach( $values as $value )
$display .= str_replace( ' ', '&nbsp;',
htmlspecialchars( $value ) ) . "<br />\n";
}
}
$attrs_display[ $attr_display ] = $display;
$attr = ldap_next_attribute( $ldapserver->connect(), $entry_id, $attrs );
} // end while( $attr )
$dn_display = strlen($dn) > 40 ?
sprintf('<acronym title="%s">%s...</acronym>',htmlspecialchars($dn),htmlspecialchars(substr($dn,0,40))) :
htmlspecialchars($dn);
$entries_display[] = $attrs_display;
$edit_url = sprintf('template_engine.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,rawurlencode($dn));
$attrs_display = array();
$attrs_display[''] = sprintf('<center><a href="%s"><img src="images/%s" /></a></center>',$edit_url,get_icon($ldapserver,$dn));
$attrs_display['dn'] = sprintf('<a href="%s">%s</a>',$edit_url,$dn_display);
//echo '<pre>';
//print_r( $attrs_display );
//echo "\n\n";
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
# Iterate over each attribute for this entry and store in associative array $attrs_display
foreach ($dndetails as $attr => $values) {
# Ignore DN, we've already displayed it.
if ($attr == 'dn')
continue;
} // end while( $entry_id )
# Clean up the attr name
if (isset($friendly_attrs[strtolower($attr)]))
$attr_display = sprintf('<acronym title="Alias for %s">%s</acronym>',
$attr,htmlspecialchars($friendly_attrs[strtolower($attr)]));
else
$attr_display = htmlspecialchars($attr);
$all_attrs = array_keys( $all_attrs );
if (! isset($all_attrs[$attr_display]))
$all_attrs[$attr_display] = 1;
/*
echo "<pre>";
print_r( $all_attrs );
print_r( $entries_display );
echo "</pre>";
*/
# Get the values
$display = '';
// Store the header row so it can be repeated later
$header_row = "<tr>";
foreach( $all_attrs as $attr )
$header_row .= "<th>$attr</th>";
$header_row .= "</tr>\n";
if ($ldapserver->isJpegPhoto($attr)) {
ob_start();
draw_jpeg_photos($ldapserver,$dn,$attr,false,false,'align="center"');
$display = ob_get_contents();
ob_end_clean();
// begin drawing table
echo "<br />";
echo "<center>";
echo "<table class=\"search_result_table\">\n";
} elseif ($ldapserver->isAttrBinary($attr)) {
$display = array('(binary)');
for( $i=0; $i<count($entries_display); $i++ ) {
$entry = $entries_display[$i];
if( $i %10 == 0 )
echo $header_row;
if( $i % 2 == 0 )
echo "<tr class=\"highlight\">";
else
echo "<tr>";
foreach( $all_attrs as $attr ) {
echo "<td>";
if( isset( $entry[ $attr ] ) )
echo $entry[ $attr ];
echo "</td>\n";
}
echo "</tr>\n";
} else {
if (! is_array($values))
$display .= str_replace(' ','&nbsp;',htmlspecialchars($values)).'<br />';
else
foreach ($values as $value )
$display .= str_replace(' ','&nbsp;',htmlspecialchars($value)).'<br />';
}
$attrs_display[$attr_display] = $display;
}
$entries_display[] = $attrs_display;
}
echo "</table>";
echo "</center>";
$all_attrs = array_keys($all_attrs);
# Store the header row so it can be repeated later
$header_row = '<tr>';
foreach ($all_attrs as $attr)
$header_row .= sprintf('<th>%s</th>',$attr);
$header_row .= '</tr>';
# Begin drawing table
echo '<br />';
echo '<center>';
echo '<table class="search_result_table">';
for ($i=0;$i<count($entries_display);$i++) {
$entry = $entries_display[$i];
if ($i %10 == 0)
echo $header_row;
if ($i % 2 == 0 )
echo '<tr class="highlight">';
else
echo '<tr>';
foreach ($all_attrs as $attr) {
echo '<td>';
if (isset($entry[$attr]))
echo $entry[$attr];
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
echo '</center>';
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/session_functions.php,v 1.14.2.2 2005/10/17 10:03:39 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/session_functions.php,v 1.16.2.1 2005/12/31 03:06:15 wurley Exp $
/**
* A collection of functions to handle sessions throughout phpLDAPadmin.
@@ -25,7 +25,7 @@ define('pla_session_id_ses_max', 36);
*/
function pla_session_get_id() {
if (DEBUG_ENABLED)
debug_log('pla_session_get_id(): Entered with ()',2);
debug_log('pla_session_get_id(): Entered with ()',1);
$id_md5 = md5(rand(1,1000000));
$ip_md5 = md5($_SERVER['REMOTE_ADDR']);
@@ -50,7 +50,7 @@ function pla_session_get_id() {
*/
function pla_session_verify_id() {
if (DEBUG_ENABLED)
debug_log('pla_session_verify_id(): Entered with ()',2);
debug_log('pla_session_verify_id(): Entered with ()',1);
$check_id = session_id();
$ip_md5 = md5($_SERVER['REMOTE_ADDR']);
@@ -76,7 +76,7 @@ function pla_session_verify_id() {
*/
function pla_session_start() {
if (DEBUG_ENABLED)
debug_log('pla_session_start(): Entered with ()',2);
debug_log('pla_session_start(): Entered with ()',1);
// If session.auto_start is on in the server's PHP configuration (php.ini), then
// we will have problems loading our schema cache since the session will have started

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/syslog.php,v 1.11 2005/08/10 06:07:32 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/syslog.php,v 1.11.4.1 2005/12/09 14:32:13 wurley Exp $
/**
* Functions related to syslog logging.
@@ -47,7 +47,7 @@ function syslog_msg ( $emergency, $log_string, $ldapserver=null ) {
if (isset($config) && $config->GetValue('debug','syslog')) {
if (isset($ldapserver->server_id))
$log_string = sprintf('(%s) %s',get_logged_in_dn($ldapserver->server_id),$log_string);
$log_string = sprintf('(%s) %s',$ldapserver->getLoggedInDN(),$log_string);
syslog ( $emergency, $log_string );
}

View File

@@ -1,5 +1,5 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.25.2.9 2005/11/12 02:46:18 wurley Exp $ */
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.29.2.15 2005/12/31 04:26:34 wurley Exp $ */
/**
* Classes and functions for the template engine.ation and capability
@@ -33,16 +33,16 @@ class xml2array {
$this->resParser = xml_parser_create();
xml_set_object($this->resParser,$this);
xml_set_element_handler($this->resParser,"tagOpen","tagClosed");
xml_set_element_handler($this->resParser,'tagOpen','tagClosed');
xml_set_character_data_handler($this->resParser,"tagData");
xml_set_character_data_handler($this->resParser,'tagData');
$this->push_pos($this->arrOutput);
$this->strXmlData = xml_parse($this->resParser,$strInputXML);
if (! $this->strXmlData)
die(sprintf("XML error: %s at line %d",
die(sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
@@ -95,14 +95,15 @@ class xml2array {
class Templates {
var $_template = array();
var $_js_hash = array();
function Templates($server_id) {
if (DEBUG_ENABLED)
debug_log('%s::__construct(): Entered with ()',2,get_class($this));
debug_log('%s::__construct(): Entered with ()',5,get_class($this));
if ($this->_template = get_cached_item($server_id,'template','all')) {
if (DEBUG_ENABLED)
debug_log('%s::init(): Using CACHED [%s]',3,get_class($this),'templates');
debug_log('%s::init(): Using CACHED [%s]',5,get_class($this),'templates');
} else {
$dir = opendir(TMPLDIR);
@@ -125,33 +126,50 @@ class Templates {
function storeTemplate($template,$xmldata) {
if (DEBUG_ENABLED)
debug_log('%s::storeTemplate(): Entered with (%s,%s)',2,
get_class($this),$template,serialize($xmldata));
debug_log('%s::storeTemplate(): Entered with (%s,%s)',5,
get_class($this),$template,$xmldata);
global $ldapserver, $lang;
global $ldapserver;
$this->_template[$template]['objectclass'] = array();
foreach ($xmldata['template'] as $xml_key => $xml_value) {
if (DEBUG_ENABLED)
debug_log('%s::storeTemplate(): Foreach loop Key [%s] Value [%s]',9,
debug_log('%s::storeTemplate(): Foreach loop Key [%s] Value [%s]',4,
get_class($this),$xml_key,is_array($xml_value));
switch ($xml_key) {
# Build our object Classes from the DN and Template.
case ('objectclasses') :
if (isset($xmldata['template']['objectclasses']) && is_array($xmldata['template']['objectclasses'])) {
foreach ($xmldata['template']['objectclasses']['objectclass'] as $index => $details) {
# XML files with only 1 objectClass dont have a numeric index.
if (is_numeric($index)) {
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($details['ID'],$this->_template[$template]['objectclass']))
if ($schema = $ldapserver->getSchemaObjectClass($details['ID'])) {
$this->_template[$template]['objectclass'][] = $details['ID'];
# If we havent recorded this objectclass already, do so now.
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($schema->getName(),$this->_template[$template]['objectclass'])) {
$this->_template[$template]['objectclass'][] = $schema->getName();
}
# This objectClass doesnt exist.
} else {
}
} else {
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($xmldata['template']['objectclasses']['objectclass']['ID'],$this->_template[$template]['objectclass']))
if ($schema = $ldapserver->getSchemaObjectClass($details)) {
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($details,$this->_template[$template]['objectclass'])) {
$this->_template[$template]['objectclass'][] = $schema->getName();
}
$this->_template[$template]['objectclass'][] = $xmldata['template']['objectclasses']['objectclass']['ID'];
# This objectClass doesnt exist.
} else {
}
}
}
}
@@ -161,7 +179,7 @@ class Templates {
# Build our attribute list from the DN and Template.
case ('attributes') :
if (DEBUG_ENABLED)
debug_log('%s::storeTemplate(): Case [%s]',8,get_class($this),'attributes');
debug_log('%s::storeTemplate(): Case [%s]',4,get_class($this),'attributes');
if (isset($xmldata['template']['attributes']) && is_array($xmldata['template']['attributes'])) {
$this->_template[$template]['attribute'] = array();
@@ -170,27 +188,28 @@ class Templates {
foreach ($tattrs as $index => $attr_details) {
if (DEBUG_ENABLED)
debug_log('%s::storeTemplate(): Foreach tattrs Key [%s] Value [%s]',9,
get_class($this),$index,is_array($attr_details));
debug_log('%s::storeTemplate(): Foreach tattrs Key [%s] Value [%s]',4,
get_class($this),$index,serialize($attr_details));
# Single attribute XML files are not indexed.
if (is_numeric($index)) {
$this->_template[$template]['attribute'][$attr_details['ID']] = $this->_parseXML($index,$attr_details);
if ($attr = $ldapserver->getSchemaAttribute($attr_details['ID']))
$this->_template[$template]['attribute'][$attr->getName()] = $this->_parseXML($index,$attr_details);
} else {
if (! strcmp($index,'ID'))
continue;
foreach ($attr_details as $key => $values) {
if (is_array($values) && isset($values['ID'])) {
$this->_template[$template]['attribute'][$tattrs['ID']][$index]['_KEY:'.$values['ID']] = $this->_parseXML($key,$values);
} elseif (is_array($values) && isset($values['#text'])) {
$this->_template[$template]['attribute'][$tattrs['ID']][$index][] = $values['#text'];
} else {
$this->_template[$template]['attribute'][$tattrs['ID']][$index] = $this->_parseXML($key,$values);
if ($attr = $ldapserver->getSchemaAttribute($tattrs['ID'])) {
foreach ($attr_details as $key => $values) {
if (is_array($values) && isset($values['ID'])) {
$this->_template[$template]['attribute'][$attr->getName()][$index]['_KEY:'.$values['ID']] = $this->_parseXML($key,$values);
} elseif (is_array($values) && isset($values['#text'])) {
$this->_template[$template]['attribute'][$attr->getName()][$index][] = $values['#text'];
} else {
$this->_template[$template]['attribute'][$attr->getName()][$index] = $this->_parseXML($key,$values);
}
}
}
}
@@ -214,6 +233,12 @@ class Templates {
}
}
if (! count($this->_template[$template]['objectclass'])) {
$this->_template[$template]['invalid'] = 1;
$this->_template[$template]['invalid_reason'] = _('ObjectClasses in XML dont exist in LDAP server.');
return;
}
# Collect our structural, must & may attributes.
$this->_template[$template]['must'] = array();
$this->_template[$template]['may'] = array();
@@ -228,24 +253,29 @@ class Templates {
while ($supclass == true) {
$schema_object = $ldapserver->getSchemaObjectClass($oclass);
/*
* Shouldnt be required now...
# Test that this is a valid objectclass - disable if an invalid one found.
if (! $schema_object) {
$this->_template[$template]['invalid'] = 1;
$supclass = false;
continue;
}
*/
if ($schema_object->getType() == 'structural' && (! $enherited))
$this->_template[$template]['structural'][] = $oclass;
if ($schema_object->getMustAttrs() )
foreach ($schema_object->getMustAttrs() as $index => $detail) {
$objectclassattr = $detail->getName();
if (! in_array($detail->getName(),$this->_template[$template]['must']) && $detail->getName() != 'objectClass') {
if (! in_array($objectclassattr,$this->_template[$template]['must']) &&
strcasecmp('objectClass',$objectclassattr) != 0) {
# Go through the aliases, and ignore any that are already defined.
$ignore = false;
$attr = $ldapserver->getSchemaAttribute($detail->GetName());
$attr = $ldapserver->getSchemaAttribute($objectclassattr);
foreach ($attr->aliases as $alias) {
if (in_array($alias,$this->_template[$template]['must'])) {
$ignore = true;
@@ -256,27 +286,30 @@ class Templates {
if ($ignore)
continue;
if (isset($this->_template[$template]['attribute'][$detail->getName()]) &&
! is_array($this->_template[$template]['attribute'][$detail->getName()]))
if (isset($this->_template[$template]['attribute'][$objectclassattr]) &&
! is_array($this->_template[$template]['attribute'][$objectclassattr]))
$this->_template[$template]['must'][] =
$this->_template[$template]['attribute'][$detail->getName()];
$this->_template[$template]['must'][] =
$this->_template[$template]['attribute'][$objectclassattr];
else
$this->_template[$template]['must'][] = $detail->getName();
$this->_template[$template]['must'][] = $objectclassattr;
}
}
if ($schema_object->getMayAttrs() )
foreach ($schema_object->getMayAttrs() as $index => $detail)
if (! in_array($detail->getName(),$this->_template[$template]['may']))
$this->_template[$template]['may'][] = $detail->getName();
if ($schema_object->getMayAttrs())
foreach ($schema_object->getMayAttrs() as $index => $detail) {
$objectclassattr = $detail->getName();
if (! in_array($objectclassattr,$this->_template[$template]['may']))
$this->_template[$template]['may'][] = $objectclassattr;
}
# Keep a list to objectclasses we have processed, so we dont get into a loop.
$oclass_processed[] = $oclass;
if ((count($schema_object->getSupClasses())) || count($superclasslist)) {
foreach ($schema_object->getSupClasses() as $supoclass) {
foreach ($schema_object->getSupClasses() as $supoclass) {
if (! in_array($supoclass,$oclass_processed))
$supoclasslist[] = $supoclass;
}
@@ -293,20 +326,6 @@ class Templates {
}
}
# Translate anything.
foreach (array('title','description','display','hint') as $transkey) {
if (isset($this->_template[$template][$transkey]) && isset($lang[$this->_template[$template][$transkey]]))
$this->_template[$template][$transkey] = $lang[$this->_template[$template][$transkey]];
foreach ($this->_template[$template]['attribute'] as $key => $value) {
if (isset($value[$transkey]) && isset($lang[$value[$transkey]]))
$this->_template[$template]['attribute'][$key][$transkey] = $lang[$value[$transkey]];
if (isset($value['helper'][$transkey]) && isset($lang[$value['helper'][$transkey]]))
$this->_template[$template]['attribute'][$key]['helper'][$transkey] = $lang[$value['helper'][$transkey]];
}
}
# Remove any must attributes in the may list.
foreach ($this->_template[$template]['may'] as $index => $detail) {
if (in_array($detail,$this->_template[$template]['must'])) {
@@ -363,6 +382,7 @@ class Templates {
//unset($this->_template[$template]);
$this->_template[$template]['invalid'] = 1;
$this->_template[$template]['invalid_reason'] = sprintf(_('Missing %s in the XML file.'),$key);
break;
}
}
@@ -370,8 +390,8 @@ class Templates {
function _parseXML($index,$attr_details) {
if (DEBUG_ENABLED)
debug_log('%s::_parseXML(): Entered with (%s,%s)',2,
get_class($this),$index,serialize($attr_details));
debug_log('%s::_parseXML(): Entered with (%s,%s)',5,
get_class($this),$index,$attr_details);
if (! $attr_details) {
return '';
@@ -408,16 +428,17 @@ class Templates {
}
function getTemplates() {
return $this->_template;
return $this->_template;
}
function OnChangeAdd($function) {
function OnChangeAdd($ldapserver,$origin,$value) {
if (DEBUG_ENABLED)
debug_log('%s::OnChangeAdd(): Entered with (%s)',2,get_class($this),$function);
debug_log('%s::OnChangeAdd(): Entered with (%s,%s,%s)',5,
get_class($this),$ldapserver->server_id,$origin,$value);
global $js;
global $_js_hash;
list($command,$arg) = split(':',$function);
list($command,$arg) = split(':',$value);
switch ($command) {
#autoFill:attr,string (with %attr%)
@@ -427,90 +448,112 @@ class Templates {
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U',$string,$matchall);
//print"<PRE>";print_r($matchall); //0 = highlevel match, 1 = attr, 2 = subst, 3 = mod
$html = sprintf('autoFill%s(this.form)',$attr);
if (! isset($_js_hash['autoFill'.$origin]))
$_js_hash['autoFill'.$origin] = '';
if (! isset($js["autoFill".$attr]) ) {
$formula = $string;
$formula = preg_replace('/^([^%])/','\'$1',$formula);
$formula = preg_replace('/([^%])$/','$1\'',$formula);
$js["autoFill".$attr] = sprintf("\nfunction autoFill%s( form ) {\n",$attr);
$formula = $string;
$formula = preg_replace('/^([^%])/','\'$1',$formula);
$formula = preg_replace('/([^%])$/','$1\'',$formula);
# Check that our attributes match our schema attributes.
foreach ($matchall[1] as $index => $checkattr) {
$matchattr = $ldapserver->getSchemaAttribute($checkattr);
foreach ($matchall[0] as $index => $null) {
$substrarray = array();
# If the attribute is the same as in the XML file, then dont need to do anything.
if ($matchattr->getName() == $checkattr)
continue;
$js["autoFill".$attr] .= sprintf(" var %s;\n",$matchall[1][$index]);
if (trim($matchall[2][$index])) {
preg_match_all('/([0-9]*)-([0-9]*)/',$matchall[2][$index],$substrarray);
}
if ($matchall[3][$index] == "/T") {
$js["autoFill".$attr] .= sprintf(" %s = form.%s.options[form.%s.selectedIndex].text;\n",
$matchall[1][$index],$matchall[1][$index],$matchall[1][$index]);
} else {
if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
$js["autoFill".$attr] .= sprintf(' %s = form.%s.value.substr(%s,%s)',
$matchall[1][$index],$matchall[1][$index],
$substrarray[1][0] ? $substrarray[1][0] : '0',
$substrarray[2][0] ? $substrarray[2][0] : sprintf('form.%s.value.length',$matchall[1][$index]));
} else {
$js["autoFill".$attr] .= sprintf(' %s = form.%s.value',$matchall[1][$index],$matchall[1][$index]);
}
switch ($matchall[3][$index]) {
case '/l':
$js["autoFill".$attr] .= ".toLowerCase()";
break;
}
$js["autoFill".$attr] .= ";\n";
}
$formula = preg_replace('/^%('.$matchall[1][$index].')%$/U','$1 + \'\'',$formula);
$formula = preg_replace('/^%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','$1 + \'',$formula);
$formula = preg_replace('/%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','\' + $1 ',$formula);
$formula = preg_replace('/%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','\' + $1 + \'',$formula);
}
$js["autoFill".$attr] .= sprintf(" form.%s.value = %s;\n",$attr,$formula);
$js["autoFill".$attr] .= "}\n";
$formula = preg_replace("/$checkattr/",$matchattr->getName(),$formula);
$matchall[1][$index] = $matchattr->getName();
}
foreach ($matchall[0] as $index => $null) {
$match_attr = $matchall[1][$index];
$match_subst = $matchall[2][$index];
$match_mod = $matchall[3][$index];
$substrarray = array();
$_js_hash['autoFill'.$origin] .= sprintf(" var %s;\n",$match_attr);
if (trim($match_subst)) {
preg_match_all('/([0-9]*)-([0-9]*)/',$match_subst,$substrarray);
}
if ($match_mod == '/T') {
$_js_hash['autoFill'.$origin] .= sprintf(
" %s = document.getElementById('%s').options[document.getElementById('%s').selectedIndex].text;\n",
$match_attr,$match_attr,$match_attr);
} else {
if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
$_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById("%s").value.substr(%s,%s)',
$match_attr,$match_attr,
$substrarray[1][0] ? $substrarray[1][0] : '0',
$substrarray[2][0] ? $substrarray[2][0] : sprintf('document.getElementById("%s").value.length',$match_attr));
} else {
$_js_hash['autoFill'.$origin] .= sprintf(' %s = document.getElementById(\'%s\').value',
$match_attr,$match_attr);
}
switch ($match_mod) {
case '/l':
$_js_hash['autoFill'.$origin] .= '.toLowerCase()';
break;
}
$_js_hash['autoFill'.$origin] .= ";\n";
}
# Matchfor only entry without modifiers.
$formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',$formula);
# Matchfor only entry with modifiers.
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','$1 + \'\'',$formula);
# Matchfor begining entry.
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','$1 + \'',$formula);
# Matchfor ending entry.
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','\' + $1 ',$formula);
# Match for entries not at begin/end.
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','\' + $1 + \'',$formula);
}
$_js_hash['autoFill'.$origin] .= sprintf(" fillRec('%s', %s);\n",$attr,$formula);
$_js_hash['autoFill'.$origin] .= "\n";
break;
default: $html = '';
default: $return = '';
}
return $html;
return '1';
}
function OnChangeDisplay() {
global $js;
return (isset($js) ? implode("\n",$js) : '');
function getJsHash() {
global $_js_hash;
return $_js_hash;
}
function EvaluateDefault($ldapserver,$value,$container,$counter='',$default=null) {
// @todo: The XML files need to change the field seperater to something else (ie: not comma)
// as it is clashing when a DN is used as an argument.
function EvaluateDefault(&$ldapserver,$value,$container,$counter='',$default=null) {
if (DEBUG_ENABLED)
debug_log('%s::EvaluateDefault(): Entered with (%s,%s,%s,%s)',2,
debug_log('%s::EvaluateDefault(): Entered with (%s,%s,%s,%s)',5,
get_class($this),$ldapserver->server_id,$value,$container,$counter);
global $lang;
global $ldapservers;
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$value,$matches)) {
$args = preg_split('/,/',$matches[2]);
switch($matches[1]) {
case 'GetNextNumber' :
$container = get_container_parent($ldapserver,$container,$args[0]);
if ($args[0] == '$')
$args[0] = $ldapservers->GetValue($ldapserver->server_id,'auto_number','search_base');
$detail['value'] = get_next_uid_number($ldapserver,$container,$args[1]);
$container = $ldapserver->getContainerParent($container,$args[0]);
$detail['value'] = get_next_number($ldapserver,$container,$args[1]);
break;
case 'PickList' :
$container = get_container_parent($ldapserver,$container,$args[0]);
$container = $ldapserver->getContainerParent($container,$args[0]);
preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$args[3],$matchall);
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
@@ -518,7 +561,7 @@ class Templates {
array_push($ldap_attrs,$args[2]);
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs);
$detail['value'] = sprintf('<select name="form[%s]" id="%%s" %%s %%s/>',(isset($args[4]) ? $args[4] : $args[2]));
$detail['value'] = sprintf('<select name="form[%s]" id="%%s" %%s %%s>',(isset($args[4]) ? $args[4] : $args[2]));
foreach ($picklistvalues as $key => $values) {
$display = $args[3];
@@ -527,7 +570,7 @@ class Templates {
}
if (! isset($picklist[$display])) {
$detail['value'] .= sprintf('<option name="%s" value="%s" %s>%s</option>',
$detail['value'] .= sprintf('<option id="%s" value="%s" %s>%s</option>',
$display,$values[$args[2]],
($default == $display ? 'selected' : ''),
$display);
@@ -540,12 +583,12 @@ class Templates {
case 'RandomPassword' :
$detail['value'] = password_generate();
printf('<script language="javascript">alert(\'%s:\n%s\')</script>',
$lang['random_password'],$detail['value']);
printf('<script type="text/javascript" language="javascript">alert(\'%s:\n%s\')</script>',
_('A random password was generated for you'),$detail['value']);
break;
case 'DrawChooserLink' :
$detail['value'] = draw_chooser_link(sprintf("template_form.%s%s",$args[0],$counter),$args[1]);
$detail['value'] = draw_chooser_link(sprintf('template_form.%s%s',$args[0],$counter),$args[1]);
break;
@@ -553,6 +596,22 @@ class Templates {
# Capture the function name and remove function name from $args
$function_name = array_shift($args);
$function_args = array();
foreach ($args as $arg) {
if (preg_match('/^%(\w+)(\|.+)?(\/[lU])?%/U',$arg,$matches)) {
$varname = $matches[1];
if (isset($_POST['form']['post'][$varname]))
$function_args[] = $_POST['form']['post'][$varname];
else
pla_error(sprintf(_('Your template calls php.Function for a default value, however (%s) is NOT available in the POST FORM variables. The following variables are available [%s].'),$varname,
(isset($_POST['form']) ? implode('|',array_keys($_POST['form'])) : 'NONE')));
} else {
$function_args[] = $arg;
}
}
# Call the PHP function if exists (PHP 4 >= 4.0.4, PHP 5)
if (function_exists($function_name))
$detail['value'] = call_user_func_array($function_name,$args);
@@ -569,14 +628,14 @@ class Templates {
}
if (DEBUG_ENABLED)
debug_log('%s::EvaluateDefault(): Returning (%s)',1,get_class($this),serialize($return));
debug_log('%s::EvaluateDefault(): Returning (%s)',5,get_class($this),$return);
return $return;
}
function HelperValue($helper,$id='',$container='',$ldapserver='',$counter='',$default='') {
if (DEBUG_ENABLED)
debug_log('%s::HelperValue(): Entered with (%s,%s,%s,%s,%s,%s)',2,
get_class($this),serialize($helper),$id,$container,$ldapserver->server_id,$counter,$default);
debug_log('%s::HelperValue(): Entered with (%s,%s,%s,%s,%s,%s)',5,
get_class($this),$helper,$id,$container,$ldapserver->server_id,$counter,$default);
if ($container && $ldapserver && ! is_array($helper)) {
if (preg_match('/^=php./',$helper))
@@ -589,9 +648,9 @@ class Templates {
} else {
if (is_array($helper)) {
$html = sprintf('<select name="%s" id="%s" />',$id,$id);
$html = sprintf('<select name="%s" id="%s">',$id,$id);
foreach ($helper as $value) {
$html .= sprintf('<option name="%s" value="%s" %s>%s</option>',
$html .= sprintf('<option id="%s" value="%s" %s>%s</option>',
$value,$value,($default == $value ? 'selected' : ''),$value);
}
$html .= '</select>';

View File

@@ -1,4 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/timeout_functions.php,v 1.6.2.5 2005/12/31 03:06:15 wurley Exp $
/**
* A collection of functions used throughout phpLDAPadmin for the timeout and automatic logout feature
@@ -16,9 +17,9 @@
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
* @return bool
*/
function set_lastactivity( $ldapserver ) {
function set_lastactivity($ldapserver) {
if (DEBUG_ENABLED)
debug_log('set_lastactivity(): Entered with (%s)',2,$ldapserver->server_id);
debug_log('set_lastactivity(): Entered with (%s)',1,$ldapserver->server_id);
$_SESSION['activity']['server'][$ldapserver->server_id] = time();
$_SESSION['activity']['rightframe_server_id'] = $ldapserver->server_id;
@@ -31,63 +32,49 @@ function set_lastactivity( $ldapserver ) {
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
*/
function unset_lastactivity( $ldapserver ) {
function unset_lastactivity($ldapserver) {
if (DEBUG_ENABLED)
debug_log('unset_lastactivity(): Entered with (%s)',2,$ldapserver->server_id);
debug_log('unset_lastactivity(): Entered with (%s)',1,$ldapserver->server_id);
if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
if (isset($_SESSION['activity']['server'][$ldapserver->server_id]))
unset($_SESSION['activity']['server'][$ldapserver->server_id]);
session_write_close();
}
}
/**
* Check if custom session timeout has been reached for server $ldapserver.
* If it has:
* - automatically log out user by calling unset_login_dn( $server_id )
* - automatically log out user by calling $ldapserver->unsetLoginDN()
* - if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
* - return true
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
* @return bool true on success, false on failure.
*/
function session_timed_out( $ldapserver ) {
function session_timed_out($ldapserver) {
if (DEBUG_ENABLED)
debug_log('session_timed_out(): Entered with (%s)',2,$ldapserver->server_id);
global $lang;
debug_log('session_timed_out(): Entered with (%s)',1,$ldapserver->server_id);
# If session hasn't expired yet
if( isset( $_SESSION[ 'activity' ]['server'][$ldapserver->server_id] ) ) {
if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
// If $session_timeout not defined, use ( session_cache_expire() - 1 )
# If $session_timeout not defined, use (session_cache_expire() - 1)
if (! isset($ldapserver->session_timeout))
$session_timeout = session_cache_expire()-1;
else
$session_timeout = $ldapserver->session_timeout;
// Get the $last_activity and $rightframe_server_id value
# Get the $last_activity and $rightframe_server_id value
$last_activity = $_SESSION['activity']['server'][$ldapserver->server_id];
$rightframe_server_id = $_SESSION['activity']['rightframe_server_id'];
// If diff between current time and last activity greater than $session_timeout, log out user
if ( ( time()-$last_activity ) > ( $session_timeout*60 ) ) {
# If diff between current time and last activity greater than $session_timeout, log out user
if ((time()-$last_activity) > ($session_timeout*60)) {
if( in_array($ldapserver->auth_type, array('cookie','session')) ) {
syslog_notice ( "Logout for " . get_logged_in_dn( $ldapserver ) );
unset_login_dn( $ldapserver ) or pla_error( $lang['could_not_logout'] );
if (in_array($ldapserver->auth_type, array('cookie','session'))) {
syslog_notice('Logout for '.$ldapserver->getLoggedInDN());
$ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
}
// If $ldapserver->server_id equal $rightframe_server_id load timeout page on right frame
if ( $ldapserver->server_id == $rightframe_server_id ) { ?>
<SCRIPT LANGUAGE="JavaScript">
<!--
parent.right_frame.location.href = 'timeout.php?server_id=<?php echo $ldapserver->server_id; ?>';
//--></SCRIPT>
<?php }
return true;
return true;
} else
return false;

View File

@@ -1,5 +1,5 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/tree_functions.php,v 1.19.2.1 2005/10/09 09:07:22 wurley Exp $
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/tree_functions.php,v 1.20.2.19 2006/01/02 13:30:34 wurley Exp $
/**
* @package phpLDAPadmin
@@ -17,37 +17,40 @@
*/
function draw_server_tree() {
if (DEBUG_ENABLED)
debug_log('draw_server_tree(): Entered with ()',2);
debug_log('draw_server_tree(): Entered with ()',33);
global $lang;
global $tree;
global $tree_icons;
global $ldapserver;
global $recently_timed_out_servers;
global $config;
$server_id = $ldapserver->server_id;
static $tm = null;
// Does this server want mass deletion availble?
$server_id = $ldapserver->server_id;
$tree = get_cached_item($ldapserver->server_id,'tree');
# Does this server want mass deletion available?
if ($ldapserver->isMassDeleteEnabled()) {
print '<form name="mass_delete" action="mass_delete.php" method="post" target="right_frame">';
echo '<form name="mass_delete" action="mass_delete.php" method="post" target="right_frame">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
echo "\n\n";
}
print '<tr class="server">';
printf('<td class="icon"><img src="images/server.png" alt="%s" /></td>',$lang['server']);
echo '<table class="tree" cellspacing="0">';
echo '<tr class="server">';
printf('<td class="icon"><img src="images/server.png" alt="%s" /></td>',_('Server'));
printf('<td colspan="99"><a name="%s"></a>',$ldapserver->server_id);
printf('<nobr>%s ',htmlspecialchars($ldapserver->name));
if ($ldapserver->haveAuthInfo() && $ldapserver->session_timeout)
printf('<acronym title="%s"><img widht=14 height=14 src="images/timeout.png" alt="timeout"><acronym>',
sprintf($lang['timeout_at'],strftime('%H:%M',time()+($ldapserver->session_timeout*60))));
if ($ldapserver->haveAuthInfo() && $ldapserver->auth_type != 'config')
printf('<acronym title="%s"><img width=14 height=14 src="images/timeout.png" alt="timeout" /></acronym>',
sprintf(_('Inactivity will log you off at %s'),strftime('%H:%M',time()+($ldapserver->session_timeout*60))));
print '</nobr></td></tr>';
echo '</nobr></td></tr>';
// do we have what it takes to authenticate here, or do we need to
// present the user with a login link (for 'cookie' and 'session' auth_types)?
/* do we have what it takes to authenticate here, or do we need to
present the user with a login link (for 'cookie' and 'session' auth_types)? */
if ($ldapserver->haveAuthInfo()) {
if ($ldapserver->connect(false)) {
$schema_href = sprintf('schema.php?server_id=%s" target="right_frame',$ldapserver->server_id);
$search_href = sprintf('search.php?server_id=%s" target="right_frame',$ldapserver->server_id);
@@ -57,52 +60,43 @@ function draw_server_tree() {
$import_href = sprintf('ldif_import_form.php?server_id=%s',$ldapserver->server_id);
$export_href = sprintf('export_form.php?server_id=%s',$ldapserver->server_id);
// Draw the quick-links below the server name:
// ( schema | search | refresh | create )
# Draw the quick-links below the server name:
echo '<tr><td colspan="100" class="links">';
echo '<nobr>';
echo '( ';
echo '<a title="' . $lang['view_schema_for'] . ' ' . $ldapserver->name . '"'.
' href="' . $schema_href . '">' . $lang['schema'] . '</a> | ';
echo '<a title="' . $lang['search'] . ' ' . $ldapserver->name . '"' .
' href="' . $search_href . '">' . $lang['search'] . '</a> | ';
echo '<a title="' . $lang['refresh_expanded_containers'] . ' ' . $ldapserver->name . '"'.
' href="' . $refresh_href . '">' . $lang['refresh'] . '</a> | ';
printf('<a title="%s %s" href="%s">%s</a> | ',_('View schema for'),$ldapserver->name,$schema_href,_('schema'));
printf('<a title="%s %s" href="%s">%s</a> | ',_('search'),$ldapserver->name,$search_href,_('search'));
printf('<a title="%s %s" href="%s">%s</a> | ',_('Refresh all expanded containers for'),$ldapserver->name,$refresh_href,_('refresh'));
printf('<a title="%s" target="right_frame" href="%s">%s</a> | ',_('View server-supplied information'),$info_href,_('info'));
printf('<a title="%s" target="right_frame" href="%s">%s</a> | ',_('Import entries from an LDIF file'),$import_href,_('import'));
printf('<a href="%s" target="right_frame">%s</a>',$export_href,_('export'));
// if ($ldapserver->isShowCreateEnabled())
// echo '<a title="' . $lang['create_new_entry_on'] . ' ' . $ldapserver->name . '"'.
// ' href="' . sprintf('create_form.php?server_id=%s',$server_id) . '" target="right_frame">' . $lang['create'] . '</a> | ';
echo '<a title="' . $lang['view_server_info'] . '" target="right_frame" '.
'href="' . $info_href . '">' . $lang['info'] . '</a> | ';
echo '<a title="' . $lang['import_from_ldif'] . '" target="right_frame" ' .
'href="' . $import_href .'">' . $lang['import'] . '</a> | ';
echo '<a href="' . $export_href . '" target="right_frame">' . $lang['export_lcase'] . '</a>';
if( $ldapserver->auth_type != 'config' )
echo ' | <a title="' . $lang['logout_of_this_server'] . '" href="' . $logout_href .
'" target="right_frame">' . $lang['logout'] . '</a>';
if ($ldapserver->auth_type != 'config')
printf(' | <a title="%s" href="%s" target="right_frame">%s</a>',_('Logout of this server'),$logout_href,_('logout'));
echo ' )</nobr></td></tr>';
if ($ldapserver->auth_type != 'config') {
$logged_in_dn = get_logged_in_dn( $ldapserver );
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" . $lang['logged_in_as'];
$logged_in_dn = $ldapserver->getLoggedInDN();
echo '<tr><td class="links" colspan="100"><nobr>'._('Logged in as: ');
if (dn_get_base($ldapserver,$logged_in_dn) == $logged_in_dn) {
if ($ldapserver->getDNBase($logged_in_dn) == $logged_in_dn) {
$logged_in_branch = '';
$logged_in_dn_array = array();
} else {
$logged_in_branch = preg_replace("/,".dn_get_base($ldapserver,$logged_in_dn)."$/","",$logged_in_dn);
$logged_in_branch = preg_replace('/,'.$ldapserver->getDNBase($logged_in_dn).'$/','',$logged_in_dn);
$logged_in_dn_array = explode(',',$logged_in_branch);
}
$logged_in_dn_array[] = dn_get_base($ldapserver,$logged_in_dn);
$logged_in_dn_array[] = $ldapserver->getDNBase($logged_in_dn);
$rdn = $logged_in_dn;
if (strcasecmp("anonymous",$logged_in_dn)) {
if (strcasecmp('anonymous',$logged_in_dn)) {
foreach ($logged_in_dn_array as $rdn_piece) {
printf('<a class="logged_in_dn" href="edit.php?server_id=%s&amp;dn=%s" target="right_frame">%s</a>',
printf('<a class="logged_in_dn" href="template_engine.php?server_id=%s&amp;dn=%s" target="right_frame">%s</a>',
$server_id,rawurlencode($rdn),pretty_print_dn($rdn_piece));
if ($rdn_piece != end($logged_in_dn_array))
@@ -112,118 +106,116 @@ function draw_server_tree() {
}
} else
echo "Anonymous";
echo 'Anonymous';
echo "</nobr></td></tr>";
echo '</nobr></td></tr>';
}
if( $ldapserver->isReadOnly() )
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" .
"(" . $lang['read_only'] . ")</nobr></td></tr>";
if ($ldapserver->isReadOnly())
printf('<tr><td class="links" colspan="100"><nobr>(%s)</nobr></td></tr>',_('read only'));
$javascript_forms = '';
$javascript_id = 0;
foreach ($ldapserver->getBaseDN() as $base_dn) {
// Did we get a base_dn for this server somehow?
if ($base_dn) {
echo "\n\n<!-- base DN row -->\n<tr>\n";
$tree_plm = '';
// is the root of the tree expanded already?
if( isset( $tree[$ldapserver->server_id][$base_dn] ) ) {
if ($config->GetValue('appearance','tree_plm') && ! isset($tm)) {
$tm = new TreeMenu();
$tm->setDirroot(JSDIR.'phplayersmenu/');
$tm->setIcondir(HTDOCDIR.'/images/');
$tm->setIconwww('images/');
$tm->setImgwww(JSDIR.'phplayersmenu/menuimages/');
}
foreach ($ldapserver->getBaseDN() as $base_dn) {
# Did we get a base_dn for this server somehow?
if ($base_dn) {
# is the root of the tree expanded already?
if (isset($tree['browser'][$base_dn]['open']) && $tree['browser'][$base_dn]['open']) {
$expand_href = sprintf('collapse.php?server_id=%s&amp;dn=%s',
$ldapserver->server_id,rawurlencode( $base_dn ));
$expand_img = "images/minus.png";
$expand_alt = "-";
$child_count = number_format( count( $tree[$ldapserver->server_id][$base_dn] ) );
$expand_img = 'images/minus.png';
$expand_alt = '-';
$child_count = number_format(count($tree['browser'][$base_dn]['children']));
} else {
// Check if the LDAP server is not yet initialized
// (ie, the base DN configured in config.php does not exist)
if( ! dn_exists( $ldapserver, $base_dn ) ) {
/* Check if the LDAP server is not yet initialized
(ie, the base DN configured in config.php does not exist) */
if (! $ldapserver->dnExists($base_dn)) {
$javascript_id++;
?>
<tr>
<td class="spacer"></td>
<td><img src="images/unknown.png" /></td>
<td colspan="98"><?php echo pretty_print_dn( $base_dn ); ?></td>
</tr>
printf('<tr><td class="spacer"></td><td><img src="images/unknown.png" /></td><td colspan="98">%s</td></tr>',
pretty_print_dn($base_dn));
<?php // Move this form and add it to the end of the html - otherwise the javascript
// doesnt work when isMassDeleteEnabled returning true.
$javascript_forms .= sprintf('<form name="create_base_form_%s" method="post" action="creation_template.php" target="right_frame">',$javascript_id);
$javascript_forms .= sprintf('<input type="hidden" name="template" value="custom" />');
$javascript_forms .= sprintf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
$javascript_forms .= sprintf('<input type="hidden" name="container" value="" />');
$javascript_forms .= sprintf('<input type="hidden" name="rdn" value="%s" />',htmlspecialchars($base_dn));
$javascript_forms .= sprintf('</form>'); ?>
/* Move this form and add it to the end of the html - otherwise the javascript
doesnt work when isMassDeleteEnabled returning true. */
$javascript_forms .= sprintf('<form name="create_base_form_%s" method="post" action="template_engine.php" target="right_frame">',
$javascript_id);
$javascript_forms .= sprintf('<input type="hidden" name="template" value="custom" />');
$javascript_forms .= sprintf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
$javascript_forms .= sprintf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($rdn));
$javascript_forms .= sprintf('<input type="hidden" name="rdn" value="%s" />',get_rdn($base_dn));
$javascript_forms .= sprintf('</form>');
<tr>
<td class="spacer"></td>
<td colspan="98">
<small><?php echo $lang['base_entry_does_not_exist']; ?>
<a href="javascript:document.create_base_form_<?php echo $javascript_id ?>.submit()"><?php echo $lang['create_it']; ?></a></small>
</td>
</tr>
<?php
printf('<tr><td class="spacer"></td><td colspan="98"><small>%s<a href="javascript:document.create_base_form_%s.submit()">%s</a></small></td></tr>',
_('This base entry does not exist.'),$javascript_id,_('Create it?'));
continue;
} else {
$expand_href = sprintf('expand.php?server_id=%s&amp;dn=%s',
$ldapserver->server_id,rawurlencode( $base_dn ));
$expand_img = "images/plus.png";
$expand_alt = "+";
$size_limit = $config->GetValue('search','size_limit');
$expand_img = 'images/plus.png';
$expand_alt = '+';
# $size_limit = $config->GetValue('search','size_limit');
$size_limit = -1;
if( $ldapserver->isLowBandwidth() ) {
if ($ldapserver->isLowBandwidth()) {
$child_count = null;
} else {
$child_count = count( get_container_contents(
$ldapserver, $base_dn, $size_limit+1,
'(objectClass=*)', $config->GetValue('deref','tree') ) );
$children = $ldapserver->getContainerContents($base_dn,$size_limit+1,'(objectClass=*)',
$config->GetValue('deref','tree'));
if( $child_count > $size_limit )
$child_count = $size_limit . '+';
}
$child_count = count($children);
# if ($child_count > $size_limit)
# $child_count = $size_limit.'+';
}
}
}
$create_href = sprintf('create_form.php?server_id=%s&amp;container=%s',$ldapserver->server_id,
rawurlencode( $base_dn ));
$create_href = sprintf('create_form.php?server_id=%s&amp;container=%s',$ldapserver->server_id,rawurlencode($base_dn));
$edit_href = sprintf('template_engine.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,rawurlencode($base_dn));
$edit_href = sprintf("edit.php?server_id=%s&amp;dn=%s",$ldapserver->server_id,rawurlencode( $base_dn ));
$icon = isset($tree['browser'][$base_dn]['icon']) ? $tree['browser'][$base_dn]['icon'] : get_icon($ldapserver,$base_dn);
$icon = isset( $tree_icons[ $ldapserver->server_id ][ $base_dn ] )
? $tree_icons[ $ldapserver->server_id ][ $base_dn ]
: get_icon( $ldapserver, $base_dn );
# Shall we draw the "mass-delete" checkbox?
if ($ldapserver->isMassDeleteEnabled())
printf('<td><input type="checkbox" name="mass_delete[%s]" /></td>',htmlspecialchars($base_dn));
// Shall we draw the "mass-delete" checkbox?
if( $ldapserver->isMassDeleteEnabled() ) {
echo "<td><input type=\"checkbox\" name=\"mass_delete[" . htmlspecialchars($base_dn) . "]\" /></td>\n";
if ($config->GetValue('appearance','tree_plm')) {
$tree_plm .= sprintf(".|%s|%s|%s|%s|%s|%s\n",
pretty_print_dn($base_dn).($child_count ? ' ('.$child_count.')' : ''),$edit_href,$base_dn,$icon,'right_frame',0);
} else {
echo '<tr>';
printf('<td class="expander"><a href="%s"><img src="%s" alt="%s" /></a></td>',$expand_href,$expand_img,$expand_alt);
printf('<td class="icon"><a href="%s" target="right_frame"><img src="images/%s" alt="img" /></a></td>',$edit_href,$icon);
printf('<td class="rdn" colspan="98"><nobr><a href="%s" target="right_frame">%s</a>',$edit_href,pretty_print_dn($base_dn));
if ($child_count)
printf(' <span class="count">(%s)</span>',$child_count);
echo '</nobr></td>';
echo '</tr>';
}
echo "<td class=\"expander\">";
echo "<a href=\"$expand_href\"><img src=\"$expand_img\" alt=\"$expand_alt\" /></a></td>";
echo "<td class=\"icon\"><a href=\"$edit_href\" target=\"right_frame\">";
echo "<img src=\"images/$icon\" alt=\"img\" /></a></td>\n";
echo "<td class=\"rdn\" colspan=\"98\"><nobr><a href=\"$edit_href\" ";
echo " target=\"right_frame\">" . pretty_print_dn( $base_dn ) . '</a>';
if( $child_count )
echo " <span class=\"count\">($child_count)</span>";
echo "</nobr></td>\n";
echo "</tr>\n<!-- end of base DN row -->";
if( $ldapserver->isShowCreateEnabled() && isset( $tree[ $ldapserver->server_id ][ $base_dn ])
&& count( $tree[ $ldapserver->server_id ][ $base_dn ] ) > 10 )
draw_create_link( $ldapserver->server_id, $base_dn, -1, urlencode( $base_dn ));
} else { // end if( $base_dn )
# The server refuses to give out the base dn
printf('<tr><td class="spacer"></td><td colspan="98"><small>%s<br />%s<br /><b>%s</b></small></td></tr>',
$lang['could_not_determine_root'],$lang['ldap_refuses_to_give_root'],$lang['please_specify_in_config']);
_('Could not determine the root of your LDAP tree.'),_('It appears that the LDAP server has been configured to not reveal its root.'),_('Please specify it in config.php'));
# Proceed to the next server. We cannot draw anything else for this server.
continue;
@@ -231,70 +223,254 @@ function draw_server_tree() {
flush();
// Is the root of the tree expanded already?
if( isset( $tree[$ldapserver->server_id][$base_dn] ) && is_array( $tree[$ldapserver->server_id][$base_dn] ) ) {
foreach( $tree[ $ldapserver->server_id ][ $base_dn ] as $child_dn )
draw_tree_html( $child_dn, $ldapserver, 0 );
if ($config->GetValue('appearance','tree_plm')) {
foreach ($children as $child_dn)
$tree_plm .= draw_tree_plm($child_dn,$ldapserver);
if( ! $ldapserver->isReadOnly() ) {
echo '<tr><td class="spacer"></td>';
if( $ldapserver->isShowCreateEnabled() ) {
echo '<td class="icon"><a href="' . $create_href .
'" target="right_frame"><img src="images/star.png" alt="' .
$lang['new'] . '" /></a></td>';
echo '<td class="create" colspan="100"><a href="' . $create_href
. '" target="right_frame" title="' . $lang['create_new_entry_in']
. ' ' . $base_dn.'">' . $lang['create_new'] . '</a></td></tr>';
} else {
# Is the root of the tree expanded already?
if (isset($tree['browser'][$base_dn]['open'] ) && $tree['browser'][$base_dn]['open']) {
if ($ldapserver->isShowCreateEnabled() && count($tree['browser'][$base_dn]['children']) > 10 )
draw_create_link($ldapserver->server_id,$base_dn,-1,urlencode($base_dn));
foreach ($tree['browser'][$base_dn]['children'] as $child_dn)
draw_tree_html($child_dn,$ldapserver,0);
if (! $ldapserver->isReadOnly()) {
echo '<tr><td class="spacer"></td></tr>';
if ($ldapserver->isShowCreateEnabled())
draw_create_link($ldapserver->server_id,$base_dn,-1,urlencode($base_dn));
}
}
}
} // foreeach
if ($config->GetValue('appearance','tree_plm')) {
$tm->setMenuStructureString($tree_plm);
$tm->parseStructureForMenu('pla_tree_'.$ldapserver->server_id);
$tm->setTreeMenuTheme('');
$tm->newTreeMenu('pla_tree_'.$ldapserver->server_id);
echo '<tr><td colspan=99>'.$tm->getTreeMenu('pla_tree_'.$ldapserver->server_id).'</td></tr>';
}
} else { // end if( $ldapserver->connect(false) )
// could not connect to LDAP server
echo "<tr>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td><img src=\"images/warning_small.png\" alt=\"" . $lang['warning'] . "\" /></td>\n";
echo "<td colspan=\"99\"><small><span style=\"color:red\">" . $lang['could_not_connect'] . "</span></small></td>\n";
echo "</tr>\n";
if( $ldapserver->auth_type != 'config' ) {
$logout_href = get_custom_file( $ldapserver->server_id, 'logout.php','') . '?server_id=' . $ldapserver->server_id;
echo "<tr>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td colspan=\"99\"><small>";
echo "<a target=\"right_frame\" href=\"$logout_href\">" . $lang['logout'] . "</a></small></td>\n";
echo "</tr>\n";
# could not connect to LDAP server
printf('<tr><td class="spacer"></td><td><img src="images/warning_small.png" alt="%s" /></td><td colspan="99"><small><span style="color:red">%s</span></small></td></tr>',_('warning'),_('Could not connect to LDAP server.'));
if ($ldapserver->auth_type != 'config') {
$logout_href = sprintf('%s?server_id=%s',get_custom_file($ldapserver->server_id,'logout.php',''),$ldapserver->server_id);
printf('<tr><td class="spacer"></td><td class="spacer"></td><td colspan="99"><small><a target="right_frame" href="%s">%s</a></small></td></tr>',
$logout_href,_('logout'));
}
// Proceed to the next server in the list. We cannot do anything mroe here.
# Proceed to the next server in the list. We cannot do anything mroe here.
return;
}
} else { // end if $ldapserver->haveAuthInfo()
// We don't have enough information to login to this server
// Draw the "login..." link
$login_href = get_custom_file( $ldapserver->server_id, 'login_form.php','' ) . "?server_id=$server_id";
echo '<tr class="login">';
echo '<td class="spacer"></td>';
echo '<td><a href="' . $login_href . '" target="right_frame">';
echo '<img src="images/uid.png" align="top" alt="' . $lang['login'] . '" /></a></td>';
echo '<td colspan="99"><a href="' . $login_href . '" target="right_frame">' . $lang['login_link'] . '</a>';
echo '</td></tr>';
// If the server recently timed out display the message
if ( in_array($ldapserver->server_id,$recently_timed_out_servers) )
echo '<tr><td class="spacer"></td><td colspan="100" class="links">' . $lang['session_timed_out_tree'] . '</td></tr>';
/* We don't have enough information to login to this server
Draw the "login..." link */
$login_href = sprintf('%s?server_id=%s',get_custom_file($ldapserver->server_id,'login_form.php',''),$ldapserver->server_id);
printf('<tr class="login"><td class="spacer"></td><td><a href="%s" target="right_frame"><img src="images/uid.png" align="top" alt="%s" /></a></td><td colspan="99"><a href="%s" target="right_frame">%s</a></td></tr>',$login_href,_('login'),$login_href,_('Login...'));
# If the server recently timed out display the message
if (in_array($ldapserver->server_id,$recently_timed_out_servers))
printf('<tr><td class="spacer"></td><td colspan="100" class="links">%s</td></tr>',_('(Session timed out. Automatically logged out.)'));
}
if( $ldapserver->isMassDeleteEnabled() ) {
echo "<tr><td colspan=\"99\"><input type=\"submit\" value=\"Delete Checked Entries\" \></td></tr>\n";
echo "<!-- The end of the mass deletion form -->\n";
echo "</form>\n";
if ($ldapserver->isMassDeleteEnabled() && ! $config->GetValue('appearance','tree_plm')) {
printf('<tr><td colspan="99"><input type="submit" value="%s" /></td></tr>',_('Delete Checked Entries'));
echo '<!-- The end of the mass deletion form -->';
echo '</table>';
echo '</form>';
} else {
echo '</table>';
}
echo "\n\n";
if (isset($javascript_forms) && $javascript_forms) {
echo "<!-- Forms for javascript submit to call to create base_dns -->\n";
echo $javascript_forms;
echo "<!-- The end of the forms for javascript submit to call to create base_dns -->\n";
}
}
/**
* Recursively descend on the given dn and draw the tree in html
*
* @param dn $dn Current dn.
* @param object $LDAPServer LDAPServer object
* @param int $level Level to start drawing (defaults to 0)
*/
function draw_tree_html($dn,$ldapserver,$level=0) {
global $config;
$tree = get_cached_item($ldapserver->server_id,'tree');
$encoded_dn = rawurlencode($dn);
$expand_href = sprintf('expand.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$collapse_href = sprintf('collapse.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$edit_href = sprintf('template_engine.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$img_src = sprintf('images/%s',$tree['browser'][$dn]['icon']);
$rdn = get_rdn($dn);
echo '<tr>';
for ($i=0;$i<=$level;$i++)
echo '<td class="spacer"></td>';
# Shall we draw the "mass-delete" checkbox?
if ($ldapserver->isMassDeleteEnabled())
printf('<td><input type="checkbox" name="mass_delete[%s]" /></td>',htmlspecialchars($dn));
# Is this node expanded? (deciding whether to draw "+" or "-")
if (isset($tree['browser'][$dn]['open']) && $tree['browser'][$dn]['open']) {
$child_count = number_format(count($tree['browser'][$dn]['children']));
if ((! $child_count) && (! $ldapserver->isShowCreateEnabled()))
echo '<td class="expander"><nobr><img src="images/minus.png" alt="-" /></nobr></td>';
else
printf('<td class="expander"><nobr><a href="%s"><img src="images/minus.png" alt="-" /></a></nobr></td>',$collapse_href);
} else {
$size_limit = $config->GetValue('search','size_limit');
if ($ldapserver->isLowBandwidth()) {
$child_count = null;
} else {
$child_count = count($ldapserver->getContainerContents($dn,$size_limit+1,'(objectClass=*)',$config->GetValue('deref','tree')));
if ($child_count > $size_limit)
$child_count = $size_limit.'+';
}
if ((! $child_count) && (! $ldapserver->isShowCreateEnabled()))
echo '<td class="expander"><nobr><img src="images/minus.png" alt="-" /></nobr></td>';
else
printf('<td class="expander"><nobr><a href="%s"><img src="images/plus.png" alt="+" /></a></nobr></td>',$expand_href);
}
printf('<td class="icon"><a href="%s" target="right_frame" name="%s_%s"><img src="%s" alt="img" /></a></td>',
$edit_href,$ldapserver->server_id,$encoded_dn,$img_src);
printf('<td class="rdn" colspan="%s"><nobr>',97-$level);
printf('<a href="%s" target="right_frame">%s</a>',$edit_href,draw_formatted_dn($ldapserver,$dn));
if ($child_count)
printf(' <span class="count">(%s)</span>',$child_count);
echo '</nobr></td></tr>';
if (isset($tree['browser'][$dn]['open']) && $tree['browser'][$dn]['open']) {
/* Draw the "create new" link at the top of the tree list if there are more than 10
entries in the listing for this node. */
if ((count($tree['browser'][$dn]['children']) > 10) && ($ldapserver->isShowCreateEnabled()))
draw_create_link($ldapserver->server_id,$rdn,$level,$encoded_dn);
foreach ($tree['browser'][$dn]['children'] as $dn)
draw_tree_html($dn,$ldapserver,$level+1);
# Always draw the "create new" link at the bottom of the listing
if ($ldapserver->isShowCreateEnabled())
draw_create_link($ldapserver->server_id,$rdn,$level,$encoded_dn);
}
}
/**
* Recursively descend on the given dn and draw the tree in plm
*
* @param dn $dn Current dn.
* @param object $LDAPServer LDAPServer object
* @param int $level Level to start drawing (defaults to 2)
* @todo: Currently draw PLM only shows the first 50 entries of the base children - possibly the childrens children too. Have disabed the size_limit on the base - need to check that it doesnt affect non PLM tree viewer and children where size > size_limit.
*/
function draw_tree_plm($dn,$ldapserver,$level=2) {
if (DEBUG_ENABLED)
debug_log('draw_tree_plm(): Entered with (%s,%s,%s)',33,
$dn,$ldapserver,$level);
global $config;
$tree = get_cached_item($ldapserver->server_id,'tree');
$encoded_dn = rawurlencode($dn);
#$expand_href = sprintf('expand.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
$edit_href = sprintf('template_engine.php?server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
#$img_src = sprintf('images/%s',$tree['browser'][$dn]['icon']);
$rdn = get_rdn($dn);
$dots = '';
for ($i=1;$i<=$level;$i++)
$dots .= '.';
# Have we tranversed this part of the tree yet?
if (isset($tree['browser'][$dn]['open'])) {
$tree_plm = sprintf("%s|%s|%s|%s|%s|%s|%s\n",
$dots,
$rdn.' ('.number_format(count($tree['browser'][$dn]['children'])).')',
$edit_href,$dn,$tree['browser'][$dn]['icon'],'right_frame',
(isset($tree['browser'][$dn]['open']) ? $tree['browser'][$dn]['open'] : 0));
foreach ($tree['browser'][$dn]['children'] as $dn)
$tree_plm .= draw_tree_plm($dn,$ldapserver,$level+1);
} else {
$size_limit = $config->GetValue('search','size_limit');
$child_count = count($ldapserver->getContainerContents($dn,$size_limit+1,'(objectClass=*)',$config->GetValue('deref','tree')));
if ($child_count > $size_limit)
$child_count = $size_limit.'+';
if ($child_count) {
$tree_plm = sprintf("%s|%s|%s|%s|%s|%s|%s|%s\n",
$dots,
$rdn.' ('.$child_count.')',
$edit_href,$dn,$tree['browser'][$dn]['icon'],
'right_frame',
(isset($tree['browser'][$dn]['open']) ? $tree['browser'][$dn]['open'] : 0),
$child_count);
} else {
$tree_plm = sprintf("%s|%s|%s|%s|%s|%s|%s|%s\n",
$dots,
$rdn.' (0)',
$edit_href,$dn,$tree['browser'][$dn]['icon'],
'right_frame',
(isset($tree['browser'][$dn]['open']) ? $tree['browser'][$dn]['open'] : 0),
$child_count);
}
}
if (DEBUG_ENABLED)
debug_log('draw_tree_plm(): Returning (%s)',33,$tree_plm);
return $tree_plm;
}
/**
* Print the HTML to show the "create new entry here".
*
* @param int $server_id
* @param dn $rdn
* @param int $level
* @param dn $encoded_dn
*/
function draw_create_link($server_id,$rdn,$level,$encoded_dn) {
# print the "Create New object" link.
$create_href = sprintf('create_form.php?server_id=%s&amp;container=%s',$server_id,$encoded_dn);
echo '<tr>';
for ($i=0;$i<=$level;$i++)
echo '<td class="spacer"></td>';
echo '<td class="spacer"></td>';
printf('<td class="icon"><a href="%s" target="right_frame"><img src="images/star.png" alt="%s" /></a></td>',
$create_href,_('new'));
printf('<td class="create" colspan="%s"><a href="%s" target="right_frame" title="%s %s">%s</a></td>',
97-$level,$create_href,_('Create a new entry in'),$rdn,_('Create new entry here'));
echo '</tr>';
}
?>