@@ -159,16 +180,18 @@ foreach( $avail_attrs as $i => $attr ) {
/**
* Given an attribute $x, this returns true if it is NOT already specified
* in the current entry, returns false otherwise.
+ *
+ * @param attr $x
+ * @return bool
+ * @ignore
*/
-function not_an_attr( $x )
-{
+function not_an_attr( $x ) {
global $attrs;
+
//return ! isset( $attrs[ strtolower( $x ) ] );
foreach( $attrs as $attr => $values )
if( 0 == strcasecmp( $attr, $x ) )
return false;
return true;
}
-
-
?>
diff --git a/add_oclass.php b/add_oclass.php
index 502a691..ac4f123 100644
--- a/add_oclass.php
+++ b/add_oclass.php
@@ -1,36 +1,39 @@
isReadOnly() )
+ pla_error( $lang['no_updates_in_read_only_mode'] );
+if( ! $ldapserver->haveAuthInfo())
+ pla_error( $lang['not_enough_login_info'] );
+
$dn = rawurldecode( $_POST['dn'] );
-$encoded_dn = rawurlencode( $dn );
-$new_oclass = $_POST['new_oclass'];
-$server_id = $_POST['server_id'];
+$new_oclass = unserialize( rawurldecode( $_POST['new_oclass'] ) );
$new_attrs = $_POST['new_attrs'];
-if( is_attr_read_only( $server_id, 'objectClass' ) )
- pla_error( "ObjectClasses are flagged as read only in the phpLDAPadmin configuration." );
-if( is_server_read_only( $server_id ) )
- pla_error( $lang['no_updates_in_read_only_mode'] );
+$encoded_dn = rawurlencode( $dn );
-check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
-have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
+if( is_attr_read_only( $ldapserver, 'objectClass' ) )
+ pla_error( "ObjectClasses are flagged as read only in the phpLDAPadmin configuration." );
$new_entry = array();
$new_entry['objectClass'] = $new_oclass;
@@ -42,29 +45,20 @@ if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
foreach( $new_attrs as $attr => $val ) {
// Check to see if this is a unique Attribute
- if( $badattr = checkUniqueAttr( $server_id, $dn, $attr, array($val) ) ) {
- $search_href='search.php?search=true&form=advanced&server_id=' . $server_id . '&filter=' . $attr . '=' . $badattr;
- pla_error(sprintf( $lang['unique_attr_failed'] , $attr,$badattr,$dn,$search_href ) );
+ if( $badattr = checkUniqueAttr( $ldapserver, $dn, $attr, array($val) ) ) {
+ $search_href = sprintf('search.php?search=true&form=advanced&server_id=%s&filter=%s=%s',
+ $ldapserver->server_id,$attr,$badattr);
+ pla_error(sprintf( $lang['unique_attr_failed'],$attr,$badattr,$dn,$search_href ) );
}
$new_entry[ $attr ] = $val;
}
-//echo "
";
-//print_r( $new_entry );
-//exit;
+$add_res = @ldap_mod_add( $ldapserver->connect(), $dn, $new_entry );
-$ds = pla_ldap_connect( $server_id );
-pla_ldap_connection_is_error( $ds );
-$add_res = @ldap_mod_add( $ds, $dn, $new_entry );
+if (! $add_res)
+ pla_error($lang['could_not_perform_ldap_mod_add'],ldap_error($ldapserver->connect()),ldap_errno($ldapserver->connect()));
-if( ! $add_res )
-{
- pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) );
-}
else
-{
- header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&modified_attrs[]=objectclass" );
-}
-
+ header(sprintf('Location: edit.php?server_id=%s&dn=%s&modified_attrs[]=objectclass',$ldapserver->server_id,$encoded_dn));
?>
diff --git a/add_oclass_form.php b/add_oclass_form.php
index cbe624f..2b62009 100644
--- a/add_oclass_form.php
+++ b/add_oclass_form.php
@@ -1,9 +1,7 @@
isReadOnly() )
pla_error( $lang['no_updates_in_read_only_mode'] );
+if( ! $ldapserver->haveAuthInfo())
+ pla_error( $lang['not_enough_login_info'] );
-check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
-have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
+$new_oclass = $_REQUEST['new_oclass'];
+$dn = rawurldecode( $_REQUEST['dn'] );
+$encoded_dn = rawurlencode( $dn );
/* Ensure that the object has defined all MUST attrs for this objectClass.
* If it hasn't, present a form to have the user enter values for all the
* newly required attrs. */
-$entry = get_object_attrs( $server_id, $dn, true );
+$entry = get_object_attrs( $ldapserver, $dn, true );
+
$current_attrs = array();
foreach( $entry as $attr => $junk )
$current_attrs[] = strtolower($attr);
// grab the required attributes for the new objectClass
-$oclass = get_schema_objectclass( $server_id, $new_oclass );
-if( $oclass )
- $must_attrs = $oclass->getMustAttrs();
-else
- $must_attrs = array();
+$schema_oclasses = get_schema_objectclasses( $ldapserver );
+$must_attrs = array();
+foreach( $new_oclass as $oclass_name ) {
+ $oclass = get_schema_objectclass( $ldapserver, $oclass_name );
+ if( $oclass )
+ $must_attrs = array_merge( $must_attrs, $oclass->getMustAttrNames( $schema_oclasses ) );
+}
+$must_attrs = array_unique( $must_attrs );
// We don't want any of the attr meta-data, just the string
//foreach( $must_attrs as $i => $attr )
@@ -54,52 +58,57 @@ else
// but that the object does not currently contain
$needed_attrs = array();
foreach( $must_attrs as $attr ) {
- $attr = get_schema_attribute( $server_id, $attr->getName() );
- //echo "
"; var_dump( $attr ); echo "
";
- // First, check if one of this attr's aliases is already an attribute of this entry
- foreach( $attr->getAliases() as $alias_attr_name )
- if( in_array( strtolower( $alias_attr_name ), $current_attrs ) )
- // Skip this attribute since it's already in the entry
- continue;
- if( in_array( strtolower($attr->getName()), $current_attrs ) )
- continue;
+ $attr = get_schema_attribute( $ldapserver, $attr );
- // We made it this far, so the attribute needs to be added to this entry in order
- // to add this objectClass
- $needed_attrs[] = $attr;
+ //echo "
"; var_dump( $attr ); echo "
";
+
+ // First, check if one of this attr's aliases is already an attribute of this entry
+ foreach( $attr->getAliases() as $alias_attr_name )
+ if( in_array( strtolower( $alias_attr_name ), $current_attrs ) )
+
+ // Skip this attribute since it's already in the entry
+ continue;
+
+ if( in_array( strtolower($attr->getName()), $current_attrs ) )
+ continue;
+
+ // We made it this far, so the attribute needs to be added to this entry in order
+ // to add this objectClass
+ $needed_attrs[] = $attr;
}
-if( count( $needed_attrs ) > 0 )
-{
+if( count( $needed_attrs ) > 0 ) {
include './header.php'; ?>
-
+
-
+
-
+
\n";
+ echo "\n";
foreach( $english_lang as $key => $string )
if( ! isset( $lang[ $key ] ) ) {
$has_errors = true;
diff --git a/collapse.php b/collapse.php
index 498bde5..e4bb7c9 100644
--- a/collapse.php
+++ b/collapse.php
@@ -1,44 +1,42 @@
server_id]))
+ unset($_SESSION['tree'][$ldapserver->server_id][$dn]);
-// This is for Opera. By putting "random junk" in the query string, it thinks
-// that it does not have a cached version of the page, and will thus
-// fetch the page rather than display the cached version
+/* This is for Opera. By putting "random junk" in the query string, it thinks
+ that it does not have a cached version of the page, and will thus
+ fetch the page rather than display the cached version */
$time = gettimeofday();
-$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
+$random_junk = md5(strtotime('now') . $time['usec']);
-// If cookies were disabled, build the url parameter for the session id.
-// It will be append to the url to be redirect
-$id_session_param="";
-if(SID != ""){
- $id_session_param = "&".session_name()."=".session_id();
-}
+/* If cookies were disabled, build the url parameter for the session id.
+ It will be append to the url to be redirect */
+$id_session_param = "";
+if (SID != "")
+ $id_session_param = "&".session_name()."=".session_id();
-header( "Location:tree.php?foo=$random_junk#{$server_id}_{$encoded_dn}$id_session_param" );
+header(sprintf('Location:tree.php?foo=%s#%s_%s%s',$random_junk,$ldapserver->server_id,$encoded_dn,$id_session_param));
?>
diff --git a/common.php b/common.php
index 03a7dad..b92ed07 100644
--- a/common.php
+++ b/common.php
@@ -1,157 +1,140 @@
= "5" )
- ini_set( "zend.ze1_compatibility_mode", 1 );
+@DEFINE(LIBDIR,'./');
-// Turn on all notices and warnings. This helps us write cleaner code (we hope at least)
-if( phpversion() >= "5" )
- // E_DEBUG is PHP5 specific and prevents warnings about using 'var' to declar class members
- error_reporting( 'E_DEBUG' );
-else
- // For PHP4
- error_reporting( E_ALL );
+# Turn on all notices and warnings. This helps us write cleaner code (we hope at least)
+if (phpversion() >= "5") {
+ # Work-around to get PLA to work in PHP5
+ ini_set( "zend.ze1_compatibility_mode", 1 );
+ # E_DEBUG is PHP5 specific and prevents warnings about using 'var' to declar class members
+ error_reporting( 'E_DEBUG' );
+} else
+ # For PHP4
+ error_reporting( E_ALL );
-// For PHP5 backward/forward compatibility
-if( ! defined( 'E_STRICT' ) ) {
- define( 'E_STRICT', 2048 );
-}
+# For PHP5 backward/forward compatibility
+if (! defined('E_STRICT'))
+ define('E_STRICT',2048);
-/** The minimum version of PHP required to run phpLDAPadmin. */
-@define( 'REQUIRED_PHP_VERSION', '4.1.0' );
-/** The default setting for $search_deref if unspecified or misconfigured by user. */
-@define( 'DEFAULT_SEARCH_DEREF_SETTING', LDAP_DEREF_ALWAYS );
-/** The default setting for $tree_deref if unspecified or misconfigured by user. */
-@define( 'DEFAULT_TREE_DEREF_SETTING', LDAP_DEREF_NEVER );
-/** The default setting for $export_deref if unspecified or misconfigured by user. */
-@define( 'DEFAULT_EXPORT_DEREF_SETTING', LDAP_DEREF_NEVER );
-/** The default setting for $view_deref if unspecified or misconfigured by user. */
-@define( 'DEFAULT_VIEW_DEREF_SETTING', LDAP_DEREF_NEVER );
-
-// General functions needed to proceed (pla_ldap_search(), pla_error(), get_object_attrs(), etc.)
+# General functions needed to proceed (pla_ldap_search(), pla_error(), get_object_attrs(), etc.)
ob_start();
-if( ! file_exists( realpath( './functions.php' ) ) ) {
- ob_end_clean();
- die( "Fatal error: Required file 'functions.php' does not exist." );
-}
-if( ! is_readable( realpath( './functions.php' ) ) ) {
- ob_end_clean();
- die( "Cannot read the file 'functions.php' its permissions are too strict." );
-}
-require_once realpath( './functions.php' );
+require_once realpath(LIBDIR.'functions.php');
ob_end_clean();
-// Our custom error handler receives all error notices that pass the error_reporting()
-// level set above.
-set_error_handler( 'pla_error_handler' );
+/* Our custom error handler receives all error notices that pass the error_reporting()
+ level set above. */
+set_error_handler('pla_error_handler');
-// Creates the language array which will be populated with localized strings
-// based on the user-configured language.
+/* Creates the language array which will be populated with localized strings
+ based on the user-configured language. */
$lang = array();
-// config.php might not exist (if the user hasn't configured PLA yet)
-// Only include it if it does exist.
-if( file_exists( realpath( './config.php' ) ) ) {
- ob_start();
- is_readable( realpath( './config.php' ) ) or pla_error( "Could not read config.php, its permissions are too strict." );
- include realpath( './config.php' );
- ob_end_clean();
+/*
+ * functions.php should have defined our pla_function_files array, listing all our
+ * required functions (order IS important).
+ * index.php should have checked they exist and are usable - we'll assume that the user
+ * has been via index.php, and fixed any problems already.
+ */
+ob_start();
+foreach ($pla_function_files as $file_name) {
+ require_once realpath ($file_name);
}
-$required_files = array(
- // The base English language strings
- './lang/recoded/en.php',
- // Functions for managing the session (pla_session_start(), etc.)
- './session_functions.php',
- // Functions for reading the server schema (get_schema_object_classes(), etc.)
- './schema_functions.php',
- // Functions that can be defined by the user (preEntryDelete(), postEntryDelete(), etc.)
- './custom_functions.php',
- // Functions for hashing passwords with OpenSSL binary (only if mhash not present)
- './emuhash_functions.php' );
+# Now read in config_default.php, which also reads in config.php
+require_once realpath(LIBDIR.'config_default.php');
+ob_end_clean();
+/**
+ * At this point we have read all our additional function PHP files and our configuration.
+ */
-// Include each required file and check for sanity.
-foreach( $required_files as $file_name ) {
- file_exists( realpath( $file_name ) )
- or pla_error( "Fatal error: Required file '$file_name' does not exist." );
- is_readable( realpath( $file_name ) )
- or pla_error( "Fatal error: Cannot read the file '$file_name', its permissions are too strict." );
- ob_start();
- require_once realpath( $file_name );
- ob_end_clean();
-}
+# Check our custom variables.
+$config->CheckCustom();
-if( pla_session_start() )
- postSessionInit();
+if (pla_session_start())
+ run_hook('post_session_init',array());
-// Language configuration. Auto or specified?
-// Shall we attempt to auto-determine the language?
-if( isset( $language ) ) {
- if( 0 == strcasecmp( $language, "auto" ) ) {
+/*
+ * Language configuration. Auto or specified?
+ * Shall we attempt to auto-determine the language?
+ */
+$language = $config->GetValue('appearance','language');
+if ($language == "auto") {
- // Make sure their browser correctly reports language. If not, skip this.
- if( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
+ # Make sure their browser correctly reports language. If not, skip this.
+ 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];
- }
-
- $HTTP_LANGS = array_merge ($HTTP_LANGS1, $HTTP_LANGS2);
- foreach( $HTTP_LANGS as $HTTP_LANG) {
- // try to grab one after the other the language file
- if( file_exists( realpath( "lang/recoded/$HTTP_LANG.php" ) ) &&
- is_readable( realpath( "lang/recoded/$HTTP_LANG.php" ) ) ) {
- ob_start();
- include realpath( "lang/recoded/$HTTP_LANG.php" );
- ob_end_clean();
- break;
- }
+ # 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];
+ }
+
+ $HTTP_LANGS = array_merge ($HTTP_LANGS1, $HTTP_LANGS2);
+ foreach( $HTTP_LANGS as $HTTP_LANG) {
+ # try to grab one after the other the language file
+ if( file_exists( realpath( "lang/recoded/$HTTP_LANG.php" ) ) &&
+ is_readable( realpath( "lang/recoded/$HTTP_LANG.php" ) ) ) {
+ ob_start();
+ include realpath( "lang/recoded/$HTTP_LANG.php" );
+ ob_end_clean();
+ break;
}
}
- } else {
- // grab the language file configured in config.php
- if( $language != null ) {
- if( 0 == strcmp( $language, 'english' ) )
- $language = 'en';
- if( file_exists( realpath( "lang/recoded/$language.php" ) ) &&
- is_readable( realpath( "lang/recoded/$language.php" ) ) ) {
- ob_start();
- include realpath( "lang/recoded/$language.php" );
- ob_end_clean();
- } else {
- pla_error( "Could not read language file 'lang/recoded/$language.php'. Either the file
- does not exist, or its permissions do not allow phpLDAPadmin to read it." );
- }
+ }
+
+} else {
+ # grab the language file configured in config.php
+ if( $language != null ) {
+ if( 0 == strcmp( $language, 'english' ) )
+ $language = 'en';
+ if( file_exists( realpath( "lang/recoded/$language.php" ) ) &&
+ is_readable( realpath( "lang/recoded/$language.php" ) ) ) {
+ ob_start();
+ include realpath( "lang/recoded/$language.php" );
+ ob_end_clean();
+ } else {
+ pla_error( "Could not read language file 'lang/recoded/$language.php'. Either the file
+ does not exist, or its permissions do not allow phpLDAPadmin to read it." );
}
}
}
-// If config.php doesn't create the templates array, create it here.
-if( ! isset( $templates ) || ! is_array( $templates ) )
+# If config.php doesn't create the templates array, create it here.
+if (! isset($templates) || ! is_array($templates))
$templates = array();
-// Always including the 'custom' template (the most generic and flexible)
-$templates['custom'] =
- array( 'desc' => 'Custom',
- 'icon' => 'images/object.png',
- 'handler' => 'custom.php' );
+# Always including the 'custom' template (the most generic and flexible)
+$templates['custom'] =
+ array('desc' => 'Custom',
+ 'icon' => 'images/object.png',
+ 'handler' => 'custom.php' );
-// Strip slashes from GET, POST, and COOKIE variables if this
-// PHP install is configured to automatically addslashes()
-if ( get_magic_quotes_gpc() && ( ! isset( $slashes_stripped ) || ! $slashes_stripped ) ) {
+/*
+ * Strip slashes from GET, POST, and COOKIE variables if this
+ * PHP install is configured to automatically addslashes()
+ */
+if (get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) {
+ array_stripslashes($_REQUEST);
array_stripslashes($_GET);
array_stripslashes($_POST);
array_stripslashes($_COOKIE);
@@ -159,4 +142,13 @@ if ( get_magic_quotes_gpc() && ( ! isset( $slashes_stripped ) || ! $slashes_stri
$slashes_stripped = true;
}
+/*
+ * Update $_SESSION['activity']
+ * for timeout and automatic logout feature
+ */
+if (isset($_REQUEST['server_id'])) {
+ $ldapserver = $ldapservers->Instance($_REQUEST['server_id']);
+ if ($ldapserver->haveAuthInfo())
+ set_lastactivity($ldapserver);
+}
?>
diff --git a/compare.php b/compare.php
new file mode 100644
index 0000000..2801bae
--- /dev/null
+++ b/compare.php
@@ -0,0 +1,579 @@
+Instance($server_id_src);
+if ( ! $ldapserver_src->haveAuthInfo())
+ pla_error($lang['not_enough_login_info']);
+
+$ldapserver_dst = $ldapservers->Instance($server_id_dst);
+if ( ! $ldapserver_src->haveAuthInfo())
+ pla_error($lang['not_enough_login_info']);
+
+dn_exists($ldapserver_src,$dn_src) or pla_error(sprintf($lang['no_such_entry'],pretty_print_dn($dn_src)));
+dn_exists($ldapserver_dst,$dn_dst) or pla_error(sprintf($lang['no_such_entry'],pretty_print_dn($dn_dst)));
+
+$friendly_attrs = process_friendly_attr_table();
+
+$attrs_src = get_object_attrs($ldapserver_src,$dn_src,false,$config->GetValue('deref','view'));
+$attrs_dst = get_object_attrs($ldapserver_dst,$dn_dst,false,$config->GetValue('deref','view'));
+
+# Get a list of all attributes.
+$attrs_all = array_keys($attrs_src);
+foreach ($attrs_dst as $key => $val)
+ if (! in_array($key,$attrs_all))
+ $attrs_all[] = $key;
+
+include './header.php';
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
: name; ?> :
+
+
+
: name; ?> :
+
+
+
+
+
+
+
+
+
(%s)
',$lang['no_attributes']);
+ print '
';
+ print '';
+ die();
+}
+
+sort($attrs_all);
+
+# Work through each of the attributes.
+foreach ($attrs_all as $attr) {
+ flush();
+
+ # If this is the DN, get the next attribute.
+ if (! strcasecmp($attr,'dn'))
+ continue;
+
+ # Has the config.php specified that this attribute is to be hidden or shown?
+ if (is_attr_hidden($ldapserver_src,$attr) || is_attr_hidden($ldapserver_dst,$attr))
+ continue;
+?>
+
+
+