Removed some old files where functionality has been adapted in PLA v2
This commit is contained in:
parent
8cbd4eaed5
commit
ff0bbc758d
@ -29,6 +29,7 @@ Take a look at the [Docker Container](https://github.com/leenooks/phpLDAPadmin/w
|
|||||||
The update to v2 is progressing well - here is a list of work to do and done:
|
The update to v2 is progressing well - here is a list of work to do and done:
|
||||||
|
|
||||||
- [ ] Creating new LDAP entries
|
- [ ] Creating new LDAP entries
|
||||||
|
- [ ] Delete existing LDAP entries
|
||||||
- [X] Updating existing LDAP Entries
|
- [X] Updating existing LDAP Entries
|
||||||
- [X] Password attributes
|
- [X] Password attributes
|
||||||
- [X] Support different password hash options
|
- [X] Support different password hash options
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Put your hook function files here.
|
|
@ -1,402 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* An example of a hooks implementation.
|
|
||||||
*
|
|
||||||
* Functions should return true on success and false on failure.
|
|
||||||
* If a function returns false it will trigger the rollback to be executed.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This example hooks implementation will just show system_messages after each hooks is called.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
# If you want to see this example in action, just comment out the return.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The post_session_init function is called after lib/common.php has completed its processing.
|
|
||||||
* This can be used to further initialise the session.
|
|
||||||
*
|
|
||||||
* No arguments are passed to post_session_init.
|
|
||||||
*/
|
|
||||||
function example_post_session_init() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Global Vars</i>: <small>%s</small>',join('| ',array_keys($GLOBALS))),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_session_init','example_post_session_init');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_connect function is called before making a connection to the LDAP server.
|
|
||||||
* While PLA makes many calls to connect to the LDAP server, this is called only once
|
|
||||||
* when caching is turned on.
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @see post_connect
|
|
||||||
*/
|
|
||||||
function example_pre_connect() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li></ul>',$args[0],$args[1]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_connect','example_pre_connect');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_connect function is called after making a connection to the LDAP server.
|
|
||||||
* While PLA makes many calls to connect to the LDAP server, this is called only once
|
|
||||||
* when caching is turned on.
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string User ID of the user who successfully made the connection.
|
|
||||||
* @see pre_connect
|
|
||||||
*/
|
|
||||||
function example_post_connect() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>User DN: <small>%s</small></li></ul>',$args[0],$args[1],$args[2]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_connect','example_post_connect');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_entry_create function is called before an entry is created in ds_ldap_pla::add().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry created
|
|
||||||
* @param array Attributes for the new DN
|
|
||||||
* @see post_entry_create
|
|
||||||
*/
|
|
||||||
function example_pre_entry_create() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attributes: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],join(',',(array_keys($args[3])))),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_entry_create','example_pre_entry_create');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_entry_create function is called after an entry is created in ds_ldap_pla::add().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry created
|
|
||||||
* @param array Attributes for the new DN
|
|
||||||
* @see pre_entry_create
|
|
||||||
*/
|
|
||||||
function example_post_entry_create() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attributes: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],join(',',(array_keys($args[3])))),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_entry_create','example_post_entry_create');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_entry_delete function is called before an entry is deleted in ds_ldap_pla::delete().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry deleted
|
|
||||||
* @see post_entry_delete
|
|
||||||
*/
|
|
||||||
function example_pre_entry_delete() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li></ul>',$args[0],$args[1],$args[2]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_entry_delete','example_pre_entry_delete');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_entry_delete function is called after an entry is deleted in ds_ldap_pla::delete().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry deleted
|
|
||||||
* @see pre_entry_delete
|
|
||||||
*/
|
|
||||||
function example_post_entry_delete() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li></ul>',$args[0],$args[1],$args[2]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_entry_delete','example_post_entry_delete');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_entry_rename function is called before an entry is renamed in ds_ldap_pla::rename().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string Old DN of the entry to be renamed
|
|
||||||
* @param string New RDN for the new entry
|
|
||||||
* @param string Container for the new entry
|
|
||||||
* @see post_entry_rename
|
|
||||||
*/
|
|
||||||
function example_pre_entry_rename() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>New RDN: <small>%s</small></li><li>New Container: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],$args[4]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_entry_rename','example_pre_entry_rename');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_entry_rename function is called after an entry is renamed in ds_ldap_pla::rename().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string Old DN of the entry to be renamed
|
|
||||||
* @param string New RDN for the new entry
|
|
||||||
* @param string Container for the new entry
|
|
||||||
* @see pre_entry_rename
|
|
||||||
*/
|
|
||||||
function example_post_entry_rename() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>New RDN: <small>%s</small></li><li>New Container: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],$args[4]),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_entry_rename','example_post_entry_rename');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_entry_modify function is called before an entry is modified in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry to be modified
|
|
||||||
* @param array Attributes to be modified
|
|
||||||
* @see post_entry_modify
|
|
||||||
*/
|
|
||||||
function example_pre_entry_modify() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attributes: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],join('|',array_keys($args[3]))),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_entry_modify','example_pre_entry_modify');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_entry_modify function is called after an entry is modified in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the entry to be modified
|
|
||||||
* @param array Attributes to be modified
|
|
||||||
* @see pre_entry_modify
|
|
||||||
*/
|
|
||||||
function example_post_entry_modify() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attributes: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],join('|',array_keys($args[3]))),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_entry_modify','example_post_entry_modify');
|
|
||||||
|
|
||||||
// pre_attr_add
|
|
||||||
// post_attr_add
|
|
||||||
/**
|
|
||||||
* This pre_attr_add function is called before an attribute is deleted in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be deleted
|
|
||||||
* @param string Attribute to be deleted
|
|
||||||
* @param array Old values
|
|
||||||
* @see post_attr_add
|
|
||||||
*/
|
|
||||||
function example_pre_attr_add() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>New Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_attr_add','example_pre_attr_add');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_attr_add function is called after an attribute is added in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be added
|
|
||||||
* @param string Attribute to be added
|
|
||||||
* @param array New values
|
|
||||||
* @see pre_attr_add
|
|
||||||
*/
|
|
||||||
function example_post_attr_add() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>New Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_attr_add','example_post_attr_add');
|
|
||||||
|
|
||||||
// pre_attr_modify
|
|
||||||
// post_attr_modify
|
|
||||||
/**
|
|
||||||
* This pre_attr_modify function is called before an attribute is modified in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be modified
|
|
||||||
* @param string Attribute to be modified
|
|
||||||
* @param array New values
|
|
||||||
* @see post_attr_modify
|
|
||||||
*/
|
|
||||||
function example_pre_attr_modify() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>Old Values: <small>%s</small></li><li>New Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4]),join('|',$args[5])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_attr_modify','example_pre_attr_modify');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_attr_modify function is called after an attribute is deleted in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be deleted
|
|
||||||
* @param string Attribute to be deleted
|
|
||||||
* @param array Old values
|
|
||||||
* @see pre_attr_modify
|
|
||||||
*/
|
|
||||||
function example_post_attr_modify() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>Old Values: <small>%s</small></li><li>New Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4]),join('|',$args[5])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_attr_modify','example_post_attr_modify');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This pre_attr_delete function is called before an attribute is deleted in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be deleted
|
|
||||||
* @param string Attribute to be deleted
|
|
||||||
* @param array Old values
|
|
||||||
* @see post_attr_delete
|
|
||||||
*/
|
|
||||||
function example_pre_attr_delete() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>Old Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('pre_attr_delete','example_pre_attr_delete');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This post_attr_delete function is called after an attribute is deleted in ds_ldap_pla::modify().
|
|
||||||
*
|
|
||||||
* Arguments available are:
|
|
||||||
* @param int Server ID of the server to be connected to
|
|
||||||
* @param string Method. The user connection method, normally 'user'.
|
|
||||||
* @param string DN of the attribute to be deleted
|
|
||||||
* @param string Attribute to be deleted
|
|
||||||
* @param array Old values
|
|
||||||
* @see pre_attr_delete
|
|
||||||
*/
|
|
||||||
function example_post_attr_delete() {
|
|
||||||
$args = func_get_args();
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('Hook called [%s]',__METHOD__),
|
|
||||||
'body'=>sprintf('<i>Arguments</i>:<ul><li>Server ID: <small>%s</small></li><li>Method: <small>%s</small></li><li>DN: <small>%s</small></li><li>Attribute: <small>%s</small></li><li>Old Values: <small>%s</small></li></ul>',$args[0],$args[1],$args[2],$args[3],join('|',$args[4])),
|
|
||||||
'type'=>'info','special'=>true));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
add_hook('post_attr_delete','example_post_attr_delete');
|
|
||||||
?>
|
|
@ -1,117 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* This page will allow the adding of additional ObjectClasses to an item.
|
|
||||||
* + If the ObjectClass to be added requires additional MUST attributes to be
|
|
||||||
* defined, then they will be prompted for.
|
|
||||||
* + If the ObjectClass doesnt need any additional MUST attributes, then it
|
|
||||||
* will be silently added to the object.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Page
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
|
|
||||||
require './common.php';
|
|
||||||
|
|
||||||
# The DN and OBJECTCLASS we are working with.
|
|
||||||
$request = array();
|
|
||||||
$request['dn'] = get_request('dn','REQUEST',true);
|
|
||||||
|
|
||||||
# Check if the entry exists.
|
|
||||||
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
|
|
||||||
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
|
|
||||||
|
|
||||||
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
|
|
||||||
$request['page']->setDN($request['dn']);
|
|
||||||
$request['page']->accept(true);
|
|
||||||
$request['template'] = $request['page']->getTemplate();
|
|
||||||
|
|
||||||
$attribute_factory = new AttributeFactory();
|
|
||||||
|
|
||||||
# Grab the required attributes for the new objectClass
|
|
||||||
$ldap = array();
|
|
||||||
$ldap['attrs']['must'] = array();
|
|
||||||
|
|
||||||
foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
|
|
||||||
# Exclude "top" if its there.
|
|
||||||
if (! strcasecmp('top',$oclass_name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ($soc = $app['server']->getSchemaObjectClass($oclass_name))
|
|
||||||
$ldap['attrs']['must'] = array_merge($ldap['attrs']['must'],$soc->getMustAttrNames(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
$ldap['attrs']['must'] = array_unique($ldap['attrs']['must']);
|
|
||||||
|
|
||||||
/* Build a list of the attributes that this new objectClass requires,
|
|
||||||
* but that the object does not currently contain */
|
|
||||||
$ldap['attrs']['need'] = array();
|
|
||||||
foreach ($ldap['attrs']['must'] as $attr)
|
|
||||||
if (is_null($request['template']->getAttribute($attr)))
|
|
||||||
array_push($ldap['attrs']['need'],$attribute_factory->newAttribute($attr,array('values'=>array()),$app['server']->getIndex()));
|
|
||||||
|
|
||||||
# Mark all the need attributes as shown
|
|
||||||
foreach ($ldap['attrs']['need'] as $index => $values)
|
|
||||||
$ldap['attrs']['need'][$index]->show();
|
|
||||||
|
|
||||||
if (count($ldap['attrs']['need']) > 0) {
|
|
||||||
$request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Add new objectClass to'),get_rdn($request['dn'])));
|
|
||||||
$request['page']->drawSubTitle();
|
|
||||||
|
|
||||||
echo '<div style="text-align: center">';
|
|
||||||
printf('<small><b>%s: </b>%s <b>%s</b> %s %s</small>',
|
|
||||||
_('Instructions'),
|
|
||||||
_('In order to add these objectClass(es) to this entry, you must specify'),
|
|
||||||
count($ldap['attrs']['need']),_('new attributes'),
|
|
||||||
_('that this objectClass requires.'));
|
|
||||||
|
|
||||||
echo '<br /><br />';
|
|
||||||
|
|
||||||
echo '<form action="cmd.php" method="post" id="entry_form">';
|
|
||||||
echo '<div>';
|
|
||||||
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
|
|
||||||
echo '<input type="hidden" name="cmd" value="update_confirm" />';
|
|
||||||
else
|
|
||||||
echo '<input type="hidden" name="cmd" value="update" />';
|
|
||||||
|
|
||||||
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
|
||||||
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">';
|
|
||||||
printf('<tr><th colspan="2">%s</th></tr>',_('New Required Attributes'));
|
|
||||||
|
|
||||||
$counter = 0;
|
|
||||||
echo '<tr><td colspan="2">';
|
|
||||||
foreach ($request['template']->getAttribute('objectclass')->getValues() as $value)
|
|
||||||
$request['page']->draw('HiddenValue',$request['template']->getAttribute('objectclass'),$counter++);
|
|
||||||
echo '</td></tr>';
|
|
||||||
|
|
||||||
foreach ($ldap['attrs']['need'] as $count => $attr)
|
|
||||||
$request['page']->draw('Template',$attr);
|
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
|
|
||||||
printf('<div style="text-align: center;"><br /><input type="submit" value="%s" /></div>',_('Add ObjectClass and Attributes'));
|
|
||||||
echo '</form>';
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
# There are no other required attributes, so we just need to add the objectclass to the DN.
|
|
||||||
} else {
|
|
||||||
$result = $app['server']->modify($request['dn'],$request['template']->getLDAPmodify());
|
|
||||||
|
|
||||||
if ($result) {
|
|
||||||
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=objectclass',
|
|
||||||
$app['server']->getIndex(),rawurlencode($request['dn']));
|
|
||||||
|
|
||||||
if (get_request('meth','REQUEST') == 'ajax')
|
|
||||||
$href .= '&meth=ajax';
|
|
||||||
|
|
||||||
header(sprintf('Location: %s',$href));
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,173 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Displays a form to allow the user to enter a new value to add
|
|
||||||
* to the existing list of values for a multi-valued attribute.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Page
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
|
|
||||||
require './common.php';
|
|
||||||
|
|
||||||
# The DN and ATTR we are working with.
|
|
||||||
$request = array();
|
|
||||||
$request['dn'] = get_request('dn','GET',true);
|
|
||||||
$request['attr'] = get_request('attr','GET',true);
|
|
||||||
|
|
||||||
# Check if the entry exists.
|
|
||||||
if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
|
|
||||||
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
|
|
||||||
|
|
||||||
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
|
|
||||||
$request['page']->setDN($request['dn']);
|
|
||||||
$request['page']->accept(true);
|
|
||||||
$request['template'] = $request['page']->getTemplate();
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ($request['attribute']->isReadOnly())
|
|
||||||
error(sprintf(_('The attribute (%s) is in readonly mode.'),$request['attr']),'error','index.php');
|
|
||||||
*/
|
|
||||||
|
|
||||||
# Render the form
|
|
||||||
if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') {
|
|
||||||
# Render the form.
|
|
||||||
$request['page']->drawTitle(sprintf('%s <b>%s</b> %s <b>%s</b>',_('Add new'),htmlspecialchars($request['attr']),_('value to'),htmlspecialchars(get_rdn($request['dn']))));
|
|
||||||
$request['page']->drawSubTitle();
|
|
||||||
|
|
||||||
if (! strcasecmp($request['attr'],'objectclass')) {
|
|
||||||
echo '<form action="cmd.php" method="post" class="new_value" id="entry_form">';
|
|
||||||
echo '<div>';
|
|
||||||
echo '<input type="hidden" name="cmd" value="add_oclass_form" />';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
echo '<form action="cmd.php" method="post" class="new_value" id="entry_form" enctype="multipart/form-data" onsubmit="return submitForm(this)">';
|
|
||||||
echo '<div>';
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
|
|
||||||
echo '<input type="hidden" name="cmd" value="update_confirm" />';
|
|
||||||
else
|
|
||||||
echo '<input type="hidden" name="cmd" value="update" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
|
||||||
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
echo '<table class="forminput" border="0" style="margin-left: auto; margin-right: auto;">';
|
|
||||||
echo '<tr>';
|
|
||||||
|
|
||||||
$request['attribute'] = $request['template']->getAttribute($request['attr']);
|
|
||||||
$request['count'] = $request['attribute']->getValueCount();
|
|
||||||
|
|
||||||
if ($request['count']) {
|
|
||||||
printf('<td class="top">%s <b>%s</b> %s <b>%s</b>:</td>',
|
|
||||||
_('Current list of'),$request['count'],_('values for attribute'),$request['attribute']->getFriendlyName());
|
|
||||||
|
|
||||||
echo '<td>';
|
|
||||||
|
|
||||||
# Display current attribute values
|
|
||||||
echo '<table border="0"><tr><td>';
|
|
||||||
for ($i=0;$i<$request['count'];$i++) {
|
|
||||||
if ($i > 0)
|
|
||||||
echo '<br/>';
|
|
||||||
$request['page']->draw('CurrentValue',$request['attribute'],$i);
|
|
||||||
$request['page']->draw('HiddenValue',$request['attribute'],$i);
|
|
||||||
}
|
|
||||||
echo '</td></tr></table>';
|
|
||||||
|
|
||||||
echo '</td>';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printf('<td>%s <b>%s</b>.</td>',
|
|
||||||
_('No current value for attribute'),$request['attribute']->getFriendlyName());
|
|
||||||
echo '<td><br /><br /></td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
echo '<tr>';
|
|
||||||
printf('<td class="top">%s</td>',_('Enter the value(s) you would like to add:'));
|
|
||||||
echo '<td>';
|
|
||||||
|
|
||||||
if (! strcasecmp($request['attr'],'objectclass')) {
|
|
||||||
# If our attr is an objectClass, fetch all available objectClasses and remove those from the list that are already defined in the entry
|
|
||||||
$socs = $app['server']->SchemaObjectClasses();
|
|
||||||
|
|
||||||
foreach ($request['attribute']->getValues() as $oclass)
|
|
||||||
unset($socs[strtolower($oclass)]);
|
|
||||||
|
|
||||||
# Draw objectClass selection
|
|
||||||
echo '<table border="0">';
|
|
||||||
echo '<tr><td>';
|
|
||||||
echo '<select name="new_values[objectclass][]" multiple="multiple" size="15">';
|
|
||||||
foreach ($socs as $name => $oclass) {
|
|
||||||
# Exclude any structural ones, that are not in the heirachy, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION
|
|
||||||
if (($oclass->getType() == 'structural') && ! $oclass->isRelated($request['attribute']->getValues()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
printf('<option value="%s">%s</option>',$oclass->getName(false),$oclass->getName(false));
|
|
||||||
}
|
|
||||||
echo '</select>';
|
|
||||||
echo '</td></tr><tr><td>';
|
|
||||||
|
|
||||||
echo '<br />';
|
|
||||||
printf('<input id="save_button" type="submit" value="%s" %s />',
|
|
||||||
_('Add new ObjectClass'),
|
|
||||||
(isAjaxEnabled() ? sprintf('onclick="return ajSUBMIT(\'BODY\',document.getElementById(\'entry_form\'),\'%s\');"',_('Updating Object')) : ''));
|
|
||||||
echo '</td></tr></table>';
|
|
||||||
echo '</td>';
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints'))
|
|
||||||
printf('<tr><td colspan="2"><small><br /><img src="%s/light.png" alt="Hint" /><span class="hint">%s</span></small></td></tr>',
|
|
||||||
IMGDIR,_('Note: You may be required to enter new attributes that these objectClass(es) require'));
|
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
echo '</form>';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
# Draw a blank field
|
|
||||||
echo '<table border="0"><tr><td>';
|
|
||||||
$request['page']->draw('FormValue',$request['attribute'],$request['count']);
|
|
||||||
echo '</td></tr><tr><td>';
|
|
||||||
|
|
||||||
$sattr = $app['server']->getSchemaAttribute($request['attr']);
|
|
||||||
|
|
||||||
if ($sattr->getDescription())
|
|
||||||
printf('<small><b>%s:</b> %s</small><br />',_('Description'),$sattr->getDescription());
|
|
||||||
|
|
||||||
if ($sattr->getType())
|
|
||||||
printf('<small><b>%s:</b> %s</small><br />',_('Syntax'),$sattr->getType());
|
|
||||||
|
|
||||||
if ($sattr->getMaxLength())
|
|
||||||
printf('<small><b>%s:</b> %s %s</small><br />',
|
|
||||||
_('Maximum Length'),number_format($sattr->getMaxLength()),_('characters'));
|
|
||||||
|
|
||||||
echo '<br />';
|
|
||||||
printf('<input type="submit" id="save_button" name="submit" value="%s" />',_('Add New Value'));
|
|
||||||
echo '</td></tr></table>';
|
|
||||||
|
|
||||||
echo '</td></tr>';
|
|
||||||
echo '</table>';
|
|
||||||
echo '</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (is_null($attribute = $request['template']->getAttribute($request['attr']))) {
|
|
||||||
$request['template']->addAttribute($request['attr'],array('values'=>array()));
|
|
||||||
$attribute = $request['template']->getAttribute($request['attr']);
|
|
||||||
$attribute->show();
|
|
||||||
|
|
||||||
echo '<table class="entry" cellspacing="0" align="center" border="0">';
|
|
||||||
$request['page']->draw('Template',$attribute);
|
|
||||||
$request['page']->draw('Javascript',$attribute);
|
|
||||||
echo '</table>';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$request['count'] = $attribute->getValueCount();
|
|
||||||
$request['page']->draw('FormReadWriteValue',$attribute,$request['count']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,213 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Export entries from the LDAP server.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Page
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
|
|
||||||
require './common.php';
|
|
||||||
require LIBDIR.'export_functions.php';
|
|
||||||
|
|
||||||
$request = array();
|
|
||||||
$request['dn'] = get_request('dn','GET');
|
|
||||||
$request['format'] = get_request('format','GET',false,get_line_end_format());
|
|
||||||
$request['scope'] = get_request('scope','GET',false,'base');
|
|
||||||
$request['exporter_id'] = get_request('exporter_id','GET',false,'LDIF');
|
|
||||||
$request['filter'] = get_request('filter','GET',false,'(objectClass=*)');
|
|
||||||
$request['attr'] = get_request('attributes','GET',false,'*');
|
|
||||||
$request['sys_attr'] = get_request('sys_attr','GET') ? true: false;
|
|
||||||
|
|
||||||
$available_formats = array(
|
|
||||||
'mac' => 'Macintosh',
|
|
||||||
'unix' => 'UNIX (Linux, BSD)',
|
|
||||||
'win' => 'Windows'
|
|
||||||
);
|
|
||||||
|
|
||||||
$available_scopes = array(
|
|
||||||
'base' => _('Base (base dn only)'),
|
|
||||||
'one' => _('One (one level beneath base)'),
|
|
||||||
'sub' => _('Sub (entire subtree)')
|
|
||||||
);
|
|
||||||
|
|
||||||
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
|
|
||||||
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Export')));
|
|
||||||
|
|
||||||
printf('<script type="text/javascript" src="%sdnChooserPopup.js"></script>',JSDIR);
|
|
||||||
printf('<script type="text/javascript" src="%sform_field_toggle_enable.js"></script>',JSDIR);
|
|
||||||
|
|
||||||
echo '<br />';
|
|
||||||
echo '<form id="export_form" action="cmd.php" method="post">';
|
|
||||||
echo '<div>';
|
|
||||||
echo '<input type="hidden" name="cmd" value="export" />';
|
|
||||||
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
|
||||||
|
|
||||||
echo '<table class="forminput" style="margin-left: auto; margin-right: auto;">';
|
|
||||||
echo '<tr>';
|
|
||||||
echo '<td>';
|
|
||||||
|
|
||||||
echo '<fieldset>';
|
|
||||||
printf('<legend>%s</legend>',_('Export'));
|
|
||||||
|
|
||||||
echo '<table>';
|
|
||||||
printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),$app['server']->getName());
|
|
||||||
|
|
||||||
echo '<tr>';
|
|
||||||
printf('<td style="white-space:nowrap">%s</td>',_('Base DN'));
|
|
||||||
echo '<td><span style="white-space: nowrap;">';
|
|
||||||
printf('<input type="text" name="dn" id="dn" style="width:230px" value="%s" /> ',htmlspecialchars($request['dn']));
|
|
||||||
draw_chooser_link('export_form','dn');
|
|
||||||
echo '</span></td>';
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
echo '<tr>';
|
|
||||||
printf('<td><span style="white-space: nowrap">%s</span></td>',_('Search Scope'));
|
|
||||||
|
|
||||||
echo '<td>';
|
|
||||||
|
|
||||||
foreach ($available_scopes as $id => $desc)
|
|
||||||
printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
|
|
||||||
htmlspecialchars($id),$id,($id == $request['scope']) ? 'checked="checked"' : '',
|
|
||||||
htmlspecialchars($id),$desc);
|
|
||||||
|
|
||||||
echo '</td>';
|
|
||||||
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
printf('<tr><td>%s</td><td><input type="text" name="filter" style="width:300px" value="%s" /></td></tr>',
|
|
||||||
_('Search Filter'),htmlspecialchars($request['filter']));
|
|
||||||
|
|
||||||
printf('<tr><td>%s</td><td><input type="text" name="attributes" style="width:300px" value="%s" /></td></tr>',
|
|
||||||
_('Show Attributes'),htmlspecialchars($request['attr']));
|
|
||||||
|
|
||||||
printf('<tr><td> </td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>',
|
|
||||||
$request['sys_attr'] ? 'checked="checked" ' : '',_('Include system attributes'));
|
|
||||||
|
|
||||||
printf('<tr><td> </td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="export_field_toggle(this)" /> <label for="save_as_file">%s</label></td></tr>',
|
|
||||||
_('Save as file'));
|
|
||||||
|
|
||||||
printf('<tr><td> </td><td><input type="checkbox" id="compress" name="compress" disabled="disabled" /> <label for="compress">%s</label></td></tr>',
|
|
||||||
_('Compress'));
|
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
echo '</fieldset>';
|
|
||||||
echo '</td>';
|
|
||||||
echo '</tr>';
|
|
||||||
echo '<tr>';
|
|
||||||
echo '<td>';
|
|
||||||
|
|
||||||
echo '<table style="width: 100%">';
|
|
||||||
echo '<tr>';
|
|
||||||
|
|
||||||
echo '<td style="width: 50%">';
|
|
||||||
echo '<fieldset style="height: 100px">';
|
|
||||||
|
|
||||||
printf('<legend>%s</legend>',_('Export format'));
|
|
||||||
|
|
||||||
foreach (Exporter::types() as $index => $exporter) {
|
|
||||||
printf('<input type="radio" name="exporter_id" id="exporter_id_%s" value="%s"%s/>',
|
|
||||||
htmlspecialchars($exporter['type']),htmlspecialchars($exporter['type']),($exporter['type'] === $request['exporter_id']) ? ' checked="checked"' : '');
|
|
||||||
|
|
||||||
printf('<label for="exporter_id_%s">%s</label><br />',
|
|
||||||
htmlspecialchars($exporter['type']),$exporter['type']);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</fieldset>';
|
|
||||||
echo '</td>';
|
|
||||||
|
|
||||||
echo '<td style="width: 50%">';
|
|
||||||
echo '<fieldset style="height: 100px">';
|
|
||||||
|
|
||||||
printf('<legend>%s</legend>',_('Line ends'));
|
|
||||||
foreach ($available_formats as $id => $desc)
|
|
||||||
printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
|
|
||||||
htmlspecialchars($id),htmlspecialchars($id),($request['format']==$id) ? ' checked="checked"' : '',
|
|
||||||
htmlspecialchars($id),$desc);
|
|
||||||
|
|
||||||
echo '</fieldset>';
|
|
||||||
echo '</td></tr>';
|
|
||||||
echo '</table>';
|
|
||||||
echo '</td>';
|
|
||||||
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
printf('<tr><td colspan="2" style="text-align: center;"><input type="submit" name="target" value="%s" /></td></tr>',
|
|
||||||
htmlspecialchars(_('Proceed >>')));
|
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
|
|
||||||
echo '</div>';
|
|
||||||
echo '</form>';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function for fetching the line end format.
|
|
||||||
*
|
|
||||||
* @return String 'win', 'unix', or 'mac' based on the user's browser..
|
|
||||||
*/
|
|
||||||
function get_line_end_format() {
|
|
||||||
if (is_browser('win'))
|
|
||||||
return 'win';
|
|
||||||
elseif (is_browser('unix'))
|
|
||||||
return 'unix';
|
|
||||||
elseif (is_browser('mac'))
|
|
||||||
return 'mac';
|
|
||||||
else
|
|
||||||
return 'unix';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the USER_AGENT string from the $_SERVER array, all in lower case in
|
|
||||||
* an E_NOTICE safe manner.
|
|
||||||
*
|
|
||||||
* @return string|false The user agent string as reported by the browser.
|
|
||||||
*/
|
|
||||||
function get_user_agent_string() {
|
|
||||||
if (isset($_SERVER['HTTP_USER_AGENT']))
|
|
||||||
return strtolower($_SERVER['HTTP_USER_AGENT']);
|
|
||||||
else
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine the OS for the browser
|
|
||||||
*/
|
|
||||||
function is_browser($type) {
|
|
||||||
$agents = array();
|
|
||||||
|
|
||||||
$agents['unix'] = array(
|
|
||||||
'sunos','sunos 4','sunos 5',
|
|
||||||
'i86',
|
|
||||||
'irix','irix 5','irix 6','irix6',
|
|
||||||
'hp-ux','09.','10.',
|
|
||||||
'aix','aix 1','aix 2','aix 3','aix 4',
|
|
||||||
'inux',
|
|
||||||
'sco',
|
|
||||||
'unix_sv','unix_system_v','ncr','reliant','dec','osf1',
|
|
||||||
'dec_alpha','alphaserver','ultrix','alphastation',
|
|
||||||
'sinix',
|
|
||||||
'freebsd','bsd',
|
|
||||||
'x11','vax','openvms'
|
|
||||||
);
|
|
||||||
|
|
||||||
$agents['win'] = array(
|
|
||||||
'win','win95','windows 95',
|
|
||||||
'win16','windows 3.1','windows 16-bit','windows','win31','win16','winme',
|
|
||||||
'win2k','winxp',
|
|
||||||
'win98','windows 98','win9x',
|
|
||||||
'winnt','windows nt','win32',
|
|
||||||
'32bit'
|
|
||||||
);
|
|
||||||
|
|
||||||
$agents['mac'] = array(
|
|
||||||
'mac','68000','ppc','powerpc'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($agents[$type]))
|
|
||||||
return in_array(get_user_agent_string(),$agents[$type]);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,111 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Imports an LDIF file to the specified LDAP server.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Page
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
|
|
||||||
require './common.php';
|
|
||||||
require LIBDIR.'import_functions.php';
|
|
||||||
|
|
||||||
$request = array();
|
|
||||||
$request['importer'] = new Importer($app['server']->getIndex(),'LDIF');
|
|
||||||
$request['import'] = $request['importer']->getTemplate();
|
|
||||||
|
|
||||||
$request['continuous_mode'] = get_request('continuous_mode') ? true : false;
|
|
||||||
|
|
||||||
$type = $request['import']->getType();
|
|
||||||
|
|
||||||
# Set our timelimit in case we have a lot of importing to do
|
|
||||||
@set_time_limit(0);
|
|
||||||
|
|
||||||
# String associated to the operation on the ldap server
|
|
||||||
$actionString = array(
|
|
||||||
'add' => _('Adding'),
|
|
||||||
'delete' => _('Deleting'),
|
|
||||||
'modrdn' => _('Renaming'),
|
|
||||||
'moddn' => _('Renaming'),
|
|
||||||
'modify' => _('Modifying')
|
|
||||||
);
|
|
||||||
|
|
||||||
# String associated with error
|
|
||||||
$actionErrorMsg = array(
|
|
||||||
'add' => _('Could not add object'),
|
|
||||||
'delete' => _('Could not delete object'),
|
|
||||||
'modrdn' => _('Could not rename object'),
|
|
||||||
'moddn' => _('Could not rename object'),
|
|
||||||
'modify' => _('Could not modify object')
|
|
||||||
);
|
|
||||||
|
|
||||||
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
|
|
||||||
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Import')));
|
|
||||||
$request['page']->drawSubTitle(sprintf('%s: <b>%s</b> %s: <b>%s %s %s (%s)</b>',
|
|
||||||
_('Server'),$app['server']->getName(),
|
|
||||||
_('File'),$request['import']->getSource('name'),number_format($request['import']->getSource('size')),_('bytes'),$type['description']));
|
|
||||||
|
|
||||||
echo '<br />';
|
|
||||||
|
|
||||||
# @todo When renaming DNs, the hotlink should point to the new entry on success, or the old entry on failure.
|
|
||||||
while (! $request['import']->eof()) {
|
|
||||||
while ($request['template'] = $request['import']->readEntry()) {
|
|
||||||
|
|
||||||
$edit_href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$app['server']->getIndex(),
|
|
||||||
rawurlencode($request['template']->getDN()));
|
|
||||||
|
|
||||||
$changetype = $request['template']->getType();
|
|
||||||
printf('<small>%s <a href="%s">%s</a>',$actionString[$changetype],$edit_href,$request['template']->getDN());
|
|
||||||
|
|
||||||
if ($request['import']->LDAPimport())
|
|
||||||
printf(' <span style="color:green;">%s</span></small><br />',_('Success'));
|
|
||||||
|
|
||||||
else {
|
|
||||||
printf(' <span style="color:red;">%s</span></small><br /><br />',_('Failed'));
|
|
||||||
$errormsg = sprintf('%s <b>%s</b>',$actionErrorMsg[$changetype],$request['template']->getDN());
|
|
||||||
$errormsg .= ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null));
|
|
||||||
|
|
||||||
system_message(array(
|
|
||||||
'title'=>_('LDIF text import'),
|
|
||||||
'body'=>$errormsg,
|
|
||||||
'type'=>'warn'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request['import']->error) {
|
|
||||||
printf('<small><span style="color:red;">%s: %s</span></small><br />',
|
|
||||||
_('Error'),$request['import']->error['message']);
|
|
||||||
|
|
||||||
echo '<br/>';
|
|
||||||
|
|
||||||
display_pla_parse_error($request['import']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $request['continuous_mode'])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_pla_parse_error($request) {
|
|
||||||
$type = $request->getType();
|
|
||||||
|
|
||||||
echo '<center>';
|
|
||||||
echo '<table class="error">';
|
|
||||||
echo '<tr>';
|
|
||||||
printf('<td class="img"><img src="%s/%s" /></td>',IMGDIR,'error-big.png');
|
|
||||||
|
|
||||||
printf('<td><h2>%s %s</h2></td>',$type['description'],_('Parse Error'));
|
|
||||||
echo '</tr>';
|
|
||||||
|
|
||||||
printf('<tr><td><b>%s</b>:</td><td>%s</td></tr>',_('Description'),$request->error['message']);
|
|
||||||
printf('<tr><td><b>%s</b>:</td><td>%s</td></tr>',_('Line'),$request->error['line']);
|
|
||||||
printf('<tr><td colspan=2><b>%s</b>:</td></tr>',_('Data'));
|
|
||||||
|
|
||||||
foreach ($request->error['data'] as $line)
|
|
||||||
printf('<tr><td> </td><td>%s</td></tr>',$line);
|
|
||||||
|
|
||||||
echo '</table>';
|
|
||||||
echo '</center>';
|
|
||||||
}
|
|
||||||
?>
|
|
6
htdocs/js/dnChooserPopup.js
vendored
6
htdocs/js/dnChooserPopup.js
vendored
@ -1,6 +0,0 @@
|
|||||||
function dnChooserPopup(form,element,rdn)
|
|
||||||
{
|
|
||||||
mywindow=open('entry_chooser.php','myname','resizable=no,width=600,height=370,scrollbars=1');
|
|
||||||
mywindow.location.href = 'entry_chooser.php?form=' + form + '&element=' + element + '&rdn=' + rdn;
|
|
||||||
if (mywindow.opener == null) mywindow.opener = self;
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Classes and functions for the template engine.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an attribute whose values are random passwords
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Templates
|
|
||||||
*/
|
|
||||||
class RandomPasswordAttribute extends PasswordAttribute {
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Classes and functions for the template engine.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an attribute whose values are SAMBA passwords
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Templates
|
|
||||||
*/
|
|
||||||
class SambaPasswordAttribute extends PasswordAttribute {
|
|
||||||
}
|
|
||||||
?>
|
|
334
lib/common.php
334
lib/common.php
@ -1,334 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Contains code to be executed at the top of each application page.
|
|
||||||
* include this file at the top of every PHP file.
|
|
||||||
*
|
|
||||||
* This file will "pre-initialise" an application environment so that any PHP file will have a consistent
|
|
||||||
* environment with other application PHP files.
|
|
||||||
*
|
|
||||||
* This code WILL NOT check that all required functions are usable/readable, etc. This process has
|
|
||||||
* been moved to index.php (which really is only called once when a browser hits the application for the first time).
|
|
||||||
*
|
|
||||||
* The list of ADDITIONAL function files is now defined in functions.php.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Initialize the app array. The app array is initialised each invocation of a PLA script and therefore
|
|
||||||
has no state between invocations.*/
|
|
||||||
$app = array();
|
|
||||||
|
|
||||||
/** The index we will store our config in $_SESSION */
|
|
||||||
if (! defined('APPCONFIG'))
|
|
||||||
define('APPCONFIG','plaConfig');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Catch any scripts that are called directly.
|
|
||||||
* If they are called directly, then they should be routed back through index.php
|
|
||||||
*/
|
|
||||||
$app['direct_scripts'] = array('cmd.php','index.php',
|
|
||||||
'view_jpeg_photo.php','entry_chooser.php',
|
|
||||||
'password_checker.php','download_binary_attr.php',
|
|
||||||
'unserialize.php'
|
|
||||||
);
|
|
||||||
|
|
||||||
# Which script was invoked.
|
|
||||||
$app['script_running'] = $_SERVER['SCRIPT_NAME'];
|
|
||||||
|
|
||||||
foreach ($app['direct_scripts'] as $script) {
|
|
||||||
$app['scriptOK'] = false;
|
|
||||||
|
|
||||||
if (preg_match('/'.$script.'$/',$app['script_running'])) {
|
|
||||||
$app['scriptOK'] = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Anything in the tools dir or cron dir can be executed directly.
|
|
||||||
if ((! $app['scriptOK'] && preg_match('/^\/[cron|tools]/',$app['script_running'])) || ! isset($_SERVER['SERVER_SOFTWARE']))
|
|
||||||
$app['scriptOK'] = true;
|
|
||||||
|
|
||||||
if (! $app['scriptOK']) {
|
|
||||||
if (isset($_REQUEST['server_id']))
|
|
||||||
header(sprintf('Location: index.php?server_id=%s',$_REQUEST['server_id']));
|
|
||||||
else
|
|
||||||
header('Location: index.php');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All commands are disabled in read-only unless specified here
|
|
||||||
*/
|
|
||||||
$app['readwrite_cmds'] = array(
|
|
||||||
'collapse','draw_tree_node','expand',
|
|
||||||
'compare_form','compare',
|
|
||||||
'download_binary_attr','view_jpeg_photo',
|
|
||||||
'entry_chooser',
|
|
||||||
'export_form','export',
|
|
||||||
'login_form','login','logout',
|
|
||||||
'monitor',
|
|
||||||
'password_checker',
|
|
||||||
'purge_cache',
|
|
||||||
'refresh','schema','query_engine','server_info','show_cache','template_engine',
|
|
||||||
'welcome'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Timer stopwatch, used to instrument the application
|
|
||||||
*/
|
|
||||||
if (! function_exists('stopwatch')) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# For compatability - if common has been sourced a second time, then return to the calling script.
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set the defualt time zone, if it isnt set in php.ini
|
|
||||||
if (function_exists('date_default_timezone_set') && ! ini_get('date.timezone'))
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
# If we are called from index.php, LIBDIR will be set, all other calls to common.php dont need to set it.
|
|
||||||
if (! defined('LIBDIR'))
|
|
||||||
define('LIBDIR','../lib/');
|
|
||||||
|
|
||||||
# For PHP5 backward/forward compatibility
|
|
||||||
if (! defined('E_STRICT'))
|
|
||||||
define('E_STRICT',2048);
|
|
||||||
|
|
||||||
# General functions needed to proceed.
|
|
||||||
ob_start();
|
|
||||||
require_once realpath(LIBDIR.'functions.php');
|
|
||||||
if (ob_get_level())
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn on all notices and warnings. This helps us write cleaner code (we hope at least)
|
|
||||||
* Our custom error handler receives all error notices that pass the error_reporting()
|
|
||||||
* level set above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
# Call our custom defined error handler, if it is defined in functions.php
|
|
||||||
if (function_exists('app_error_handler'))
|
|
||||||
set_error_handler('app_error_handler');
|
|
||||||
|
|
||||||
# Disable error reporting until all our required functions are loaded.
|
|
||||||
error_reporting(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* functions.php should have defined our $app['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();
|
|
||||||
if (isset($app['function_files']) && is_array($app['function_files']))
|
|
||||||
foreach ($app['function_files'] as $script)
|
|
||||||
require_once realpath($script);
|
|
||||||
|
|
||||||
# Now read in config_default.php
|
|
||||||
require_once realpath(LIBDIR.'config_default.php');
|
|
||||||
if (ob_get_level())
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
# We are now ready for error reporting.
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
# Start our session.
|
|
||||||
app_session_start();
|
|
||||||
|
|
||||||
# See if we have a session, we can then get our theme out
|
|
||||||
$app['theme'] = 'default';
|
|
||||||
if (isset($_SESSION[APPCONFIG]))
|
|
||||||
if (is_dir(realpath(sprintf('images/%s',$_SESSION[APPCONFIG]->getValue('appearance','theme'))))
|
|
||||||
&& is_file(realpath(sprintf('css/%s/%s',$_SESSION[APPCONFIG]->getValue('appearance','theme'),$_SESSION[APPCONFIG]->getValue('appearance','stylesheet')))))
|
|
||||||
|
|
||||||
$app['theme'] = $_SESSION[APPCONFIG]->getValue('appearance','theme');
|
|
||||||
|
|
||||||
define('CSSDIR',sprintf('css/%s',$app['theme']));
|
|
||||||
define('IMGDIR',sprintf('images/%s',$app['theme']));
|
|
||||||
|
|
||||||
# Initialise the hooks
|
|
||||||
if (file_exists(LIBDIR.'hooks.php'))
|
|
||||||
require_once LIBDIR.'hooks.php';
|
|
||||||
|
|
||||||
# If we get here, and $_SESSION[APPCONFIG] is not set, then redirect the user to the index.
|
|
||||||
if (isset($_SERVER['SERVER_SOFTWARE']) && ! isset($_SESSION[APPCONFIG])) {
|
|
||||||
if ($_SERVER['QUERY_STRING'])
|
|
||||||
header(sprintf('Location: index.php?URI=%s',base64_encode($_SERVER['QUERY_STRING'])));
|
|
||||||
else
|
|
||||||
header('Location: index.php');
|
|
||||||
|
|
||||||
die();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
# SF Bug #1903987
|
|
||||||
if (! method_exists($_SESSION[APPCONFIG],'CheckCustom'))
|
|
||||||
error('Unknown situation, $_SESSION[APPCONFIG] exists, but method CheckCustom() does not','error',null,true,true);
|
|
||||||
|
|
||||||
# Check our custom variables.
|
|
||||||
# @todo Change this so that we dont process a cached session.
|
|
||||||
$_SESSION[APPCONFIG]->CheckCustom();
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for safe mode.
|
|
||||||
if (@ini_get('safe_mode') && ! get_request('cmd','GET'))
|
|
||||||
system_message(array(
|
|
||||||
'title'=>_('PHP Safe Mode'),
|
|
||||||
'body'=>_('You have PHP Safe Mode enabled. This application may work unexpectedly in Safe Mode.'),
|
|
||||||
'type'=>'info'));
|
|
||||||
|
|
||||||
# Set our timezone, if it is specified in config.php
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('appearance','timezone'))
|
|
||||||
date_default_timezone_set($_SESSION[APPCONFIG]->getValue('appearance','timezone'));
|
|
||||||
|
|
||||||
# If we are here, $_SESSION is set - so enabled DEBUGing if it has been configured.
|
|
||||||
if (($_SESSION[APPCONFIG]->getValue('debug','syslog') || $_SESSION[APPCONFIG]->getValue('debug','file'))
|
|
||||||
&& $_SESSION[APPCONFIG]->getValue('debug','level'))
|
|
||||||
define('DEBUG_ENABLED',1);
|
|
||||||
else
|
|
||||||
define('DEBUG_ENABLED',0);
|
|
||||||
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('Application (%s) initialised and starting with (%s).',1,0,__FILE__,__LINE__,__METHOD__,
|
|
||||||
app_version(),$_REQUEST);
|
|
||||||
|
|
||||||
# Set our PHP timelimit.
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('session','timelimit') && ! @ini_get('safe_mode'))
|
|
||||||
set_time_limit($_SESSION[APPCONFIG]->getValue('session','timelimit'));
|
|
||||||
|
|
||||||
# If debug mode is set, increase the time_limit, since we probably need it.
|
|
||||||
if (DEBUG_ENABLED && $_SESSION[APPCONFIG]->getValue('session','timelimit') && ! @ini_get('safe_mode'))
|
|
||||||
set_time_limit($_SESSION[APPCONFIG]->getValue('session','timelimit') * 5);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Language configuration. Auto or specified?
|
|
||||||
* Shall we attempt to auto-determine the language?
|
|
||||||
*/
|
|
||||||
# If we are in safe mode, and LANG is not in the allowed vars, display an error.
|
|
||||||
if (@ini_get('safe_mode') && ! in_array('LANG',explode(',',@ini_get('safe_mode_allowed_env_vars'))))
|
|
||||||
error('You are running in SAFE_MODE, but LANG is not in the safe_mode_allowed_env_vars. Please add LANG to safe_mode_allowed_env_vars','error',true,false);
|
|
||||||
|
|
||||||
$app['language'] = $_SESSION[APPCONFIG]->getValue('appearance','language');
|
|
||||||
|
|
||||||
if ($app['language'] == 'auto') {
|
|
||||||
|
|
||||||
# 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
|
|
||||||
$app['lang_http'] = preg_split ('/[;,]+/',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
||||||
foreach ($app['lang_http'] as $key => $value) {
|
|
||||||
if (substr($value,0,2) == 'q=') {
|
|
||||||
unset($app['lang_http'][$key]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$value = preg_split('/[-]+/',$value);
|
|
||||||
if (sizeof($value) == 2)
|
|
||||||
$app['lang_http'][$key] = strtolower($value[0]).'_'.strtoupper($value[1]);
|
|
||||||
else
|
|
||||||
$app['lang_http'][$key] = auto_lang(strtolower($value[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$app['lang_http'] = array_unique($app['lang_http']);
|
|
||||||
|
|
||||||
foreach ($app['lang_http'] as $lang) {
|
|
||||||
$app['language_dir'] = LANGDIR.$lang;
|
|
||||||
|
|
||||||
if ((substr($lang,0,2) == 'en') ||
|
|
||||||
(file_exists($app['language_dir']) && is_readable($app['language_dir']))) {
|
|
||||||
|
|
||||||
# Set language
|
|
||||||
putenv('LANG='.$lang); # e.g. LANG=de_DE
|
|
||||||
$lang .= '.UTF-8';
|
|
||||||
setlocale(LC_ALL,$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#todo Generate an error if language doesnt exist.
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
# Grab the language file configured in config.php
|
|
||||||
#todo Generate an error if language doesnt exist.
|
|
||||||
if ($app['language'] != null) {
|
|
||||||
if (strcmp($app['language'],'english') == 0)
|
|
||||||
$app['language'] = 'en_GB';
|
|
||||||
|
|
||||||
# Set language
|
|
||||||
putenv('LANG='.$app['language']); # e.g. LANG=de_DE
|
|
||||||
$app['language'] .= '.UTF-8';
|
|
||||||
setlocale(LC_ALL,$app['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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
$slashes_stripped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create our application repository variable.
|
|
||||||
$app['server'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look/evaluate our timeout
|
|
||||||
*/
|
|
||||||
if (! $app['server']->isSessionValid()) {
|
|
||||||
system_message(array(
|
|
||||||
'title'=>_('Session Timed Out'),
|
|
||||||
'body'=>sprintf('%s %s %s',
|
|
||||||
_('Your Session timed out after'),$app['server']->getValue('login','timeout'),
|
|
||||||
_('min. of inactivity. You have been automatically logged out.')),
|
|
||||||
'type'=>'info'),sprintf('index.php?server_id=%s&refresh=SID_%s',$app['server']->getIndex(),$app['server']->getIndex()));
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
# If syslog is enabled, we need to include the supporting file.
|
|
||||||
if ($_SESSION[APPCONFIG]->getValue('debug','syslog'))
|
|
||||||
require LIBDIR.'syslog.php';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* At this point we have read all our additional function PHP files and our configuration.
|
|
||||||
* If we are using hooks, run the session_init hook.
|
|
||||||
*/
|
|
||||||
if (function_exists('run_hook'))
|
|
||||||
run_hook('post_session_init',array());
|
|
||||||
?>
|
|
@ -1,822 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Configuration processing and defaults.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @todo Add validation of set variables to enforce limits or particular values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** The minimum version of PHP required to run phpLDAPadmin. */
|
|
||||||
define('REQUIRED_PHP_VERSION','5.5.0');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The config class contains all our configuration settings for a session.
|
|
||||||
*
|
|
||||||
* An instance of this class should be stored in $_SESSION to maintain state, and to avoid
|
|
||||||
* rebuilding/rereading it at the state of each page output.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Tree
|
|
||||||
*/
|
|
||||||
class Config {
|
|
||||||
public $custom;
|
|
||||||
protected $default;
|
|
||||||
protected $servers = array();
|
|
||||||
|
|
||||||
public $hooks = array();
|
|
||||||
|
|
||||||
public function __construct() {
|
|
||||||
$this->custom = new stdClass;
|
|
||||||
$this->default = new stdClass;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What to do after entry creation :
|
|
||||||
* 2 : display the creation form again
|
|
||||||
* 1 : display the new created entry
|
|
||||||
* 0 : display the choice between 1 and 2
|
|
||||||
*/
|
|
||||||
$this->default->appearance['action_after_creation'] = array(
|
|
||||||
'desc'=>'Display the new created entry',
|
|
||||||
'default'=>1);
|
|
||||||
|
|
||||||
## Appearance Attributes
|
|
||||||
/** Anonymous implies read only
|
|
||||||
* Set to true if you want LDAP data to be displayed read-only (without input fields)
|
|
||||||
* when a user logs in to a server anonymously
|
|
||||||
*/
|
|
||||||
$this->default->appearance['anonymous_bind_implies_read_only'] = array(
|
|
||||||
'desc'=>'Display as read only if user logs in with anonymous bind',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['attr_display_order'] = array(
|
|
||||||
'desc'=>'Custom order to display attributes',
|
|
||||||
'default'=>array());
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @todo Compression is not working,
|
|
||||||
* purge_cache shows blank,
|
|
||||||
* tree refresh shows blank - and if view_tree_node is modified to compress output, then previously opened items show up as compressed data.
|
|
||||||
*/
|
|
||||||
$this->default->appearance['compress'] = array(
|
|
||||||
'desc'=>'Compress Output',
|
|
||||||
'untested'=>true,
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['control_icons'] = array(
|
|
||||||
'desc'=>'Show the control as icons or text',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['custom_templates_only'] = array(
|
|
||||||
'desc'=>'Only display the custom templates.',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['date'] = array(
|
|
||||||
'desc'=>'Date format whenever dates are shown',
|
|
||||||
'default'=>'%A %e %B %Y');
|
|
||||||
|
|
||||||
$this->default->appearance['date_attrs'] = array(
|
|
||||||
'desc'=>'Array of attributes that should show a jscalendar',
|
|
||||||
'default'=>array('shadowExpire'=>'%es','shadowLastChange'=>'%es'));
|
|
||||||
|
|
||||||
$this->default->appearance['date_attrs_showtime'] = array(
|
|
||||||
'desc'=>'Array of attributes that should show a the time when showing the jscalendar',
|
|
||||||
'default'=>array(''));
|
|
||||||
|
|
||||||
$this->default->appearance['disable_default_template'] = array(
|
|
||||||
'desc'=>'Disabled the Default Template',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['disable_default_leaf'] = array(
|
|
||||||
'desc'=>'Disabled creating leaf entries in the Default Template',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['friendly_attrs'] = array(
|
|
||||||
'desc'=>'Friendly names for attributes',
|
|
||||||
'default'=>array());
|
|
||||||
|
|
||||||
$this->default->appearance['hide_attrs'] = array(
|
|
||||||
'desc'=>'Hide attributes from display',
|
|
||||||
'default'=>array());
|
|
||||||
|
|
||||||
$this->default->appearance['hide_attrs_exempt'] = array(
|
|
||||||
'desc'=>'Group DN, where membership will exempt the users from hide_attrs',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->appearance['hide_debug_info'] = array(
|
|
||||||
'desc'=>'Hide the features that may provide sensitive debugging information to the browser',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['hide_template_regexp'] = array(
|
|
||||||
'desc'=>'Templates that are disabled by their regex are not shown',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['hide_template_warning'] = array(
|
|
||||||
'desc'=>'Hide template errors from being displayed',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
/** Language
|
|
||||||
* The language setting. If you set this to 'auto', phpLDAPadmin will
|
|
||||||
* attempt to determine your language automatically. Otherwise, set
|
|
||||||
* this to your applicable language in xx_XX format.
|
|
||||||
* Localization is not complete yet, but most strings have been translated.
|
|
||||||
* Please help by writing language files.
|
|
||||||
*/
|
|
||||||
$this->default->appearance['language'] = array(
|
|
||||||
'desc'=>'Language',
|
|
||||||
'default'=>'auto');
|
|
||||||
|
|
||||||
$this->default->appearance['max_add_attrs'] = array(
|
|
||||||
'desc'=>'Maximum number of attrs to show in the add attr form',
|
|
||||||
'default'=>10);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If you want certain attributes to be editable as multi-line, include them in this list
|
|
||||||
* A multi-line textarea will be drawn instead of a single-line text field
|
|
||||||
*/
|
|
||||||
$this->default->appearance['multi_line_attributes'] = array(
|
|
||||||
'desc'=>'Attributes to show as multiline attributes',
|
|
||||||
'default'=>array('postalAddress','homePostalAddress','personalSignature','description','mailReplyText'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of syntax OIDs which support multi-line attribute values:
|
|
||||||
*/
|
|
||||||
$this->default->appearance['multi_line_syntax_oids'] = array(
|
|
||||||
'desc'=>'Attributes to show as multiline attributes',
|
|
||||||
'default'=>array(
|
|
||||||
// octet string syntax OID:
|
|
||||||
'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'));
|
|
||||||
|
|
||||||
/** Obfuscate Password
|
|
||||||
* If true, display all password hash values as "******". Note that clear-text
|
|
||||||
* passwords will always be displayed as "******", regardless of this setting.
|
|
||||||
*/
|
|
||||||
$this->default->appearance['obfuscate_password_display'] = array(
|
|
||||||
'desc'=>'Obfuscate the display of passwords',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['page_title'] = array(
|
|
||||||
'desc'=>'Change the page title to this text',
|
|
||||||
'default'=>'');
|
|
||||||
|
|
||||||
$this->default->appearance['rdn_all_attrs'] = array(
|
|
||||||
'desc'=>'Whether to show all attributes in the RDN chooser, or just the required ones',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['readonly_attrs'] = array(
|
|
||||||
'desc'=>'Mark these attributes as readonly',
|
|
||||||
'default'=>array());
|
|
||||||
|
|
||||||
$this->default->appearance['readonly_attrs_exempt'] = array(
|
|
||||||
'desc'=>'Group DN, where membership will exempt the users from readonly attrs',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->appearance['remoteurls'] = array(
|
|
||||||
'desc'=>'Whether to include renders for remote URLs',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['show_clear_password'] = array(
|
|
||||||
'desc'=>'Whether to show clear passwords if we dont obfuscate them',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->appearance['show_hints'] = array(
|
|
||||||
'desc'=>'Show helpful hints',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['show_top_create'] = array(
|
|
||||||
'desc'=>'Show a additional create link on the top of the list if there are more than 10 entries',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['show_schema_link'] = array(
|
|
||||||
'desc'=>'Show the schema link for each attribute',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['show_attribute_notes'] = array(
|
|
||||||
'desc'=>'Show notes for each attribute',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->appearance['stylesheet'] = array(
|
|
||||||
'desc'=>'Style sheet to use',
|
|
||||||
'default'=>'style.css');
|
|
||||||
|
|
||||||
$this->default->appearance['theme'] = array(
|
|
||||||
'desc'=>'Which theme to use',
|
|
||||||
'default'=>'default');
|
|
||||||
|
|
||||||
$this->default->appearance['timezone'] = array(
|
|
||||||
'desc'=>'Define our timezone, if not defined in php.ini',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->appearance['tree'] = array(
|
|
||||||
'desc'=>'Class name which inherits from Tree class and implements the draw() method',
|
|
||||||
'default'=>'AJAXTree');
|
|
||||||
|
|
||||||
/** Tree display
|
|
||||||
* An array of format strings used to display enties in the
|
|
||||||
* tree viewer (left-hand side). The first format string that
|
|
||||||
* is completely defined (i.e., does not reference attributes
|
|
||||||
* that are not defined the object). If there is no format
|
|
||||||
* string that is completely defined, the last one is used.
|
|
||||||
*
|
|
||||||
* You can use special tokens to draw the entries as you wish.
|
|
||||||
* You can even mix in HTML to format the string.
|
|
||||||
* Here are all the tokens you can use:
|
|
||||||
* %rdn - draw the RDN of the entry (ie, "cn=Dave")
|
|
||||||
* %dn - draw the DN of the entry (ie, "cn=Dave,ou=People,dc=example,dc=com"
|
|
||||||
* %rdnValue - draw the value of the RDN (ie, instead of "cn=Dave", just draw "Dave")
|
|
||||||
* %[attrname]- draw the value (or values) of the specified attribute.
|
|
||||||
* example: %gidNumber
|
|
||||||
*
|
|
||||||
* Any multivalued attributes will be displayed as a comma separated list.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
*
|
|
||||||
* To draw the gidNumber and uidNumber to the right of the RDN in a small, gray font:
|
|
||||||
* '%rdn <small style="color:gray">( %gidNumber / %uidNumber )</small>'
|
|
||||||
* To draw the full DN of each entry:
|
|
||||||
* '%dn'
|
|
||||||
* To draw the objectClasses to the right in parenthesis:
|
|
||||||
* '%rdn <small style="color: gray">( %objectClass )</small>'
|
|
||||||
* To draw the user-friendly RDN value (ie, instead of "cn=Dave", just draw "Dave"):
|
|
||||||
* '%rdnValue'
|
|
||||||
*/
|
|
||||||
$this->default->appearance['tree_display_format'] = array(
|
|
||||||
'desc'=>'LDAP attribute to show in the tree',
|
|
||||||
'default'=>array('%rdn'));
|
|
||||||
|
|
||||||
$this->default->appearance['tree_height'] = array(
|
|
||||||
'desc'=>'Pixel height of the tree browser',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->appearance['tree_width'] = array(
|
|
||||||
'desc'=>'Pixel width of the tree browser',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
/** Tree display filter
|
|
||||||
* LDAP filter used to search entries for the tree viewer (left-hand side)
|
|
||||||
*/
|
|
||||||
$this->default->appearance['tree_filter'] = array(
|
|
||||||
'desc'=>'LDAP search filter for the tree entries',
|
|
||||||
'default'=>'(objectClass=*)');
|
|
||||||
|
|
||||||
# PLA will not display the header and footer parts in minimal mode.
|
|
||||||
$this->default->appearance['minimalMode'] = array(
|
|
||||||
'desc'=>'Minimal mode hides header and footer parts',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
## Caching
|
|
||||||
$this->default->cache['schema'] = array(
|
|
||||||
'desc'=>'Cache Schema Activity',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->cache['query'] = array(
|
|
||||||
'desc'=>'Cache Query Configuration',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->cache['query_time'] = array(
|
|
||||||
'desc'=>'Cache the query configuration for atleast this amount of time in seconds',
|
|
||||||
'default'=>5);
|
|
||||||
|
|
||||||
$this->default->cache['template'] = array(
|
|
||||||
'desc'=>'Cache Template Configuration',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->cache['template_time'] = array(
|
|
||||||
'desc'=>'Cache the template configuration for atleast this amount of time in seconds',
|
|
||||||
'default'=>60);
|
|
||||||
|
|
||||||
$this->default->cache['tree'] = array(
|
|
||||||
'desc'=>'Cache Browser Tree',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
/** Confirm actions
|
|
||||||
*/
|
|
||||||
$this->default->confirm['copy'] = array(
|
|
||||||
'desc'=>'Confirm copy actions',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->confirm['create'] = array(
|
|
||||||
'desc'=>'Confirm creation actions',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->confirm['update'] = array(
|
|
||||||
'desc'=>'Confirm update actions',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
/** Commands
|
|
||||||
* Define command availability ; if the value of a command is true,
|
|
||||||
* the command will be available.
|
|
||||||
*/
|
|
||||||
$this->default->commands['cmd'] = array(
|
|
||||||
'desc'=>'Define command availability',
|
|
||||||
'default'=> array(
|
|
||||||
'entry_internal_attributes_show' => true,
|
|
||||||
'entry_refresh' => true,
|
|
||||||
'oslinks' => true,
|
|
||||||
'switch_template' => true
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->default->commands['script'] = array(
|
|
||||||
'desc'=>'Define scripts availability',
|
|
||||||
'default'=> array(
|
|
||||||
'add_attr_form' => true,
|
|
||||||
'add_oclass_form' => true,
|
|
||||||
'add_value_form' => true,
|
|
||||||
'collapse' => true,
|
|
||||||
'compare' => true,
|
|
||||||
'compare_form' => true,
|
|
||||||
'copy' => true,
|
|
||||||
'copy_form' => true,
|
|
||||||
'create' => true,
|
|
||||||
'create_confirm' => true,
|
|
||||||
'delete' => true,
|
|
||||||
'delete_attr' => true,
|
|
||||||
'delete_form' => true,
|
|
||||||
'draw_tree_node' => true,
|
|
||||||
'expand' => true,
|
|
||||||
'export' => true,
|
|
||||||
'export_form' => true,
|
|
||||||
'import' => true,
|
|
||||||
'import_form' => true,
|
|
||||||
'login' => true,
|
|
||||||
'logout' => true,
|
|
||||||
'login_form' => true,
|
|
||||||
'mass_delete' => true,
|
|
||||||
'mass_edit' => true,
|
|
||||||
'mass_update' => true,
|
|
||||||
'modify_member_form' => true,
|
|
||||||
'monitor' => true,
|
|
||||||
'purge_cache' => true,
|
|
||||||
'query_engine' => true,
|
|
||||||
'rename' => true,
|
|
||||||
'rename_form' => true,
|
|
||||||
'rdelete' => true,
|
|
||||||
'refresh' => true,
|
|
||||||
'schema' => true,
|
|
||||||
'server_info' => true,
|
|
||||||
'show_cache' => true,
|
|
||||||
'template_engine' => true,
|
|
||||||
'update_confirm' => true,
|
|
||||||
'update' => 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.
|
|
||||||
* For the following four settings, avaialable options include:
|
|
||||||
*
|
|
||||||
* LDAP_DEREF_NEVER - aliases are never dereferenced (eg, the contents of
|
|
||||||
* the alias itself are shown and not the referenced entry).
|
|
||||||
* LDAP_DEREF_SEARCHING - aliases should be dereferenced during the search but
|
|
||||||
* not when locating the base object of the search.
|
|
||||||
* LDAP_DEREF_FINDING - aliases should be dereferenced when locating the base
|
|
||||||
* object but not during the search.
|
|
||||||
* LDAP_DEREF_ALWAYS - aliases should be dereferenced always (eg, the contents
|
|
||||||
* of the referenced entry is shown and not the aliasing entry)
|
|
||||||
* We superceed these definitions with @ to suppress the error if php-ldap is
|
|
||||||
* not installed.
|
|
||||||
*/
|
|
||||||
@$this->default->deref['export'] = array(
|
|
||||||
'desc'=>'',
|
|
||||||
'default'=>LDAP_DEREF_NEVER);
|
|
||||||
|
|
||||||
@$this->default->deref['search'] = array(
|
|
||||||
'desc'=>'',
|
|
||||||
'default'=>LDAP_DEREF_ALWAYS);
|
|
||||||
|
|
||||||
@$this->default->deref['tree'] = array(
|
|
||||||
'desc'=>'',
|
|
||||||
'default'=>LDAP_DEREF_NEVER);
|
|
||||||
|
|
||||||
@$this->default->deref['view'] = array(
|
|
||||||
'desc'=>'',
|
|
||||||
'default'=>LDAP_DEREF_NEVER);
|
|
||||||
|
|
||||||
## Debug Attributes
|
|
||||||
$this->default->debug['level'] = array(
|
|
||||||
'desc'=>'Debug level verbosity',
|
|
||||||
'default'=>0);
|
|
||||||
|
|
||||||
$this->default->debug['syslog'] = array(
|
|
||||||
'desc'=>'Whether to send debug messages to syslog',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->debug['file'] = array(
|
|
||||||
'desc'=>'Name of file to send debug output to',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->debug['addr'] = array(
|
|
||||||
'desc'=>'IP address of client to provide debugging info.',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
$this->default->debug['append'] = array(
|
|
||||||
'desc'=>'Whether to append to the debug file, or create it fresh each time',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
## Temp Directories
|
|
||||||
/** JPEG TMPDir
|
|
||||||
* This directory must be readable and writable by your web server
|
|
||||||
*/
|
|
||||||
$this->default->jpeg['tmpdir'] = array(
|
|
||||||
'desc'=>'Temporary directory for jpegPhoto data',
|
|
||||||
'default'=>'/tmp');
|
|
||||||
|
|
||||||
## Mass update commands
|
|
||||||
$this->default->mass['enabled'] = array(
|
|
||||||
'desc'=>'Are mass update commands enabled',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
## Modify members feature
|
|
||||||
/**
|
|
||||||
* Search filter setting for new members. This is used to search possible members that can be added
|
|
||||||
* to the group. See modify_member_form.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['filter'] = array(
|
|
||||||
'desc'=>'Search filter for member searches',
|
|
||||||
'default'=>'(objectclass=Person)');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Group attributes. When these attributes are seen in template_engine.php, add "modify group members"
|
|
||||||
* link to the attribute
|
|
||||||
* See template_engine.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['groupattr'] = array(
|
|
||||||
'desc'=>'Group member attributes',
|
|
||||||
'default'=>array('member','uniqueMember','memberUid','uid'));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute that is added to the group member attribute. For groupOfNames or groupOfUniqueNames this is dn,
|
|
||||||
* for posixGroup it's uid. See modify_member_form.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['attr'] = array(
|
|
||||||
'desc'=>'Default attribute that is added to the group member attribute',
|
|
||||||
'default'=>'dn');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute that is added to the group member attribute.
|
|
||||||
* For posixGroup it's uid. See modify_member_form.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['posixattr'] = array(
|
|
||||||
'desc'=>'Contents of the group member attribute',
|
|
||||||
'default'=>'uid');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search filter setting for new members to group. This is used to search possible members that can be added
|
|
||||||
* to the posixGroup. See modify_member_form.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['posixfilter'] = array(
|
|
||||||
'desc'=>'Search filter for posixmember searches',
|
|
||||||
'default'=>'(uid=*)');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* posixGroup attribute. When this attribute are seen in modify_member_form.php, only posixGroup members are shown
|
|
||||||
* See modify_member_form.php
|
|
||||||
*/
|
|
||||||
$this->default->modify_member['posixgroupattr'] = array(
|
|
||||||
'desc'=>'posixGroup member attribute',
|
|
||||||
'default'=>'memberUid');
|
|
||||||
|
|
||||||
## Session Attributes
|
|
||||||
/** Cookie Encryption
|
|
||||||
* phpLDAPadmin can encrypt the content of sensitive cookies if you set this to a big random string.
|
|
||||||
*/
|
|
||||||
$this->default->session['blowfish'] = array(
|
|
||||||
'desc'=>'Blowfish key to encrypt cookie details',
|
|
||||||
'default'=>null);
|
|
||||||
|
|
||||||
/** Cookie Time
|
|
||||||
* If you used auth_type 'form' in the servers list, you can adjust how long the cookie will last
|
|
||||||
* (default is 0 seconds, which expires when you close the browser)
|
|
||||||
*/
|
|
||||||
$this->default->session['cookie_time'] = array(
|
|
||||||
'desc'=>'Time in seconds for the life of cookies',
|
|
||||||
'default'=>0);
|
|
||||||
|
|
||||||
$this->default->session['http_realm'] = array(
|
|
||||||
'desc'=>'HTTP Authentication Realm',
|
|
||||||
'default'=>sprintf('%s %s',app_name(),_('login')));
|
|
||||||
|
|
||||||
$this->default->session['memorylimit'] = array(
|
|
||||||
'desc'=>'Set the PHP memorylimit warning threshold.',
|
|
||||||
'default'=>24);
|
|
||||||
|
|
||||||
$this->default->session['timelimit'] = array(
|
|
||||||
'desc'=>'Set the PHP timelimit.',
|
|
||||||
'default'=>30);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Session Menu
|
|
||||||
*/
|
|
||||||
$this->default->menu['session'] = array(
|
|
||||||
'desc'=>'Menu items when logged in.',
|
|
||||||
'default'=>array(
|
|
||||||
'schema'=>true,
|
|
||||||
'search'=>true,
|
|
||||||
'refresh'=>true,
|
|
||||||
'server_info'=>true,
|
|
||||||
'monitor'=>true,
|
|
||||||
'import'=>true,
|
|
||||||
'export'=>true
|
|
||||||
));
|
|
||||||
|
|
||||||
## Password Generation
|
|
||||||
$this->default->password['length'] = array(
|
|
||||||
'desc'=>'Length of autogenerated password',
|
|
||||||
'default'=>8);
|
|
||||||
|
|
||||||
$this->default->password['numbers'] = array(
|
|
||||||
'desc'=>'Number of numbers required in the password',
|
|
||||||
'default'=>2);
|
|
||||||
|
|
||||||
$this->default->password['lowercase'] = array(
|
|
||||||
'desc'=>'Number of lowercase letters required in the password',
|
|
||||||
'default'=>2);
|
|
||||||
|
|
||||||
$this->default->password['uppercase'] = array(
|
|
||||||
'desc'=>'Number of uppercase letters required in the password',
|
|
||||||
'default'=>2);
|
|
||||||
|
|
||||||
$this->default->password['punctuation'] = array(
|
|
||||||
'desc'=>'Number of punctuation letters required in the password',
|
|
||||||
'default'=>2);
|
|
||||||
|
|
||||||
$this->default->password['use_similar'] = array(
|
|
||||||
'desc'=>'Whether to use similiar characters',
|
|
||||||
'default'=>true);
|
|
||||||
|
|
||||||
$this->default->password['no_random_crypt_salt'] = array(
|
|
||||||
'desc'=>'Disable random salt for crypt()',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
/** 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.
|
|
||||||
* Set this to 'list' to see "Google" style formatted search results.
|
|
||||||
*/
|
|
||||||
$this->default->search['display'] = array(
|
|
||||||
'desc'=>'Display a list or table of search results',
|
|
||||||
'default'=>'list');
|
|
||||||
|
|
||||||
$this->default->search['size_limit'] = array(
|
|
||||||
'desc'=>'Limit the size of searchs on the search page',
|
|
||||||
'default'=>50);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of attributes to display in each search result entry.
|
|
||||||
* Note that you can add * to the list to display all attributes
|
|
||||||
*/
|
|
||||||
$this->default->search['result_attributes'] = array(
|
|
||||||
'desc'=>'List of attributes to display in each search result entry',
|
|
||||||
'default'=>array('cn','sn','uid','postalAddress','telephoneNumber'));
|
|
||||||
|
|
||||||
$this->default->search['time_limit'] = array(
|
|
||||||
'desc'=>'Maximum time to allow unlimited size_limit searches to the ldap server',
|
|
||||||
'default'=>120);
|
|
||||||
|
|
||||||
/* reCAPTCHA Login */
|
|
||||||
|
|
||||||
$this->default->session['reCAPTCHA-enable'] = array(
|
|
||||||
'desc'=>'Status reCAPTCHA (true | false)',
|
|
||||||
'default'=>false);
|
|
||||||
|
|
||||||
$this->default->session['reCAPTCHA-key-site'] = array(
|
|
||||||
'desc'=>'Site Key',
|
|
||||||
'default'=>"<put-here-key-site>");
|
|
||||||
|
|
||||||
$this->default->session['reCAPTCHA-key-server'] = array(
|
|
||||||
'desc'=>'Server key',
|
|
||||||
'default'=>"<put-here-key-server>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access the configuration, taking into account the defaults and the customisations
|
|
||||||
*/
|
|
||||||
private function getConfigArray($usecache=true) {
|
|
||||||
static $CACHE = array();
|
|
||||||
|
|
||||||
if ($usecache && count($CACHE))
|
|
||||||
return $CACHE;
|
|
||||||
|
|
||||||
foreach ($this->default as $key => $vals)
|
|
||||||
$CACHE[$key] = $vals;
|
|
||||||
|
|
||||||
foreach ($this->custom as $key => $vals)
|
|
||||||
foreach ($vals as $index => $val)
|
|
||||||
$CACHE[$key][$index]['value'] = $val;
|
|
||||||
|
|
||||||
return $CACHE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a configuration value.
|
|
||||||
*/
|
|
||||||
public function getValue($key,$index,$fatal=true) {
|
|
||||||
$config = $this->getConfigArray();
|
|
||||||
|
|
||||||
if (! isset($config[$key]))
|
|
||||||
if ($fatal)
|
|
||||||
error(sprintf('A call was made in [%s] to getValue requesting [%s] that isnt predefined.',
|
|
||||||
basename($_SERVER['PHP_SELF']),$key),'error',null,true);
|
|
||||||
else
|
|
||||||
return '';
|
|
||||||
|
|
||||||
if (! isset($config[$key][$index]))
|
|
||||||
if ($fatal)
|
|
||||||
error(sprintf('Requesting an index [%s] in key [%s] that isnt predefined.',$index,$key),'error',null,true);
|
|
||||||
else
|
|
||||||
return '';
|
|
||||||
|
|
||||||
return isset($config[$key][$index]['value']) ? $config[$key][$index]['value'] : $config[$key][$index]['default'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the untested config items
|
|
||||||
*/
|
|
||||||
public function untested() {
|
|
||||||
$result = array();
|
|
||||||
|
|
||||||
foreach ($this->default as $option => $details)
|
|
||||||
foreach ($details as $param => $values)
|
|
||||||
if (isset($values['untested']) && $values['untested'])
|
|
||||||
array_push($result,sprintf('%s.%s',$option,$param));
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to check and warn about any unusual defined variables.
|
|
||||||
*/
|
|
||||||
public function CheckCustom() {
|
|
||||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if (isset($this->custom)) {
|
|
||||||
foreach ($this->custom as $masterkey => $masterdetails) {
|
|
||||||
|
|
||||||
if (isset($this->default->$masterkey)) {
|
|
||||||
|
|
||||||
if (! is_array($masterdetails))
|
|
||||||
error(sprintf('Error in configuration file, [%s] should be an ARRAY.',$masterdetails),'error',null,true);
|
|
||||||
|
|
||||||
foreach ($masterdetails as $key => $value) {
|
|
||||||
# Test that the key is correct.
|
|
||||||
if (! in_array($key,array_keys($this->default->$masterkey)))
|
|
||||||
error(sprintf('Error in configuration file, [%s] has not been defined as a configurable variable.',$key),'error',null,true);
|
|
||||||
|
|
||||||
# Test if its should be an array or not.
|
|
||||||
if (is_array($this->default->{$masterkey}[$key]['default']) && ! is_array($value))
|
|
||||||
error(sprintf('Error in configuration file, %s[\'%s\'] SHOULD be an array of values.',$masterkey,$key),'error',null,true);
|
|
||||||
|
|
||||||
if (! is_array($this->default->{$masterkey}[$key]['default']) && is_array($value))
|
|
||||||
error(sprintf('Error in configuration file, %s[\'%s\'] should NOT be an array of values.',$masterkey,$key),'error',null,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
error(sprintf('Error in configuration file, [%s] has not been defined as a MASTER configurable variable.',$masterkey),'error',null,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of available commands.
|
|
||||||
*/
|
|
||||||
public function getCommandList() {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
$config = $this->getConfigArray(false);
|
|
||||||
|
|
||||||
masort($config['command'],'summary');
|
|
||||||
|
|
||||||
if (isset($config['command']) && is_array($config['command']))
|
|
||||||
return $config['command'];
|
|
||||||
else
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple ACL to see if commands can be run
|
|
||||||
*/
|
|
||||||
public function isCommandAvailable($index='cmd') {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
$a = func_get_args();
|
|
||||||
array_shift($a);
|
|
||||||
$a = $a[0];
|
|
||||||
|
|
||||||
# Command availability list
|
|
||||||
$cmd = $this->getValue('commands',$index);
|
|
||||||
|
|
||||||
if (! is_string($a) || ! isset($cmd[$a]))
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return $cmd[$a];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configDefinition($key,$index,$config) {
|
|
||||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if (! is_array($config) || ! array_key_exists('desc',$config) || ! array_key_exists('default',$config))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isset($this->default->$key))
|
|
||||||
$definition = $this->default->$key;
|
|
||||||
|
|
||||||
$definition[$index] = $config;
|
|
||||||
$this->default->$key = $definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the friendly attributes names
|
|
||||||
*/
|
|
||||||
private function getFriendlyAttrs() {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
return array_change_key_case($this->getValue('appearance','friendly_attrs'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will return the friendly name of an attribute, if it exists.
|
|
||||||
* If the friendly name doesnt exist, the attribute name will be returned.
|
|
||||||
*
|
|
||||||
* @param attribute
|
|
||||||
* @return string friendly name|attribute
|
|
||||||
*/
|
|
||||||
public function getFriendlyName($attr) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
static $friendly_attrs;
|
|
||||||
|
|
||||||
if (! $friendly_attrs)
|
|
||||||
$friendly_attrs = $this->getFriendlyAttrs();
|
|
||||||
|
|
||||||
if (! is_object($attr))
|
|
||||||
if (isset($friendly_attrs[$attr]))
|
|
||||||
return $friendly_attrs[$attr];
|
|
||||||
else
|
|
||||||
return $attr;
|
|
||||||
|
|
||||||
if (isset($friendly_attrs[$attr->getName()]))
|
|
||||||
return $friendly_attrs[$attr->getName()];
|
|
||||||
else
|
|
||||||
return $attr->getName(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will return true if a friendly name exists for an attribute.
|
|
||||||
* If the friendly name doesnt exist, it will return false.
|
|
||||||
*
|
|
||||||
* @param attribute
|
|
||||||
* @return boolean true|false
|
|
||||||
*/
|
|
||||||
public function haveFriendlyName($attr) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
return $attr->getName(false) != $this->getFriendlyName($attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will return the <ancronym> html for a friendly name attribute.
|
|
||||||
*
|
|
||||||
* @param attribute
|
|
||||||
* @return string html for the friendly name.
|
|
||||||
*/
|
|
||||||
public function getFriendlyHTML($attr) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if ($this->haveFriendlyName($attr))
|
|
||||||
return sprintf('<acronym title="%s %s">%s</acronym>',
|
|
||||||
_('Alias for'),$attr->getName(false),$this->getFriendlyName($attr));
|
|
||||||
else
|
|
||||||
return $attr->getName(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setServers($servers) {
|
|
||||||
$this->servers = $servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServer($index=null) {
|
|
||||||
return $this->servers->Instance($index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a list of our servers
|
|
||||||
* @param boolean $visible - Only return visible servers
|
|
||||||
*/
|
|
||||||
public function getServerList($visible=true) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
return $this->servers->getServerList($visible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*******************************************************************************
|
|
||||||
* @package default
|
|
||||||
* emuhash - partly emulates the php mhash functions
|
|
||||||
* version: 2004040701
|
|
||||||
*
|
|
||||||
* (c) 2004 - Simon Matter <simon.matter@invoca.ch>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Do we have builtin mhash support in this PHP version ? */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
if (! function_exists('mhash') && ! function_exists('mhash_keygen_s2k')) {
|
|
||||||
$emuhash_emu = array();
|
|
||||||
|
|
||||||
if (! isset($emuhash_emu['openssl']))
|
|
||||||
$emuhash_emu['openssl'] = '/usr/bin/openssl';
|
|
||||||
|
|
||||||
# Don't create mhash functions if we don't have a working openssl
|
|
||||||
if (! file_exists($emuhash_emu['openssl']))
|
|
||||||
unset($emuhash_emu['openssl']);
|
|
||||||
|
|
||||||
elseif (function_exists('is_executable') && ! is_executable($emuhash_emu['openssl']))
|
|
||||||
unset($emuhash_emu['openssl']);
|
|
||||||
|
|
||||||
else {
|
|
||||||
if (! isset($emuhash_emu['tmpdir']))
|
|
||||||
$emuhash_emu['tmpdir'] = '/tmp';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Define constants used in the mhash emulation code. */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
define('MHASH_MD5','md5');
|
|
||||||
define('MHASH_SHA1','sha1');
|
|
||||||
define('MHASH_RIPEMD160','rmd160');
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Functions to emulate parts of php-mash. */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
function openssl_hash($openssl_hash_id,$password_clear) {
|
|
||||||
global $emuhash_emu;
|
|
||||||
|
|
||||||
if (PHP_VERSION < 6) {
|
|
||||||
$current_magic_quotes = @get_magic_quotes_runtime();
|
|
||||||
@set_magic_quotes_runtime(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmpfile = tempnam($emuhash_emu['tmpdir'],'emuhash');
|
|
||||||
$pwhandle = fopen($tmpfile,'w');
|
|
||||||
|
|
||||||
if (! $pwhandle)
|
|
||||||
error(sprintf('Unable to create a temporary file %s to create hashed password',$tmpfile) ,'error','index.php');
|
|
||||||
|
|
||||||
fwrite($pwhandle,$password_clear);
|
|
||||||
fclose($pwhandle);
|
|
||||||
$cmd = sprintf('%s %s -binary <%s',$emuhash_emu['openssl'],$openssl_hash_id,$tmpfile);
|
|
||||||
$prog = popen($cmd,'r');
|
|
||||||
$pass = fread($prog,1024);
|
|
||||||
pclose($prog);
|
|
||||||
unlink($tmpfile);
|
|
||||||
|
|
||||||
if (PHP_VERSION < 6)
|
|
||||||
@set_magic_quotes_runtime($current_magic_quotes);
|
|
||||||
|
|
||||||
return $pass;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mhash($hash_id,$password_clear) {
|
|
||||||
switch($hash_id) {
|
|
||||||
case MHASH_MD5:
|
|
||||||
$emuhash = openssl_hash(MHASH_MD5,$password_clear);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MHASH_SHA1:
|
|
||||||
$emuhash = openssl_hash(MHASH_SHA1,$password_clear);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MHASH_RIPEMD160:
|
|
||||||
$emuhash = openssl_hash(MHASH_RIPEMD160,$password_clear);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$emuhash = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $emuhash;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mhash_keygen_s2k($hash_id,$password_clear,$salt,$bytes) {
|
|
||||||
return substr(pack('H*',bin2hex(mhash($hash_id,($salt.$password_clear)))),0,$bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
201
lib/hooks.php
201
lib/hooks.php
@ -1,201 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Functions related to hooks management.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
||||||
* USA
|
|
||||||
*
|
|
||||||
* @author Benjamin Drieu <benjamin.drieu@fr.alcove.com> and AlcÃ?ve
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares two arrays by numerically comparing their 'prority'
|
|
||||||
* value. Standard `cmp-like' function.
|
|
||||||
*
|
|
||||||
* @param a First element to compare.
|
|
||||||
* @param b Second element to compare.
|
|
||||||
*
|
|
||||||
* @return -1 if priority of first element is smaller than second
|
|
||||||
* element priority. 1 otherwise.
|
|
||||||
*/
|
|
||||||
function sort_array_by_priority($a,$b) {
|
|
||||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',257,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
return (($a['priority'] < $b['priority']) ? -1 : 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs procedures attached to a hook.
|
|
||||||
*
|
|
||||||
* @param hook_name Name of hook to run.
|
|
||||||
* @param args Array of optional arguments set by phpldapadmin. It is normally in a form known by call_user_func_array() :
|
|
||||||
*
|
|
||||||
* <pre>[ 'server_id' => 0,
|
|
||||||
* 'dn' => 'uid=epoussa,ou=tech,o=corp,o=fr' ]</pre>
|
|
||||||
*
|
|
||||||
* @return true if all procedures returned true, false otherwise.
|
|
||||||
*/
|
|
||||||
function run_hook($hook_name,$args) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',257,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
$hooks = isset($_SESSION[APPCONFIG]) ? $_SESSION[APPCONFIG]->hooks : array();
|
|
||||||
|
|
||||||
if (! count($hooks) || ! array_key_exists($hook_name,$hooks)) {
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('Returning, HOOK not defined (%s)',257,0,__FILE__,__LINE__,__METHOD__,$hook_name);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rollbacks = array();
|
|
||||||
reset($hooks[$hook_name]);
|
|
||||||
|
|
||||||
/* Execution of procedures attached is done using a numeric order
|
|
||||||
* since all procedures have been attached to the hook with a
|
|
||||||
* numerical weight. */
|
|
||||||
foreach ($hooks[$hook_name] as $key=>$hook) {
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('Calling HOOK Function (%s)(%s)',257,0,__FILE__,__LINE__,__METHOD__,
|
|
||||||
$hook['hook_function'],$args);
|
|
||||||
|
|
||||||
array_push($rollbacks,$hook['rollback_function']);
|
|
||||||
|
|
||||||
$result = call_user_func_array($hook['hook_function'],$args);
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('Called HOOK Function (%s)',257,0,__FILE__,__LINE__,__METHOD__,
|
|
||||||
$hook['hook_function']);
|
|
||||||
|
|
||||||
/* If a procedure fails (identified by a false return), its optional rollback is executed with
|
|
||||||
* the same arguments. After that, all rollbacks from
|
|
||||||
* previously executed procedures are executed in the reverse
|
|
||||||
* order. */
|
|
||||||
if (! is_null($result) && $result == false) {
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('HOOK Function [%s] return (%s)',257,0,__FILE__,__LINE__,__METHOD__,
|
|
||||||
$hook['hook_function'],$result);
|
|
||||||
|
|
||||||
while ($rollbacks) {
|
|
||||||
$rollback = array_pop($rollbacks);
|
|
||||||
|
|
||||||
if ($rollback != false) {
|
|
||||||
if (DEBUG_ENABLED)
|
|
||||||
debug_log('HOOK Function Rollback (%s)',257,0,__FILE__,__LINE__,__METHOD__,
|
|
||||||
$rollback);
|
|
||||||
|
|
||||||
call_user_func_array($rollback,$args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a procedure to a hook for later execution.
|
|
||||||
*
|
|
||||||
* @param hook_name Name of the hook.
|
|
||||||
* @param hook_function Name of the php function called upon hook trigger.
|
|
||||||
* @param priority Numeric priority. Lowest means procedure will be executed before.
|
|
||||||
* @param rollback_function Name of the php rollback function called upon failure.
|
|
||||||
*/
|
|
||||||
function add_hook($hook_name,$hook_function,$priority=0,$rollback_function=null) {
|
|
||||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',257,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
# First, see if the hook function exists.
|
|
||||||
if (! function_exists($hook_function)) {
|
|
||||||
system_message(array(
|
|
||||||
'title'=>_('Hook function does not exist'),
|
|
||||||
'body'=>sprintf('Hook name: %s<br/>Hook function: %s',$hook_name,$hook_function),
|
|
||||||
'type'=>'warn'));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks))
|
|
||||||
$_SESSION[APPCONFIG]->hooks[$hook_name] = array();
|
|
||||||
|
|
||||||
remove_hook($hook_name,$hook_function,-1,null);
|
|
||||||
|
|
||||||
array_push($_SESSION[APPCONFIG]->hooks[$hook_name],array(
|
|
||||||
'priority' => $priority,
|
|
||||||
'hook_function' => $hook_function,
|
|
||||||
'rollback_function' => $rollback_function));
|
|
||||||
|
|
||||||
uasort($_SESSION[APPCONFIG]->hooks[$hook_name],'sort_array_by_priority');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a procedure from a hook, based on a filter.
|
|
||||||
*
|
|
||||||
* @param hook_name Name of the hook.
|
|
||||||
* @param priority Numeric priority. If set, all procedures of that priority will be removed.
|
|
||||||
* @param hook_function Name of the procedure function. If set, all procedures that call this function will be removed.
|
|
||||||
* @param rollback_function Name of the php rollback function called upon failure. If set, all
|
|
||||||
* procedures that call this function as a rollback will be removed.
|
|
||||||
*/
|
|
||||||
function remove_hook($hook_name,$hook_function,$priority,$rollback_function) {
|
|
||||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',257,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if (array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks)) {
|
|
||||||
reset($_SESSION[APPCONFIG]->hooks[$hook_name]);
|
|
||||||
|
|
||||||
foreach ($_SESSION[APPCONFIG]->hooks[$hook_name] as $key=>$hook) {
|
|
||||||
if (($priority >= 0 && $priority == $hook['priority']) ||
|
|
||||||
($hook_function && $hook_function == $hook['hook_function']) ||
|
|
||||||
($rollback_function && $rollback_function == $hook['rollback_function'])) {
|
|
||||||
|
|
||||||
unset($_SESSION[APPCONFIG]->hooks[$hook_name][$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all procedures from a hook.
|
|
||||||
*
|
|
||||||
* @param hook_name Name of hook to clear.
|
|
||||||
*/
|
|
||||||
function clear_hooks($hook_name) {
|
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
|
||||||
debug_log('Entered (%%)',257,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
|
||||||
|
|
||||||
if (array_key_exists($hook_name,$_SESSION[APPCONFIG]->hooks))
|
|
||||||
unset($_SESSION[APPCONFIG]->hooks[$hook_name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$hooks = array();
|
|
||||||
|
|
||||||
# Evaluating user-made hooks
|
|
||||||
if (is_dir(HOOKSDIR.'functions')) {
|
|
||||||
$hooks['dir'] = dir(HOOKSDIR.'functions');
|
|
||||||
|
|
||||||
while ($hooks['file'] = $hooks['dir']->read()) {
|
|
||||||
$script = sprintf('%s/%s/%s',HOOKSDIR,'functions',$hooks['file']);
|
|
||||||
|
|
||||||
if (is_file($script) && preg_match('/php[0-9]?$/',$hooks['file']))
|
|
||||||
require_once $script;
|
|
||||||
}
|
|
||||||
|
|
||||||
$hooks['dir']->close();
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,609 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Classes and functions for importing data to LDAP
|
|
||||||
*
|
|
||||||
* These classes provide differnet import formats.
|
|
||||||
*
|
|
||||||
* @author The phpLDAPadmin development team
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @see import.php and import_form.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Importer Class
|
|
||||||
*
|
|
||||||
* This class serves as a top level importer class, which will return
|
|
||||||
* the correct Import class.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Import
|
|
||||||
*/
|
|
||||||
class Importer {
|
|
||||||
# Server ID that the export is linked to
|
|
||||||
private $server_id;
|
|
||||||
# Import Type
|
|
||||||
private $template_id;
|
|
||||||
private $template;
|
|
||||||
|
|
||||||
public function __construct($server_id,$template_id) {
|
|
||||||
$this->server_id = $server_id;
|
|
||||||
$this->template_id = $template_id;
|
|
||||||
|
|
||||||
$this->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
static function types() {
|
|
||||||
$type = array();
|
|
||||||
|
|
||||||
$details = ImportLDIF::getType();
|
|
||||||
$type[$details['type']] = $details;
|
|
||||||
|
|
||||||
return $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function accept() {
|
|
||||||
switch($this->template_id) {
|
|
||||||
case 'LDIF':
|
|
||||||
$this->template = new ImportLDIF($this->server_id);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
system_message(array(
|
|
||||||
'title'=>sprintf('%s %s',_('Unknown Import Type'),$this->template_id),
|
|
||||||
'body'=>_('phpLDAPadmin has not been configured for that import type'),
|
|
||||||
'type'=>'warn'),'index.php');
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->template->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTemplate() {
|
|
||||||
return $this->template;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import Class
|
|
||||||
*
|
|
||||||
* This abstract classes provides all the common methods and variables for the
|
|
||||||
* custom import classes.
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Import
|
|
||||||
*/
|
|
||||||
abstract class Import {
|
|
||||||
protected $server_id = null;
|
|
||||||
protected $input = null;
|
|
||||||
protected $source = array();
|
|
||||||
|
|
||||||
public function __construct($server_id) {
|
|
||||||
$this->server_id = $server_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function accept() {
|
|
||||||
if (get_request('ldif','REQUEST')) {
|
|
||||||
$this->input = explode("\n",get_request('ldif','REQUEST'));
|
|
||||||
$this->source['name'] = 'STDIN';
|
|
||||||
$this->source['size'] = strlen(get_request('ldif','REQUEST'));
|
|
||||||
|
|
||||||
} elseif (isset($_FILES['ldif_file']) && is_array($_FILES['ldif_file']) && ! $_FILES['ldif_file']['error']) {
|
|
||||||
$input = file_get_contents($_FILES['ldif_file']['tmp_name']);
|
|
||||||
$this->input = preg_split("/\n|\r\n|\r/",$input);
|
|
||||||
$this->source['name'] = $_FILES['ldif_file']['name'];
|
|
||||||
$this->source['size'] = $_FILES['ldif_file']['size'];
|
|
||||||
|
|
||||||
} else {
|
|
||||||
system_message(array(
|
|
||||||
'title'=>_('No import input'),
|
|
||||||
'body'=>_('You must either upload a file or provide an import in the text box.'),
|
|
||||||
'type'=>'error'),sprintf('cmd.php?cmd=import_form&server_id=%s',get_request('server_id','REQUEST')));
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSource($attr) {
|
|
||||||
if (isset($this->source[$attr]))
|
|
||||||
return $this->source[$attr];
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
# @todo integrate hooks
|
|
||||||
public function LDAPimport() {
|
|
||||||
$template = $this->getTemplate();
|
|
||||||
$server = $this->getServer();
|
|
||||||
|
|
||||||
switch ($template->getType()) {
|
|
||||||
case 'add':
|
|
||||||
return $server->add($template->getDN(),$template->getLDAPadd());
|
|
||||||
|
|
||||||
case 'modify':
|
|
||||||
return $server->modify($template->getDN(),$template->getLDAPmodify());
|
|
||||||
|
|
||||||
case 'moddn':
|
|
||||||
case 'modrdn':
|
|
||||||
return $server->rename($template->getDN(),$template->modrdn['newrdn'],$template->modrdn['newsuperior'],$template->modrdn['deleteoldrdn']);
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug_dump_backtrace(sprintf('Unknown template type %s',$template->getType()),1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import entries from LDIF
|
|
||||||
*
|
|
||||||
* The LDIF spec is described by RFC2849
|
|
||||||
* http://www.ietf.org/rfc/rfc2849.txt
|
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Import
|
|
||||||
*/
|
|
||||||
class ImportLDIF extends Import {
|
|
||||||
private $_currentLineNumber = 0;
|
|
||||||
private $_currentLine = '';
|
|
||||||
private $template;
|
|
||||||
public $error = array();
|
|
||||||
|
|
||||||
static public function getType() {
|
|
||||||
return array('type'=>'LDIF','description' => _('LDIF Import'),'extension'=>'ldif');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getTemplate() {
|
|
||||||
return $this->template;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getServer() {
|
|
||||||
return $_SESSION[APPCONFIG]->getServer($this->server_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function readEntry() {
|
|
||||||
static $haveVersion = false;
|
|
||||||
|
|
||||||
if ($lines = $this->nextLines()) {
|
|
||||||
|
|
||||||
# If we have a version line.
|
|
||||||
if (! $haveVersion && preg_match('/^version:/',$lines[0])) {
|
|
||||||
list($text,$version) = $this->getAttrValue(array_shift($lines));
|
|
||||||
|
|
||||||
if ($version != 1)
|
|
||||||
return $this->error(sprintf('%s %s',_('LDIF import only suppports version 1'),$version),$lines);
|
|
||||||
|
|
||||||
$haveVersion = true;
|
|
||||||
$lines = $this->nextLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
$server = $this->getServer();
|
|
||||||
|
|
||||||
# The first line should be the DN
|
|
||||||
if (preg_match('/^dn:/',$lines[0])) {
|
|
||||||
list($text,$dn) = $this->getAttrValue(array_shift($lines));
|
|
||||||
|
|
||||||
# The second line should be our changetype
|
|
||||||
if (preg_match('/^changetype:[ ]*(delete|add|modrdn|moddn|modify)/i',$lines[0])) {
|
|
||||||
$attrvalue = $this->getAttrValue($lines[0]);
|
|
||||||
$changetype = $attrvalue[1];
|
|
||||||
array_shift($lines);
|
|
||||||
|
|
||||||
} else
|
|
||||||
$changetype = 'add';
|
|
||||||
|
|
||||||
$this->template = new Template($this->server_id,null,null,$changetype);
|
|
||||||
|
|
||||||
switch ($changetype) {
|
|
||||||
case 'add':
|
|
||||||
$rdn = get_rdn($dn);
|
|
||||||
$container = $server->getContainer($dn);
|
|
||||||
|
|
||||||
$this->template->setContainer($container);
|
|
||||||
$this->template->accept();
|
|
||||||
|
|
||||||
$this->getAddDetails($lines);
|
|
||||||
$this->template->setRDNAttributes($rdn);
|
|
||||||
|
|
||||||
return $this->template;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'modify':
|
|
||||||
if (! $server->dnExists($dn))
|
|
||||||
return $this->error(sprintf('%s %s',_('DN does not exist'),$dn),$lines);
|
|
||||||
|
|
||||||
$this->template->setDN($dn);
|
|
||||||
$this->template->accept(false,true);
|
|
||||||
|
|
||||||
return $this->getModifyDetails($lines);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'moddn':
|
|
||||||
case 'modrdn':
|
|
||||||
if (! $server->dnExists($dn))
|
|
||||||
return $this->error(sprintf('%s %s',_('DN does not exist'),$dn),$lines);
|
|
||||||
|
|
||||||
$this->template->setDN($dn);
|
|
||||||
$this->template->accept();
|
|
||||||
|
|
||||||
return $this->getModRDNAttributes($lines);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (! $server->dnExists($dn))
|
|
||||||
return $this->error(_('Unkown change type'),$lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('A valid dn line is required'),$lines);
|
|
||||||
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Attribute and Decoded Value
|
|
||||||
*/
|
|
||||||
private function getAttrValue($line) {
|
|
||||||
list($attr,$value) = explode(':',$line,2);
|
|
||||||
|
|
||||||
# Get the DN
|
|
||||||
if (substr($value,0,1) == ':')
|
|
||||||
$value = base64_decode(trim(substr($value,1)));
|
|
||||||
else
|
|
||||||
$value = trim($value);
|
|
||||||
|
|
||||||
return array($attr,$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the lines of the next entry
|
|
||||||
*
|
|
||||||
* @return The lines (unfolded) of the next entry
|
|
||||||
*/
|
|
||||||
private function nextLines() {
|
|
||||||
$current = array();
|
|
||||||
$endEntryFound = false;
|
|
||||||
|
|
||||||
if ($this->hasMoreEntries() && ! $this->eof()) {
|
|
||||||
# The first line is the DN one
|
|
||||||
$current[0]= trim($this->_currentLine);
|
|
||||||
|
|
||||||
# While we end on a blank line, fetch the attribute lines
|
|
||||||
$count = 0;
|
|
||||||
while (! $this->eof() && ! $endEntryFound) {
|
|
||||||
# Fetch the next line
|
|
||||||
$this->nextLine();
|
|
||||||
|
|
||||||
/* If the next line begin with a space, we append it to the current row
|
|
||||||
* else we push it into the array (unwrap)*/
|
|
||||||
if ($this->isWrappedLine())
|
|
||||||
$current[$count] .= trim($this->_currentLine);
|
|
||||||
elseif ($this->isCommentLine()) {}
|
|
||||||
# Do nothing
|
|
||||||
elseif (! $this->isBlankLine())
|
|
||||||
$current[++$count] = trim($this->_currentLine);
|
|
||||||
else
|
|
||||||
$endEntryFound = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Return the LDIF entry array
|
|
||||||
return $current;
|
|
||||||
|
|
||||||
} else
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private method to check if there is more entries in the input.
|
|
||||||
*
|
|
||||||
* @return boolean true if an entry was found, false otherwise.
|
|
||||||
*/
|
|
||||||
private function hasMoreEntries() {
|
|
||||||
$entry_found = false;
|
|
||||||
|
|
||||||
while (! $this->eof() && ! $entry_found) {
|
|
||||||
# If it's a comment or blank line, switch to the next line
|
|
||||||
if ($this->isCommentLine() || $this->isBlankLine()) {
|
|
||||||
# Do nothing
|
|
||||||
$this->nextLine();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$this->_currentDnLine = $this->_currentLine;
|
|
||||||
$this->dnLineNumber = $this->_currentLineNumber;
|
|
||||||
$entry_found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $entry_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to switch to the next line
|
|
||||||
*/
|
|
||||||
private function nextLine() {
|
|
||||||
$this->_currentLineNumber++;
|
|
||||||
$this->_currentLine = array_shift($this->input);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if it's a comment line.
|
|
||||||
*
|
|
||||||
* @return boolean true if it's a comment line,false otherwise
|
|
||||||
*/
|
|
||||||
private function isCommentLine() {
|
|
||||||
return substr(trim($this->_currentLine),0,1) == '#' ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if it's a wrapped line.
|
|
||||||
*
|
|
||||||
* @return boolean true if it's a wrapped line,false otherwise
|
|
||||||
*/
|
|
||||||
private function isWrappedLine() {
|
|
||||||
return substr($this->_currentLine,0,1) == ' ' ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if is the current line is a blank line.
|
|
||||||
*
|
|
||||||
* @return boolean if it is a blank line,false otherwise.
|
|
||||||
*/
|
|
||||||
private function isBlankLine() {
|
|
||||||
return(trim($this->_currentLine) == '') ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if we reached the end of the input.
|
|
||||||
*
|
|
||||||
* @return boolean true if it's the end of file, false otherwise.
|
|
||||||
*/
|
|
||||||
public function eof() {
|
|
||||||
return count($this->input) > 0 ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function error($msg,$data) {
|
|
||||||
$this->error['message'] = sprintf('%s [%s]',$msg,$this->template ? $this->template->getDN() : '');
|
|
||||||
$this->error['line'] = $this->_currentLineNumber;
|
|
||||||
$this->error['data'] = $data;
|
|
||||||
$this->error['changetype'] = $this->template ? $this->template->getType() : 'Not set';
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to retrieve the attribute value of a ldif line,
|
|
||||||
* and get the base 64 decoded value if it is encoded
|
|
||||||
*/
|
|
||||||
private function getAttributeValue($value) {
|
|
||||||
$return = '';
|
|
||||||
|
|
||||||
if (substr($value,0,1) == '<') {
|
|
||||||
$url = trim(substr($value,1));
|
|
||||||
|
|
||||||
if (preg_match('^file://',$url)) {
|
|
||||||
$filename = substr(trim($url),7);
|
|
||||||
|
|
||||||
if ($fh = @fopen($filename,'rb')) {
|
|
||||||
if (! $return = @fread($fh,filesize($filename)))
|
|
||||||
return $this->error(_('Unable to read file for'),$value);
|
|
||||||
|
|
||||||
@fclose($fh);
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('Unable to open file for'),$value);
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('The url attribute value should begin with file:// for'),$value);
|
|
||||||
|
|
||||||
# It's a string
|
|
||||||
} else
|
|
||||||
$return = $value;
|
|
||||||
|
|
||||||
return trim($return);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the attributes array when the change type is add.
|
|
||||||
*/
|
|
||||||
private function getAddDetails($lines) {
|
|
||||||
foreach ($lines as $line) {
|
|
||||||
list($attr,$value) = $this->getAttrValue($line);
|
|
||||||
|
|
||||||
if (is_null($attribute = $this->template->getAttribute($attr))) {
|
|
||||||
$attribute = $this->template->addAttribute($attr,array('values'=>array($value)));
|
|
||||||
$attribute->justModified();
|
|
||||||
|
|
||||||
} else
|
|
||||||
if ($attribute->hasBeenModified())
|
|
||||||
$attribute->addValue($value);
|
|
||||||
else
|
|
||||||
$attribute->setValue(array($value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the attributes array for the entry when the change type is modify
|
|
||||||
*/
|
|
||||||
private function getModifyDetails($lines) {
|
|
||||||
if (! count($lines))
|
|
||||||
return $this->error(_('Missing attributes for'),$lines);
|
|
||||||
|
|
||||||
# While the array is not empty
|
|
||||||
while (count($lines)) {
|
|
||||||
$processline = false;
|
|
||||||
$deleteattr = false;
|
|
||||||
|
|
||||||
# Get the current line with the action
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
$attrvalue = $this->getAttrValue($currentLine);
|
|
||||||
$action_attribute = $attrvalue[0];
|
|
||||||
$action_attribute_value = $attrvalue[1];
|
|
||||||
|
|
||||||
if (! in_array($action_attribute,array('add','delete','replace')))
|
|
||||||
return $this->error(_('Missing modify command add, delete or replace'),array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
$processline = true;
|
|
||||||
switch ($action_attribute) {
|
|
||||||
case 'add':
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'delete':
|
|
||||||
$attribute = $this->template->getAttribute($action_attribute_value);
|
|
||||||
|
|
||||||
if (is_null($attribute))
|
|
||||||
return $this->error(sprintf('%s %s',_('Attempting to delete a non existant attribute'),$action_attribute_value),
|
|
||||||
array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
$deleteattr = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'replace':
|
|
||||||
$attribute = $this->template->getAttribute($action_attribute_value);
|
|
||||||
|
|
||||||
if (is_null($attribute))
|
|
||||||
return $this->error(sprintf('%s %s',_('Attempting to replace a non existant attribute'),$action_attribute_value),
|
|
||||||
array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug_dump_backtrace(sprintf('Unknown action %s',$action_attribute),1);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Fetch the attribute for the following line
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
|
|
||||||
while ($processline && trim($currentLine) && (trim($currentLine) != '-')) {
|
|
||||||
$processline = false;
|
|
||||||
|
|
||||||
# If there is a valid line
|
|
||||||
if (preg_match('/:/',$currentLine)) {
|
|
||||||
$attrvalue = $this->getAttrValue($currentLine);
|
|
||||||
$attr = $attrvalue[0];
|
|
||||||
$attribute_value_part = $attrvalue[1];
|
|
||||||
|
|
||||||
# Check that it correspond to the one specified before
|
|
||||||
if ($attr == $action_attribute_value) {
|
|
||||||
# Get the value part of the attribute
|
|
||||||
$attribute_value = $this->getAttributeValue($attribute_value_part);
|
|
||||||
|
|
||||||
$attribute = $this->template->getAttribute($attr);
|
|
||||||
|
|
||||||
# This should be a add/replace operation
|
|
||||||
switch ($action_attribute) {
|
|
||||||
case 'add':
|
|
||||||
if (is_null($attribute))
|
|
||||||
$attribute = $this->template->addAttribute($attr,array('values'=>array($attribute_value_part)));
|
|
||||||
else
|
|
||||||
$attribute->addValue($attribute_value_part,-1);
|
|
||||||
|
|
||||||
$attribute->justModified();
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'delete':
|
|
||||||
$deleteattr = false;
|
|
||||||
|
|
||||||
if (($key = array_search($attribute_value_part,$attribute->getValues())) !== false)
|
|
||||||
$attribute->delValue($key);
|
|
||||||
else
|
|
||||||
return $this->error(sprintf('%s %s',_('Delete value doesnt exist in DN'),$attribute_value_part),
|
|
||||||
array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'replace':
|
|
||||||
if ($attribute->hasBeenModified())
|
|
||||||
$attribute->addValue($attribute_value_part,-1);
|
|
||||||
else
|
|
||||||
$attribute->setValue(array($attribute_value_part));
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
debug_dump_backtrace(sprintf('Unexpected operation %s',$action_attribute));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(sprintf('%s %s',_('The attribute to modify doesnt match the one specified by'),$action_attribute),
|
|
||||||
array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(sprintf('%s %s',_('Attribute not valid'),$currentLine),
|
|
||||||
array_merge(array($currentLine),$lines));
|
|
||||||
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
if (trim($currentLine))
|
|
||||||
$processline = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action_attribute == 'delete' && $deleteattr)
|
|
||||||
$attribute->setValue(array());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->template;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build the attributes for the entry when the change type is modrdn
|
|
||||||
*/
|
|
||||||
function getModRDNAttributes($lines) {
|
|
||||||
$server = $this->getServer();
|
|
||||||
$attrs = array();
|
|
||||||
|
|
||||||
# MODRDN MODDN should only be 2 or 3 lines.
|
|
||||||
if (count($lines) != 2 && count($lines) !=3)
|
|
||||||
return $this->error(_('Invalid entry'),$lines);
|
|
||||||
|
|
||||||
else {
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
|
|
||||||
# First we need to check if there is an new rdn specified
|
|
||||||
if (preg_match('/^newrdn:(:?)/',$currentLine)) {
|
|
||||||
|
|
||||||
$attrvalue = $this->getAttrValue($currentLine);
|
|
||||||
$attrs['newrdn'] = $attrvalue[1];
|
|
||||||
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
|
|
||||||
if (preg_match('/^deleteoldrdn:[ ]*(0|1)/',$currentLine)) {
|
|
||||||
$attrvalue = $this->getAttrValue($currentLine);
|
|
||||||
$attrs['deleteoldrdn'] = $attrvalue[1];
|
|
||||||
|
|
||||||
# Switch to the possible new superior attribute
|
|
||||||
if (count($lines)) {
|
|
||||||
$currentLine = array_shift($lines);
|
|
||||||
|
|
||||||
# then the possible new superior attribute
|
|
||||||
if (preg_match('/^newsuperior:/',$currentLine)) {
|
|
||||||
$attrvalue = $this->getAttrValue($currentLine);
|
|
||||||
$attrs['newsuperior'] = $attrvalue[1];
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('A valid newsuperior attribute should be specified'),$lines);
|
|
||||||
|
|
||||||
} else
|
|
||||||
$attrs['newsuperior'] = $server->getContainer($this->template->getDN());
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('A valid deleteoldrdn attribute should be specified'),$lines);
|
|
||||||
|
|
||||||
} else
|
|
||||||
return $this->error(_('A valid newrdn attribute should be specified'),$lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Well do something out of the ordinary here, since our template doesnt handle mod[r]dn yet.
|
|
||||||
$this->template->modrdn = $attrs;
|
|
||||||
return $this->template;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user