Latest SANDPIT - MERGE from CVS (MERGE-GIT)

This commit is contained in:
Deon George 2009-07-01 16:09:17 +10:00
parent 388783fc84
commit ea17aadef4
210 changed files with 37284 additions and 52716 deletions

View File

@ -1 +1 @@
$Name: RELEASE-1_1_0_7 $ $Name$

View File

@ -13,11 +13,11 @@
* To override a default, use the $config->custom variable to do so. * To override a default, use the $config->custom variable to do so.
* For example, the default for defining the language in config_default.php * For example, the default for defining the language in config_default.php
* *
* $this->default->appearance['lang'] = array( * $this->default->appearance['language'] = array(
* 'desc'=>'Language', * 'desc'=>'Language',
* 'default'=>'auto'); * 'default'=>'auto');
* *
* to override this, use $config->custom->appearance['lang'] = 'en'; * to override this, use $config->custom->appearance['language'] = 'en_EN';
* *
* This file is also used to configure your LDAP server connections. * This file is also used to configure your LDAP server connections.
* *
@ -57,8 +57,8 @@
/* The temporary storage directory where we will put jpegPhoto data /* The temporary storage directory where we will put jpegPhoto data
This directory must be readable and writable by your web server. */ This directory must be readable and writable by your web server. */
// $config->custom->jpeg['tmpdir'] = "/tmp"; // Example for Unix systems // $config->custom->jpeg['tmpdir'] = '/tmp'; // Example for Unix systems
# $config->custom->jpeg['tmpdir'] = "c:\\temp"; // Example for Windows systems # $config->custom->jpeg['tmpdir'] = 'c:\\temp'; // Example for Windows systems
/* Set this to (bool)true if you do NOT want a random salt used when /* Set this to (bool)true if you do NOT want a random salt used when
calling crypt(). Instead, use the first two letters of the user's calling crypt(). Instead, use the first two letters of the user's
@ -84,6 +84,7 @@
$config->custom->commands['all'] = array( $config->custom->commands['all'] = array(
'home' => true, 'home' => true,
'external_links' => array('feature' => true, 'external_links' => array('feature' => true,
'forum' => true,
'bug' => true, 'bug' => true,
'donation' => true, 'donation' => true,
'help' => true, 'help' => true,
@ -118,21 +119,8 @@ $config->custom->commands['all'] = array(
/* If you want to choose the appearance of the tree, specify a class name which /* If you want to choose the appearance of the tree, specify a class name which
inherits from the Tree class. */ inherits from the Tree class. */
// $config->custom->appearance['tree'] = "AJAXTree"; // $config->custom->appearance['tree'] = 'AJAXTree';
# $config->custom->appearance['tree'] = "HTMLTree"; # $config->custom->appearance['tree'] = 'HTMLTree';
/* If you want to customise the entry view/edition, specify your factory name which
inherits from the EntryFactory class.
The 'DefaultEntryFactory' draws all the attributes of an entry according this
config file and the ldap schema definition ; the 'TemplateEntryFactory' draws
an entry according to the template whose regexp matches with the dn. */
# $config->custom->appearance['entry_factory'] = "DefaultEntryFactory";
// $config->custom->appearance['entry_factory'] = "TemplateEntryFactory";
/* If you want to customise an attribute view/edition, specify your factory name which
inherits from the AttributeFactory class.
An AttributeFactory defines which class to use to represent a given attribute */
// $config->custom->appearance['attribute_factory'] = "AttributeFactory";
/* Just show your custom templates. */ /* Just show your custom templates. */
// $config->custom->appearance['custom_templates_only'] = false; // $config->custom->appearance['custom_templates_only'] = false;
@ -150,30 +138,118 @@ $config->custom->commands['all'] = array(
// $config->custom->appearance['tree_width'] = null; // $config->custom->appearance['tree_width'] = null;
# $config->custom->appearance['tree_width'] = 250; # $config->custom->appearance['tree_width'] = 250;
/*********************************************/
/* User-friendly attribute translation */
/*********************************************/
/* Use this array to map attribute names to user friendly names. For example, if
you don't want to see "facsimileTelephoneNumber" but rather "Fax". */
// $config->custom->appearance['friendly_attrs'] = array();
$config->custom->appearance['friendly_attrs'] = array(
'facsimileTelephoneNumber' => 'Fax',
'gid' => 'Group',
'mail' => 'Email',
'telephoneNumber' => 'Telephone',
'uid' => 'User Name',
'userPassword' => 'Password'
);
/*********************************************/
/* Hidden attributes */
/*********************************************/
/* You may want to hide certain attributes from being edited. If you want to
hide attributes from the user, you should use your LDAP servers ACLs.
NOTE: The user must be able to read the hide_attrs_exempt entry to be
excluded. */
// $config->custom->appearance['hide_attrs'] = array();
# $config->custom->appearance['hide_attrs'] = array('objectClass');
/* Members of this list will be exempt from the hidden attributes.*/
// $config->custom->appearance['hide_attrs_exempt'] = null;
# $config->custom->appearance['hide_attrs_exempt'] = 'cn=PLA UnHide,ou=Groups,c=AU';
/*********************************************/
/* Read-only attributes */
/*********************************************/
/* You may want to phpLDAPadmin to display certain attributes as read only,
meaning that users will not be presented a form for modifying those
attributes, and they will not be allowed to be modified on the "back-end"
either. You may configure this list here:
NOTE: The user must be able to read the readonly_attrs_exempt entry to be
excluded. */
// $config->custom->appearance['readonly_attrs'] = array();
/* Members of this list will be exempt from the readonly attributes.*/
// $config->custom->appearance['readonly_attrs_exempt'] = null;
# $config->custom->appearance['readonly_attrs_exempt'] = 'cn=PLA ReadWrite,ou=Groups,c=AU';
/*********************************************/
/* Group attributes */
/*********************************************/
/* Add "modify group members" link to the attribute. */
// $config->custom->modify_member['groupattr'] = array('member','uniqueMember','memberUid');
/* Configure filter for member search. This only applies to "modify group members" feature */
// $config->custom->modify_member['filter'] = '(objectclass=Person)';
/* Attribute that is added to the group member attribute. */
// $config->custom->modify_member['attr'] = 'dn';
/* For Posix attributes */
// $config->custom->modify_member['posixattr'] = 'uid';
// $config->custom->modify_member['posixfilter'] = '(uid=*)';
// $config->custom->modify_member['posixgroupattr'] = 'memberUid';
/*********************************************/
/* Support for attrs display order */
/*********************************************/
/* Use this array if you want to have your attributes displayed in a specific
order. You can use default attribute names or their fridenly names.
For example, "sn" will be displayed right after "givenName". All the other
attributes that are not specified in this array will be displayed after in
alphabetical order. */
// $config->custom->appearance['attr_display_order'] = array();
# $config->custom->appearance['attr_display_order'] = array(
# 'givenName',
# 'sn',
# 'cn',
# 'displayName',
# 'uid',
# 'uidNumber',
# 'gidNumber',
# 'homeDirectory',
# 'mail',
# 'userPassword'
# );
/*********************************************/ /*********************************************/
/* Define your LDAP servers in this section */ /* Define your LDAP servers in this section */
/*********************************************/ /*********************************************/
$i=0; $servers = new Datastore();
$ldapservers = new LDAPServers; $servers->newServer('ldap_pla');
/* A convenient name that will appear in the tree viewer and throughout /* A convenient name that will appear in the tree viewer and throughout
phpLDAPadmin to identify this LDAP server to users. */ phpLDAPadmin to identify this LDAP server to users. */
$ldapservers->SetValue($i,'server','name','My LDAP Server'); $servers->setValue('server','name','My LDAP Server');
/* Examples: /* Examples:
'ldap.example.com', 'ldap.example.com',
'ldaps://ldap.example.com/', 'ldaps://ldap.example.com/',
'ldapi://%2fusr%local%2fvar%2frun%2fldapi' 'ldapi://%2fusr%local%2fvar%2frun%2fldapi'
(Unix socket at /usr/local/var/run/ldap) */ (Unix socket at /usr/local/var/run/ldap) */
// $ldapservers->SetValue($i,'server','host','127.0.0.1'); // $servers->setValue('server','host','127.0.0.1');
/* The port your LDAP server listens on (no quotes). 389 is standard. */ /* The port your LDAP server listens on (no quotes). 389 is standard. */
// $ldapservers->SetValue($i,'server','port',389); // $servers->setValue('server','port',389);
/* Array of base DNs of your LDAP server. Leave this blank to have phpLDAPadmin /* Array of base DNs of your LDAP server. Leave this blank to have phpLDAPadmin
auto-detect it for you. */ auto-detect it for you. */
// $ldapservers->SetValue($i,'server','base',array('')); // $servers->setValue('server','base',array(''));
/* Four options for auth_type: /* Four options for auth_type:
1. 'cookie': you will login via a web form, and a client-side cookie will 1. 'cookie': you will login via a web form, and a client-side cookie will
@ -189,23 +265,23 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
your situation. If you choose 'cookie', your cookie contents will be your situation. If you choose 'cookie', your cookie contents will be
encrypted using blowfish and the secret your specify above as encrypted using blowfish and the secret your specify above as
session['blowfish']. */ session['blowfish']. */
// $ldapservers->SetValue($i,'server','auth_type','cookie'); // $servers->setValue('login','auth_type','session');
/* The DN of the user for phpLDAPadmin to bind with. For anonymous binds or /* The DN of the user for phpLDAPadmin to bind with. For anonymous binds or
'cookie' or 'session' auth_types, LEAVE THE LOGIN_DN AND LOGIN_PASS BLANK. If 'cookie' or 'session' auth_types, LEAVE THE LOGIN_DN AND LOGIN_PASS BLANK. If
you specify a login_attr in conjunction with a cookie or session auth_type, you specify a login_attr in conjunction with a cookie or session auth_type,
then you can also specify the login_dn/login_pass here for searching the then you can also specify the login_dn/login_pass here for searching the
directory for users (ie, if your LDAP server does not allow anonymous binds. */ directory for users (ie, if your LDAP server does not allow anonymous binds. */
// $ldapservers->SetValue($i,'login','dn',''); // $servers->setValue('login','bind_id','');
# $ldapservers->SetValue($i,'login','dn','cn=Manager,dc=example,dc=com'); # $servers->setValue('login','bind_id','cn=Manager,dc=example,dc=com');
/* Your LDAP password. If you specified an empty login_dn above, this MUST also /* Your LDAP password. If you specified an empty login_dn above, this MUST also
be blank. */ be blank. */
// $ldapservers->SetValue($i,'login','pass',''); // $servers->setValue('login','bind_pass','');
# $ldapservers->SetValue($i,'login','pass','secret'); # $servers->setValue('login','bind_pass','secret');
/* Use TLS (Transport Layer Security) to connect to the LDAP server. */ /* Use TLS (Transport Layer Security) to connect to the LDAP server. */
// $ldapservers->SetValue($i,'server','tls',false); // $servers->setValue('server','tls',false);
/************************************ /************************************
* SASL Authentication * * SASL Authentication *
@ -214,19 +290,19 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
/* Enable SASL authentication LDAP SASL authentication requires PHP 5.x /* Enable SASL authentication LDAP SASL authentication requires PHP 5.x
configured with --with-ldap-sasl=DIR. If this option is disabled (ie, set to configured with --with-ldap-sasl=DIR. If this option is disabled (ie, set to
false), then all other sasl options are ignored. */ false), then all other sasl options are ignored. */
// $ldapservers->SetValue($i,'server','sasl_auth',false); // $servers->setValue('server','sasl_auth',false);
/* SASL auth mechanism */ /* SASL auth mechanism */
// $ldapservers->SetValue($i,'server','sasl_mech','PLAIN'); // $servers->setValue('server','sasl_mech','PLAIN');
/* SASL authentication realm name */ /* SASL authentication realm name */
// $ldapservers->SetValue($i,'server','sasl_realm',''); // $servers->setValue('server','sasl_realm','');
# $ldapservers->SetValue($i,'server','sasl_realm',"example.com"); # $servers->setValue('server','sasl_realm','example.com');
/* SASL authorization ID name /* SASL authorization ID name
If this option is undefined, authorization id will be computed from bind DN, If this option is undefined, authorization id will be computed from bind DN,
using sasl_authz_id_regex and sasl_authz_id_replacement. */ using sasl_authz_id_regex and sasl_authz_id_replacement. */
// $ldapservers->SetValue($i,'server','sasl_authz_id', null); // $servers->setValue('server','sasl_authz_id', null);
/* SASL authorization id regex and replacement /* SASL authorization id regex and replacement
When sasl_authz_id property is not set (default), phpLDAPAdmin will try to When sasl_authz_id property is not set (default), phpLDAPAdmin will try to
@ -241,24 +317,19 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
For info about pcre regexes, see: For info about pcre regexes, see:
- pcre(3), perlre(3) - pcre(3), perlre(3)
- http://www.php.net/preg_replace */ - http://www.php.net/preg_replace */
// $ldapservers->SetValue($i,'server','sasl_authz_id_regex',null); // $servers->setValue('server','sasl_authz_id_regex',null);
// $ldapservers->SetValue($i,'server','sasl_authz_id_replacement',null); // $servers->setValue('server','sasl_authz_id_replacement',null);
# $ldapservers->SetValue($i,'server','sasl_authz_id_regex','/^uid=([^,]+)(.+)/i'); # $servers->setValue('server','sasl_authz_id_regex','/^uid=([^,]+)(.+)/i');
# $ldapservers->SetValue($i,'server','sasl_authz_id_replacement','$1'); # $servers->setValue('server','sasl_authz_id_replacement','$1');
/* SASL auth security props. /* SASL auth security props.
See http://beepcore-tcl.sourceforge.net/tclsasl.html#anchor5 for explanation. See http://beepcore-tcl.sourceforge.net/tclsasl.html#anchor5 for explanation.
*/ */
// $ldapservers->SetValue($i,'server','sasl_props',null); // $servers->setValue('server','sasl_props',null);
/* If the link between your web server and this LDAP server is slow, it is
recommended that you set 'low_bandwidth' to true. This will enable
phpLDAPadmin to forego some "fancy" features to conserve bandwidth. */
// $ldapservers->SetValue($i,'server','low_bandwidth',false);
/* Default password hashing algorithm. One of md5, ssha, sha, md5crpyt, smd5, /* Default password hashing algorithm. One of md5, ssha, sha, md5crpyt, smd5,
blowfish, crypt or leave blank for now default algorithm. */ blowfish, crypt or leave blank for now default algorithm. */
// $ldapservers->SetValue($i,'appearance','password_hash','md5'); // $servers->setValue('appearance','password_hash','md5');
/* If you specified 'cookie' or 'session' as the auth_type above, you can /* If you specified 'cookie' or 'session' as the auth_type above, you can
optionally specify here an attribute to use when logging in. If you enter optionally specify here an attribute to use when logging in. If you enter
@ -269,7 +340,7 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
DN to use when searching in 'login_dn' and 'login_pass' above. You may also DN to use when searching in 'login_dn' and 'login_pass' above. You may also
specify 'string', in which case you can provide a string to use for logging specify 'string', in which case you can provide a string to use for logging
users in. See 'login_string' directly below. */ users in. See 'login_string' directly below. */
// $ldapservers->SetValue($i,'login','attr','dn'); // $servers->setValue('login','attr','dn');
/* If you specified something different from 'dn', for example 'uid', as the /* If you specified something different from 'dn', for example 'uid', as the
login_attr above, you can optionally specify here to fall back to login_attr above, you can optionally specify here to fall back to
@ -278,7 +349,7 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
the ldap administrator wants to log in with his root-dn, that does not the ldap administrator wants to log in with his root-dn, that does not
necessarily have the uid attribute. necessarily have the uid attribute.
When using this feature, login_class is ignored. */ When using this feature, login_class is ignored. */
// $ldapservers->SetValue($i,'login','fallback_dn',false); // $servers->setValue('login','fallback_dn',false);
/* If you specified 'cookie' or 'session' as the auth_type above, and you /* If you specified 'cookie' or 'session' as the auth_type above, and you
specified 'string' for 'login_attr' above, you must provide a string here for specified 'string' for 'login_attr' above, you must provide a string here for
@ -286,24 +357,24 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
"uid=dsmith,ou=People,dc=example,dc=com", then I can specify a string "uid=dsmith,ou=People,dc=example,dc=com", then I can specify a string
"uid=<username>,ou=People,dc=example,dc=com" and my users can login with "uid=<username>,ou=People,dc=example,dc=com" and my users can login with
their user names alone, ie: "dsmith" in this case. */ their user names alone, ie: "dsmith" in this case. */
# $ldapservers->SetValue($i,'login','string','uid=<username>,ou=People,dc=example,dc=com'); # $servers->setValue('login','string','uid=<username>,ou=People,dc=example,dc=com');
/* If 'login_attr' is used above such that phpLDAPadmin will search for your DN /* If 'login_attr' is used above such that phpLDAPadmin will search for your DN
at login, you may restrict the search to a specific objectClass. EG, set this at login, you may restrict the search to a specific objectClass. EG, set this
to 'posixAccount' or 'inetOrgPerson', depending upon your setup. */ to 'posixAccount' or 'inetOrgPerson', depending upon your setup. */
// $ldapservers->SetValue($i,'login','class',null); // $servers->setValue('login','class',null);
/* Specify true If you want phpLDAPadmin to not display or permit any /* Specify true If you want phpLDAPadmin to not display or permit any
modification to the LDAP server. */ modification to the LDAP server. */
// $ldapservers->SetValue($i,'server','read_only',false); // $servers->setValue('server','read_only',false);
/* Specify false if you do not want phpLDAPadmin to draw the 'Create new' links /* Specify false if you do not want phpLDAPadmin to draw the 'Create new' links
in the tree viewer. */ in the tree viewer. */
// $ldapservers->SetValue($i,'appearance','show_create',true); // $servers->setValue('appearance','show_create',true);
/* This feature allows phpLDAPadmin to automatically determine the next /* This feature allows phpLDAPadmin to automatically determine the next
available uidNumber for a new entry. */ available uidNumber for a new entry. */
// $ldapservers->SetValue($i,'auto_number','enable',true); // $servers->setValue('auto_number','enable',true);
/* The mechanism to use when finding the next available uidNumber. Two possible /* The mechanism to use when finding the next available uidNumber. Two possible
values: 'uidpool' or 'search'. values: 'uidpool' or 'search'.
@ -311,75 +382,62 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
blindly lookup the next available uidNumber. The 'search' mechanism searches blindly lookup the next available uidNumber. The 'search' mechanism searches
for entries with a uidNumber value and finds the first available uidNumber for entries with a uidNumber value and finds the first available uidNumber
(slower). */ (slower). */
// $ldapservers->SetValue($i,'auto_number','mechanism','search'); // $servers->setValue('auto_number','mechanism','search');
/* The DN of the search base when the 'search' mechanism is used above. */ /* The DN of the search base when the 'search' mechanism is used above. */
# $ldapservers->SetValue($i,'auto_number','search_base','ou=People,dc=example,dc=com'); # $servers->setValue('auto_number','search_base','ou=People,dc=example,dc=com');
/* The minimum number to use when searching for the next available UID number /* The minimum number to use when searching for the next available number
(only when 'search' is used for auto_uid_number_mechanism' */ (only when 'search' is used for auto_number */
// $ldapservers->SetValue($i,'auto_number','min',1000); // $servers->setValue('auto_number','min',array('uidNumber'=>1000,'gidNumber'=>500));
/* The DN of the uidPool entry when 'uidpool' mechanism is used above. */
// $ldapservers->SetValue($i,'auto_number','uidpool_dn','cn=uidPool,dc=example,dc=com');
/* If you set this, then phpldapadmin will bind to LDAP with this user ID when /* If you set this, then phpldapadmin will bind to LDAP with this user ID when
searching for the uidnumber. The idea is, this user id would have full searching for the uidnumber. The idea is, this user id would have full
(readonly) access to uidnumber in your ldap directory (the logged in user (readonly) access to uidnumber in your ldap directory (the logged in user
may not), so that you can be guaranteed to get a unique uidnumber for your may not), so that you can be guaranteed to get a unique uidnumber for your
directory. */ directory. */
// $ldapservers->SetValue($i,'auto_number','dn',null); // $servers->setValue('auto_number','dn',null);
/* The password for the dn above. */ /* The password for the dn above. */
// $ldapservers->SetValue($i,'auto_number','pass',null); // $servers->setValue('auto_number','pass',null);
/* Enable anonymous bind login. */ /* Enable anonymous bind login. */
// $ldapservers->SetValue($i,'login','anon_bind',true); // $servers->setValue('login','anon_bind',true);
/* Use customized page with prefix when available. */ /* Use customized page with prefix when available. */
# $ldapservers->SetValue($i,'custom','pages_prefix','custom_'); # $servers->setValue('custom','pages_prefix','custom_');
/* If you set this, then phpldapadmin will bind to LDAP with this user when
testing for unique attributes (as set in unique_attrs array). If you want to
enforce unique attributes, than this id should have full (readonly) access
to the attributes in question (the logged in user may not have enough access)
*/
// $ldapservers->SetValue($i,'unique_attrs','dn',null);
/* The password for the dn above */
// $ldapservers->SetValue($i,'unique_attrs','pass',null);
/* If you set this, then only these DNs are allowed to log in. This array can /* If you set this, then only these DNs are allowed to log in. This array can
contain individual users, groups or ldap search filter(s). Keep in mind that contain individual users, groups or ldap search filter(s). Keep in mind that
the user has not authenticated yet, so this will be an anonymous search to the user has not authenticated yet, so this will be an anonymous search to
the LDAP server, so make your ACLs allow these searches to return results! */ the LDAP server, so make your ACLs allow these searches to return results! */
# $ldapservers->SetValue($i,'login','allowed_dns',array( # $servers->setValue('login','allowed_dns',array(
# 'uid=stran,ou=People,dc=example,dc=com', # 'uid=stran,ou=People,dc=example,dc=com',
# '(&(gidNumber=811)(objectClass=groupOfNames))', # '(&(gidNumber=811)(objectClass=groupOfNames))',
# '(|(uidNumber=200)(uidNumber=201))', # '(|(uidNumber=200)(uidNumber=201))',
# 'cn=callcenter,ou=Group,dc=example,dc=com')); # 'cn=callcenter,ou=Group,dc=example,dc=com'));
/* Set this if you dont want this LDAP server to show in the tree */ /* Set this if you dont want this LDAP server to show in the tree */
// $ldapservers->SetValue($i,'appearance','visible',true); // $servers->setValue('server','visible',true);
/* This is the time out value in minutes for the server. After as many minutes /* This is the time out value in minutes for the server. After as many minutes
of inactivity you will be automatically logged out. If not set, the default of inactivity you will be automatically logged out. If not set, the default
value will be ( session_cache_expire()-1 ) */ value will be ( session_cache_expire()-1 ) */
# $ldapservers->SetValue($i,'login','timeout',30); # $servers->setValue('login','timeout',30);
/* Set this if you want phpldapadmin to perform rename operation on entry which /* Set this if you want phpldapadmin to perform rename operation on entry which
has children. Certain servers are known to allow it, certain are not */ has children. Certain servers are known to allow it, certain are not */
// $ldapservers->SetValue($i,'server','branch_rename',false); // $servers->setValue('server','branch_rename',false);
/* If you set this, then phpldapadmin will show these attributes as /* If you set this, then phpldapadmin will show these attributes as
internal attributes, even if they are not defined in your schema. */ internal attributes, even if they are not defined in your schema. */
// $ldapservers->SetValue($i,'server','custom_sys_attrs',array('')); // $servers->setValue('server','custom_sys_attrs',array(''));
# $ldapservers->SetValue($i,'server','custom_sys_attrs',array('passwordExpirationTime','passwordAllowChangeTime')); # $servers->setValue('server','custom_sys_attrs',array('passwordExpirationTime','passwordAllowChangeTime'));
/* If you set this, then phpldapadmin will show these attributes on /* If you set this, then phpldapadmin will show these attributes on
objects, even if they are not defined in your schema. */ objects, even if they are not defined in your schema. */
// $ldapservers->SetValue($i,'server','custom_attrs',array('')); // $servers->setValue('server','custom_attrs',array(''));
# $ldapservers->SetValue($i,'server','custom_attrs',array('nsRoleDN','nsRole','nsAccountLock')); # $servers->setValue('server','custom_attrs',array('nsRoleDN','nsRole','nsAccountLock'));
/* These attributes will be forced to MAY attributes and become option in the /* These attributes will be forced to MAY attributes and become option in the
templates. If they are not defined in the templates, then they wont appear templates. If they are not defined in the templates, then they wont appear
@ -387,8 +445,27 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
server may automatically calculate a default value. server may automatically calculate a default value.
In Fedora Directory Server using the DNA Plugin one could ignore uidNumber, In Fedora Directory Server using the DNA Plugin one could ignore uidNumber,
gidNumber and sambaSID. */ gidNumber and sambaSID. */
// $ldapservers->SetValue($i,'force_may','attrs',array('')); // $servers->setValue('force_may','attrs',array(''));
# $ldapservers->SetValue($i,'force_may','attrs',array('uidNumber','gidNumber','sambaSID')); # $servers->setValue('force_may','attrs',array('uidNumber','gidNumber','sambaSID'));
/*********************************************/
/* Unique attributes */
/*********************************************/
/* You may want phpLDAPadmin to enforce some attributes to have unique values
(ie: not belong to other entries in your tree. This (together with
'unique','dn' and 'unique','pass' option will not let updates to
occur with other attributes have the same value. */
# $servers->setValue('unique','attrs',array('mail','uid','uidNumber'));
/* If you set this, then phpldapadmin will bind to LDAP with this user ID when
searching for attribute uniqueness. The idea is, this user id would have full
(readonly) access to your ldap directory (the logged in user may not), so
that you can be guaranteed to get a unique uidnumber for your directory. */
// $servers->setValue('unique','dn',null);
/* The password for the dn above. */
// $servers->setValue('unique','pass',null);
/************************************************************************** /**************************************************************************
* If you want to configure additional LDAP servers, do so below. * * If you want to configure additional LDAP servers, do so below. *
@ -397,172 +474,50 @@ $ldapservers->SetValue($i,'server','name','My LDAP Server');
**************************************************************************/ **************************************************************************/
/* /*
$i++; $servers->setValue('server','name','LDAP Server');
$ldapservers->SetValue($i,'server','name','LDAP Server'); $servers->setValue('server','host','127.0.0.1');
$ldapservers->SetValue($i,'server','host','127.0.0.1'); $servers->setValue('server','port',389);
$ldapservers->SetValue($i,'server','port',389); $servers->setValue('server','base',array(''));
$ldapservers->SetValue($i,'server','base',array('')); $servers->setValue('login','auth_type','cookie');
$ldapservers->SetValue($i,'server','auth_type','cookie'); $servers->setValue('login','bind_id','');
$ldapservers->SetValue($i,'login','dn',''); $servers->setValue('login','bind_pass','');
$ldapservers->SetValue($i,'login','pass',''); $servers->setValue('server','tls',false);
$ldapservers->SetValue($i,'server','tls',false);
$ldapservers->SetValue($i,'server','low_bandwidth',false);
$ldapservers->SetValue($i,'appearance','password_hash','md5');
$ldapservers->SetValue($i,'login','attr','dn');
$ldapservers->SetValue($i,'login','string',null);
$ldapservers->SetValue($i,'login','class',null);
$ldapservers->SetValue($i,'server','read_only',false);
$ldapservers->SetValue($i,'appearance','show_create',true);
$ldapservers->SetValue($i,'auto_number','enable',true);
$ldapservers->SetValue($i,'auto_number','mechanism','search');
$ldapservers->SetValue($i,'auto_number','search_base',null);
$ldapservers->SetValue($i,'auto_number','min',1000);
$ldapservers->SetValue($i,'auto_number','dn',null);
$ldapservers->SetValue($i,'auto_number','pass',null);
$ldapservers->SetValue($i,'login','anon_bind',true);
$ldapservers->SetValue($i,'custom','pages_prefix','custom_');
$ldapservers->SetValue($i,'unique_attrs','dn',null);
$ldapservers->SetValue($i,'unique_attrs','pass',null);
# SASL auth # SASL auth
$ldapservers->SetValue($i,'server','sasl_auth',true); $servers->setValue('server','sasl_auth',true);
$ldapservers->SetValue($i,'server','sasl_mech','PLAIN'); $servers->setValue('server','sasl_mech','PLAIN');
$ldapservers->SetValue($i,'server','sasl_realm','EXAMPLE.COM'); $servers->setValue('server','sasl_realm','EXAMPLE.COM');
$ldapservers->SetValue($i,'server','sasl_authz_id',null); $servers->setValue('server','sasl_authz_id',null);
$ldapservers->SetValue($i,'server','sasl_authz_id_regex','/^uid=([^,]+)(.+)/i'); $servers->setValue('server','sasl_authz_id_regex','/^uid=([^,]+)(.+)/i');
$ldapservers->SetValue($i,'server','sasl_authz_id_replacement','$1'); $servers->setValue('server','sasl_authz_id_replacement','$1');
$ldapservers->SetValue($i,'server','sasl_props',null); $servers->setValue('server','sasl_props',null);
$servers->setValue('appearance','password_hash','md5');
$servers->setValue('login','attr','dn');
$servers->setValue('login','fallback_dn',false);
$servers->setValue('login','string',null);
$servers->setValue('login','class',null);
$servers->setValue('server','read_only',false);
$servers->setValue('appearance','show_create',true);
$servers->setValue('auto_number','enable',true);
$servers->setValue('auto_number','mechanism','search');
$servers->setValue('auto_number','search_base',null);
$servers->setValue('auto_number','min',array('uidNumber'=>1000,'gidNumber'=>500));
$servers->setValue('auto_number','dn',null);
$servers->setValue('auto_number','pass',null);
$servers->setValue('login','anon_bind',true);
$servers->setValue('custom','pages_prefix','custom_');
$servers->setValue('unique','attrs',array('mail','uid','uidNumber'));
$servers->setValue('unique','dn',null);
$servers->setValue('unique','pass',null);
$servers->setValue('server','visible',true);
$servers->setValue('login','timeout',30);
$servers->setValue('server','branch_rename',false);
$servers->setValue('server','custom_sys_attrs',array('passwordExpirationTime','passwordAllowChangeTime'));
$servers->setValue('server','custom_attrs',array('nsRoleDN','nsRole','nsAccountLock'));
$servers->setValue('force_may','attrs',array('uidNumber','gidNumber','sambaSID'));
*/ */
/*********************************************/
/* User-friendly attribute translation */
/*********************************************/
/* Use this array to map attribute names to user friendly names. For example, if
you don't want to see "facsimileTelephoneNumber" but rather "Fax". */
$friendly_attrs = array();
$friendly_attrs['facsimileTelephoneNumber'] = 'Fax';
$friendly_attrs['telephoneNumber'] = 'Phone';
$friendly_attrs['uid'] = 'User Name';
/*********************************************/
/* Support for attrs display order */
/*********************************************/
/* Use this array if you want to have your attributes displayed in a specific
order. You can use default attribute names or their fridenly names.
For example, "sn" will be displayed right after "givenName". All the other
attributes that are not specified in this array will be displayed after in
alphabetical order. */
# $attrs_display_order = array(
# 'givenName',
# 'sn',
# 'cn',
# 'displayName',
# 'uid',
# 'uidNumber',
# 'gidNumber',
# 'homeDirectory',
# 'mail',
# 'userPassword'
# );
/*********************************************/
/* Hidden attributes */
/*********************************************/
/* You may want to hide certain attributes from being displayed in the editor
screen. Do this by adding the desired attributes to this list (and uncomment
it). This only affects the editor screen. Attributes will still be visible in
the schema browser and elsewhere. An example is provided below:
NOTE: The user must be able to read the hidden_except_dn entry to be
excluded. */
# $hidden_attrs = array( 'jpegPhoto', 'objectClass' );
# $hidden_except_dn = "cn=PLA UnHide,ou=Groups,c=AU";
/* Hidden attributes in read-only mode. If undefined, it will be equal to
$hidden_attrs. */
# $hidden_attrs_ro = array(
# 'objectClass','shadowWarning', 'shadowLastChange', 'shadowMax',
# 'shadowFlag', 'shadowInactive', 'shadowMin', 'shadowExpire');
/** **/
/** Read-only attributes **/
/** **/
/* You may want to phpLDAPadmin to display certain attributes as read only,
meaning that users will not be presented a form for modifying those
attributes, and they will not be allowed to be modified on the "back-end"
either. You may configure this list here:
NOTE: The user must be able to read the read_only_except_dn entry to be
excluded. */
# $read_only_attrs = array( 'objectClass' );
# $read_only_except_dn = "cn=PLA ReadWrite,ou=Groups,c=AU";
/* An example of how to specify multiple read-only attributes: */
# $read_only_attrs = array( 'jpegPhoto', 'objectClass', 'someAttribute' );
/*********************************************/
/* Unique attributes */
/*********************************************/
/* You may want phpLDAPadmin to enforce some attributes to have unique values
(ie: not belong to other entries in your tree. This (together with
unique_attrs['dn'] and unique_attrs['pass'] option will not let updates to
occur with other attributes have the same value.
NOTE: Currently the unique_attrs is NOT enforced when copying a dn. (Need to
present a user with the option of changing the unique attributes. */
# $unique_attrs = array('uid','uidNumber','mail');
/*********************************************/
/* Group attributes */
/*********************************************/
/* Add "modify group members" link to the attribute. */
// $config->custom->modify_member['groupattr'] = array('member','uniqueMember','memberUid');
/* Configure filter for member search. This only applies to "modify group members" feature */
// $config->custom->modify_member['filter'] = '(objectclass=Person)';
/* Attribute that is added to the group member attribute. */
// $config->custom->modify_member['attr'] = 'dn';
/*********************************************/
/* Predefined Queries (canned views) */
/*********************************************/
/* To make searching easier, you may setup predefined queries below: */
$q=0;
$queries = array();
/* The name that will appear in the simple search form */
$queries[$q]['name'] = 'User List';
/* The base to search on */
$queries[$q]['base'] = 'dc=example,dc=com';
/* The search scope (sub, base, one) */
$queries[$q]['scope'] = 'sub';
/* The LDAP filter to use */
$queries[$q]['filter'] = '(&(objectClass=posixAccount)(uid=*))';
/* The attributes to return */
$queries[$q]['attributes'] = 'cn, uid, homeDirectory, telephonenumber, jpegphoto';
/* If you want to configure more pre-defined queries, copy and paste the above (including the "$q++;") */
$q++;
$queries[$q]['name'] = 'Samba Users';
$queries[$q]['base'] = 'dc=example,dc=com';
$queries[$q]['scope'] = 'sub';
$queries[$q]['filter'] = '(&(|(objectClass=sambaAccount)(objectClass=sambaSamAccount))(objectClass=posixAccount)(!(uid=*$)))';
$queries[$q]['attributes'] = 'uid, smbHome, uidNumber';
$q++;
$queries[$q]['name'] = 'Samba Computers';
$queries[$q]['base'] = 'dc=example,dc=com';
$queries[$q]['scope'] = 'sub';
$queries[$q]['filter'] = '(&(objectClass=sambaAccount)(uid=*$))';
$queries[$q]['attributes'] = 'uid, homeDirectory';
?> ?>

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
for i in $(grep directory phpldapadmin-demo.conf|awk '{print $2}'); do for i in $(grep directory phpldapadmin-demo.conf|awk '{print $2}'); do
rm -f $i/*dbb $i/alock $i/log.* rm -f $i/*.dbb $i/*.bdb $i/__db.??? $i/alock $i/log.*
done done
slapadd -b "dc=example.com" -l ldif-example.com slapadd -b "dc=example.com" -l ldif-example.com

View File

@ -1,19 +1,27 @@
include /etc/openldap/schema/uidpool.schema
TLSCACertificateFile /etc/openldap/pla/ca-bundle.crt TLSCACertificateFile /etc/openldap/pla/ca-bundle.crt
TLSCertificateFile /etc/openldap/pla/slapd.crt TLSCertificateFile /etc/openldap/pla/slapd.crt
TLSCertificateKeyFile /etc/openldap/pla/slapd.key TLSCertificateKeyFile /etc/openldap/pla/slapd.key
access to dn.regex="o=Simpsons$" attrs=userpassword
by anonymous auth
by self write
by * none
access to dn.base="" by * read
access to dn.regex="dc=example.com$" access to dn.regex="dc=example.com$"
by * write by * write
access to dn.regex="dc=example,dc=com$" access to dn.regex="dc=example,dc=com$"
by * write by * write
access to dn.regex="o=Simpsons$" access to dn.regex="o=Simpsons$"
by self write by self write
by dn.regex="cn=.*,ou=People,o=Simpsons" write by dn.regex="cn=.*,ou=Pets,o=Simpsons" write
by * read by * read
access to * access to *
by * read by * read
database ldbm database bdb
suffix "dc=example.com" suffix "dc=example.com"
rootdn "cn=Manager,dc=example.com" rootdn "cn=Manager,dc=example.com"
rootpw NotAllowed rootpw NotAllowed
@ -28,7 +36,7 @@ index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub index nisMapName,nisMapEntry eq,pres,sub
database ldbm database bdb
suffix "dc=example,dc=com" suffix "dc=example,dc=com"
rootdn "cn=Manager,dc=example,dc=com" rootdn "cn=Manager,dc=example,dc=com"
rootpw NotAllowed rootpw NotAllowed
@ -43,7 +51,7 @@ index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub index nisMapName,nisMapEntry eq,pres,sub
database ldbm database bdb
suffix "o=Simpsons" suffix "o=Simpsons"
rootdn "cn=Manager,o=Simpsons" rootdn "cn=Manager,o=Simpsons"
rootpw NotAllowed rootpw NotAllowed
@ -57,3 +65,11 @@ index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub index nisMapName,nisMapEntry eq,pres,sub
database monitor
access to * by * read
database config
access to * by * read
rootdn cn=admin,cn=config
rootpw password

View File

@ -1,4 +1,4 @@
# $Header: /cvsroot/phpldapadmin/phpldapadmin/doc/pla-test-i18n.ldif,v 1.4 2004/03/19 20:22:54 i18phpldapadmin Exp $ # $Header$
# This is a Test-File for characters / encoding # This is a Test-File for characters / encoding
# 1. Change the # 1. Change the
# ,dc=example,dc=com # ,dc=example,dc=com

404
hooks/functions/example.php Normal file
View File

@ -0,0 +1,404 @@
<?php
// $Header$
/**
* 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');
?>

View File

@ -1,167 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr.php,v 1.20.2.2 2008/12/12 12:20:22 wurley Exp $
/**
* Adds an attribute/value pair to an object
*
* Variables that come in as POST vars:
* - dn
* - attr
* - val
* - binary
*
* @package phpLDAPadmin
* @todo: For boolean attributes, convert the response to TRUE/FALSE.
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute')),'error','index.php');
$entry = array();
$entry['val'] = get_request('val','POST');
$entry['binary'] = get_request('binary','POST');
$entry['dn']['string'] = get_request('dn','POST');
$entry['dn']['encode'] = rawurlencode($entry['dn']['string']);
$entry['attr']['string'] = get_request('attr','POST');
$entry['attr']['encode'] = rawurlencode($entry['attr']['string']);
if ((strlen($entry['binary']) <= 0) && (strlen($entry['val']) <= 0))
error(_('You left the attribute value blank. Please go back and try again.'),'error','index.php');
/*
* Special case for binary attributes (like jpegPhoto and userCertificate):
* we must go read the data from the file and override $val with the binary data
* Secondly, we must check if the ";binary" option has to be appended to the name
* of the attribute.
*/
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($entry['dn']['string'],$entry['attr']['string'],array($entry['val']))) {
$href = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&form=advanced&server_id=%s&filter=%s=%s',
$ldapserver->server_id,$entry['attr']['string'],$badattr));
error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$entry['attr']['string'],$badattr,$entry['dn']['string'],$href),'error','index.php');
}
if (strlen($entry['binary']) > 0) {
if ($_FILES['val']['size'] == 0)
error(_('The file you chose is either empty or does not exist. Please go back and try again.'),'error','index.php');
if (! is_uploaded_file($_FILES['val']['tmp_name'])) {
if (isset($_FILES['val']['error']))
switch($_FILES['val']['error']) {
case 0: # No error; possible file attack!
error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
break;
case 1: # Uploaded file exceeds the upload_max_filesize directive in php.ini
error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'),'error','index.php');
break;
case 2: # Uploaded file exceeds the MAX_FILE_SIZE directive specified in the html form
error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'),'error','index.php');
break;
case 3: # Uploaded file was only partially uploaded
error(_('The file you selected was only partially uploaded, likley due to a network error.'),'error','index.php');
break;
case 4: # No file was uploaded
error(_('You left the attribute value blank. Please go back and try again.'),'error','index.php');
break;
default: # A default error, just in case! :)
error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
break;
}
else
error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
}
$binaryfile['name'] = $_FILES['val']['tmp_name'];
$binaryfile['handle'] = fopen($binaryfile['name'],'r');
$binaryfile['data'] = fread($binaryfile['handle'],filesize($binaryfile['name']));
fclose($binaryfile['handle']);
$entry['val'] = $binaryfile['data'];
if (is_binary_option_required($ldapserver,$entry['attr']['string']))
$entry['attr']['string'] .= ';binary';
}
/* Automagically hash new userPassword attributes according to the
chosen in config.php. */
if (strcasecmp($entry['attr']['string'],'userpassword') == 0) {
if (trim($ldapserver->default_hash) != '' ) {
$enc_type = $ldapserver->default_hash;
$entry['val'] = password_hash($entry['val'],$enc_type);
}
} elseif (strcasecmp($entry['attr']['string'],'sambaNTPassword') == 0) {
$sambapassword = new smbHash;
$entry['val'] = $sambapassword->nthash($entry['val']);
} elseif (strcasecmp($entry['attr']['string'],'sambaLMPassword') == 0) {
$sambapassword = new smbHash;
$entry['val'] = $sambapassword->lmhash($entry['val']);
}
$new_entry = array($entry['attr']['string'] => $entry['val']);
$result = $ldapserver->attrModify($entry['dn']['string'],$new_entry);
if ($result) {
header(sprintf('Location: cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=%s',
$ldapserver->server_id,$entry['dn']['encode'],$entry['attr']['encode']));
die();
} else {
system_message(array(
'title'=>_('Failed to add the attribute.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
}
/**
* Check if we need to append the ;binary option to the name
* of some binary attribute
*
* @param object $ldapserver Server Object that the attribute is in.
* @param attr $attr Attribute to test to see if it requires ;binary added to it.
* @return bool
*/
function is_binary_option_required($ldapserver,$attr) {
# List of the binary attributes which need the ";binary" option
$binary_attributes_with_options = array(
# Superior: Ldapv3 Syntaxes (1.3.6.1.4.1.1466.115.121.1)
'1.3.6.1.4.1.1466.115.121.1.8' => 'userCertificate',
'1.3.6.1.4.1.1466.115.121.1.8' => 'caCertificate',
'1.3.6.1.4.1.1466.115.121.1.10' => 'crossCertificatePair',
'1.3.6.1.4.1.1466.115.121.1.9' => 'certificateRevocationList',
'1.3.6.1.4.1.1466.115.121.1.9' => 'authorityRevocationList',
# Superior: Netscape Ldap attributes types (2.16.840.1.113730.3.1)
'2.16.840.1.113730.3.1.40' => 'userSMIMECertificate'
);
$schema_attr = $ldapserver->getSchemaAttribute($attr);
if (! $schema_attr)
return false;
$syntax = $schema_attr->getSyntaxOID();
if (isset($binary_attributes_with_options[$syntax]))
return true;
return false;
}
?>

View File

@ -1,116 +1,90 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr_form.php,v 1.16.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays a form for adding an attribute/value to an LDAP entry. * Displays a form for adding an attribute/value to an LDAP entry.
* *
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
$request['dn'] = get_request('dn','GET');
$entry = array(); # Check if the entry exists.
$entry['dn']['string'] = get_request('dn','GET'); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
$entry['rdn'] = get_rdn($entry['dn']['string']); error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
printf('<h3 class="title">%s <b>%s</b></h3>',_('Add new attribute'),htmlspecialchars($entry['rdn'])); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>', $request['page']->setDN($request['dn']);
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($entry['dn']['string'])); $request['page']->accept(true);
$request['template'] = $request['page']->getTemplate();
$dn = array(); # Render the form
$dn['attrs'] = $ldapserver->getDNAttrs($entry['dn']['string']); if (get_request('meth','REQUEST') != 'ajax') {
$dn['oclasses'] = $ldapserver->getDNAttr($entry['dn']['string'],'objectClass'); $request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Add new attribute'),get_rdn($request['dn'])));
$request['page']->drawSubTitle();
if (! is_array($dn['oclasses'])) echo '<center>';
$dn['oclasses'] = array($dn['oclasses']); if (count($request['template']->getAvailAttrs())) {
# If we have more than the configured entries, we'll separate our input to the old ways.
if (count($request['template']->getAvailAttrs()) > $_SESSION[APPCONFIG]->getValue('appearance','max_add_attrs')) {
$attr = array();
$attr['avail'] = array();
$attr['binary'] = array();
$ldap['attrs']['avail'] = array(); foreach ($request['template']->getAvailAttrs() as $attribute)
if ($app['server']->isAttrBinary($attribute->getName()))
array_push($attr['binary'],$attribute);
else
array_push($attr['avail'],$attribute);
if (array_search('extensibleObject',$dn['oclasses']) !== false) { if (count($attr['avail']) > 0) {
$ldap['attrs']['ldap'] = $ldapserver->SchemaAttributes();
foreach ($ldap['attrs']['ldap'] as $attr)
$ldap['attrs']['avail'][] = $attr->getName();
} else {
$ldap['oclasses'] = $ldapserver->SchemaObjectClasses($entry['dn']['string']);
foreach ($dn['oclasses'] as $oclass) {
$ldap['oclass'] = $ldapserver->getSchemaObjectClass($oclass,$entry['dn']['string']);
if ($ldap['oclass'] && strcasecmp('objectclass',get_class($ldap['oclass'])) == 0)
$ldap['attrs']['avail'] = array_merge($ldap['oclass']->getMustAttrNames($ldap['oclasses']),
$ldap['oclass']->getMayAttrNames($ldap['oclasses']),
$ldap['attrs']['avail']);
}
}
$ldap['attrs']['avail'] = array_unique($ldap['attrs']['avail']);
$ldap['attrs']['avail'] = array_filter($ldap['attrs']['avail'],'not_an_attr');
sort($ldap['attrs']['avail']);
$ldap['binattrs']['avail'] = array();
foreach ($ldap['attrs']['avail'] as $i => $attr) {
if ($ldapserver->isAttrBinary($attr)) {
$ldap['binattrs']['avail'][] = $attr;
unset($ldap['attrs']['avail'][$i]);
}
}
echo '<center>';
if (is_array($ldap['attrs']['avail']) && count($ldap['attrs']['avail']) > 0) {
echo '<br />'; echo '<br />';
echo _('Add new attribute'); echo _('Add new attribute');
echo '<br />'; echo '<br />';
echo '<br />'; echo '<br />';
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="add_attr" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($entry['dn']['string']));
echo '<select name="attr">'; if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />';
else
echo '<input type="hidden" name="cmd" value="update" />';
$attr_select_html = ''; printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
usort($ldap['attrs']['avail'],'sortAttrs'); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
foreach ($ldap['attrs']['avail'] as $a) { echo '<select name="single_item_attr">';
# is there a user-friendly translation available for this attribute? foreach ($attr['avail'] as $attribute) {
if ($_SESSION[APPCONFIG]->haveFriendlyName($a)) { # Is there a user-friendly translation available for this attribute?
$attr_display = sprintf('%s (%s)', if ($attribute->haveFriendlyName())
htmlspecialchars($_SESSION[APPCONFIG]->getFriendlyName($a)), $attr_display = sprintf('%s (%s)',$attribute->getFriendlyName(),$attribute->getName(false));
htmlspecialchars($a)); else
$attr_display = $attribute->getName(false);
} else { printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display);
$attr_display = htmlspecialchars($a);
}
printf('<option value="%s">%s</option>',htmlspecialchars($a),$attr_display);
} }
echo '</select>'; echo '</select>';
echo '<input type="text" name="val" size="20" />'; echo '<input type="text" name="single_item_value" size="20" />';
printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add')); printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add'));
echo '</form>'; echo '</form>';
} else { } else {
echo '<br />'; echo '<br />';
printf('<small>(%s)</small>',_('no new attributes available for this entry')); printf('<small>(%s)</small>',_('no new attributes available for this entry'));
} }
if (count($ldap['binattrs']['avail']) > 0) { if (count($attr['binary']) > 0) {
echo '<br />'; echo '<br />';
echo _('Add new binary attribute'); echo _('Add new binary attribute');
echo '<br />'; echo '<br />';
@ -118,34 +92,31 @@ if (count($ldap['binattrs']['avail']) > 0) {
echo '<!-- Form to add a new BINARY attribute to this entry -->'; echo '<!-- Form to add a new BINARY attribute to this entry -->';
echo '<form action="cmd.php" method="post" enctype="multipart/form-data">'; echo '<form action="cmd.php" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" name="cmd" value="add_attr" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
printf('<input type="hidden" name="dn" value="%s" />',$entry['dn']['string']); 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" />',$request['dn']);
echo '<input type="hidden" name="binary" value="true" />'; echo '<input type="hidden" name="binary" value="true" />';
echo '<select name="attr">'; echo '<select name="single_item_attr">';
$attr_select_html = ''; foreach ($attr['binary'] as $attribute) {
usort($ldap['binattrs']['avail'],'sortAttrs'); # Is there a user-friendly translation available for this attribute?
if ($attribute->haveFriendlyName())
$attr_display = sprintf('%s (%s)',$attribute->getFriendlyName(),$attribute->getName(false));
else
$attr_display = $attribute->getName(false);
foreach ($ldap['binattrs']['avail'] as $a) { printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attr_display);
# is there a user-friendly translation available for this attribute?
if ($_SESSION[APPCONFIG]->haveFriendlyName($a)) {
$attr_display = sprintf('%s (%s)',
htmlspecialchars($_SESSION[APPCONFIG]->getFriendlyName($a)),
htmlspecialchars($a));
} else {
$attr_display = htmlspecialchars($a);
}
printf('<option value="%s">%s</option>',htmlspecialchars($a),$attr_display);
} }
echo '</select>'; echo '</select>';
echo '<input type="file" name="val" size="20" />'; echo '<input type="file" name="single_item_value" size="20" />';
printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add')); printf('<input type="submit" name="submit" value="%s" class="update_dn" />',_('Add'));
if (! ini_get('file_uploads')) if (! ini_get('file_uploads'))
@ -157,28 +128,56 @@ if (count($ldap['binattrs']['avail']) > 0) {
echo '</form>'; echo '</form>';
} else { } else {
echo '<br />'; echo '<br />';
printf('<small>(%s)</small>',_('no new binary attributes available for this entry')); printf('<small>(%s)</small>',_('no new binary attributes available for this entry'));
} }
echo '</center>'; } else {
echo '<br />';
/** $request['page']->drawFormStart();
* Given an attribute $x, this returns true if it is NOT already specified printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
* in the current entry, returns false otherwise. printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
*
* @param attr $x
* @return bool
* @ignore
*/
function not_an_attr($x) {
global $dn;
foreach ($dn['attrs'] as $attr => $values) echo '<table class="entry" cellspacing="0" align="center" border=0>';
if (strcasecmp($attr,$x) == 0)
return false;
return true; foreach ($request['template']->getAvailAttrs() as $attribute)
$request['page']->draw('Template',$attribute);
$request['page']->drawFormSubmitButton();
echo '</table>';
$request['page']->drawFormEnd();
}
} else {
printf('<small>(%s)</small>',_('no new attributes available for this entry'));
}
echo '</center>';
# The ajax addition (it is going into an existing TemplateRendered page
} else {
# Put our DIV there for the callback
echo '<fieldset>';
printf('<legend>%s</legend>',_('Add Attribute'));
echo '<div id="ajADDATTR">';
echo '<table class="entry" cellspacing="0" align="center" border=0>';
echo '<td valign="top" align="center">';
printf('<select name="attr" onChange="displayAJ(\'%s\',\'cmd=add_value_form&server_id=%s&dn=%s&meth=ajax&attr=\'+this.value,\'%s\',\'append\');">',
'ADDATTR',$app['server']->getIndex(),rawurlencode(get_request('dn','REQUEST')),_('Please Wait'));
printf('<option value="%s">%s</option>','','');
foreach ($request['template']->getAvailAttrs() as $attribute)
printf('<option value="%s">%s</option>',htmlspecialchars($attribute->getName()),$attribute->getFriendlyName());
echo '</select>';
echo '</td>';
echo '</table>';
echo '</div>';
echo '</fieldset>';
} }
?> ?>

View File

@ -1,70 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_oclass.php,v 1.19.2.1 2008/12/12 12:20:22 wurley Exp $
/**
* Adds an objectClass to the specified dn.
*
* Note, this does not do any schema violation checking. That is
* performed in add_oclass_form.php.
*
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - new_oclass
* - new_attrs (array, if any)
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
if ($ldapserver->isAttrReadOnly('objectClass'))
error(_('ObjectClasses are flagged as read only in the phpLDAPadmin configuration.'),'error','index.php');
$entry = array();
$entry['dn']['encode'] = get_request('dn');
$entry['dn']['string'] = urldecode($entry['dn']['encode']);
$entry['new']['oclass'] = unserialize(rawurldecode(get_request('new_oclass')));
$entry['new']['attrs'] = get_request('new_attrs');
$new_entry = array();
$new_entry['objectClass'] = $entry['new']['oclass'];
if (is_array($entry['new']['attrs']) && count($entry['new']['attrs']) > 0)
foreach ($entry['new']['attrs'] as $attr => $val) {
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($entry['dn']['string'],$attr,array($val))) {
$href['search'] = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&form=advanced&server_id=%s&filter=%s=%s',
$ldapserver->server_id,$attr,$badattr));
error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$entry['dn']['string'],$href['search']),'error','index.php');
}
$new_entry[$attr] = $val;
}
$result = $ldapserver->attrModify($entry['dn']['string'],$new_entry);
if (! $result)
system_message(array(
'title'=>_('Could not perform ldap_mod_add operation.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
else {
$modified_attrs = array_keys($entry['new']['attrs']);
$modified_attrs[] = 'objectclass';
$href['complete'] = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs=%s',
$ldapserver->server_id,$entry['dn']['encode'],serialize($modified_attrs));
header(sprintf('Location: %s',$href['complete']));
die();
}
?>

View File

@ -1,81 +1,68 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_oclass_form.php,v 1.25.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* This page may simply add the objectClass and take you back to the edit page, * This page will allow the adding of additional ObjectClasses to an item.
* but, in one condition it may prompt the user for input. That condition is this: * + If the ObjectClass to be added requires additional MUST attributes to be
* * defined, then they will be prompted for.
* If the user has requested to add an objectClass that requires a set of * + If the ObjectClass doesnt need any additional MUST attributes, then it
* attributes with 1 or more not defined by the object. In that case, we will * will be silently added to the object.
* present a form for the user to add those attributes to the object.
*
* Variables that come in as REQUEST vars:
* - dn (rawurlencoded)
* - new_oclass
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @todo If an attribute expects a DN, show the dn browser. * @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$entry = array(); # The DN and OBJECTCLASS we are working with.
$entry['oclass']['new'] = get_request('new_oclass','REQUEST'); $request = array();
$entry['dn']['string'] = get_request('dn','REQUEST'); $request['dn'] = get_request('dn','REQUEST',true);
if ($ldapserver->isReadOnly()) # Check if the entry exists.
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
if (! $entry['oclass']['new']) $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
error(_('You did not select any ObjectClasses for this object. Please go back and do so.'),'error','index.php'); $request['page']->setDN($request['dn']);
$request['page']->accept(true);
$request['template'] = $request['page']->getTemplate();
/* Ensure that the object has defined all MUST attrs for this objectClass. $attribute_factory = new AttributeFactory();
* If it hasn't, present a form to have the user enter values for all the
* newly required attrs.
*/
$entry['dn']['attrs'] = $ldapserver->getDNAttrs($entry['dn']['string'],true);
$entry['attrs']['current'] = array();
foreach ($entry['dn']['attrs'] as $attr => $junk)
$entry['attrs']['current'][] = strtolower($attr);
# Grab the required attributes for the new objectClass # Grab the required attributes for the new objectClass
$ldap['oclasses'] = $ldapserver->SchemaObjectClasses(); $ldap = array();
$ldap['attrs']['must'] = array(); $ldap['attrs']['must'] = array();
foreach ($entry['oclass']['new'] as $oclass_name) {
$ldap['oclass'] = $ldapserver->getSchemaObjectClass($oclass_name);
if ($ldap['oclass']) foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
$ldap['attrs']['must'] = array_merge($ldap['attrs']['must'],$ldap['oclass']->getMustAttrNames($ldap['oclasses'])); # 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']); $ldap['attrs']['must'] = array_unique($ldap['attrs']['must']);
/* Build a list of the attributes that this new objectClass requires, /* Build a list of the attributes that this new objectClass requires,
* but that the object does not currently contain * but that the object does not currently contain */
*/
$ldap['attrs']['need'] = array(); $ldap['attrs']['need'] = array();
foreach ($ldap['attrs']['must'] as $attr) { foreach ($ldap['attrs']['must'] as $attr)
$attr = $ldapserver->getSchemaAttribute($attr); if (is_null($request['template']->getAttribute($attr)))
array_push($ldap['attrs']['need'],$attribute_factory->newAttribute($attr,array('values'=>array()),$app['server']->getIndex()));
# First, check if one of this attr's aliases is already an attribute of this entry # Mark all the need attributes as shown
foreach ($attr->getAliases() as $alias_attr_name) foreach ($ldap['attrs']['need'] as $index => $values)
if (in_array(strtolower($alias_attr_name),$entry['attrs']['current'])) $ldap['attrs']['need'][$index]->show();
continue;
if (in_array(strtolower($attr->getName()),$entry['attrs']['current']))
continue;
/* We made it this far, so the attribute needs to be added to this entry in order
* to add this objectClass */
$ldap['attrs']['need'][] = $attr;
}
if (count($ldap['attrs']['need']) > 0) { if (count($ldap['attrs']['need']) > 0) {
printf('<h3 class="title">%s</h3>',_('New Required Attributes')); $request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Add new objectClass to'),get_rdn($request['dn'])));
printf('<h3 class="subtitle">%s %s %s</h3>',_('This action requires you to add'),count($ldap['attrs']['need']),_('new attributes')); $request['page']->drawSubTitle();
echo '<center>';
printf('<small><b>%s: </b>%s <b>%s</b> %s %s</small>', printf('<small><b>%s: </b>%s <b>%s</b> %s %s</small>',
_('Instructions'), _('Instructions'),
_('In order to add these objectClass(es) to this entry, you must specify'), _('In order to add these objectClass(es) to this entry, you must specify'),
@ -84,39 +71,44 @@ if (count($ldap['attrs']['need']) > 0) {
echo '<br /><br />'; echo '<br /><br />';
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post" name="entry_form">';
echo '<input type="hidden" name="cmd" value="add_oclass" />';
printf('<input type="hidden" name="new_oclass" value="%s" />',rawurlencode(serialize($entry['oclass']['new']))); if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
printf('<input type="hidden" name="dn" value="%s" />',rawurlencode($entry['dn']['string'])); echo '<input type="hidden" name="cmd" value="update_confirm" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); 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 '<table class="entry" cellspacing="0">'; echo '<table class="entry" cellspacing="0">';
printf('<tr><th colspan="2">%s</th></tr>',_('New Required Attributes')); printf('<tr><th colspan="2">%s</th></tr>',_('New Required Attributes'));
foreach ($ldap['attrs']['need'] as $count => $attr) { $counter = 0;
printf('<tr><td class="title">%s</td></tr>',htmlspecialchars($attr->getName())); foreach ($request['template']->getAttribute('objectclass')->getValues() as $value) {
printf('<tr><td class="value"><input type="text" name="new_attrs[%s]" value="" size="40" /></td></tr>',htmlspecialchars($attr->getName())); echo '<tr><td colspan=2>';
$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>'; echo '</table>';
echo '<br /><br />'; echo '<br />';
printf('<center><input type="submit" value="%s" /></center>',_('Add ObjectClass and Attributes')); printf('<center><input type="submit" value="%s" /></center>',_('Add ObjectClass and Attributes'));
echo '</form>'; echo '</form>';
echo '</center>';
# There are no other required attributes, so we just need to add the objectclass to the DN.
} else { } else {
$result = $ldapserver->attrModify($entry['dn']['string'],array('objectClass'=>$entry['oclass']['new'])); $result = $app['server']->modify($request['dn'],$request['template']->getLDAPmodify());
if (! $result) if ($result) {
system_message(array( $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=objectclass',
'title'=>_('Could not perform ldap_mod_add operation.'), $app['server']->getIndex(),rawurlencode($request['dn']));
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
else {
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=objectClass',
$ldapserver->server_id,rawurlencode($entry['dn']['string']));
header(sprintf('Location: %s',$href)); header(sprintf('Location: %s',$href));
die(); die();

View File

@ -1,88 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value.php,v 1.21.2.2 2008/12/12 12:20:22 wurley Exp $
/**
* Adds a value to an attribute for a given dn.
*
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
* - new_value (form element)
* - binary
*
* On success, redirect to the edit_dn page. On failure, echo an error.
*
* @package phpLDAPadmin
*/
/**
*/
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute value')),'error','index.php');
# The DN and ATTR we are working with.
$entry = array();
$entry['dn']['encode'] = get_request('dn','POST',true);
$entry['dn']['string'] = rawurldecode($entry['dn']['encode']);
$entry['attr']['encode'] = get_request('attr','POST',true);
$entry['attr']['string'] = rawurldecode($entry['attr']['encode']);
$entry['attr']['html'] = htmlspecialchars($entry['attr']['string']);
$entry['value']['string'] = get_request('new_value','POST',true);
$entry['value']['bin'] = get_request('binary','POST') ? true : false;
if ($ldapserver->isAttrReadOnly($entry['attr']['string']))
error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),$entry['attr']['html']),'error','index.php');
/*
* Special case for binary attributes:
* we must go read the data from the file.
*/
if ($entry['value']['bin']) {
$binaryfile['name'] = $_FILES['new_value']['tmp_name'];
$binaryfile['handle'] = fopen($binaryfile['name'],'r');
$binaryfile['data'] = fread($binaryfile['handle'],filesize($binaryfile['name']));
fclose($binaryfile['handle']);
$entry['value']['string'] = $binaryfile['data'];
}
$new_entry = array($entry['attr']['string']=>$entry['value']['string']);
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($entry['dn']['string'],$entry['attr']['string'],$new_entry)) {
$href = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&form=advanced&server_id=%s&filter=%s=%s',
$ldapserver->server_id,$entry['attr']['string'],$badattr));
error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$entry['attr']['string'],$badattr,$entry['dn']['string'],$href),'error','index.php');
}
# Call the custom callback for each attribute modification and verify that it should be modified.
if (run_hook('pre_attr_add',
array('server_id'=>$ldapserver->server_id,'dn'=> $entry['dn']['string'],'attr_name'=>$entry['attr']['string'],'new_value'=>$new_entry))) {
if (run_hook('pre_attr_modify',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'attr_name'=>$entry['attr']['string'],'new_value'=>$new_entry))) {
$add_result = $ldapserver->attrModify($entry['dn']['string'],$new_entry);
if (! $add_result) {
system_message(array(
'title'=>_('Could not perform ldap_mod_add operation.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
} else {
run_hook('post_attr_modify',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'attr_name'=>$entry['attr']['string'],'new_value'=>$new_entry));
}
}
}
header(sprintf('Location: cmd.php?cmd=template_engine&server_id=%s&dn=%s&modified_attrs[]=%s',
$ldapserver->server_id,$entry['dn']['encode'],$entry['attr']['encode']));
die();
?>

View File

@ -1,153 +1,120 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_value_form.php,v 1.39.2.6 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays a form to allow the user to enter a new value to add * 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. * to the existing list of values for a multi-valued attribute.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
# The DN and ATTR we are working with. # The DN and ATTR we are working with.
$entry = array(); $request = array();
$entry['dn']['encode'] = get_request('dn','GET',true); $request['dn'] = get_request('dn','GET',true);
$entry['dn']['string'] = urldecode($entry['dn']['encode']); $request['attr'] = get_request('attr','GET',true);
$entry['dn']['html'] = htmlspecialchars($entry['dn']['string']);
$entry['attr']['string'] = get_request('attr','GET',true);
$entry['attr']['encode'] = rawurlencode($entry['attr']['string']);
$entry['attr']['html'] = htmlspecialchars($entry['attr']['string']);
if (! is_null($entry['dn']['string'])) # Check if the entry exists.
$entry['rdn']['string'] = get_rdn($entry['dn']['string']); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
else error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
$entry['rdn']['string'] = null;
$entry['rdn']['html'] = htmlspecialchars($entry['rdn']['string']);
/***************/ $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
/* get entry */ $request['page']->setDN($request['dn']);
/***************/ $request['page']->accept(true);
$request['template'] = $request['page']->getTemplate();
if (! $entry['dn']['string'] || ! $ldapserver->dnExists($entry['dn']['string'])) /*
error(sprintf(_('The entry (%s) does not exist.'),$entry['dn']['html']),'error','index.php'); if ($request['attribute']->isReadOnly())
error(sprintf(_('The attribute (%s) is in readonly mode.'),$request['attr']),'error','index.php');
$tree = get_cached_item($ldapserver->server_id,'tree');
$entry['ldap'] = null;
if ($tree) {
$entry['ldap'] = $tree->getEntry($entry['dn']['string']);
if (! $entry['ldap'])
$tree->addEntry($entry['dn']['string']);
$entry['ldap'] = $tree->getEntry($entry['dn']['string']);
}
# Define the template of the entry if possible
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_reader').'($ldapserver);');
$reader->visit('Start', $entry['ldap']);
if (! $entry['ldap'] || $entry['ldap']->isReadOnly())
error(sprintf(_('The entry (%s) is in readonly mode.'),$entry['dn']['html']),'error','index.php');
/*********************/
/* attribute values */
/*********************/
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_writer').'($ldapserver);');
$ldap['attr'] = $entry['ldap']->getAttribute($entry['attr']['string']);
if (!$ldap['attr']) {
# Define a new attribute for the entry
$attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory');
eval('$attribute_factory = new '.$attributefactoryclass.'();');
$ldap['attr'] = $attribute_factory->newAttribute($entry['attr']['string'], array());
$ldap['attr']->setEntry($entry['ldap']);
}
$ldap['count'] = $ldap['attr']->getValueCount();
if ($ldap['attr']->isReadOnly())
error(sprintf(_('The attribute (%s) is in readonly mode.'),$entry['attr']['html']),'error','index.php');
# Check our permissions
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute value')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('add attribute value')),'error','index.php');
if (($ldap['attr']->getValueCount() == 0) && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add')) if (($request['attribute']->getValueCount() == 0) && ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('add attribute')),'error','index.php');
*/
$entry['attr']['oclass'] = (strcasecmp($entry['attr']['string'],'objectClass') == 0) ? true : false; # Render the form
if (get_request('meth','REQUEST') != 'ajax') {
# Render the form.
$request['page']->drawTitle(sprintf('%s <b>%s</b> %s <b>%s</b>',_('Add new'),$request['attr'],_('value to'),get_rdn($request['dn'])));
$request['page']->drawSubTitle();
if ($entry['attr']['oclass']) { if (! strcasecmp($request['attr'],'objectclass')) {
# Fetch all available objectClasses and remove those from the list that are already defined in the entry
$ldap['oclasses'] = $ldapserver->SchemaObjectClasses();
foreach($ldap['attr']->getValues() as $oclass)
unset($ldap['oclasses'][strtolower($oclass)]);
} else {
$ldap['schema'] = $ldapserver->getSchemaAttribute($entry['attr']['string']);
}
printf('<h3 class="title">%s <b>%s</b> %s <b>%s</b></h3>',
_('Add new'),$entry['attr']['html'],_('value to'),$entry['rdn']['html']);
printf('<h3 class="subtitle">%s <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
_('Server'),$ldapserver->name,_('Distinguished Name'),$entry['dn']['html']);
if ($entry['attr']['oclass']) {
echo '<form action="cmd.php" method="post" class="new_value" name="entry_form">'; echo '<form action="cmd.php" method="post" class="new_value" name="entry_form">';
echo '<input type="hidden" name="cmd" value="add_oclass_form" />'; echo '<input type="hidden" name="cmd" value="add_oclass_form" />';
} else {
} else {
echo '<form action="cmd.php" method="post" class="new_value" name="entry_form" enctype="multipart/form-data" onSubmit="return submitForm(this)">'; echo '<form action="cmd.php" method="post" class="new_value" name="entry_form" enctype="multipart/form-data" onSubmit="return submitForm(this)">';
if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />'; echo '<input type="hidden" name="cmd" value="update_confirm" />';
} else
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); echo '<input type="hidden" name="cmd" value="update" />';
printf('<input type="hidden" name="dn" value="%s" />',$entry['dn']['encode']); }
echo '<center>'; printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
echo '<table class="forminput" border=0>'; printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
echo '<tr>';
if ($ldap['count']) { echo '<center>';
printf('<td class="top">%s <b>%s</b> %s <b>%s</b>%s</td>', echo '<table class="forminput" border=0>';
_('Current list of'),$ldap['count'],_('values for attribute'),$ldap['attr']->getFriendlyName(),_(':')); echo '<tr>';
} else {
printf('<td>%s <b>%s</b>.</td>', $request['attribute'] = $request['template']->getAttribute($request['attr']);
_('No current value for attribute'),$ldap['attr']->getFriendlyName()); $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>';
echo '<td>';
if ($ldap['count']) {
# Display current attribute values # Display current attribute values
echo '<table border=0><tr><td>'; echo '<table border=0><tr><td>';
for ($i = 0; $i < $ldap['count']; $i++) { for ($i=0;$i<$request['count'];$i++) {
$writer->draw('OldValue', $ldap['attr'], $i); if ($i > 0)
$writer->draw('ReadOnlyValue', $ldap['attr'], $i); echo '<br/>';
$request['page']->draw('CurrentValue',$request['attribute'],$i);
$request['page']->draw('HiddenValue',$request['attribute'],$i);
} }
echo '</td></tr></table>'; echo '</td></tr></table>';
} else { echo '</td>';
echo '<br /><br />';
}
echo '</td>';
echo '</tr>';
echo '<tr>'; } else {
printf('<td class="top">%s</td>',_('Enter the value you would like to add:')); printf('<td>%s <b>%s</b>.</td>',
echo '<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)]);
if ($entry['attr']['oclass']) {
# Draw objectClass selection # Draw objectClass selection
echo '<table border=0><tr><td>'; echo '<table border=0>';
echo '<select name="new_oclass[]" multiple="true" size="15">'; echo '<tr><td>';
foreach ($ldap['oclasses'] as $name => $oclass) { echo '<select name="new_values[objectclass][]" multiple="true" size="15">';
# exclude any structural ones, as they'll only generate an LDAP_OBJECT_CLASS_VIOLATION foreach ($socs as $name => $oclass) {
if ($oclass->getType() == 'structural') # 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; continue;
printf('<option value="%s">%s</option>',$oclass->getName(),$oclass->getName()); printf('<option value="%s">%s</option>',$oclass->getName(false),$oclass->getName(false));
} }
echo '</select>'; echo '</select>';
echo '</td></tr><tr><td>'; echo '</td></tr><tr><td>';
@ -158,28 +125,31 @@ if ($entry['attr']['oclass']) {
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
if ($_SESSION[APPCONFIG]->GetValue('appearance','show_hints')) 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>', 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')); IMGDIR,_('Note: You may be required to enter new attributes that these objectClass(es) require'));
echo '</table>'; echo '</table>';
echo '</center>'; echo '</center>';
echo '</form>'; echo '</form>';
} else { } else {
# Draw a blank field # Draw a blank field
echo '<table border=0><tr><td>'; echo '<table border=0><tr><td>';
$writer->draw('BlankValue',$ldap['attr'],$ldap['count'],$reader); $request['page']->draw('FormValue',$request['attribute'],$request['count']);
echo '</td></tr><tr><td>'; echo '</td></tr><tr><td>';
if ($ldap['schema']->getDescription()) $sattr = $app['server']->getSchemaAttribute($request['attr']);
printf('<small><b>%s:</b> %s</small><br />',_('Description'),$ldap['schema']->getDescription());
if ($ldap['schema']->getType()) if ($sattr->getDescription())
printf('<small><b>%s:</b> %s</small><br />',_('Syntax'),$ldap['schema']->getType()); printf('<small><b>%s:</b> %s</small><br />',_('Description'),$sattr->getDescription());
if ($ldap['schema']->getMaxLength()) 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 />', printf('<small><b>%s:</b> %s %s</small><br />',
_('Maximum Length'),number_format($ldap['schema']->getMaxLength()),_('characters')); _('Maximum Length'),number_format($sattr->getMaxLength()),_('characters'));
echo '<br />'; echo '<br />';
printf('<input type="submit" id="save_button" name="submit" value="%s" />',_('Add New Value')); printf('<input type="submit" id="save_button" name="submit" value="%s" />',_('Add New Value'));
@ -189,139 +159,21 @@ if ($entry['attr']['oclass']) {
echo '</table>'; echo '</table>';
echo '</center>'; echo '</center>';
echo '</form>'; echo '</form>';
# Javascript
echo '<script type="text/javascript" language="javascript">
function pla_getComponentById(id) {
return document.getElementById(id);
} }
function pla_getComponentsByName(name) { } else {
return document.getElementsByName(name); 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);
echo '</table>';
function pla_getComponentValue(component) {
if (component.type == "checkbox") {
if (component.checked) return component.value;
} else if (component.type == "select-one") {
if (component.selectedIndex >= 0) return component.options[component.selectedIndex].value;
} else if (component.type == "select-multiple") {
if (component.selectedIndex >= 0) return component.options[component.selectedIndex].value;
} else if (component.type == undefined) { // option
if (component.selected) return component.value;
} else { } else {
return component.value; $request['count'] = $attribute->getValueCount();
$request['page']->draw('FormReadWriteValue',$attribute,$request['count']);
} }
return "";
}
function pla_setComponentValue(component, value) {
if (component.type == "checkbox") {
if (component.value == value) component.checked = true;
else component.checked = false;
} else if (component.type == "select-one") {
for (var i = 0; i < component.options.length; i++) {
if (component.options[i].value == value) component.options[i].selected = true;
}
} else if (component.type == "select-multiple") {
for (var i = 0; i < component.options.length; i++) {
if (component.options[i].value == value) component.options[i].selected = true;
}
} else if (component.type == undefined) { // option
if (component.value == value) component.selected = true;
else component.selected = false;
} else { // text, textarea
component.value = value;
}
}</script>';
echo '<script type="text/javascript" language="javascript">
function getAttributeComponents(prefix, name) {
var components = new Array();
var i = 0;
var j = 0;
var c = pla_getComponentsByName(prefix + "_values[" + name + "][" + j + "]");
while (c && (c.length > 0)) {
for (var k = 0; k < c.length; k++) {
components[i++] = c[k];
}
++j;
c = pla_getComponentsByName(prefix + "_values[" + name + "][" + j + "]");
}
c = pla_getComponentsByName(prefix + "_values[" + name + "][]");
if (c && (c.length > 0)) {
for (var k = 0; k < c.length; k++) {
components[i++] = c[k];
}
}
return components;
}
function getAttributeValues(prefix, name) {
var components = getAttributeComponents(prefix, name);
var values = new Array();
for (var k = 0; k < components.length; k++) {
var val = pla_getComponentValue(components[k]);
if (val) values[values.length] = val;
}
return values;
}</script>';
echo '<script type="text/javascript" language="javascript">
function validateForm(silence) {
var i = 0;
var valid = true;
var components = null;
components = getAttributeComponents("new", "'.$ldap['attr']->getName().'");
for (i = 0; i < components.length; i++) {
if (window.validate_'.$ldap['attr']->getName().') {
valid = (!validate_'.$ldap['attr']->getName().'(components[i], silence) || !valid) ? false : true;
}
}
return valid;
}
</script>';
echo '<script type="text/javascript" language="javascript">
function submitForm(form) {
for (var i = 0; i < form.elements.length; i++) {
form.elements[i].blur();
}
return validateForm(true);
}
function alertError(err, silence) {
if (!silence) alert(err);
}
</script>';
echo '<script type="text/javascript" language="javascript">
var attrTrace;
function fill(id, value) {
attrTrace = new Array();
fillRec(id, value);
}
function fillRec(id, value) {
if (attrTrace[id] == 1) {
return;
} else {
var pre = "";
var suf = "";
var i;
attrTrace[id] = 1;
pla_setComponentValue(pla_getComponentById(id), value);
// here comes template-specific implementation, generated by php
if (false) {}';
$attr = $ldap['attr']->getName();
echo "\t\t\telse if ((i = id.indexOf('_".$attr."_')) >= 0) {\n";
echo "\t\t\t\tpre = id.substring(0, i+1);\n";
echo "\t\t\t\tsuf = id.substring(i + 1 + '$attr'.length, id.length);\n";
$writer->draw('FillJavascript', $ldap['attr'], 'id', 'value');
echo "\t\t\t}\n";
echo '}}</script>';
$writer->draw('Javascript', $ldap['attr']);
echo '<script type="text/javascript" language="javascript">
validateForm(true);
</script>';
} }
?> ?>

View File

@ -1,8 +1,15 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/cmd.php,v 1.3.2.3 2008/01/10 12:28:34 wurley Exp $ // $Header$
/** /**
* Main command page for phpLDAPadmin
* All pages are rendered through this script.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/
/**
*/ */
require_once './common.php'; require_once './common.php';
@ -11,32 +18,55 @@ $www['cmd'] = get_request('cmd','REQUEST');
$www['meth'] = get_request('meth','REQUEST'); $www['meth'] = get_request('meth','REQUEST');
ob_start(); ob_start();
$file = '';
switch ($www['cmd']) { switch ($www['cmd']) {
case '_debug' : case '_debug':
debug_dump($_REQUEST,1); debug_dump($_REQUEST,1);
break; break;
default : default:
if (defined('HOOKSDIR') && file_exists(HOOKSDIR.$www['cmd'].'.php')) if (defined('HOOKSDIR') && file_exists(HOOKSDIR.$www['cmd'].'.php'))
$file = HOOKSDIR.$www['cmd'].'.php'; $app['script_cmd'] = HOOKSDIR.$www['cmd'].'.php';
elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php')) elseif (defined('HTDOCDIR') && file_exists(HTDOCDIR.$www['cmd'].'.php'))
$file = HTDOCDIR.$www['cmd'].'.php'; $app['script_cmd'] = HTDOCDIR.$www['cmd'].'.php';
elseif (file_exists('welcome.php')) elseif (file_exists('welcome.php'))
$file = 'welcome.php'; $app['script_cmd'] = 'welcome.php';
else
$app['script_cmd'] = null;
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Ready to render page for command [%s,%s].',128,__FILE__,__LINE__,__METHOD__,$www['cmd'],$file); debug_log('Ready to render page for command [%s,%s].',128,__FILE__,__LINE__,__METHOD__,$www['cmd'],$app['script_cmd']);
# Create page. # Create page.
$www['page'] = new page($ldapserver->server_id); # Set the index so that we render the right server tree.
$www['page'] = new page($app['server']->getIndex());
if ($file) # See if we can render the command
include $file; if (trim($www['cmd'])) {
# If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
# If this command has been disabled by the config.
if (! $_SESSION[APPCONFIG]->isCommandAvailable('script',$www['cmd']))
system_message(array('title'=>_('Command disabled by the server configuration'),
_('Error'),'body'=>sprintf('%s: <b>%s</b>.',_('The command could not be run'),$www['cmd']),'type'=>'error'),'index.php');
}
if ($app['script_cmd'])
include $app['script_cmd'];
# Refresh a frame - this is so that one frame can trigger another frame to be refreshed.
if (isAjaxEnabled() && get_request('refresh','REQUEST') && get_request('refresh','REQUEST') != get_request('frame','REQUEST')) {
printf("
<script type=\"text/javascript\" language=\"javascript\">
displayAJ('%s','cmd=refresh&server_id=%s&meth=ajax&noheader=%s','%s');
</script>",get_request('refresh','REQUEST'),$app['server']->getIndex(),get_request('noheader','REQUEST',false,0),_('Auto refresh'));
}
# Capture the output and put into the body of the page. # Capture the output and put into the body of the page.
$www['body'] = new block(); $www['body'] = new block();
@ -44,8 +74,8 @@ $www['body']->SetBody(ob_get_contents());
$www['page']->block_add('body',$www['body']); $www['page']->block_add('body',$www['body']);
ob_end_clean(); ob_end_clean();
if ($www['meth'] == 'get_body') if ($www['meth'] == 'ajax')
$www['page']->body(true); $www['page']->show(get_request('frame','REQUEST',false,'BODY'),true,get_request('raw','REQUEST',false,false));
else else
$www['page']->display(); $www['page']->display();
?> ?>

View File

@ -1,26 +1,29 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/collapse.php,v 1.16 2007/12/15 07:50:30 wurley Exp $ // $Header$
/** /**
* This script alters the session variable 'tree', collapsing it * This script alters the session variable 'tree', collapsing it
* at the dn specified in the query string. * at the dn specified in the query string.
* *
* Note: this script is equal and opposite to expand.php * Note: this script is equal and opposite to expand.php
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Tree
* @see expand.php * @see expand.php
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$dn = get_request('dn','GET',true); $dn = get_request('dn','GET',true);
$tree = get_cached_item($ldapserver->server_id,'tree'); $tree = get_cached_item($app['server']->getIndex(),'tree');
$entry = $tree->getEntry($dn); $entry = $tree->getEntry($dn);
$entry->close(); $entry->close();
set_cached_item($ldapserver->server_id,'tree','null',$tree); set_cached_item($app['server']->getIndex(),'tree','null',$tree);
header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s', header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s',
$ldapserver->server_id,random_junk(),htmlid($ldapserver->server_id,$dn),pla_session_param())); $app['server']->getIndex(),random_junk(),htmlid($app['server']->getIndex(),$dn),app_session_param()));
die(); die();
?> ?>

View File

@ -1,11 +1,15 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/common.php,v 1.3.2.3 2007/12/26 08:21:10 wurley Exp $ // $Header$
/** /**
* This script provides a convienent method to call the proper common.php
*
* @package phpLDAPadmin * @package phpLDAPadmin
*/ */
# This is just here to provide a convenient link back to the proper common.php /**
*/
if (! defined('LIBDIR')) if (! defined('LIBDIR'))
define('LIBDIR',sprintf('%s/',realpath('../lib/'))); define('LIBDIR',sprintf('%s/',realpath('../lib/')));
require_once LIBDIR.'common.php'; require_once LIBDIR.'common.php';

View File

@ -1,520 +1,189 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/compare.php,v 1.16.2.7 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Compare two DNs - the destination DN is editable. * Compares two DN entries side by side.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
require_once './common.php'; /**
*/
$dn_src = get_request('dn_src'); require './common.php';
$dn_dst = get_request('dn_dst');
$encoded_dn_src = rawurlencode($dn_src); # The DNs we are working with
$encoded_dn_dst = rawurlencode($dn_dst); $request = array();
$request['dnSRC'] = get_request('dn_src');
$request['dnDST'] = get_request('dn_dst');
$server_id_src = get_request('server_id_src'); $ldap = array();
$server_id_dst = get_request('server_id_dst'); $ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_src'));
$ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
$ldapserver_src = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id_src); if (! $ldap['SRC']->dnExists($request['dnSRC']))
if (! $ldapserver_src->haveAuthInfo()) error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($request['dnSRC'])),'error','index.php');
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
$ldapserver_dst = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id_dst); if (! $ldap['DST']->dnExists($request['dnDST']))
if (! $ldapserver_src->haveAuthInfo()) error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($request['dnDST'])),'error','index.php');
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
if (! $ldapserver_src->dnExists($dn_src)) $request['pageSRC'] = new PageRender($ldap['SRC']->getIndex(),get_request('template','REQUEST',false,'none'));
error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($dn_src)),'error','index.php'); $request['pageSRC']->setDN($request['dnSRC']);
$request['pageSRC']->accept();
$request['templateSRC'] = $request['pageSRC']->getTemplate();
if (! $ldapserver_dst->dnExists($dn_dst)) $request['pageDST'] = new PageRender($ldap['DST']->getIndex(),get_request('template','REQUEST',false,'none'));
error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($dn_dst)),'error','index.php'); $request['pageDST']->setDN($request['dnDST']);
$request['pageDST']->accept();
$attrs_src = $ldapserver_src->getDNAttrs($dn_src,false,$_SESSION[APPCONFIG]->GetValue('deref','view')); $request['templateDST'] = $request['pageDST']->getTemplate();
$attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst,false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
# Get a list of all attributes. # Get a list of all attributes.
$attrs_all = array_keys($attrs_src); $attrs_all = array_unique(array_merge($request['templateSRC']->getAttributeNames(),$request['templateDST']->getAttributeNames()));
foreach ($attrs_dst as $key => $val)
if (! in_array($key,$attrs_all))
$attrs_all[] = $key;
printf('<h3 class="title">%s</h3>',_('Comparing the following DNs')); $request['pageSRC']->drawTitle(_('Comparing the following DNs'));
echo '<table class="entry" width=100% border=0>'; echo '<br/>';
echo '<tr>';
printf('<td colspan=2 width=20%%><h3 class="subtitle">%s<br />&nbsp;</h3></td>',_('Attribute'));
printf('<td colspan=2 width=40%%><h3 class="subtitle">%s: <b>%s</b><br />%s: <b>%s</b></h3></td>', echo '<table class="entry" width=100% border=0>';
_('Server'),$ldapserver_src->name,_('Distinguished Name'),htmlspecialchars($dn_src)); echo '<tr class="heading">';
printf('<td colspan=2 width=40%%><h3 class="subtitle">%s: <b>%s</b><br />%s: <b>%s</b></h3></td>', $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
_('Server'),$ldapserver_dst->name,_('Distinguished Name'),htmlspecialchars($dn_dst)); $ldap['SRC']->getIndex(),rawurlencode($request['dnSRC']));
printf('<td colspan=2 width=40%%>%s: <b>%s</b><br />%s: <b><a href="%s">%s</a></b></td>',
_('Server'),$ldap['SRC']->getName(),_('Distinguished Name'),
htmlspecialchars($href),$request['dnSRC']);
echo '</tr>'; $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$ldap['DST']->getIndex(),rawurlencode($request['dnDST']));
printf('<td colspan=2 width=40%%>%s: <b>%s</b><br />%s: <b><a href="%s">%s</a></b></td>',
_('Server'),$ldap['DST']->getName(),_('Distinguished Name'),
htmlspecialchars($href),$request['dnDST']);
echo '<tr>'; echo '</tr>';
echo '<td colspan=6 align=right>';
echo '<form action="cmd.php?cmd=compare" method="post" name="compare_form">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="hidden" name="server_id_src" value="%s" />',$ldapserver_dst->server_id);
printf('<input type="hidden" name="server_id_dst" value="%s" />',$ldapserver_src->server_id);
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($dn_dst));
printf('<input type="hidden" name="dn_dst" value="%s" />',htmlspecialchars($dn_src));
printf('<input type="submit" value="%s" />',_('Switch Entry'));
echo '</form>';
echo '</td>';
echo '</tr>';
if (! $attrs_all || ! is_array($attrs_all)) { echo '<tr>';
printf('<tr><td colspan="2">(%s)</td></tr>',_('This entry has no attributes')); echo '<td colspan=4 align=right>';
echo '<form action="cmd.php?cmd=compare" method="post" name="compare_form">';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id_src" value="%s" />',$ldap['DST']->getIndex());
printf('<input type="hidden" name="server_id_dst" value="%s" />',$ldap['SRC']->getIndex());
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($request['dnDST']));
printf('<input type="hidden" name="dn_dst" value="%s" />',htmlspecialchars($request['dnSRC']));
printf('<input type="submit" value="%s" />',_('Switch Entry'));
echo '</form>';
echo '</td>';
echo '</tr>';
if (! is_array($attrs_all) || ! count($attrs_all)) {
printf('<tr><td colspan="4">(%s)</td></tr>',_('This entry has no attributes'));
print '</table>'; print '</table>';
return; return;
} }
sort($attrs_all); sort($attrs_all);
$formdisplayed = false;
# Work through each of the attributes. # Work through each of the attributes.
foreach ($attrs_all as $attr) { foreach ($attrs_all as $attr) {
# If this is the DN, get the next attribute.
if (! strcasecmp($attr,'dn'))
continue;
# Has the config.php specified that this attribute is to be hidden or shown? # Has the config.php specified that this attribute is to be hidden or shown?
if ($ldapserver_src->isAttrHidden($attr) || $ldapserver_dst->isAttrHidden($attr)) if ($ldap['SRC']->isAttrHidden($attr) || $ldap['DST']->isAttrHidden($attr))
continue; continue;
$schema_attr_src = $ldapserver_src->getSchemaAttribute($attr,$dn_src); $attributeSRC = $request['templateSRC']->getAttribute($attr);
$schema_attr_dst = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst); $attributeDST = $request['templateDST']->getAttribute($attr);
# Get the values and see if they are the same. # Get the values and see if they are the same.
if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr]) if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
echo '<tr>'; echo '<tr>';
else else
echo '<tr class="updated">'; echo '<tr>';
foreach (array('src','dst') as $side) { foreach (array('src','dst') as $side) {
# If we are on the source side, show the attribute name.
# Setup the $attr_note, which will be displayed to the right of the attr name (if any)
$attr_note = '&nbsp;';
# is there a user-friendly translation available for this attribute?
if ($_SESSION[APPCONFIG]->haveFriendlyName($attr)) {
$attr_display = $_SESSION[APPCONFIG]->getFriendlyName($attr);
$attr_note = sprintf('<acronym title="%s: \'%s\' %s \'%s\'">%s</acronym>',_('Note'),$attr_display,_('is an alias for'),$attr,_('alias'));
} else {
$attr_display = $attr;
$attr_note = '&nbsp;';
}
# is this attribute required by an objectClass?
$required_by = '';
switch ($side) { switch ($side) {
case 'src': case 'src':
$ldapserver = $ldapserver_src; if ($attributeSRC) {
if ($schema_attr_src)
foreach ($schema_attr_src->getRequiredByObjectClasses() as $required)
if (isset($attrs_src['objectClass']) && in_array(strtolower($required),arrayLower($attrs_src['objectClass'])))
$required_by .= $required . ' ';
# It seems that some LDAP servers (Domino) returns attributes in lower case?
elseif (isset($attrs_src['objectclass']) && in_array(strtolower($required),arrayLower($attrs_src['objectclass'])))
$required_by .= $required . ' ';
break;
case 'dst':
$ldapserver = $ldapserver_dst;
if ($schema_attr_dst)
foreach ($schema_attr_dst->getRequiredByObjectClasses() as $required)
if (isset($attrs_dst['objectClass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectClass'])))
$required_by .= $required . ' ';
# It seems that some LDAP servers (Domino) returns attributes in lower case?
elseif (isset($attrs_dst['objectclass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectclass'])))
$required_by .= $required . ' ';
break;
}
# If we are on the source side, show the attr
if ($side == 'src') {
echo '<td class="title">'; echo '<td class="title">';
$schema_href = sprintf('cmd.php?cmd=schema&amp;server_id=%s&amp;view=attributes&amp;viewvalue=%s',$server_id_src,real_attr_name($attr)); $request['pageSRC']->draw('Name',$attributeSRC);
printf('<a title="%s" href="%s">%s</a>',sprintf(_('Click to view the schema definition for attribute type \'%s\''),$attr),$schema_href,$attr_display);
echo '</td>'; echo '</td>';
printf('<td class="note"><sup><small>%s</small></sup></td>',$attr_note); if ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID())
echo '<td class="title">&nbsp;</td>';
else {
echo '<td class="note" align="right">';
$request['pageSRC']->draw('Notes',$attributeSRC);
echo '</td>';
} }
echo '<td colspan=2 class="note">'; } else {
echo '<td colspan=2>&nbsp;</td>';
# Create our form if the dst is editable.
if ($side == 'dst' && ! $ldapserver_dst->isReadOnly() && ! $formdisplayed) {
$formdisplayed = true;
echo '<form action="cmd.php?cmd=update_confirm" method="post" name="edit_form">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver_dst->server_id);
printf('<input type="hidden" name="dn" value="%s" />',$dn_dst);
} }
if ($required_by) break;
printf('<sup><small><acronym title="%s">%s</acronym></small></sup>',sprintf(_('Required attribute for objectClass(es) %s'),$required_by),_('required'));
case 'dst':
if ($attributeDST) {
if ($attributeSRC && ($request['pageSRC']->getServerID() == $request['pageDST']->getServerID()))
echo '<td class="title">&nbsp;</td>';
else {
echo '<td class="title" >';
$request['pageDST']->draw('Name',$attributeDST);
echo '</td>';
}
echo '<td class="note" align="right">';
$request['pageDST']->draw('Notes',$attributeDST);
echo '</td>'; echo '</td>';
if ($ldapserver->isAttrReadOnly($attr)) } else {
printf('<small>(<acronym title="%s">%s</acronym>)</small>',_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),_('read only')); echo '<td colspan=2>&nbsp;</td>';
}
break;
}
} }
echo '</tr>'; echo '</tr>';
echo "\n\n";
if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr])
echo '<tr>';
else
echo '<tr class="updated">';
foreach (array('src','dst') as $side) {
$vals = null;
# If this attribute isnt set, then show a blank.
$toJump = 0;
switch ($side) {
case 'src':
print '<td colspan=2>&nbsp;</td><td class="value">';
if (! isset($attrs_src[$attr])) {
echo "<small>&lt;". _('No Value')."&gt;</small></td>";
$toJump = 1;
continue;
} else
$vals = $attrs_src[$attr];
$ldapserver = $ldapserver_src;
break;
case 'dst':
print '<td colspan=2>&nbsp;</td><td class="value">';
if (! isset($attrs_dst[$attr])) {
echo "<small>&lt;". _('No Value')."&gt;</small></td>";
$toJump = 1;
continue;
} else
$vals = $attrs_dst[$attr];
$ldapserver = $ldapserver_dst;
break;
}
if ($toJump)
continue;
if (! is_array($vals))
$vals = array($vals);
# Is this attribute a jpegPhoto?
if ($ldapserver->isJpegPhoto($attr)) {
switch ($side) {
case 'src':
# Don't draw the delete buttons if there is more than one jpegPhoto (phpLDAPadmin can't handle this case yet)
draw_jpeg_photos($ldapserver,$dn_src,$attr,false);
break;
case 'dst':
if ($ldapserver_dst->isReadOnly() || $ldapserver_dst->isAttrReadOnly($attr))
draw_jpeg_photos($ldapserver,$dn_dst,$attr,false);
else
draw_jpeg_photos($ldapserver,$dn_dst,$attr,true);
break;
}
# proceed to the next attribute
echo '</td>'."\n";
continue;
}
# Is this attribute binary?
if ($ldapserver->isAttrBinary($attr)) {
switch ($side) {
case 'src':
$href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_src,$attr);
break;
case 'dst':
$href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_dst,$attr);
break;
}
echo '<small>';
echo _('Binary value');
echo '<br />';
if (count($vals) > 1)
for ($i=1; $i<=count($vals); $i++)
printf('<a href="%s&amp;value_num=%s"><img src="%s/save.png" /> %s(%s)</a><br />',$href,$i,_('download value'),IMGDIR,$i);
else
printf('<a href="%s"><img src="%s/save.png" /> %s</a><br />',$href,IMGDIR,_('download value'));
if ($side == 'dst' && ! $ldapserver_dst->isReadOnly() && ! $ldapserver->isAttrReadOnly($attr))
printf('<a href="javascript:deleteAttribute(\'%s\');" style="color:red;"><img src="%s/trash.png" /> %s</a>',$attr,IMGDIR,_('delete attribute'));
echo '</small>';
echo '</td>';
continue;
}
# Note: at this point, the attribute must be text-based (not binary or jpeg)
/*
* If this server is in read-only mode or this attribute is configured as read_only,
* simply draw the attribute values and continue.
*/
if ($side == 'dst' && ($ldapserver->isReadOnly() || $ldapserver->isAttrReadOnly($attr))) {
if (is_array($vals)) {
foreach ($vals as $i => $val) {
if (trim($val) == '')
printf('<span style="color:red">[%s]</span><br />',_('empty'));
elseif (strcasecmp($attr,'userPassword') == 0 && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display'))
echo preg_replace('/./','*',$val).'<br />';
else
echo htmlspecialchars($val).'<br />';
}
# @todo: redundant - $vals is always an array.
} else {
if (strcasecmp($attr,'userPassword') == 0 && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display'))
echo preg_replace('/./','*',$vals).'<br />';
else
echo $vals.'<br />';
}
echo '</td>';
continue;
}
# Is this a userPassword attribute?
if (! strcasecmp($attr,'userpassword')) {
$user_password = $vals[0];
$enc_type = get_enc_type($user_password);
# Set the default hashing type if the password is blank (must be newly created)
if ($user_password == '') {
$enc_type = get_default_hash($server_id);
}
if ($side == 'dst') {
printf('<input type="hidden" name="old_values[userpassword]" value="%s" />',htmlspecialchars($user_password));
echo '<!-- Special case of enc_type to detect changes when user changes enc_type but not the password value -->';
printf('<input size="38" type="hidden" name="old_enc_type" value="%s" />',$enc_type == '' ? 'clear' : $enc_type);
}
if (obfuscate_password_display($enc_type))
echo htmlspecialchars(preg_replace('/./','*',$user_password));
else
echo htmlspecialchars($user_password);
echo '<br />';
if ($side == 'dst') {
printf('<input style="width: 260px" type="password" name="new_values[userpassword]" value="%s" />',htmlspecialchars($user_password));
echo enc_type_select_list($enc_type,'enc','userpassword',0);
}
echo '<br />';
?>
<script type="text/javascript" language="javascript">
<!--
function passwordComparePopup()
{
mywindow = open('password_checker.php','myname','resizable=no,width=450,height=200,scrollbars=1');
mywindow.location.href = 'password_checker.php?hash=<?php echo base64_encode($user_password); ?>&base64=true';
if (mywindow.opener == null)
mywindow.opener = self;
}
-->
</script>
<?php
printf('<small><a href="javascript:passwordComparePopup()">%s</a></small>',_('Check password'));
echo '</td>';
continue;
}
# Is this a boolean attribute?
if ($ldapserver->isAttrBoolean($attr)) {
$val = $vals[0];
if ($side = 'dst') {
printf('<input type="hidden" name="old_values[%s]" value="%s" />',htmlspecialchars($attr),htmlspecialchars($val));
printf('<select name="new_values[%s]">',htmlspecialchars($attr));
printf('<option value="TRUE"%s>%s</option>',$val == 'TRUE' ? ' selected' : '',_('true'));
printf('<option value="FALSE"%s>%s</option>',$val == 'FALSE' ? ' selected' : '',_('false'));
printf('<option value="">(%s)</option>',_('none, remove value'));
echo '</select>';
}
echo '</td>';
continue;
}
# End of special case attributes (non plain text).
foreach ($vals as $i => $val) {
if ($side == 'dst') {
$input_name = sprintf('new_values[%s][%s]',htmlspecialchars($attr),$i);
/* We smack an id="..." tag in here that doesn't have [][] in it to allow the
* draw_chooser_link() to identify it after the user clicks.*/
$input_id = sprintf('"new_values_%s_%s',htmlspecialchars($attr),$i);
echo '<!-- The old_values array will let update.php know if the entry contents changed
between the time the user loaded this page and saved their changes. -->';
printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />',htmlspecialchars($attr),$i,htmlspecialchars($val));
}
# Is this value is a structural objectClass, make it read-only
if (0 == strcasecmp($attr,'objectClass')) {
printf('<a title="%s" href="cmd.php?cmd=schema&amp;server_id=%s&amp;view=objectClasses&amp;viewvalue=%s"><img src="%s/info.png" /></a>',
_('View the schema description for this objectClass'),$ldapserver->server_id,htmlspecialchars($val),IMGDIR);
$schema_object = $ldapserver->getSchemaObjectClass($val);
if ($schema_object->getType() == 'structural') {
printf('%s <small>(<acronym title="%s">%s</acronym>)</small><br />',
$val,_('This is a structural ObjectClass and cannot be removed.'),_('structural'));
if ($side == 'dst')
printf('<input type="hidden" name="%s" id="%s" value="%s" />',$input_name,$input_id,htmlspecialchars($val));
continue;
}
}
if (is_dn_string($val) || $ldapserver->isDNAttr($attr))
printf('<a title="%s" href="cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s"><img style="vertical-align: top" src="%s/go.png" /></a>',
sprintf(_('Go to %s'),htmlspecialchars($val)),$ldapserver->server_id,rawurlencode($val),IMGDIR);
elseif (is_mail_string($val))
printf('<a href="mailto:%s><img style="vertical-align: center" src="%s/mail.png" /></a>',htmlspecialchars($val),IMGDIR);
elseif (is_url_string($val))
printf('<a href="%s" target="new"><img style="vertical-align: center" src="%s/dc.png" /></a>',htmlspecialchars($val),IMGDIR);
if ($ldapserver->isMultiLineAttr($attr,$val)) {
if ($side == 'dst')
printf('<textarea class="value" rows="3" cols="30" name="%s" id="%s">%s</textarea>',$input_name,$input_id,htmlspecialchars($val));
else
echo htmlspecialchars($val);
} else {
if ($side == 'dst')
printf('<input type="text" class="value" name="%s" id="%s" value="%s" />',$input_name,$input_id,htmlspecialchars($val));
else
echo htmlspecialchars($val);
}
# draw a link for popping up the entry browser if this is the type of attribute that houses DNs.
if ($ldapserver->isDNAttr($attr))
draw_chooser_link("edit_form.$input_id",false);
echo '<br />';
}
echo '</td>';
} /* end foreach value */
echo '</tr>';
# Draw the "add value" link under the list of values for this attributes
if (! $ldapserver_dst->isReadOnly()) {
# First check if the required objectClass is in this DN
$isOK = 0;
$src_oclass = array();
$attr_object = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst);
foreach ($attr_object->used_in_object_classes as $oclass) {
if (in_array(strtolower($oclass),arrayLower($attrs_dst['objectClass']))) {
$isOK = 1;
break;
} else {
# Find oclass that the source has that provides this attribute.
if (in_array($oclass,$attrs_src['objectClass']))
$src_oclass[] = $oclass;
}
}
echo '<tr><td colspan=2></td><td colspan=2>&nbsp;</td><td>&nbsp;</td><td>';
if (! $isOK) {
if (count($src_oclass) == 1)
$add_href = sprintf('cmd.php?cmd=add_oclass_form&amp;server_id=%s&amp;dn=%s&amp;new_oclass=%s',
$ldapserver_dst->server_id,$encoded_dn_dst,$src_oclass[0]);
else
$add_href = sprintf('cmd.php?cmd=add_value_form&amp;server_id=%s&amp;dn=%s&amp;attr=objectClass',
$ldapserver_dst->server_id,$encoded_dn_dst);
if ($attr == 'objectClass')
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',$add_href,_('Add ObjectClass and Attributes'),_('add value'));
else
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',
$add_href,sprintf(_('You need one of the following ObjectClass(es) to add this attribute %s.'),implode(" ",$src_oclass)),
_('Add new ObjectClass'));
} else {
if (! $schema_attr_dst->getIsSingleValue() || (! isset($vals))) {
$add_href = sprintf('cmd.php?cmd=add_value_form&amp;erver_id=%s&amp;dn=%s&amp;attr=%s',
$ldapserver_dst->server_id,$encoded_dn_dst,rawurlencode($attr));
printf('<div class="add_value">(<a href="%s" title="%s">%s</a>)</div>',
$add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value'));
}
}
}
echo '</td></tr>';
# Get the values and see if they are the same. # Get the values and see if they are the same.
if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr]) if ($attributeSRC && $attributeDST && ($attributeSRC->getValues() == $attributeDST->getValues()))
echo '<tr>'; echo '<tr style="background-color: #F0F0F0;">';
else else
echo '<tr class="updated"><td class="bottom" colspan="0">&nbsp;</td></tr>'; echo '<tr>';
} /* End foreach ($attrs as $attr => $vals) */ foreach (array('src','dst') as $side) {
switch ($side) {
case 'src':
echo '<td class="value" colspan=2><table border=0>';
if (! $ldapserver_dst->isReadOnly()) if ($attributeSRC && count($attributeSRC->getValues()))
printf('<tr><td colspan=3>&nbsp;</td><td colspan=3><center><input type="submit" value="%s" /></center></form></td></tr>',_('Save Changes')); $request['pageSRC']->draw('CurrentValues',$attributeSRC);
else
echo '<tr><td>&nbsp;</td></tr>';
echo '</table>'; echo '</table></td>';
# If this entry has a binary attribute,we need to provide a form for it to submit when deleting it. */ break;
?>
<script type="text/javascript" language="javascript"> case 'dst':
//<!-- echo '<td class="value" colspan=2><table>';
function deleteAttribute(attrName)
{ if ($attributeDST && count($attributeDST->getValues()))
if (confirm("<?php echo _('Really delete attribute'); ?> '" + attrName + "'?")) { $request['pageDST']->draw('CurrentValues',$attributeDST);
document.delete_attribute_form.attr.value = attrName; else
document.delete_attribute_form.submit(); echo '<tr><td>&nbsp;</td></tr>';
echo '</table></td>';
break;
}
} }
}
//-->
</script>
<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute --> echo '</tr>';
<form name="delete_attribute_form" action="cmd.php?cmd=delete_attr" method="post"> }
<input type="hidden" name="server_id" value="<?php echo $ldapserver_dst->server_id; ?>" /> echo '</table>';
<input type="hidden" name="dn" value="<?php echo $dn_dst; ?>" /> ?>
<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />
</form>

View File

@ -1,56 +1,50 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/compare_form.php,v 1.5.2.1 2008/12/12 07:29:55 wurley Exp $ // $Header$
/** /**
* Compares to DN entries side by side. * Compares two DN entries side by side.
* * This is the entry form to determine which DN to compare this DN with.
* - dn (rawurlencoded)
* - server_id
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require_once './common.php'; require './common.php';
$dn = get_request('dn','GET'); # The DN we are working with
$rdn = get_rdn($dn); $request = array();
$select_server_html = server_select_list($ldapserver->server_id,true,'server_id_dst'); $request['dn'] = get_request('dn','GET');
printf('<h3 class="title">%s %s</h3>',_('Compare another DN with'),htmlspecialchars($rdn)); # Check if the entry exists.
printf('<h3 class="subtitle">%s: <b>%s</b>',_('Server'),$ldapserver->name); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
if ($dn) error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
printf('&nbsp;&nbsp;&nbsp;%s: <b>%s</b>',_('Distinguished Name'),htmlspecialchars($dn));
echo '</h3>'; $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
echo "\n"; $request['page']->setDN($request['dn']);
$request['page']->accept();
# Render the form
$request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Compare another DN with'),get_rdn($request['dn'])));
$request['page']->drawSubTitle();
echo '<center>'; echo '<center>';
printf('%s <b>%s</b> %s<br />',_('Compare'),htmlspecialchars($rdn),_('with ')); printf('%s <b>%s</b> %s<br />',_('Compare'),get_rdn($request['dn']),_('with '));
echo '<form action="cmd.php?cmd=compare" method="post" name="compare_form">'; echo '<form action="cmd.php" method="post" name="compare_form">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); echo '<input type="hidden" name="cmd" value="compare" />';
printf('<input type="hidden" name="server_id_src" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id_src" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($request['dn']));
echo "\n"; echo "\n";
echo '<table style="border-spacing: 10px">'; echo '<table style="border-spacing: 10px">';
echo "\n";
echo '<tr><td>';
if (! $dn) {
printf('<acronym title="%s">%s</acronym>:',_('Compare this DN with another'),_('Source DN'));
echo '</td><td>';
printf('<input type="text" name="dn_src" size="45" value="%s" />',htmlspecialchars($dn));
draw_chooser_link('compare_form.dn_src','true',$rdn);
} else
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($dn));
echo '</td></tr>';
echo "\n";
echo '<tr>'; echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',_('Compare this DN with another'),_('Destination DN')); printf('<td><acronym title="%s">%s</acronym>:</td>',
_('Compare this DN with another'),_('Destination DN'));
echo '<td>'; echo '<td>';
echo '<input type="text" name="dn_dst" size="45" value="" />'; echo '<input type="text" name="dn_dst" size="45" value="" />';
draw_chooser_link('compare_form.dn_dst','true',''); draw_chooser_link('compare_form.dn_dst','true','');
@ -58,7 +52,7 @@ echo '</td>';
echo '</tr>'; echo '</tr>';
echo "\n"; echo "\n";
printf('<tr><td>%s:</td><td>%s</td></tr>',_('Destination Server'),$select_server_html); printf('<tr><td>%s:</td><td>%s</td></tr>',_('Destination Server'),server_select_list($app['server']->getIndex(),true,'server_id_dst'));
echo "\n"; echo "\n";
printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Compare')); printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Compare'));

View File

@ -1,89 +1,82 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/copy.php,v 1.44.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Copies a given object to create a new one. * Copies a given object to create a new one.
* *
* Vars that come in as POST vars
* - source_dn (rawurlencoded)
* - new_dn (form element)
* - server_id
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_move')) # The DNs we are working with
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('copy entry')),'error','index.php'); $request = array();
$request['dnSRC'] = get_request('dn_src');
$request['dnDST'] = get_request('dn_dst');
$entry = array(); $ldap = array();
$entry['src']['id'] = get_request('server_id'); $ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_src'));
$entry['dst']['id'] = get_request('dest_server_id'); $ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
$entry['src']['ldapserver'] = $_SESSION[APPCONFIG]->ldapservers->Instance($entry['src']['id']);
$entry['dst']['ldapserver'] = $_SESSION[APPCONFIG]->ldapservers->Instance($entry['dst']['id']);
if ($entry['dst']['ldapserver']->isReadOnly())
error(_('Destination server is currently READ-ONLY.'),'error','index.php');
if (! $entry['src']['ldapserver']->haveAuthInfo() || ! $entry['dst']['ldapserver']->haveAuthInfo())
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
$entry['src']['dn'] = get_request('old_dn');
$entry['dst']['dn'] = get_request('new_dn');
$entry['src']['recursive'] = (get_request('recursive') == 'on') ? true : false;
$entry['src']['remove'] = (get_request('remove') == 'yes') ? true : false;
# Error checking # Error checking
if (strlen(trim($entry['dst']['dn'])) == 0) if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_move'))
error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('copy entry')),'error','index.php');
if (! trim($request['dnDST']))
error(_('You left the destination DN blank.'),'error','index.php'); error(_('You left the destination DN blank.'),'error','index.php');
if (pla_compare_dns($entry['src']['dn'],$entry['dst']['dn']) == 0 && $entry['src']['id'] == $entry['dst']['id']) if ($ldap['DST']->isReadOnly())
error(_('Destination server is currently READ-ONLY.'),'error','index.php');
if ($ldap['DST']->dnExists($request['dnDST']))
error(sprintf(_('The destination entry (%s) already exists.'),pretty_print_dn($request['dnDST'])),'error','index.php');
if (! $ldap['DST']->dnExists($ldap['DST']->getContainer($request['dnDST'])))
error(sprintf(_('The destination container (%s) does not exist.'),
pretty_print_dn($ldap['DST']->getContainer($request['dnDST']))),'error','index.php');
if (pla_compare_dns($request['dnSRC'],$request['dnDST']) == 0 && $ldap['SRC']->getIndex() == $ldap['DST']->getIndex())
error(_('The source and destination DN are the same.'),'error','index.php'); error(_('The source and destination DN are the same.'),'error','index.php');
if ($entry['dst']['ldapserver']->dnExists($entry['dst']['dn'])) $request['recursive'] = (get_request('recursive') == 'on') ? true : false;
error(sprintf(_('The destination entry (%s) already exists.'),pretty_print_dn($entry['dst']['dn'])),'error','index.php'); $request['remove'] = (get_request('remove') == 'yes') ? true : false;
if (! $entry['dst']['ldapserver']->dnExists(get_container($entry['dst']['dn']))) if ($request['recursive']) {
error(sprintf(_('The destination container (%s) does not exist.'),pretty_print_dn(get_container($entry['dst']['dn']))),'error','index.php');
if ($entry['src']['recursive']) {
$filter = get_request('filter','POST',false,'(objectClass=*)'); $filter = get_request('filter','POST',false,'(objectClass=*)');
# Build a tree similar to that of the tree browser to give to r_copy_dn # Build a tree similar to that of the tree browser to give to r_copy_dn
$snapshot_tree = array(); $ldap['tree'] = array();
printf('<h3 class="title">%s%s</h3>',_('Copying '),htmlspecialchars($entry['src']['dn'])); printf('<h3 class="title">%s%s</h3>',_('Copying '),$request['dnSRC']);
printf('<h3 class="subtitle">%s</h3>',_('Recursive copy progress')); printf('<h3 class="subtitle">%s</h3>',_('Recursive copy progress'));
print '<br /><br />'; print '<br /><br />';
print '<small>';
print _('Building snapshot of tree to copy... ');
$snapshot_tree = build_tree($entry['src']['ldapserver'],$entry['src']['dn'],array(),$filter); print '<small>';
printf ('%s...',_('Building snapshot of tree to copy'));
$ldap['tree'] = build_tree($ldap['SRC'],$request['dnSRC'],array(),$filter);
printf('<span style="color:green">%s</span><br />',_('Success')); printf('<span style="color:green">%s</span><br />',_('Success'));
# Prevent script from bailing early on a long delete # Prevent script from bailing early on a long delete
@set_time_limit(0); @set_time_limit(0);
$copy_result = r_copy_dn($entry['src']['ldapserver'],$entry['dst']['ldapserver'],$snapshot_tree,$entry['src']['dn'],$entry['dst']['dn']); $copy_result = r_copy_dn($ldap['SRC'],$ldap['DST'],$ldap['tree'],$request['dnSRC'],$request['dnDST'],$request['remove']);
# @todo: This is not showing the complete results - only the children of the dst - need to look at.
$copy_message = $copy_result; $copy_message = $copy_result;
print '</small>'; print '</small>';
} else { } else {
$copy_result = copy_dn($entry['src']['ldapserver'],$entry['dst']['ldapserver'],$entry['src']['dn'],$entry['dst']['dn']); $copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']);
$copy_message = sprintf('%s DN%s <b>%s</b> %s',_('Copy successful!'),_(':'),htmlspecialchars($entry['dst']['dn']),_('has been created.')); $copy_message = sprintf('%s %s: <b>%s</b> %s',
$request['remove'] ? _('Move successful') : _('Copy successful'),
_('DN'),$request['dnDST'],_('has been created.'));
} }
if ($copy_result) { if ($copy_result) {
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$entry['dst']['id'],rawurlencode($entry['dst']['dn'])); $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&refresh=SID_%s_nodes&noheader=1',
$new_rdn = get_rdn($entry['dst']['dn']); $ldap['DST']->getIndex(),rawurlencode($request['dnDST']),$ldap['DST']->getIndex());
$container = get_container($entry['dst']['dn']);
if ($entry['src']['remove'])
$redirect_url = sprintf('cmd.php?cmd=delete_form&server_id=%s&dn=%s',$entry['src']['id'],rawurlencode($entry['src']['dn']));
system_message(array( system_message(array(
'title'=>_('Copy Entry'), 'title'=>_('Copy Entry'),
@ -92,91 +85,102 @@ if ($copy_result) {
$redirect_url); $redirect_url);
} }
function r_copy_dn($ldapserver_src,$ldapserver_dst,$snapshottree,$root_dn,$dn_dst) { function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, debug_log('Entered with (%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,
$ldapserver_src->server_id,$ldapserver_dst->server_id,$snapshottree,$root_dn,$dn_dst); $serverSRC->getIndex(),$serverDST->getIndex(),$snapshottree,$dnSRC,$dnDST);
$copy_message = array(); $copy_message = array();
$copy_result = copy_dn($ldapserver_src,$ldapserver_dst,$root_dn,$dn_dst); $children = isset($snapshottree[$dnSRC]) ? $snapshottree[$dnSRC] : null;
# If we have children, then we need to copy, then delete for a move
if (is_array($children) && count($children)) {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,false);
if (! $copy_result) if (! $copy_result)
return false; return false;
$copy_message[] = sprintf('%s DN: <b>%s</b> %s',_('Copy successful!'),htmlspecialchars($dn_dst),_('has been created.')); array_push($copy_message,sprintf('%s %s: <b>%s</b> %s',_('Copy successful'),_('DN'),$dnDST,_('has been created.')));
$children = isset($snapshottree[$root_dn]) ? $snapshottree[$root_dn] : null; $hadError = false;
if (is_array($children) && count($children) > 0) { foreach ($children as $child_dn) {
foreach($children as $child_dn) { $dnDST_new = sprintf('%s,%s',get_rdn($child_dn),$dnDST);
$child_rdn = get_rdn($child_dn); $copy_result = r_copy_dn($serverSRC,$serverDST,$snapshottree,$child_dn,$dnDST_new,$remove);
$new_dest_dn = sprintf('%s,%s',$child_rdn,$dn_dst); $copy_message = array_merge($copy_message,array_values($copy_result));
$copy_result = r_copy_dn($ldapserver_src,$ldapserver_dst,$snapshottree,$child_dn,$new_dest_dn);
$copy_message[] = array_shift($copy_result); if (! $copy_result)
$hadError = true;
} }
if (! $hadError && $remove) {
$delete_result = $serverSRC->delete($dnSRC);
if ($delete_result)
array_push($copy_message,sprintf('%s %s: <b>%s</b> %s',_('Delete successful'),_('DN'),$dnDST,_('has been deleted.')));
}
} else {
$copy_result = copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove);
array_push($copy_message,sprintf('%s %s: <b>%s</b> %s',
$remove ? _('Move successful') : _('Copy successful'),
_('DN'),$dnDST,_('has been created.')));
} }
return $copy_message; return $copy_message;
} }
function copy_dn($ldapserver_src,$ldapserver_dst,$dn_src,$dn_dst) { function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__, debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,
$ldapserver_src->server_id,$ldapserver_dst->server_id,$dn_src,$dn_dst); $serverSRC->getIndex(),$serverDST->getIndex(),$dnSRC,$dnDST);
$new_entry = $ldapserver_src->getDNAttrs($dn_src); $request = array();
$request['pageSRC'] = new PageRender($serverSRC->getIndex(),get_request('template','REQUEST',false,'none'));
$request['pageSRC']->setDN($dnSRC);
$request['pageSRC']->accept();
# modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value. $request['pageDST'] = new PageRender($serverDST->getIndex(),get_request('template','REQUEST',false,'none'));
$rdn_attr = substr($dn_dst,0,strpos($dn_dst,'=')); $request['pageDST']->setContainer($serverDST->getContainer($dnDST));
$rdn_value = get_rdn($dn_dst); $request['pageDST']->accept();
$rdn_value = substr($rdn_value,strpos($rdn_value,'=') + 1);
$new_entry[$rdn_attr] = $rdn_value;
# don't need a dn attribute in the new entry $request['templateSRC'] = $request['pageSRC']->getTemplate();
unset($new_entry['dn']); $request['templateDST'] = $request['pageDST']->getTemplate();
$request['templateDST']->copy($request['pageSRC']->getTemplate(),get_rdn($dnDST,0));
# Check the user-defined custom call back first # Create of move the entry
if (run_hook('pre_entry_create', if ($remove)
array ('server_id'=>$ldapserver_dst->server_id,'dn'=>$dn_dst,'attrs'=>$new_entry))) { $add_result = $serverDST->rename($request['templateSRC']->getDN(),$request['templateDST']->getRDN(),$serverDST->getContainer($dnDST),true);
else
$add_result = $ldapserver_dst->add($dn_dst,$new_entry); $add_result = $serverDST->add($request['templateDST']->getDN(),$request['templateDST']->getLDAPadd());
if (! $add_result) {
echo '</small><br /><br />';
system_message(array(
'title'=>_('Failed to copy DN.').sprintf(' (%s)',$dn_dst),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
} else {
run_hook('post_entry_create',
array('server_id'=>$ldapserver_dst->server_id,'dn'=>$dn_dst,'attrs'=>$new_entry));
}
if ($add_result) {
return $add_result; return $add_result;
} else { } else {
system_message(array(
'title'=>sprintf('%s (%s)',_('Failed to copy DN'),$request['templateDST']->getDN()),
'body'=>ldap_error_msg($serverDST->getErrorMessage(null),$serverDST->getErrorNum(null)),
'type'=>'error'));
return false; return false;
} }
} }
/** function build_tree($server,$dn,$buildtree) {
* @param object $ldapserver
* @param dn $dn
* @param array $tree
* @param string $filter
*/
function build_tree($ldapserver,$dn,$buildtree) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,
$ldapserver->server_id,$dn,$buildtree); $server->getIndex(),$dn,$buildtree);
# we search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
$children = $ldapserver->getContainerContents($dn,0); $children = $server->getContainerContents($dn,null,0);
if (is_array($children) && count($children) > 0) { if (count($children)) {
$buildtree[$dn] = $children; $buildtree[$dn] = $children;
foreach ($children as $child_dn) foreach ($children as $child_dn)
$buildtree = build_tree($ldapserver,$child_dn,$buildtree); $buildtree = build_tree($server,$child_dn,$buildtree);
} }
if (DEBUG_ENABLED) if (DEBUG_ENABLED)

View File

@ -1,32 +1,104 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/copy_form.php,v 1.30.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Copies a given object to create a new one. * Copies a given object to create a new one.
* *
* Variables that come in via GET variables
* - dn (rawurlencoded)
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
$request['dn'] = get_request('dn','GET');
$entry = array(); # Check if the entry exists.
$entry['dn'] = get_request('dn','GET'); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
$entry['rdn'] = get_rdn($entry['dn']); error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setDN($request['dn']);
$request['page']->accept();
# Render the form
$request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Copy'),get_rdn($request['dn'])));
$request['page']->drawSubTitle();
echo '<center>';
printf('%s <b>%s</b> %s:<br /><br />',_('Copy'),get_rdn($request['dn']),_('to a new object'));
echo '<form action="cmd.php" method="post" name="copy_form">';
echo '<input type="hidden" name="cmd" value="copy" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id_src" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn_src" value="%s" />',htmlspecialchars($request['dn']));
echo "\n";
echo '<table style="border-spacing: 10px">';
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',
_('The full DN of the new entry to be created when copying the source entry'),_('Destination DN'));
echo '<td>';
printf('<input type="text" name="dn_dst" size="45" value="%s" />',htmlspecialchars($request['dn']));
draw_chooser_link('copy_form.dn_dst','true',get_rdn($request['dn']));
echo '</td>';
echo '</tr>';
echo "\n";
printf('<tr><td>%s:</td><td>%s</td></tr>',_('Destination Server'),server_select_list($app['server']->getIndex(),true,'server_id_dst'));
echo "\n";
# We search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
$entry['children'] = $ldapserver->getContainerContents($entry['dn']); $request['children'] = $app['server']->getContainerContents($request['dn']);
# Draw some javaScrpt to enable/disable the filter field if this may be a recursive copy if (count($request['children']) > 0) {
if (is_array($entry['children']) && count($entry['children']) > 0) { ?> echo '<tr>';
printf('<td><label for="recursive">%s</label>:</td>',_('Recursive copy'));
echo '<td><input type="checkbox" id="recursive" name="recursive" onClick="toggle_disable_filter_field(this)" />';
printf('<small>(%s)</small></td>',_('Recursively copy all children of this object as well.'));
echo '</tr>';
echo "\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',
_('When performing a recursive copy, only copy those entries which match this filter'),_('Filter'));
echo '<td><input type="text" name="filter" value="(objectClass=*)" size="45" disabled />';
echo '</tr>';
echo "\n";
echo '<tr>';
printf('<td>%s</td>',_('Delete after copy (move):'));
echo '<td><input type="checkbox" name="remove" value="yes" disabled />';
printf('<small>(%s)</small)</td>',_('Make sure your filter (above) will select all child records.'));
echo '</tr>';
echo "\n";
} else {
printf('<tr><td>%s</td><td><input type="checkbox" name="remove" value="yes"/></td></tr>',_('Delete after copy (move):'));
}
echo "\n";
printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Copy '));
echo "\n";
echo '</table>';
echo '</form>';
if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints'))
printf('<small><img src="%s/light.png" alt="Light" /><span class="hint">%s</span></small>',
IMGDIR,_('Hint: Copying between different servers only works if there are no schema violations'));
echo '</center>';
# Draw the javascrpt to enable/disable the filter field if this may be a recursive copy
if (count($request['children']) > 0) {
?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
function toggle_disable_filter_field(recursive_checkbox) function toggle_disable_filter_field(recursive_checkbox)
{ {
@ -40,67 +112,6 @@ if (is_array($entry['children']) && count($entry['children']) > 0) { ?>
} }
} }
</script> </script>
<?php
<?php }
printf('<h3 class="title">%s %s</h3>',_('Copy'),htmlspecialchars($entry['rdn']));
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',_('Server'),$ldapserver->name,
_('Distinguished Name'),htmlspecialchars($entry['dn']));
echo "\n";
echo '<center>';
printf('%s <b>%s</b> %s:<br /><br />',_('Copy'),htmlspecialchars($entry['rdn']),_('to a new object'));
echo '<form action="cmd.php" method="post" name="copy_form">';
echo '<input type="hidden" name="cmd" value="copy" />';
printf('<input type="hidden" name="old_dn" value="%s" />',htmlspecialchars($entry['dn']));
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
echo "\n";
echo '<table style="border-spacing: 10px">';
echo "\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',
_('The full DN of the new entry to be created when copying the source entry'),_('Destination DN'));
printf('<td><input type="text" name="new_dn" size="45" value="%s" />',htmlspecialchars($entry['dn']));
draw_chooser_link('copy_form.new_dn','true',htmlspecialchars($entry['rdn']));
echo '</td></tr>';
echo "\n";
printf('<tr><td>%s</td><td>%s</td></tr>',_('Destination Server'),server_select_list($ldapserver->server_id,true,'dest_server_id'));
echo "\n";
if (is_array($entry['children']) && count($entry['children']) > 0) {
echo '<tr>';
printf('<td><label for="recursive">%s</label>:</td>',_('Recursive copy'));
echo '<td><input type="checkbox" id="recursive" name="recursive" onClick="toggle_disable_filter_field(this)" />';
printf('<small>(%s)</small></td>',_('Recursively copy all children of this object as well.'));
echo '</tr>'."\n";
echo '<tr>';
printf('<td><acronym title="%s">%s</acronym>:</td>',_('When performing a recursive copy, only copy those entries which match this filter'),_('Filter'));
echo '<td><input type="text" name="filter" value="(objectClass=*)" size="45" disabled />';
echo '</tr>'."\n";
echo '<tr>';
printf('<td>%s</td>',_('Delete after copy (move):'));
echo '<td><input type="checkbox" name="remove" value="yes" disabled />';
printf('<small>(%s)</small)</td>',_('Make sure your filter (above) will select all child records.'));
echo '</tr>';
} else {
printf('<tr><td>%s</td><td><input type="checkbox" name="remove" value="yes"/></td></tr>',_('Delete after copy (move):'));
} }
echo "\n";
printf('<tr><td colspan="2" align="right"><input type="submit" value="%s" /></td></tr>',_('Copy '));
echo "\n";
echo '</table></form>';
echo "\n";
if ($_SESSION[APPCONFIG]->GetValue('appearance','show_hints'))
printf('<small><img src="%s/light.png" alt="Light" /><span class="hint">%s</span></small>',IMGDIR,_('Hint: Copying between different servers only works if there are no schema violations'));
echo '</center>';
?> ?>

View File

@ -1,138 +1,111 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/create.php,v 1.48.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Creates a new object. * Creates a new object in LDAP.
*
* Variables that come in as POST vars:
* - new_dn
* - required_attrs (an array with indices being the attributes,
* and the values being their respective values)
* - object_classes (rawurlencoded, and serialized array of objectClasses)
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
* @todo: posixgroup with empty memberlist generates an error.
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # If cancel was selected, we'll redirect
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); if (get_request('cancel','REQUEST')) {
header('Location: index.php');
die();
}
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_create')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_create'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('create entry')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('create entry')),'error','index.php');
$rdn_attr = get_request('rdn_attribute'); $request = array();
$request['redirect'] = get_request('redirect','POST',false,false);
$entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory'); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
eval('$entry_factory = new '.$entryfactoryclass.'();'); $request['page']->setContainer(get_request('container','REQUEST',true));
$entry = $entry_factory->newCreatingEntry(''); $request['page']->accept();
$request['template'] = $request['page']->getTemplate();
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);'); if (! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer()))
$entry->accept($reader); error(sprintf(_('The container you specified (%s) does not exist. Please try again.'),$request['template']->getContainer()),'error','index.php');
$container = $entry->getContainer(); # Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry...
$tree = get_cached_item($app['server']->getIndex(),'tree');
$request['container'] = $tree->getEntry($request['template']->getContainer());
if (! $request['container'])
$tree->addEntry($request['template']->getContainer());
if (!$container || !$ldapserver->dnExists($container)) $request['container'] = $tree->getEntry($request['template']->getContainer());
error(sprintf(_('The container you specified (%s) does not exist. Please try again.'),htmlspecialchars($container)),'error','index.php');
$tree = get_cached_item($ldapserver->server_id,'tree'); if ($request['container']->isLeaf())
if ($tree) { error(sprintf(_('The container (%s) is a leaf.'),$request['template']->getContainer()),'error','index.php');
$container_entry = $tree->getEntry($container);
if (!$container_entry)
$tree->addEntry($container);
$container_entry = $tree->getEntry($container); # Check our RDN
if ($container_entry->isLeaf()) if (! count($request['template']->getRDNAttrs()))
error(sprintf(_('The container (%s) is a leaf.'), htmlspecialchars($container)),'error','index.php'); error(_('The were no attributes marked as an RDN attribute.'),'error','index.php');
if (! $request['template']->getRDN())
error(_('The RDN field is empty?'),'error','index.php');
# Some other attribute checking...
foreach ($request['template']->getAttributes() as $attribute) {
# Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through.
# @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
error(sprintf(_('You left the value blank for required attribute (%s).'),
$attribute->getName(false)),'error','index.php');
} }
$entry->setRdnAttributeName($rdn_attr); # Create the entry
if (!$entry->getRdnAttribute()) $add_result = $app['server']->add($request['template']->getDN(),$request['template']->getLDAPadd());
error(sprintf(_('The Rdn attribute (%s) does not exist.'), htmlspecialchars($rdn_attr)),'error','index.php');
$new_dn = $entry->getDn();
if (! $new_dn)
error(_('You left the RDN field blank.'),'error','index.php');
$redirect = get_request('redirect','POST',false,false);
$new_entry = array();
$attrs = $entry->getAttributes();
foreach ($attrs as $attr) {
$vals = $attr->getValues();
$new_vals = array();
foreach ($vals as $val) {
if (strlen($val) > 0)
$new_vals[] = $val;
}
if ($attr->isRequired() && !$new_vals && !$ldapserver->isIgnoredAttr($attr->getName()))
error(sprintf(_('You left the value blank for required attribute (%s).'),htmlspecialchars($attr->getName())),'error','index.php');
if ($new_vals)
$new_entry[$attr->getName()] = $new_vals;
}
if (! in_array('top', $new_entry['objectClass']))
$new_entry['objectClass'][] = 'top';
foreach ($new_entry as $attr => $vals) {
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($new_dn,$attr,$vals)) {
$search_href = sprintf('?cmd=search&amp;search=true&amp;form=advanced&amp;server_id=%s&amp;filter=%s=%s', $ldapserver->server_id,$attr,$badattr);
error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$attr,$badattr,$new_dn,$search_href),'error','index.php');
}
}
# Check the user-defined custom call back first
if (run_hook('pre_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=>$new_dn,'attrs'=>$new_entry)))
$add_result = $ldapserver->add($new_dn,$new_entry);
if ($add_result) { if ($add_result) {
run_hook('post_entry_create',array('server_id'=>$ldapserver->server_id,'dn'=>$new_dn,'attrs'=>$new_entry)); $action_number = $_SESSION[APPCONFIG]->getValue('appearance','action_after_creation');
$href = sprintf('cmd=template_engine&server_id=%s',$app['server']->getIndex());
$action_number = $_SESSION[APPCONFIG]->GetValue('appearance', 'action_after_creation'); if ($request['redirect'])
$redirect_url = $request['redirect'];
$container = get_container($new_dn,false); else if ($action_number == 2)
//$container_container = get_container($container); $redirect_url = sprintf('cmd.php?%s&template=%s&container=%s',
$href,$request['template']->getID(),rawurlencode($request['template']->getContainer()));
if ($redirect) { else
$redirect_url = $redirect; $redirect_url = sprintf('cmd.php?%s&template=%s&dn=%s',
} else if ($action_number == 2) { $href,$request['template']->getID(),rawurlencode($request['template']->getDN()));
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s', $ldapserver->server_id, rawurlencode($container));
} else {
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', $ldapserver->server_id, rawurlencode($new_dn));
}
if ($action_number == 1 || $action_number == 2) if ($action_number == 1 || $action_number == 2)
printf('<meta http-equiv="refresh" content="0; url=%s" />',$redirect_url); printf('<meta http-equiv="refresh" content="0; url=%s" />',$redirect_url);
if ($action_number == 1 || $action_number == 2) { if ($action_number == 1 || $action_number == 2) {
$create_message = sprintf('%s DN%s <b>%s</b> %s',_('Creation successful!'),_(':'),htmlspecialchars($new_dn),_('has been created.')); $create_message = sprintf('%s %s: <b>%s</b> %s',
_('Creation successful!'),_('DN'),$request['template']->getDN(),_('has been created.'));
if (isAjaxEnabled())
$redirect_url .= sprintf('&refresh=SID_%s_nodes&noheader=1',$app['server']->getIndex());
system_message(array( system_message(array(
'title'=>_('Create Entry'), 'title'=>_('Create Entry'),
'body'=>$create_message, 'body'=>$create_message,
'type'=>'info'), 'type'=>'info'),
$redirect_url); $redirect_url);
} else { } else {
printf('<h3 class="title">%s</h3>',_('Entry created')); $request['page']->drawTitle(_('Entry created'));
$request['page']->drawSubTitle(sprintf('%s: <b>%s</b>&nbsp;&nbsp;&nbsp;%s: <b>%s</b>',
_('Server'),$app['server']->getName(),_('Distinguished Name'),$request['template']->getDN()));
echo '<br />'; echo '<br />';
echo '<center>'; echo '<center>';
printf('<a href="cmd.php?cmd=template_engine&server_id=%s&dn=%s">%s</a>.',$ldapserver->server_id,rawurlencode($new_dn),_('Display the new created entry')); printf('<a href="cmd.php?%s&amp;dn=%s">%s</a>.',
htmlspecialchars($href),rawurlencode($request['template']->getDN()),_('Display the new created entry'));
echo '<br />'; echo '<br />';
printf('<a href="cmd.php?cmd=template_engine&server_id=%s&container=%s">%s</a>.',$ldapserver->server_id,rawurlencode($container),_('Create another entry')); printf('<a href="cmd.php?%s&amp;container=%s">%s</a>.',
htmlspecialchars($href),rawurlencode($request['template']->getContainer()),_('Create another entry'));
echo '</center>'; echo '</center>';
} }
} else {
system_message(array(
'title'=>_('Could not add the object to the LDAP server.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
} }
?> ?>

134
htdocs/create_confirm.php Normal file
View File

@ -0,0 +1,134 @@
<?php
// $Header$
/**
* Creates a new object in LDAP.
*
* @package phpLDAPadmin
* @subpackage Page
*/
/**
*/
require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_create'))
error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('create entry')),'error','index.php');
$request = array();
$request['redirect'] = get_request('redirect','POST',false,false);
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->setContainer(get_request('container','REQUEST',true));
$request['page']->accept();
$request['template'] = $request['page']->getTemplate();
if (! $request['template']->getContainer() || ! $app['server']->dnExists($request['template']->getContainer()))
error(sprintf(_('The container you specified (%s) does not exist. Please try again.'),$request['template']->getContainer()),'error','index.php');
# Check if the container is a leaf - we shouldnt really return a hit here, the template engine shouldnt have allowed a user to attempt to create an entry...
$tree = get_cached_item($app['server']->getIndex(),'tree');
$request['container'] = $tree->getEntry($request['template']->getContainer());
if (! $request['container'])
$tree->addEntry($request['template']->getContainer());
$request['container'] = $tree->getEntry($request['template']->getContainer());
if ($request['container']->isLeaf())
error(sprintf(_('The container (%s) is a leaf.'),$request['template']->getContainer()),'error','index.php');
# Check our RDN
if (! count($request['template']->getRDNAttrs()))
error(_('The were no attributes marked as an RDN attribute.'),'error','index.php');
if (! $request['template']->getRDN())
error(_('The RDN field is empty?'),'error','index.php');
# Some other attribute checking...
foreach ($request['template']->getAttributes() as $attribute) {
# Check that our Required Attributes have a value - we shouldnt really return a hit here, the template engine shouldnt have allowed this to slip through.
# @todo this isIgnoredAttr() function is missing?
if ($attribute->isRequired() && ! count($attribute->getValues()) && ! $app['server']->isIgnoredAttr($attr->getName()))
error(sprintf(_('You left the value blank for required attribute (%s).'),
$attribute->getName(false)),'error','index.php');
}
# Check for unique attributes
$app['server']->checkUniqueAttrs($request['template']->getDN(),$request['template']->getLDAPadd());
$request['page']->drawTitle(_('Create LDAP Entry'));
$request['page']->drawSubTitle(sprintf('%s: <b>%s</b>&nbsp;&nbsp;&nbsp;%s: <b>%s</b>',
_('Server'),$app['server']->getName(),_('Container'),$request['template']->getContainer()));
# Confirm the creation
if (count($request['template']->getLDAPadd(true))) {
echo '<center>';
echo _('Do you want to create this entry?');
echo '<br /><br />';
echo "\n\n";
echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="create" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($request['template']->getContainer()));
printf('<input type="hidden" name="template" value="%s" />',$request['template']->getID());
foreach ($request['template']->getRDNAttrs() as $rdn)
printf('<input type="hidden" name="rdn_attribute[]" value="%s" />',htmlspecialchars($rdn));
echo "\n";
$request['page']->drawHiddenAttributes();
echo '<table class="result_table">';
echo "\n";
printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td></tr>',
_('Attribute'),_('New Value'),_('Skip'));
echo "\n\n";
$counter = 0;
printf('<tr class="%s"><td colspan=3><center><b>%s</b></center></td><tr>',$counter%2 ? 'even' : 'odd',$request['template']->getDN());
foreach ($request['template']->getLDAPadd(true) as $attribute) {
$counter++;
printf('<tr class="%s">',$counter%2 ? 'even' : 'odd');
printf('<td><b>%s</b></td>',$attribute->getFriendlyName());
# Show NEW Values
echo '<td><span style="white-space: nowrap;">';
$request['page']->draw('CurrentValues',$attribute);
echo '</span></td>';
# Show SKIP Option
$input_disabled = '';
$input_onclick = '';
if ($attribute->isRequired())
$input_disabled = 'disabled="disabled"';
printf('<td><input name="skip_array[%s]" id="skip_array_%s" type="checkbox" %s %s/></td>',
htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick);
echo '</tr>';
echo "\n\n";
}
echo '</table>';
echo '<br />';
printf('<input type="submit" value="%s" />',_('Commit'));
printf('<input type="submit" name="cancel" value="%s" />',_('Cancel'));
echo '</form>';
echo '<br />';
echo '</center>';
} else {
echo '<center>';
echo _('You made no changes');
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn']));
printf(' <a href="%s">%s</a>.',htmlspecialchars($href),_('Go back'));
echo '</center>';
}
?>

View File

@ -1,11 +1,11 @@
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/css/style.css,v 1.48.2.9 2009/03/20 07:33:04 wurley Exp $ */ /* $Header$ */
/* Global Page */ /* Global Page */
table.page { table.page {
font-weight: normal; font-weight: normal;
color: #000000; color: #000000;
font-family: bitstream vera sans,luxi sans,verdana,geneva,arial,helvetica,sans-serif; font-family: "bitstream vera sans","luxi sans",verdana,geneva,arial,helvetica,sans-serif;
background-color: #FFFFFF; background-color: #FFFFFF;
font-size: 13px; font-size: 13px;
empty-cells: hide; empty-cells: hide;
@ -32,7 +32,7 @@ table.page tr.head {
color: #FFFFFF; color: #FFFFFF;
background-color: #001188; background-color: #001188;
font-weight: bold; font-weight: bold;
font-size: 12px; font-size: 11px;
height: 25px; height: 25px;
} }
@ -44,6 +44,15 @@ table.page tr.head img.logo {
height: 60px; height: 60px;
} }
table.page tr.pagehead {
}
table.page tr.pagehead td.imagetop {
width: 100%;
vertical-align: bottom;
text-align: right;
}
/* Global Page - Control Line */ /* Global Page - Control Line */
table.page tr.control td { table.page tr.control td {
border-top: 1px solid #AAAACC; border-top: 1px solid #AAAACC;
@ -59,12 +68,13 @@ table.page table.control {
table.page table.control td { table.page table.control td {
border-top: 0px; border-top: 0px;
border-bottom: 0px; border-bottom: 0px;
width: 30px;
padding: 0px; padding: 0px;
padding-top: 5px; padding-top: 2px;
text-align: center; padding-bottom: 2px;
text-align: left;
vertical-align: top; vertical-align: top;
font-size: 11px; font-size: 11px;
font-weight: bold;
} }
table.page table.control img { table.page table.control img {
@ -349,6 +359,11 @@ table.tree a:hover {
color: blue; color: blue;
} }
table.tree span.dnicon img {
width: 16px;
padding-bottom: 0px;
}
/* Standard Form */ /* Standard Form */
table.forminput { table.forminput {
background-color: #F9F9FA; background-color: #F9F9FA;
@ -548,56 +563,6 @@ span.hint {
color: #888; color: #888;
} }
/* Edit DN - EntryWriter2 */
table.entry tr.spacer {
background-color: #D0D0D0;
}
table.entry tr td.ew2_icon {
vertical-align: top;
}
table.entry tr td.ew2_attr {
vertical-align: top;
text-align: right;
font-size: 75%;
background-color: #fff;
font-weight: bold;
}
table.entry tr td.ew2_attr a {
text-decoration: none;
color: #000000;
}
table.entry tr td.ew2_attr a:hover {
text-decoration: underline;
color: #016;
}
table.entry tr td.ew2_val {
text-align: left;
vertical-align: top;
padding-bottom: 10px;
padding-left: 50px;
}
table.entry tr.updated td.ew2_attr {
text-align: right;
font-size: 75%;
border-top: 1px dashed green;
border-left: 1px dashed green;
border-bottom: 1px dashed green;
background-color: #ded;
}
table.entry tr.updated td.ew2_val {
border-top: 1px dashed green;
border-left: 1px dashed green;
border-right: 1px dashed green;
border-bottom: 1px dashed green;
}
/* Login Box */ /* Login Box */
#login { #login {
background: url('../images/uid.png') no-repeat 0 1px; background: url('../images/uid.png') no-repeat 0 1px;
@ -652,7 +617,7 @@ table.entry tr.updated td.ew2_val {
div.execution_time { div.execution_time {
font-size: 75%; font-size: 75%;
font-weight: normal; font-weight: normal;
text-align: center; text-align: left;
} }
table.result { table.result {
@ -697,6 +662,12 @@ table.result tr.list_item td.value {
font-size: 12px; font-size: 12px;
} }
table.result_box {
border: 1px solid #AAAACC;
border-collapse: collapse;
empty-cells: show;
}
table.result_table { table.result_table {
border: 1px solid #AAAACC; border: 1px solid #AAAACC;
border-collapse: collapse; border-collapse: collapse;
@ -704,6 +675,7 @@ table.result_table {
} }
table.result_table td { table.result_table td {
font-size: 12px;
vertical-align: top; vertical-align: top;
border: 1px solid #AAAACC; border: 1px solid #AAAACC;
padding: 4px; padding: 4px;
@ -732,7 +704,7 @@ table.result_table tr.highlight td {
table.result_table td.heading { table.result_table td.heading {
color: #FFFFFF; color: #FFFFFF;
background-color: #000088; background-color: #000088;
font-size: 15px; font-size: 12px;
} }
table.result_table td.value { table.result_table td.value {
@ -743,12 +715,14 @@ table.result_table td.value {
table.result_table tr.heading { table.result_table tr.heading {
color: #FFFFFF; color: #FFFFFF;
background-color: #000088; background-color: #000088;
font-size: 15px; font-size: 12px;
font-weight: bold;
} }
table.result_table tr.heading a { table.result_table tr.heading a {
color: #FFFFFF; color: #FFFFFF;
font-size: 20px; font-size: 12px;
font-weight: bold;
} }
table.result_table tr.heading td { table.result_table tr.heading td {

View File

@ -1,55 +1,40 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete.php,v 1.27.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Deletes a DN and presents a "job's done" message. * Deletes a DN and presents a "job's done" message.
* *
* Variables that come in as POST vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DNs we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
$request['dn'] = get_request('dn','REQUEST',true);
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete', 'simple_delete')) if (! $app['server']->dnExists($request['dn']))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry')),'error','index.php'); error(sprintf('%s (%s)',_('No such entry.'),'<b>'.pretty_print_dn($request['dn']).'</b>'),'error','index.php');
$entry = array(); if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete','simple_delete'))
$entry['dn'] = get_request('dn'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('delete entry')),'error','index.php');
if (! $entry['dn']) # Delete the entry.
error(_('You must specify a DN'),'error','index.php'); $result = $app['server']->delete($request['dn']);
if (! $ldapserver->dnExists($entry['dn']))
error(sprintf('%s (%s)',_('No such entry.'),'<b>'.pretty_print_dn($entry['dn']).'</b>'),'error','index.php');
# Check the user-defined custom callback first.
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn'])))
$result = $ldapserver->delete($entry['dn']);
else
error(sprintf(_('Could not delete the entry: %s'),'<b>'.pretty_print_dn($entry['dn']).'</b>'),'error','index.php');
if ($result) {
# Custom callback
run_hook('post_entry_delete',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']));
if ($result)
system_message(array( system_message(array(
'title'=>_('Delete DN'), 'title'=>_('Delete DN'),
'body'=>_('Successfully deleted DN ').sprintf('<b>%s</b>',$entry['dn']), 'body'=>_('Successfully deleted DN ').sprintf('<b>%s</b>',$request['dn']),
'type'=>'info'), 'type'=>'info'),
sprintf('index.php?server_id=%s',$ldapserver->server_id)); sprintf('index.php?server_id=%s',$app['server']->getIndex()));
else
} else {
system_message(array( system_message(array(
'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($entry['dn'])), 'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($request['dn'])),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()), 'body'=>ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null)),
'type'=>'error')); 'type'=>'error'));
}
?> ?>

View File

@ -1,56 +1,54 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_attr.php,v 1.16.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Deletes an attribute from an entry with NO confirmation. * Deletes an attribute from an entry with NO confirmation.
* *
* On success, redirect to template_engine.php
* On failure, echo an error.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('delete attribute')),'error','index.php');
$entry = array(); $request = array();
$entry['dn']['string'] = get_request('dn'); $request['dn'] = get_request('dn','REQUEST',true);
$entry['dn']['encode'] = rawurlencode($entry['dn']['string']); $request['attr'] = get_request('attr','REQUEST',true);
$entry['attr'] = get_request('attr'); $request['index'] = get_request('index','REQUEST',true);
if (! $entry['dn']['string']) if ($app['server']->isAttrReadOnly($request['attr']))
error(_('No DN specified'),'error','index.php'); error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),$request['attr']),'error','index.php');
if (! $entry['attr'])
error(_('No attribute name specified.'),'error','index.php');
if ($ldapserver->isAttrReadOnly($entry['attr']))
error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),htmlspecialchars($entry['attr'])),'error','index.php');
$update_array = array(); $update_array = array();
$update_array[$entry['attr']] = array(); $update_array[$request['attr']] = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
$result = $ldapserver->modify($entry['dn']['string'],$update_array); $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
if ($result) { $app['server']->getIndex(),rawurlencode($request['dn']));
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$ldapserver->server_id,$entry['dn']['encode']);
if (! isset($update_array[$request['attr']][$request['index']]))
system_message(array(
'title'=>_('Could not delete attribute value.'),
'body'=>sprintf('%s. %s/%s',_('The attribute value does not exist'),$request['attr'],$request['index']),
'type'=>'warn'),$redirect_url);
else {
unset($update_array[$request['attr']][$request['index']]);
foreach ($update_array as $key => $values)
$update_array[$key] = array_values($values);
$result = $app['server']->modify($request['dn'],$update_array);
if ($result) {
foreach ($update_array as $attr => $junk) foreach ($update_array as $attr => $junk)
$redirect_url .= "&modified_attrs[]=$attr"; $redirect_url .= sprintf('&modified_attrs[]=%s',$attr);
header("Location: $redirect_url"); header("Location: $redirect_url");
die(); die();
}
} else {
system_message(array(
'title'=>_('Could not perform ldap_modify operation.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
} }
?> ?>

View File

@ -1,50 +1,53 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/delete_form.php,v 1.26.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* delete_form.php * Displays a last chance confirmation form to delete a DN.
* Displays a last chance confirmation form to delete a dn.
*
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
$request['dn'] = get_request('dn','GET');
$entry = array(); # Check if the entry exists.
$entry['dn']['string'] = get_request('dn','GET'); if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
$entry['dn']['html'] = htmlspecialchars($entry['dn']['string']); error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
# We search all children, not only the visible children in the tree # We search all children, not only the visible children in the tree
$entry['children'] = $ldapserver->getContainerContents($entry['dn']['string'],0,'(objectClass=*)',LDAP_DEREF_NEVER); $request['children'] = $app['server']->getContainerContents($request['dn'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
printf('<h3 class="title">'._('Delete %s').'</h3>',htmlspecialchars(get_rdn($entry['dn']['string']))); printf('<h3 class="title">%s %s</h3>',_('Delete'),get_rdn($request['dn']));
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>', printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
_('Server'),$ldapserver->name,_('Distinguished Name'),$entry['dn']['html']); _('Server'),$app['server']->getName(),_('Distinguished Name'),$request['dn']);
echo "\n"; echo "\n";
echo '<center>'; echo '<center>';
if (count($entry['children'])) { if (count($request['children'])) {
printf('<b>%s</b><br /><br />',_('Permanently delete all children also?')); printf('<b>%s</b><br /><br />',_('Permanently delete all children also?'));
# Get the total number of child objects (whole sub-tree) $search['href'] = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&server_id=%s&filter=%s&base_dn=%s&form=advanced&scope=sub',
$search['entries'] = $ldapserver->search(null,dn_escape($entry['dn']['string']),'objectClass=*',array('dn')); $app['server']->getIndex(),rawurlencode('objectClass=*'),rawurlencode($request['dn'])));
$search['count'] = count($search['entries']);
$search['href'] = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&;server_id=%s&filter=%s&base_dn=%s&form=advanced&scope=sub', $query = array();
$ldapserver->server_id,rawurlencode('objectClass=*'),rawurlencode($entry['dn']['string']))); $query['base'] = $request['dn'];
$query['scope'] = 'sub';
$query['attrs'] = array('dn');
$query['deref'] = LDAP_DEREF_NEVER;
$request['search'] = $app['server']->query($query,null);
echo '<table class="forminput" border=0>'; echo '<table class="forminput" border=0>';
echo '<tr>'; echo '<tr>';
echo '<td colspan=2>'; echo '<td colspan=2>';
printf(_('This entry is the root of a sub-tree containing %s entries.'),$search['count']); printf(_('This entry is the root of a sub-tree containing %s entries.'),count($request['search']));
printf(' <small>(<a href="%s">%s</a>)</small>', printf(' <small>(<a href="%s">%s</a>)</small>',
$search['href'],_('view entries')); $search['href'],_('view entries'));
echo '</td></tr>'; echo '</td></tr>';
@ -52,7 +55,7 @@ if (count($entry['children'])) {
echo '<tr><td colspan=2>&nbsp;</td></tr>'; echo '<tr><td colspan=2>&nbsp;</td></tr>';
printf('<tr><td colspan=2>%s</td></tr>', printf('<tr><td colspan=2>%s</td></tr>',
sprintf(_('phpLDAPadmin can recursively delete this entry and all %s of its children. See below for a list of all the entries that this action will delete. Do you want to do this?'),$search['count']-1)); sprintf(_('phpLDAPadmin can recursively delete this entry and all %s of its children. See below for a list of all the entries that this action will delete. Do you want to do this?'),count($request['search'])));
echo '<tr><td colspan=2>&nbsp;</td></tr>'; echo '<tr><td colspan=2>&nbsp;</td></tr>';
@ -64,17 +67,17 @@ if (count($entry['children'])) {
echo '<td width=50%><center>'; echo '<td width=50%><center>';
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="rdelete" />'; echo '<input type="hidden" name="cmd" value="rdelete" />';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($entry['dn']['string'])); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
printf('<input type="submit" value="%s" />',sprintf(_('Delete all %s objects'),$search['count'])); printf('<input type="submit" value="%s" />',sprintf(_('Delete all %s objects'),count($request['search'])));
echo '</form>'; echo '</form>';
echo '</center></td>'; echo '</center></td>';
echo '<td width=50%><center>'; echo '<td width=50%><center>';
echo '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
echo '<input type="hidden" name="cmd" value="template_engine" />'; echo '<input type="hidden" name="cmd" value="template_engine" />';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($entry['dn']['string'])); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
printf('<input type="submit" name="submit" value="%s" />',_('Cancel')); printf('<input type="submit" name="submit" value="%s" />',_('Cancel'));
echo '</form>'; echo '</form>';
echo '</center></td>'; echo '</center></td>';
@ -88,12 +91,10 @@ if (count($entry['children'])) {
echo _('List of entries to be deleted:'); echo _('List of entries to be deleted:');
echo '<br />'; echo '<br />';
printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,$search['count']));
$i = 0; $i = 0;
foreach ($search['entries'] as $dn => $junk) { printf('<select size="%s" multiple disabled style="background:white; color:black;width:500px" >',min(10,count($request['search'])));
$i++; foreach ($request['search'] as $key => $value)
printf('<option>%s. %s</option>',$i,htmlspecialchars(dn_unescape($dn))); printf('<option>%s. %s</option>',++$i,dn_unescape($value['dn']));
}
echo '</select>'; echo '</select>';
echo "\n"; echo "\n";
@ -103,9 +104,9 @@ if (count($entry['children'])) {
printf('<tr><td colspan=4>%s</td></tr>',_('Are you sure you want to permanently delete this object?')); printf('<tr><td colspan=4>%s</td></tr>',_('Are you sure you want to permanently delete this object?'));
echo '<tr><td colspan=4>&nbsp;</td></tr>'; echo '<tr><td colspan=4>&nbsp;</td></tr>';
printf('<tr><td width=10%%>%s:</td><td colspan=3 width=75%%><b>%s</b></td></tr>',_('Server'),htmlspecialchars($ldapserver->name)); printf('<tr><td width=10%%>%s:</td><td colspan=3 width=75%%><b>%s</b></td></tr>',_('Server'),$app['server']->getName());
printf('<tr><td width=10%%><acronym title="%s">%s</acronym></td><td colspan=3 width=75%%><b>%s</b></td></tr>', printf('<tr><td width=10%%><acronym title="%s">%s</acronym></td><td colspan=3 width=75%%><b>%s</b></td></tr>',
_('Distinguished Name'),_('DN'),$entry['dn']['string']); _('Distinguished Name'),_('DN'),$request['dn']);
echo '<tr><td colspan=4>&nbsp;</td></tr>'; echo '<tr><td colspan=4>&nbsp;</td></tr>';
echo "\n"; echo "\n";
@ -113,8 +114,8 @@ if (count($entry['children'])) {
echo '<td colspan=2 width=50%><center>'; echo '<td colspan=2 width=50%><center>';
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="delete" />'; echo '<input type="hidden" name="cmd" value="delete" />';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($entry['dn']['string'])); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
printf('<input type="submit" name="submit" value="%s" />',_('Delete')); printf('<input type="submit" name="submit" value="%s" />',_('Delete'));
echo '</form>'; echo '</form>';
@ -123,8 +124,8 @@ if (count($entry['children'])) {
echo '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
echo '<input type="hidden" name="cmd" value="template_engine" />'; echo '<input type="hidden" name="cmd" value="template_engine" />';
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($entry['dn']['string'])); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($request['dn']));
printf('<input type="submit" name="submit" value="%s" />',_('Cancel')); printf('<input type="submit" name="submit" value="%s" />',_('Cancel'));
echo '</form>'; echo '</form>';

View File

@ -1,45 +1,51 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/download_binary_attr.php,v 1.15.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Download a binary value attribute to the user.
* A server ID, DN and Attribute must be provided in the GET attributes.
* Optionally an index, type and filename can be supplied.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* Variables that come in via common.php * @subpackage Page
* - server_id
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) $request = array();
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request['dn'] = get_request('dn','GET');
$request['attr'] = strtolower(get_request('attr','GET',true));
$request['index'] = get_request('index','GET',false,0);
$request['type'] = get_request('type','GET',false,'octet-stream');
$request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr']));
if (! $ldapserver->haveAuthInfo()) if (! $app['server']->dnExists($request['dn']))
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php'); error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
$dn = rawurldecode(get_request('dn','GET')); $search = $app['server']->getDNAttrValues($request['dn'],null,LDAP_DEREF_NEVER,array($request['attr']));
$attr = get_request('attr','GET');
# if there are multiple values in this attribute, which one do you want to see?
$value_num = get_request('value_num','GET');
if (! $ldapserver->dnExists($dn))
error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($dn)),'error','index.php');
$search = $ldapserver->search(null,$dn,'(objectClass=*)',array($attr),'base',false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
# Dump the binary data to the browser # Dump the binary data to the browser
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
ob_end_clean(); ob_end_clean();
header('Content-type: octet-stream'); if (! isset($search[$request['attr']][$request['index']])) {
header("Content-disposition: attachment; filename=$attr"); # We cant display an error, but we can set a system message, which will be display on the next page render.
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); system_message(array(
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); 'title'=>_('No binary data available'),
'body'=>sprintf(_('Could not fetch binary data from LDAP server for attribute [%s].'),$request['attr']),
'type'=>'warn'));
if ($value_num && is_array($search[$attr][$dn])) die();
echo $search[$dn][$attr][$value_num]; }
else
echo $search[$dn][$attr]; header(sprintf('Content-type: %s',$request['type']));
header(sprintf('Content-disposition: attachment; filename="%s"',$request['filename']));
header(sprintf('Expires: Mon, 26 Jul 1997 05:00:00 GMT',gmdate('r')));
header(sprintf('Last-Modified: %s',gmdate('r')));
echo $search[$request['attr']][$request['index']];
die();
?> ?>

View File

@ -1,42 +1,63 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/draw_tree_node.php,v 1.2.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Draw a portion of the LDAP tree.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Tree
*/ */
$entry = array(); /**
$entry['dn'] = get_request('dn','REQUEST'); */
$entry['server_id'] = get_request('server_id','REQUEST');
$entry['code'] = get_request('code','REQUEST');
$entry['action'] = get_request('action','REQUEST');
$tree = Tree::getInstance($entry['server_id']); $request = array();
$request['dn'] = get_request('dn','REQUEST');
$request['server_id'] = get_request('server_id','REQUEST');
$request['code'] = get_request('code','REQUEST');
$request['action'] = get_request('action','REQUEST');
$request['noheader'] = get_request('noheader','REQUEST',false,0);
$tree = Tree::getInstance($request['server_id']);
if (! $tree) if (! $tree)
die(); die();
$dnentry = $tree->getEntry($entry['dn']); $treesave = false;
if (! $dnentry) {
$tree->addEntry($entry['dn']);
$dnentry = $this->getEntry($entry['dn']);
}
if (! $dnentry) if ($request['dn']) {
die(); $dnentry = $tree->getEntry($request['dn']);
if ($entry['action'] == 0) { if (! $dnentry) {
$tree->addEntry($request['dn']);
$dnentry = $tree->getEntry($request['dn']);
$treesave = true;
}
switch ($request['action']) {
case 0:
$dnentry->close(); $dnentry->close();
} elseif ($entry['action'] == 2) { break;
$dnentry->open();
case 2:
default:
if ($dnentry->isSizeLimited()) {
$tree->readChildren($request['dn'],true);
$treesave = true;
}
} else {
$dnentry->open(); $dnentry->open();
if ($entry['dn']) {
echo $tree->draw_children($dnentry,$entry['code']);
} else {
$tree->draw(true);
} }
} }
if ($treesave)
set_cached_item($app['server']->getIndex(),'tree','null',$tree);
if ($request['dn'])
echo $tree->draw_children($dnentry,$request['code']);
else
$tree->draw($request['noheader']);
die(); die();
?> ?>

View File

@ -1,125 +1,123 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/entry_chooser.php,v 1.31.2.5 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Display a selection (popup window) to pick a DN. * Display a selection (popup window) to pick a DN.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/
/**
*/ */
include './common.php'; include './common.php';
include HTDOCDIR.'header.php';
$entry = array(); $www['page'] = new page();
$entry['container'] = get_request('container','GET');
$entry['element'] = get_request('form_element','GET'); $request = array();
$entry['rdn'] = get_request('rdn','GET'); $request['container'] = get_request('container','GET');
$request['element'] = get_request('form_element','GET');
$request['rdn'] = get_request('rdn','GET');
echo '<body>';
echo '<div class="popup">'; echo '<div class="popup">';
printf('<h3 class="subtitle">%s</h3>',_('Entry Chooser')); printf('<h3 class="subtitle">%s</h3>',_('Entry Chooser'));
?>
<script type="text/javascript" language="javascript"> echo '<script type="text/javascript" language="javascript">';
function returnDN(dn) { echo ' function returnDN(dn) {';
opener.document.<?php echo $entry['element']; ?>.value = dn; printf(' opener.document.%s.value = dn;',$request['element']);
close(); echo ' close();';
} echo ' }';
</script> echo '</script>';
<?php
echo '<table class="forminput" width=100% border=0>'; echo '<table class="forminput" width=100% border=0>';
if ($entry['container']) { if ($request['container']) {
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name)); printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Server'),$app['server']->getName());
printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Looking in'),htmlspecialchars($entry['container'])); printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>',_('Looking in'),$request['container']);
echo '<tr><td class="blank" colspan=4>&nbsp;</td></tr>'; echo '<tr><td class="blank" colspan=4>&nbsp;</td></tr>';
} }
/* Has the use already begun to descend into a specific server tree? */ # Has the user already begun to descend into a specific server tree?
if (isset($ldapserver) && ! is_null($entry['container'])) { if (isset($app['server']) && ! is_null($request['container'])) {
if (! $ldapserver->haveAuthInfo()) $request['children'] = $app['server']->getContainerContents($request['container'],null,0,'(objectClass=*)',$_SESSION[APPCONFIG]->getValue('deref','tree'));
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php'); sort($request['children']);
$entry['children'] = $ldapserver->getContainerContents($entry['container'],0,'(objectClass=*)',$_SESSION[APPCONFIG]->GetValue('deref','tree')); foreach ($app['server']->getBaseDN() as $base) {
sort($entry['children']);
foreach ($ldapserver->getBaseDN() as $base_dn) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn,$entry['container']); debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base,$request['container']);
if (! pla_compare_dns($entry['container'],$base_dn)) { if (! pla_compare_dns($request['container'],$base)) {
$parent_container = false; $parent_container = false;
$href['up'] = htmlspecialchars(sprintf('entry_chooser.php?form_element=%s&rdn=%s',$entry['element'],$entry['rdn'])); $href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s',$request['element'],rawurlencode($request['rdn']));
break; break;
} else { } else {
$parent_container = get_container($entry['container']); $parent_container = $app['server']->getContainer($request['container']);
$href['up'] = htmlspecialchars(sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s', $href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s',
$entry['element'],$entry['rdn'],$ldapserver->server_id,rawurlencode($parent_container))); $request['element'],$request['rdn'],$app['server']->getIndex(),rawurlencode($parent_container));
} }
} }
echo '<tr>'; echo '<tr>';
echo '<td class="blank">&nbsp;</td>'; echo '<td class="blank">&nbsp;</td>';
printf('<td class="icon"><a href="%s"><img src="%s/up.png" alt="Up" /></a></td>',$href['up'],IMGDIR); printf('<td class="icon"><a href="%s"><img src="%s/up.png" alt="Up" /></a></td>',$href['up'],IMGDIR);
printf('<td colspan=2><a href="%s">%s</a></td>',$href['up'],_('Back Up...')); printf('<td colspan=2><a href="%s">%s...</a></td>',$href['up'],_('Back Up'));
echo '</tr>'; echo '</tr>';
if (! count($entry['children'])) if (! count($request['children']))
printf('<td class="blank" colspan=2>&nbsp;</td><td colspan=2">(%s)</td>',_('no entries')); printf('<td class="blank" colspan=2>&nbsp;</td><td colspan=2">(%s)</td>',_('no entries'));
else else
foreach ($entry['children'] as $dn) { foreach ($request['children'] as $dn) {
$href['return'] = sprintf("javascript:returnDN('%s%s')",($entry['rdn'] ? sprintf('%s,',$entry['rdn']) : ''),rawurlencode($dn)); $href['return'] = sprintf("javascript:returnDN('%s%s')",($request['rdn'] ? sprintf('%s,',$request['rdn']) : ''),rawurlencode($dn));
$href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s', $href['expand'] = sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
$ldapserver->server_id,$entry['element'],$entry['rdn'],rawurlencode($dn))); $app['server']->getIndex(),$request['element'],$request['rdn'],rawurlencode($dn));
echo '<tr>'; echo '<tr>';
echo '<td class="blank">&nbsp;</td>'; echo '<td class="blank">&nbsp;</td>';
printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR); printf('<td class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn)); printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],$dn);
echo '</tr>'; echo '</tr>';
echo "\n\n"; echo "\n\n";
} }
/* draw the root of the selection tree (ie, list all the servers) */ # Draw the root of the selection tree (ie, list all the servers)
} else { } else {
foreach ($_SESSION[APPCONFIG]->ldapservers->GetServerList() as $id) { foreach ($_SESSION[APPCONFIG]->getServerList() as $index => $server) {
if ($server->isLoggedIn(null)) {
$ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($id); printf('<tr><td class="heading" colspan=3>%s:</td><td class="heading">%s</td></tr>',_('Server'),$server->getName());
foreach ($server->getBaseDN() as $dn) {
if ($ldapserver->isVisible()) {
if (! $ldapserver->haveAuthInfo())
continue;
else {
printf('<tr><td class="heading" colspan=3>%s:</td><td class="heading">%s</td></tr>',_('Server'),htmlspecialchars($ldapserver->name));
foreach ($ldapserver->getBaseDN() as $dn) {
if (! $dn) { if (! $dn) {
printf('<tr><td class="blank">&nbsp;</td><td colspan=3>(%s)</td></tr>',_('Could not determine base DN')); printf('<tr><td class="blank">&nbsp;</td><td colspan=3>(%s)</td></tr>',_('Could not determine base DN'));
} else { } else {
$href['return'] = sprintf("javascript:returnDN('%s%s')",($entry['rdn'] ? sprintf('%s,',$entry['rdn']) : ''),rawurlencode($dn)); $href['return'] = sprintf("javascript:returnDN('%s%s')",($request['rdn'] ? sprintf('%s,',$request['rdn']) : ''),rawurlencode($dn));
$href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s', $href['expand'] = htmlspecialchars(sprintf('entry_chooser.php?server_id=%s&form_element=%s&rdn=%s&container=%s',
$ldapserver->server_id,$entry['element'],$entry['rdn'],rawurlencode($dn))); $server->getIndex(),$request['element'],$request['rdn'],rawurlencode($dn)));
echo '<tr>'; echo '<tr>';
echo '<td class="blank">&nbsp;</td>'; echo '<td class="blank">&nbsp;</td>';
printf('<td colspan=2 class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR); printf('<td colspan=2 class="icon"><a href="%s"><img src="%s/plus.png" alt="Plus" /></a></td>',$href['expand'],IMGDIR);
printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],htmlspecialchars($dn)); printf('<td colspan=2><a href="%s">%s</a></td>',$href['return'],$dn);
} }
} }
echo '<tr><td class="blank" colspan=4>&nbsp;</td></tr>'; echo '<tr><td class="blank" colspan=4>&nbsp;</td></tr>';
} }
} }
}
} }
echo '</table>'; echo '</table>';
echo '</div>'; echo '</div>';
echo '</body>';
# Capture the output and put into the body of the page.
$www['body'] = new block();
$www['body']->SetBody(ob_get_contents());
$www['page']->block_add('body',$www['body']);
ob_end_clean();
# Render the popup.
$www['page']->display(array('CONTROL'=>false,'FOOT'=>false,'HEAD'=>false,'TREE'=>false));
?> ?>

View File

@ -1,26 +1,29 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/expand.php,v 1.26 2007/12/15 07:50:30 wurley Exp $ // $Header$
/** /**
* This script alters the session variable 'tree', expanding it * This script alters the session variable 'tree', expanding it
* at the dn specified in the query string. * at the dn specified in the query string.
* *
* Note: this script is equal and opposite to collapse.php * Note: this script is equal and opposite to collapse.php
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Tree
* @see collapse.php * @see collapse.php
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$dn = get_request('dn','GET',true); $dn = get_request('dn','GET',true);
$tree = get_cached_item($ldapserver->server_id,'tree'); $tree = get_cached_item($app['server']->getIndex(),'tree');
$entry = $tree->getEntry($dn); $entry = $tree->getEntry($dn);
$entry->open(); $entry->open();
set_cached_item($ldapserver->server_id,'tree','null',$tree); set_cached_item($app['server']->getIndex(),'tree','null',$tree);
header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s', header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s',
$ldapserver->server_id,random_junk(),htmlid($ldapserver->server_id,$dn),pla_session_param())); $app['server']->getIndex(),random_junk(),htmlid($app['server']->getIndex(),$dn),app_session_param()));
die(); die();
?> ?>

View File

@ -1,117 +1,45 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/export.php,v 1.18.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Performs the export of data from the LDAP server
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
# Fix a bug with IE:
ini_set('session.cache_limiter','');
require LIBDIR.'export_functions.php'; require LIBDIR.'export_functions.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('export')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('export'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('export')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('export')),'error','index.php');
$entry = array(); # Prevent script from bailing early for long search
$entry['base_dn'] = get_request('dn');
$entry['format'] = get_request('format','POST',false,'unix');
$entry['scope'] = get_request('scope','POST',false,'base');
$entry['filter'] = get_request('filter','POST',false,'objectclass=*');
$entry['attr'] = get_request('attributes');
$entry['sys_attr'] = get_request('sys_attr');
$entry['file'] = get_request('save_as_file') ? true : false;
$entry['exporter_id'] = get_request('exporter_id');
if ($entry['filter']) {
$entry['filter'] = preg_replace('/\s+/','',$entry['filter']);
$attributes = split(',',preg_replace('/\s+/','',$entry['attr']));
} else {
$attributes = array();
}
# Add system attributes if needed
if ($entry['sys_attr']) {
array_push($attributes,'*');
array_push($attributes,'+');
}
(! is_null($entry['exporter_id'])) or error(_('You must choose an export format.'),'error','index.php');
isset($exporters[$entry['exporter_id']]) or error(_('Invalid export format'),'error','index.php');
# Initialisation of other variables
$friendly_rdn = get_rdn($entry['base_dn'],1);
$extension = $exporters[$entry['exporter_id']]['extension'];
# default case not really needed
switch ($entry['format']) {
case 'win':
$br = "\r\n";
break;
case 'mac':
$br = "\r";
break;
case 'unix':
default:
$br = "\n";
}
# get the decoree,ie the source
$plaLdapExporter = new PlaLdapExporter($ldapserver->server_id,$entry['filter'],$entry['base_dn'],$entry['scope'],$attributes);
# the decorator do it that way for the moment
$exporter = null;
switch ($entry['exporter_id']) {
case 0:
$exporter = new PlaLdifExporter($plaLdapExporter);
break;
case 1:
$exporter = new PlaDsmlExporter($plaLdapExporter);
break;
case 2:
$exporter = new PlaVcardExporter($plaLdapExporter);
break;
case 3:
$exporter = new PlaCSVExporter($plaLdapExporter);
break;
default:
# truly speaking,this default case will never be reached. See check at the bottom.
error(_('No available exporter found.'),'error','index.php');
}
# set the CLRN
$exporter->setOutputFormat($br);
if (get_request('compress','REQUEST') == 'on')
$exporter->compress(true);
# prevent script from bailing early for long search
@set_time_limit(0); @set_time_limit(0);
$request = array();
$request['file'] = get_request('save_as_file') ? true : false;
$request['exporter'] = new Exporter($app['server']->getIndex(),get_request('exporter_id','REQUEST'));
$request['export'] = $request['exporter']->getTemplate();
$types = $request['export']->getType();
# send the header # send the header
if ($entry['file']) { if ($request['file']) {
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
ob_end_clean(); ob_end_clean();
header('Content-type: application/download'); header('Content-type: application/download');
header(sprintf('Content-Disposition: filename="%s.%s"',$friendly_rdn,$exporters[$entry['exporter_id']]['extension'].($exporter->isCompressed()?'.gz':''))); header(sprintf('Content-Disposition: inline; filename="%s.%s"','export',$types['extension'].($request['export']->isCompressed() ? '.gz' : '')));
$exporter->export(); $request['export']->export();
die(); die();
} else { } else {
print '<span style="font-size: 14px; font-family: courier;"><pre>'; print '<span style="font-size: 14px; font-family: courier;"><pre>';
$exporter->export(); $request['export']->export();
print '</pre></span>'; print '</pre></span>';
} }
?> ?>

View File

@ -1,44 +1,49 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/export_form.php,v 1.26.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* export_form.php * Export entries from the LDAP server.
* Html form to choose an export format(ldif,...) *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
require LIBDIR.'export_functions.php'; require LIBDIR.'export_functions.php';
$entry = array(); $request = array();
$entry['format'] = get_request('format','GET',false,get_line_end_format()); $request['dn'] = get_request('dn','GET');
$entry['scope'] = get_request('scope','GET',false,'base'); $request['format'] = get_request('format','GET',false,get_line_end_format());
$entry['id'] = get_request('exporter_id','GET',false,0); $request['scope'] = get_request('scope','GET',false,'base');
$entry['dn'] = get_request('dn','GET'); $request['exporter_id'] = get_request('exporter_id','GET',false,'LDIF');
$entry['filter'] = get_request('filter','GET',false,'(objectClass=*)'); $request['filter'] = get_request('filter','GET',false,'(objectClass=*)');
$entry['attr'] = get_request('attributes','GET',false,'*'); $request['attr'] = get_request('attributes','GET',false,'*');
$entry['sys_attr'] = get_request('sys_attr','GET') ? true: false; $request['sys_attr'] = get_request('sys_attr','GET') ? true: false;
$available_formats = array ( $available_formats = array(
'unix' => 'UNIX (Linux, BSD)',
'mac' => 'Macintosh', 'mac' => 'Macintosh',
'unix' => 'UNIX (Linux, BSD)',
'win' => 'Windows' 'win' => 'Windows'
); );
$available_scopes = array ( $available_scopes = array(
'base' => _('Base (base dn only)'), 'base' => _('Base (base dn only)'),
'one' => _('One (one level beneath base)'), 'one' => _('One (one level beneath base)'),
'sub' => _('Sub (entire subtree)') 'sub' => _('Sub (entire subtree)')
); );
printf('<h3 class="title">%s</h3>',_('Export')); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Export')));
echo '<br />'; echo '<br />';
echo '<center>'; echo '<center>';
echo '<form name="export_form" action="cmd.php" method="post">'; echo '<form name="export_form" action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="export" />'; echo '<input type="hidden" name="cmd" value="export" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
echo '<table class="forminput">'; echo '<table class="forminput">';
echo '<tr>'; echo '<tr>';
echo '<td>'; echo '<td>';
@ -47,11 +52,12 @@ echo '<fieldset>';
printf('<legend>%s</legend>',_('Export')); printf('<legend>%s</legend>',_('Export'));
echo '<table>'; echo '<table>';
printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),server_select_list($ldapserver->server_id)); printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),server_select_list($app['server']->getIndex()));
echo '<tr>'; echo '<tr>';
printf('<td style="white-space:nowrap">%s</td>',_('Base DN')); printf('<td style="white-space:nowrap">%s</td>',_('Base DN'));
printf('<td><span style="white-space: nowrap;"><input type="text" name="dn" id="dn" style="width:230px" value="%s" />&nbsp;',htmlspecialchars($entry['dn'])); echo '<td><span style="white-space: nowrap;">';
printf('<input type="text" name="dn" id="dn" style="width:230px" value="%s" />&nbsp;',htmlspecialchars($request['dn']));
draw_chooser_link('export_form.dn'); draw_chooser_link('export_form.dn');
echo '</span></td>'; echo '</span></td>';
echo '</tr>'; echo '</tr>';
@ -63,20 +69,21 @@ echo '<td>';
foreach ($available_scopes as $id => $desc) foreach ($available_scopes as $id => $desc)
printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />', printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id),htmlspecialchars($id),($id == $entry['scope']) ? 'checked="true"' : '', htmlspecialchars($id),$id,($id == $request['scope']) ? 'checked="true"' : '',
htmlspecialchars($id),htmlspecialchars($desc)); htmlspecialchars($id),$desc);
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
printf('<tr><td>%s</td><td><input type="text" name="filter" style="width:300px" value="%s" /></td></tr>', printf('<tr><td>%s</td><td><input type="text" name="filter" style="width:300px" value="%s" /></td></tr>',
_('Search Filter'),htmlspecialchars($entry['filter'])); _('Search Filter'),htmlspecialchars($request['filter']));
printf('<tr><td>%s</td><td><input type="text" name="attributes" style="width:300px" value="%s" /></td></tr>', printf('<tr><td>%s</td><td><input type="text" name="attributes" style="width:300px" value="%s" /></td></tr>',
_('Show Attributtes'),htmlspecialchars($entry['attr'])); _('Show Attributtes'),htmlspecialchars($request['attr']));
printf('<tr><td>&nbsp;</td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>', printf('<tr><td>&nbsp;</td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>',
$entry['sys_attr'] ? 'checked="true" ' : '',_('Include system attributes')); $request['sys_attr'] ? 'checked="true" ' : '',_('Include system attributes'));
printf('<tr><td>&nbsp;</td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="toggle_disable_field_saveas(this)" /> <label for="save_as_file">%s</label></td></tr>', printf('<tr><td>&nbsp;</td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="toggle_disable_field_saveas(this)" /> <label for="save_as_file">%s</label></td></tr>',
_('Save as file')); _('Save as file'));
@ -92,71 +99,131 @@ echo '<tr>';
echo '<td>'; echo '<td>';
echo '<table style="width: 100%">'; echo '<table style="width: 100%">';
echo '<tr><td style="width: 50%">'; echo '<tr>';
echo '<td style="width: 50%">';
echo '<fieldset style="height: 100px">'; echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Export format')); printf('<legend>%s</legend>',_('Export format'));
foreach ($exporters as $index => $exporter) { foreach (Exporter::types() as $index => $exporter) {
printf('<input type="radio" name="exporter_id" id="exporter_id_%s" value="%s"%s />', printf('<input type="radio" name="exporter_id" id="exporter_id_%s" value="%s"%s/>',
htmlspecialchars($index),htmlspecialchars($index),($index==$entry['id']) ? ' checked="true"' : ''); htmlspecialchars($exporter['type']),htmlspecialchars($exporter['type']),($exporter['type'] === $request['exporter_id']) ? ' checked="true"' : '');
printf('<label for="%s">%s</label><br />', printf('<label for="%s">%s</label><br />',
htmlspecialchars($index),htmlspecialchars($exporter['desc'])); htmlspecialchars($exporter['type']),$exporter['type']);
} }
echo '</fieldset>'; echo '</fieldset>';
echo '</td>'; echo '</td>';
echo '<td style="width: 50%">'; echo '<td style="width: 50%">';
echo '<fieldset style="height: 100px">'; echo '<fieldset style="height: 100px">';
printf('<legend>%s</legend>',_('Line ends')); printf('<legend>%s</legend>',_('Line ends'));
foreach ($available_formats as $id => $desc) foreach ($available_formats as $id => $desc)
printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />', printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
htmlspecialchars($id),htmlspecialchars($id),($entry['format']==$id) ? ' checked="true"' : '', htmlspecialchars($id),htmlspecialchars($id),($request['format']==$id) ? ' checked="true"' : '',
htmlspecialchars($id),htmlspecialchars($desc)); htmlspecialchars($id),$desc);
echo '</fieldset>'; echo '</fieldset>';
echo '</td></tr>'; echo '</td></tr>';
echo '</table>'; echo '</table>';
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
echo '<tr>'; printf('<tr><td colspan="2"><center><input type="submit" name="target" value="%s" /></center></td></tr>',
echo '<td colspan="2">';
printf('<center><input type="submit" name="target" value="%s" /></center>',
htmlspecialchars(_('Proceed >>'))); htmlspecialchars(_('Proceed >>')));
echo '</td>';
echo '</tr>';
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
echo '</center>'; echo '</center>';
/** /**
* Helper functoin for fetching the line end format. * Helper function for fetching the line end format.
*
* @return String 'win', 'unix', or 'mac' based on the user's browser.. * @return String 'win', 'unix', or 'mac' based on the user's browser..
*/ */
function get_line_end_format() { function get_line_end_format() {
if (is_browser_os_windows()) if (is_browser('win'))
return 'win'; return 'win';
elseif (is_browser_os_unix()) elseif (is_browser('unix'))
return 'unix'; return 'unix';
elseif (is_browser_os_mac()) elseif (is_browser('mac'))
return 'mac'; return 'mac';
else else
return 'unix'; 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 = '';
if (DEBUG_ENABLED)
debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return);
return $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;
}
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- <!--
function toggle_disable_field_saveas(id) { function toggle_disable_field_saveas(id) {
if (id.checked) { if (id.checked) {
id.form.compress.disabled = false; id.form.compress.disabled = false;
} else { } else {
id.form.compress.disabled = true; id.form.compress.disabled = true;
id.form.compress.checked = false; id.form.compress.checked = false;
} }
} }
--> -->
</script> </script>

View File

@ -1,69 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/header.php,v 1.27.2.2 2008/01/27 11:57:38 wurley Exp $
/**
* @package phpLDAPadmin
*/
require_once LIBDIR.'./common.php';
/* We want to get $language into scope in case we were included
from within a function */
$language = isset($_SESSION[APPCONFIG]) ? $language = $_SESSION[APPCONFIG]->GetValue('appearance','language') : 'auto';
# text/xml won't work with MSIE, but is very useful for debugging xhtml code.
# header('Content-type: text/xml; charset="UTF-8"');
@header('Content-type: text/html; charset="UTF-8"');
# XML version and encoding for well-behaved browsers
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'."\n";
echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="%s" lang="%s" dir="ltr">',$language,$language);
echo "\n\n";
echo '<head>';
if (isset($_SESSION[APPCONFIG]) && $pagetitle = $_SESSION[APPCONFIG]->GetValue('appearance','page_title'))
printf('<title>phpLDAPadmin - %s</title>',$pagetitle);
else
echo '<title>phpLDAPadmin</title>';
if (isset($_SESSION[APPCONFIG]))
$css = $_SESSION[APPCONFIG]->GetValue('appearance','stylesheet');
else
$css = 'style.css';
printf('<link type="text/css" rel="stylesheet" href="%s%s" media="screen" />',CSSDIR,$css);
if (isset($server_id)) {
$custom_file = get_custom_file($server_id,'style.css',CSSDIR);
if (strcmp($custom_file,'style.css') != 0)
printf('<link type="text/css" rel="stylesheet" href="%s" media="screen" />',$custom_file);
}
printf('<script type="text/javascript" src="%sentry_chooser.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sie_png_work_around.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sgeneric_utils.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sto_ascii.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%smodify_member.js"></script>',JSDIR);
printf('<link type="text/css" rel="stylesheet" media="all" href="%s/jscalendar/calendar-blue.css" title="blue" />',JSDIR);
echo "\n<!--\n";
printf('<script type="text/javascript" src="%sjscalendar/calendar.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sjscalendar/lang/calendar-en.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sjscalendar/calendar-setup.js"></script>',JSDIR);
printf('<script type="text/javascript" src="%sdate_selector.js"></script>',JSDIR);
echo "\n-->\n";
printf('<link type="text/css" rel="stylesheet" href="%s/phplayersmenu/layerstreemenu.css"></link>',JSDIR);
if (isset($meta_refresh_variable))
printf('<meta http-equiv="refresh" content="%s" />',$meta_refresh_variable);
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo '</head>';
echo "\n\n";
?>

BIN
htdocs/images/disabled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 796 B

BIN
htdocs/images/invalid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 796 B

116
htdocs/import.php Normal file
View File

@ -0,0 +1,116 @@
<?php
// $Header$
/**
* Imports an LDIF file to the specified LDAP server.
*
* @package phpLDAPadmin
* @subpackage Page
*/
/**
*/
require './common.php';
require LIBDIR.'import_functions.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('import'))
error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('import')),'error','index.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&amp;server_id=%s&amp;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>&nbsp;</td><td>%s</td></tr>',$line);
echo '</table>';
echo '</center>';
}
?>

View File

@ -1,12 +1,14 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/ldif_import_form.php,v 1.22.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays a form to allow the user to upload and import * Displays a form to allow the user to upload and import
* an LDIF file. * an LDIF file.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
@ -15,15 +17,14 @@ require './common.php';
if (! ini_get('file_uploads')) if (! ini_get('file_uploads'))
error(_('Your PHP.INI does not have file_uploads = ON. Please enable file uploads in PHP.'),'error','index.php'); error(_('Your PHP.INI does not have file_uploads = ON. Please enable file uploads in PHP.'),'error','index.php');
if ($ldapserver->isReadOnly()) $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request['page']->drawTitle(sprintf('<b>%s</b>',_('Import')));
$request['page']->drawSubTitle(sprintf('%s: <b>%s</b>',_('Server'),$app['server']->getName()));
printf('<h3 class="title" colspan=0>%s</h3>',_('Import LDIF File'));
printf('<h3 class="subtitle" colspan=0>%s: <b>%s</b></h3>',_('Server'),htmlspecialchars($ldapserver->name));
echo '<center>'; echo '<center>';
echo '<form action="cmd.php" method="post" class="new_value" enctype="multipart/form-data">'; echo '<form action="cmd.php" method="post" class="new_value" enctype="multipart/form-data">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
echo '<input type="hidden" name="cmd" value="ldif_import" />'; echo '<input type="hidden" name="cmd" value="import" />';
echo '<table class="forminput" border=0>'; echo '<table class="forminput" border=0>';

View File

@ -1,8 +1,14 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/index.php,v 1.49.2.10 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* phpLDAPadmin Start Page
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/
/**
*/ */
/******************************************* /*******************************************
@ -18,6 +24,7 @@ PHP is not installed on your web server!!!
* We will perform some sanity checking here, since this file is normally loaded first when users * We will perform some sanity checking here, since this file is normally loaded first when users
* first access the application. * first access the application.
*/ */
# The index we will store our config in $_SESSION # The index we will store our config in $_SESSION
define('APPCONFIG','plaConfig'); define('APPCONFIG','plaConfig');
@ -96,24 +103,47 @@ if (isset($app['function_files']) && is_array($app['function_files']))
# Configuration File check # Configuration File check
if (! file_exists($app['config_file'])) { if (! file_exists($app['config_file'])) {
error(sprintf(_('You need to configure %s. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),'phpLDAPadmin',$app['config_file'],$app['config_file']),'error',null,true); error(sprintf(_('You need to configure %s. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),app_name(),$app['config_file'],$app['config_file']),'error',null,true);
} elseif (! is_readable($app['config_file'])) { } elseif (! is_readable($app['config_file'])) {
error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file']),'error',null,true); error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file']),'error',null,true);
} }
# If our config file fails the sanity check, then stop now. # If our config file fails the sanity check, then stop now.
if (! check_config($app['config_file'])) { if (! $config = check_config($app['config_file'])) {
$www['page'] = new page(); $www['page'] = new page();
$www['body'] = new block(); $www['body'] = new block();
$www['page']->block_add('body',$www['body']); $www['page']->block_add('body',$www['body']);
$www['page']->display(); $www['page']->display();
exit; exit;
} else {
app_session_start();
$_SESSION[APPCONFIG] = $config;
} }
if ($uri = get_request('URI','GET')) if ($uri = get_request('URI','GET'))
header(sprintf('Location: cmd.php?%s',base64_decode($uri))); header(sprintf('Location: cmd.php?%s',base64_decode($uri)));
if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
system_message(array(
'title'=>_('This is a development version of phpLDAPadmin'),
'body'=>'This is a development version of phpLDAPadmin! You should <b>NOT</b> use it in a production environment (although we dont think it should do any damage).',
'type'=>'info','special'=>true));
if (count($_SESSION[APPCONFIG]->untested()))
system_message(array(
'title'=>'Untested configuration paramaters',
'body'=>sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>',implode(', ',$_SESSION[APPCONFIG]->untested())),
'type'=>'info','special'=>true));
$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
if (count($server->untested()))
system_message(array(
'title'=>'Untested server configuration paramaters',
'body'=>sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>',implode(', ',$server->untested())),
'type'=>'info','special'=>true));
}
include './cmd.php'; include './cmd.php';
?> ?>

163
htdocs/js/ajaxtree.js Normal file
View File

@ -0,0 +1,163 @@
var nodeLayer = null;
var sonLayer = null;
var oldstyle = '';
var newstyle = '';
var oldimg = '';
var newimg = '';
function readCollapsedNodes() {
collapsedNodes = new Array();
cn = document.cookie.split('collapsedNodes=');
if (cn.length < 2) return;
vl = cn[1];
if (vl.indexOf(';') != -1) {
vl = vl.split(';');
vl = vl[0];
}
if (vl) {
collapsed = vl.split('|');
for (i = 0; i < collapsed.length; i++) {
collapsedNodes[i] = collapsed[i];
}
}
}
function writeCollapsedNodes() {
document.cookie = 'collapsedNodes=' + collapsedNodes.join('|') + ';path=/';
}
function addCollapsedNode(nodeId) {
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] == nodeId) return;
}
collapsedNodes[collapsedNodes.length] = nodeId;
writeCollapsedNodes();
}
function delCollapsedNode(nodeId) {
newCollapsedNodes = new Array();
j = 0;
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] != nodeId) {
newCollapsedNodes[j++] = collapsedNodes[i];
}
}
collapsedNodes = newCollapsedNodes;
writeCollapsedNodes();
}
function updateNewStyle() {
nodeLayer.src = newimg;
sonLayer.style.display = newstyle;
}
function cancelNewStyle() {
nodeLayer.src = oldimg;
sonLayer.style.display = oldstyle;
}
function alertTreeNodeContents(html) {
if (html.replace(/(^\s*)|(\s*$)/g, '')) {
includeHTML(sonLayer, html);
}
updateNewStyle();
}
function opencloseTreeNode(nodeid, params) {
cancelHttpRequest(); // cancel last request
// get the node element
if ((!DOM || Opera56 || Konqueror22) && !IE4) return;
if (!IE4) {
sonLayer = document.getElementById('jt' + nodeid + 'son');
nodeLayer = document.getElementById('jt' + nodeid + 'node');
} else {
sonLayer = document.all('jt' + nodeid + 'son');
nodeLayer = document.all('jt' + nodeid + 'node');
}
if (!sonLayer || !nodeLayer) return false;
// update global variables
oldstyle = sonLayer.style.display;
oldimg = nodeLayer.src;
var action = 0; // (action = 1) => expand ; (action = 2) => collapse
if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_expand.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_collapse.png';
action = 1;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_expand_first.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_collapse_first.png';
action = 1;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_expand_corner.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_collapse_corner.png';
action = 1;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_expand_corner_first.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_collapse_corner_first.png';
action = 1;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_collapse.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_expand.png';
action = 2;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_collapse_first.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_expand_first.png';
action = 2;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_collapse_corner.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_expand_corner.png';
action = 2;
} else if (oldimg.indexOf('js/phplayersmenu/menuimages/tree_collapse_corner_first.png') > -1) {
newimg = 'js/phplayersmenu/menuimages/tree_expand_corner_first.png';
action = 2;
}
nodeLayer.src = 'images/ajax-spinner.gif';
// perform action
if (action == 2) {
newstyle = 'none';
updateNewStyle();
addCollapsedNode(nodeid);
} else if (action == 1) {
newstyle = 'block';
if (sonLayer.innerHTML == '') {
makeGETRequest('cmd.php', params+'&cmd=draw_tree_node&action=1', 'alertTreeNodeContents', 'cancelNewStyle');
} else {
updateNewStyle();
}
delCollapsedNode(nodeid);
}
return false;
}
function getDiv(div) {
if (!IE4) {
return document.getElementById('aj'+div);
} else {
return document.all('aj'+div);
}
}
function alertAJ(html,div) {
var pageDiv = getDiv(div);
if (pageDiv) includeHTML(pageDiv, html);
}
function cancelAJ(div) {
var pageDiv = getDiv(div);
if (pageDiv) includeHTML(pageDiv, '');
}
function displayAJ(div,urlParameters,display) {
var pageDiv = getDiv(div);
if (pageDiv)
includeHTML(pageDiv, '<img src="images/ajax-progress.gif"><br><small>'+display+'...</small>');
else
return true;
makeGETRequest('cmd.php', urlParameters+'&meth=ajax', 'alertAJ', 'cancelAJ',div);
return false;
}
// close initial collapsed nodes
// Cant figure out why, but this runs twice in AJAX mode when using "refresh".
// Causing the collapsedNodes to be incorrect.
readCollapsedNodes();
for (k = 0; k < collapsedNodes.length; k++) {
opencloseTreeNode(collapsedNodes[k], '#');
}

View File

@ -1,4 +1,4 @@
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/js/entry_chooser.js,v 1.3 2005/02/10 12:34:26 wurley Exp $ // $Header$
function dnChooserPopup(form_element,rdn) function dnChooserPopup(form_element,rdn)
{ {
mywindow=open('entry_chooser.php','myname','resizable=no,width=600,height=370,scrollbars=1'); mywindow=open('entry_chooser.php','myname','resizable=no,width=600,height=370,scrollbars=1');

View File

@ -1,236 +0,0 @@
/* The main calendar widget. DIV containing a table. */
div.calendar { position: relative; }
.calendar, .calendar table {
border: 1px solid #206A9B;
font-size: 11px;
color: #000;
cursor: default;
background: #F1F8FC;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center; /* They are the navigation buttons */
padding: 2px; /* Make the buttons seem like they're pressing */
}
.calendar .nav {
background: #007ED1 url(menuarrow2.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
background: #000;
color: #fff;
padding: 2px;
}
.calendar thead tr { /* Row <TR> containing navigation buttons */
background: #007ED1;
color: #fff;
}
.calendar thead .daynames { /* Row <TR> containing the day names */
background: #C7E1F3;
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #206A9B;
padding: 2px;
text-align: center;
color: #000;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #a66;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
background-color: #34ABFA;
color: #000;
border: 1px solid #016DC5;
padding: 1px;
}
.calendar thead .active { /* Active (pressed) buttons in header */
background-color: #006AA9;
border: 1px solid #008AFF;
padding: 2px 0px 0px 2px;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
color: #456;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #bbb;
}
.calendar tbody .day.othermonth.oweekend {
color: #fbb;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #C7E1F3;
}
.calendar tbody .rowhilite td {
background: #def;
}
.calendar tbody .rowhilite td.wn {
background: #F1F8FC;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
background: #def;
padding: 1px 3px 1px 1px;
border: 1px solid #8FC4E8;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
background: #cde;
padding: 2px 2px 0px 2px;
}
.calendar tbody td.selected { /* Cell showing today date */
font-weight: bold;
border: 1px solid #000;
padding: 1px 3px 1px 1px;
background: #fff;
color: #000;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #a66;
}
.calendar tbody td.today { /* Cell showing selected date */
font-weight: bold;
color: #D50000;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
text-align: center;
background: #206A9B;
color: #fff;
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #000;
color: #fff;
border-top: 1px solid #206A9B;
padding: 1px;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
background: #B8DAF0;
border: 1px solid #178AEB;
color: #000;
padding: 1px;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
background: #006AA9;
padding: 2px 0px 0px 2px;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
top: 0px;
left: 0px;
width: 4em;
cursor: default;
border: 1px solid #655;
background: #def;
color: #000;
font-size: 90%;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .hilite {
background: #34ABFA;
border-top: 1px solid #46a;
border-bottom: 1px solid #46a;
font-weight: bold;
}
.calendar .combo .active {
border-top: 1px solid #46a;
border-bottom: 1px solid #46a;
background: #F1F8FC;
font-weight: bold;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #E3F0F9;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #F1F8FC;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #267DB7;
color: #fff;
}
.calendar td.time span.active {
border-color: red;
background-color: #000;
color: #A5FF00;
}

View File

@ -1,225 +0,0 @@
/* The main calendar widget. DIV containing a table. */
div.calendar { position: relative; }
.calendar, .calendar table {
border: 1px solid #655;
font-size: 11px;
color: #000;
cursor: default;
background: #ffd;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center; /* They are the navigation buttons */
padding: 2px; /* Make the buttons seem like they're pressing */
}
.calendar .nav {
background: #edc url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
background: #654;
color: #fed;
padding: 2px;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
background: #edc;
color: #000;
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #655;
padding: 2px;
text-align: center;
color: #000;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
background-color: #faa;
color: #000;
border: 1px solid #f40;
padding: 1px;
}
.calendar thead .active { /* Active (pressed) buttons in header */
background-color: #c77;
padding: 2px 0px 0px 2px;
}
.calendar thead .daynames { /* Row <TR> containing the day names */
background: #fed;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #bbb;
}
.calendar tbody .day.othermonth.oweekend {
color: #fbb;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #fed;
}
.calendar tbody .rowhilite td {
background: #ddf;
}
.calendar tbody .rowhilite td.wn {
background: #efe;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
background: #ffe;
padding: 1px 3px 1px 1px;
border: 1px solid #bbb;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
background: #ddc;
padding: 2px 2px 0px 2px;
}
.calendar tbody td.selected { /* Cell showing today date */
font-weight: bold;
border: 1px solid #000;
padding: 1px 3px 1px 1px;
background: #fea;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { font-weight: bold; }
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
text-align: center;
background: #988;
color: #000;
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
border-top: 1px solid #655;
background: #dcb;
color: #840;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
background: #faa;
border: 1px solid #f40;
padding: 1px;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
background: #c77;
padding: 2px 0px 0px 2px;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
top: 0px;
left: 0px;
width: 4em;
cursor: default;
border: 1px solid #655;
background: #ffe;
color: #000;
font-size: 90%;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .hilite {
background: #fc8;
}
.calendar .combo .active {
border-top: 1px solid #a64;
border-bottom: 1px solid #a64;
background: #fee;
font-weight: bold;
}
.calendar td.time {
border-top: 1px solid #a88;
padding: 1px 0px;
text-align: center;
background-color: #fed;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #988;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #866;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,229 +0,0 @@
/* The main calendar widget. DIV containing a table. */
div.calendar { position: relative; }
.calendar, .calendar table {
border: 1px solid #565;
font-size: 11px;
color: #000;
cursor: default;
background: #efe;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center; /* They are the navigation buttons */
padding: 2px; /* Make the buttons seem like they're pressing */
background: #676;
color: #fff;
font-size: 90%;
}
.calendar .nav {
background: #676 url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
padding: 2px;
background: #250;
color: #efa;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #565;
padding: 2px;
text-align: center;
color: #000;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #a66;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
background-color: #afa;
color: #000;
border: 1px solid #084;
padding: 1px;
}
.calendar thead .active { /* Active (pressed) buttons in header */
background-color: #7c7;
padding: 2px 0px 0px 2px;
}
.calendar thead .daynames { /* Row <TR> containing the day names */
background: #dfb;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
color: #564;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #bbb;
}
.calendar tbody .day.othermonth.oweekend {
color: #fbb;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #8a8;
background: #dfb;
}
.calendar tbody .rowhilite td {
background: #dfd;
}
.calendar tbody .rowhilite td.wn {
background: #efe;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
background: #efd;
padding: 1px 3px 1px 1px;
border: 1px solid #bbb;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
background: #dec;
padding: 2px 2px 0px 2px;
}
.calendar tbody td.selected { /* Cell showing today date */
font-weight: bold;
border: 1px solid #000;
padding: 1px 3px 1px 1px;
background: #f8fff8;
color: #000;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #a66;
}
.calendar tbody td.today { font-weight: bold; color: #0a0; }
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
text-align: center;
background: #565;
color: #fff;
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
padding: 2px;
background: #250;
color: #efa;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
background: #afa;
border: 1px solid #084;
color: #000;
padding: 1px;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
background: #7c7;
padding: 2px 0px 0px 2px;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
top: 0px;
left: 0px;
width: 4em;
cursor: default;
border: 1px solid #565;
background: #efd;
color: #000;
font-size: 90%;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .hilite {
background: #af8;
}
.calendar .combo .active {
border-top: 1px solid #6a4;
border-bottom: 1px solid #6a4;
background: #efe;
font-weight: bold;
}
.calendar td.time {
border-top: 1px solid #8a8;
padding: 1px 0px;
text-align: center;
background-color: #dfb;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #898;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #686;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -19,7 +19,7 @@
* than modifying calendar.js itself). * than modifying calendar.js itself).
*/ */
// $Id: calendar-setup.js,v 1.2 2005/10/09 11:16:50 wurley Exp $ // $Id$
/** /**
* This function "patches" an input field (or other element) to use a calendar * This function "patches" an input field (or other element) to use a calendar

View File

@ -1,21 +0,0 @@
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
* ---------------------------------------------------------------------------
*
* The DHTML Calendar
*
* Details and latest version at:
* http://dynarch.com/mishoo/calendar.epl
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*
* This file defines helper functions for setting up the calendar. They are
* intended to help non-programmers get a working calendar on their site
* quickly. This script should not be seen as part of the calendar. It just
* shows you what one can do with the calendar, while in the same time
* providing a quick and simple method for setting it up. If you need
* exhaustive customization of the calendar creation process feel free to
* modify this code to suit your needs (this is recommended and much better
* than modifying calendar.js itself).
*/
Calendar.setup=function(params){function param_default(pname,def){if(typeof params[pname]=="undefined"){params[pname]=def;}};param_default("inputField",null);param_default("displayArea",null);param_default("button",null);param_default("eventName","click");param_default("ifFormat","%Y/%m/%d");param_default("daFormat","%Y/%m/%d");param_default("singleClick",true);param_default("disableFunc",null);param_default("dateStatusFunc",params["disableFunc"]);param_default("dateText",null);param_default("firstDay",null);param_default("align","Br");param_default("range",[1900,2999]);param_default("weekNumbers",true);param_default("flat",null);param_default("flatCallback",null);param_default("onSelect",null);param_default("onClose",null);param_default("onUpdate",null);param_default("date",null);param_default("showsTime",false);param_default("timeFormat","24");param_default("electric",true);param_default("step",2);param_default("position",null);param_default("cache",false);param_default("showOthers",false);param_default("multiple",null);var tmp=["inputField","displayArea","button"];for(var i in tmp){if(typeof params[tmp[i]]=="string"){params[tmp[i]]=document.getElementById(params[tmp[i]]);}}if(!(params.flat||params.multiple||params.inputField||params.displayArea||params.button)){alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");return false;}function onSelect(cal){var p=cal.params;var update=(cal.dateClicked||p.electric);if(update&&p.inputField){p.inputField.value=cal.date.print(p.ifFormat);if(typeof p.inputField.onchange=="function")p.inputField.onchange();}if(update&&p.displayArea)p.displayArea.innerHTML=cal.date.print(p.daFormat);if(update&&typeof p.onUpdate=="function")p.onUpdate(cal);if(update&&p.flat){if(typeof p.flatCallback=="function")p.flatCallback(cal);}if(update&&p.singleClick&&cal.dateClicked)cal.callCloseHandler();};if(params.flat!=null){if(typeof params.flat=="string")params.flat=document.getElementById(params.flat);if(!params.flat){alert("Calendar.setup:\n Flat specified but can't find parent.");return false;}var cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect);cal.showsOtherMonths=params.showOthers;cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.params=params;cal.weekNumbers=params.weekNumbers;cal.setRange(params.range[0],params.range[1]);cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;if(params.ifFormat){cal.setDateFormat(params.ifFormat);}if(params.inputField&&typeof params.inputField.value=="string"){cal.parseDate(params.inputField.value);}cal.create(params.flat);cal.show();return false;}var triggerEl=params.button||params.displayArea||params.inputField;triggerEl["on"+params.eventName]=function(){var dateEl=params.inputField||params.displayArea;var dateFmt=params.inputField?params.ifFormat:params.daFormat;var mustCreate=false;var cal=window.calendar;if(dateEl)params.date=Date.parseDate(dateEl.value||dateEl.innerHTML,dateFmt);if(!(cal&&params.cache)){window.calendar=cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect,params.onClose||function(cal){cal.hide();});cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.weekNumbers=params.weekNumbers;mustCreate=true;}else{if(params.date)cal.setDate(params.date);cal.hide();}if(params.multiple){cal.multiple={};for(var i=params.multiple.length;--i>=0;){var d=params.multiple[i];var ds=d.print("%Y%m%d");cal.multiple[ds]=d;}}cal.showsOtherMonths=params.showOthers;cal.yearStep=params.step;cal.setRange(params.range[0],params.range[1]);cal.params=params;cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;cal.setDateFormat(dateFmt);if(mustCreate)cal.create();cal.refresh();if(!params.position)cal.showAtElement(params.button||params.displayArea||params.inputField,params.align);else cal.showAt(params.position[0],params.position[1]);return false;};return cal;};

View File

@ -1,251 +0,0 @@
/* The main calendar widget. DIV containing a table. */
.calendar {
position: relative;
display: none;
border: 1px solid;
border-color: #fff #000 #000 #fff;
font-size: 11px;
cursor: default;
background: Window;
color: WindowText;
font-family: tahoma,verdana,sans-serif;
}
.calendar table {
border: 1px solid;
border-color: #fff #000 #000 #fff;
font-size: 11px;
cursor: default;
background: Window;
color: WindowText;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center;
padding: 1px;
border: 1px solid;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
background: ButtonFace;
}
.calendar .nav {
background: ButtonFace url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold;
padding: 1px;
border: 1px solid #000;
background: ActiveCaption;
color: CaptionText;
text-align: center;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .daynames { /* Row <TR> containing the day names */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid ButtonShadow;
padding: 2px;
text-align: center;
background: ButtonFace;
color: ButtonText;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
border: 2px solid;
padding: 0px;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.calendar thead .active { /* Active (pressed) buttons in header */
border-width: 1px;
padding: 2px 0px 0px 2px;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid ButtonShadow;
background: ButtonFace;
color: ButtonText;
}
.calendar tbody .rowhilite td {
background: Highlight;
color: HighlightText;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
padding: 1px 3px 1px 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
padding: 2px 2px 0px 2px;
border: 1px solid;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.calendar tbody td.selected { /* Cell showing selected date */
font-weight: bold;
border: 1px solid;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
padding: 2px 2px 0px 2px;
background: ButtonFace;
color: ButtonText;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { /* Cell showing today date */
font-weight: bold;
color: #00f;
}
.calendar tbody td.disabled { color: GrayText; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: ButtonFace;
padding: 1px;
border: 1px solid;
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
color: ButtonText;
text-align: center;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
padding: 1px;
background: #e4e0d8;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
width: 4em;
top: 0px;
left: 0px;
cursor: default;
border: 1px solid;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
background: Menu;
color: MenuText;
font-size: 90%;
padding: 1px;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .active {
padding: 0px;
border: 1px solid #000;
}
.calendar .combo .hilite {
background: Highlight;
color: HighlightText;
}
.calendar td.time {
border-top: 1px solid ButtonShadow;
padding: 1px 0px;
text-align: center;
background-color: ButtonFace;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: Menu;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: Highlight;
color: HighlightText;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,239 +0,0 @@
/* The main calendar widget. DIV containing a table. */
div.calendar { position: relative; }
.calendar, .calendar table {
border: 1px solid #655;
font-size: 11px;
color: #000;
cursor: default;
background: #ffd;
font-family: tahoma,verdana,sans-serif;
filter:
progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#DDDCCC,EndColorStr=#FFFFFF);
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center; /* They are the navigation buttons */
padding: 2px; /* Make the buttons seem like they're pressing */
color:#363636;
}
.calendar .nav {
background: #edc url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
background: #654;
color: #363636;
padding: 2px;
filter:
progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff,EndColorStr=#dddccc);
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
/*background: #3B86A0;*/
color: #363636;
font-weight: bold;
filter:
progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff,EndColorStr=#3b86a0);
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #655;
padding: 2px;
text-align: center;
color: #363636;
filter:
progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#DDDCCC,EndColorStr=#FFFFFF);
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
background-color: #ffcc86;
color: #000;
border: 1px solid #b59345;
padding: 1px;
}
.calendar thead .active { /* Active (pressed) buttons in header */
background-color: #c77;
padding: 2px 0px 0px 2px;
}
.calendar thead .daynames { /* Row <TR> containing the day names */
background: #fed;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #fed;
}
.calendar tbody .rowhilite td {
background: #ddf;
}
.calendar tbody .rowhilite td.wn {
background: #efe;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
background: #ffe;
padding: 1px 3px 1px 1px;
border: 1px solid #bbb;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
background: #ddc;
padding: 2px 2px 0px 2px;
}
.calendar tbody td.selected { /* Cell showing today date */
font-weight: bold;
border: 1px solid #000;
padding: 1px 3px 1px 1px;
background: #fea;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { font-weight: bold; }
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
text-align: center;
background: #988;
color: #000;
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
border-top: 1px solid #655;
background: #dcb;
color: #363636;
font-weight: bold;
filter:
progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#FFFFFF,EndColorStr=#DDDCCC);
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
background: #faa;
border: 1px solid #f40;
padding: 1px;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
background: #c77;
padding: 2px 0px 0px 2px;
}
/* Combo boxes (menus that display months/years for direct selection) */
.combo {
position: absolute;
display: none;
top: 0px;
left: 0px;
width: 4em;
cursor: default;
border: 1px solid #655;
background: #ffe;
color: #000;
font-size: smaller;
z-index: 100;
}
.combo .label,
.combo .label-IEfix {
text-align: center;
padding: 1px;
}
.combo .label-IEfix {
width: 4em;
}
.combo .hilite {
background: #fc8;
}
.combo .active {
border-top: 1px solid #a64;
border-bottom: 1px solid #a64;
background: #fee;
font-weight: bold;
}
.calendar td.time {
border-top: 1px solid #a88;
padding: 1px 0px;
text-align: center;
background-color: #fed;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #988;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #866;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,271 +0,0 @@
/* The main calendar widget. DIV containing a table. */
.calendar {
position: relative;
display: none;
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
font-size: 11px;
color: #000;
cursor: default;
background: #d4d0c8;
font-family: tahoma,verdana,sans-serif;
}
.calendar table {
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
font-size: 11px;
color: #000;
cursor: default;
background: #d4d0c8;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center;
padding: 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar .nav {
background: transparent url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold;
padding: 1px;
border: 1px solid #000;
background: #848078;
color: #fff;
text-align: center;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .daynames { /* Row <TR> containing the day names */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #000;
padding: 2px;
text-align: center;
background: #f4f0e8;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
padding: 0px;
background-color: #e4e0d8;
}
.calendar thead .active { /* Active (pressed) buttons in header */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
background-color: #c4c0b8;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #f4f0e8;
}
.calendar tbody .rowhilite td {
background: #e4e0d8;
}
.calendar tbody .rowhilite td.wn {
background: #d4d0c8;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
padding: 1px 3px 1px 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
padding: 2px 2px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar tbody td.selected { /* Cell showing selected date */
font-weight: bold;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
padding: 2px 2px 0px 2px;
background: #e4e0d8;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { /* Cell showing today date */
font-weight: bold;
color: #00f;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #f4f0e8;
padding: 1px;
border: 1px solid #000;
background: #848078;
color: #fff;
text-align: center;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
padding: 1px;
background: #e4e0d8;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
width: 4em;
top: 0px;
left: 0px;
cursor: default;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
background: #e4e0d8;
font-size: 90%;
padding: 1px;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .active {
background: #c4c0b8;
padding: 0px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar .combo .hilite {
background: #048;
color: #fea;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #f4f0e8;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #766;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,271 +0,0 @@
/* The main calendar widget. DIV containing a table. */
.calendar {
position: relative;
display: none;
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
font-size: 11px;
color: #000;
cursor: default;
background: #d4c8d0;
font-family: tahoma,verdana,sans-serif;
}
.calendar table {
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
font-size: 11px;
color: #000;
cursor: default;
background: #d4c8d0;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center;
padding: 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar .nav {
background: transparent url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold;
padding: 1px;
border: 1px solid #000;
background: #847880;
color: #fff;
text-align: center;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .daynames { /* Row <TR> containing the day names */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #000;
padding: 2px;
text-align: center;
background: #f4e8f0;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
padding: 0px;
background-color: #e4d8e0;
}
.calendar thead .active { /* Active (pressed) buttons in header */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
background-color: #c4b8c0;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #f4e8f0;
}
.calendar tbody .rowhilite td {
background: #e4d8e0;
}
.calendar tbody .rowhilite td.wn {
background: #d4c8d0;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
padding: 1px 3px 1px 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
padding: 2px 2px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar tbody td.selected { /* Cell showing selected date */
font-weight: bold;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
padding: 2px 2px 0px 2px;
background: #e4d8e0;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { /* Cell showing today date */
font-weight: bold;
color: #00f;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #f4e8f0;
padding: 1px;
border: 1px solid #000;
background: #847880;
color: #fff;
text-align: center;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
padding: 1px;
background: #e4d8e0;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
width: 4em;
top: 0px;
left: 0px;
cursor: default;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
background: #e4d8e0;
font-size: 90%;
padding: 1px;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .active {
background: #d4c8d0;
padding: 0px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar .combo .hilite {
background: #408;
color: #fea;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #f4f0e8;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #766;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,265 +0,0 @@
/* The main calendar widget. DIV containing a table. */
.calendar {
position: relative;
display: none;
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
font-size: 11px;
color: #000;
cursor: default;
background: #c8d0d4;
font-family: tahoma,verdana,sans-serif;
}
.calendar table {
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
font-size: 11px;
color: #000;
cursor: default;
background: #c8d0d4;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center;
padding: 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar .nav {
background: transparent url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold;
padding: 1px;
border: 1px solid #000;
background: #788084;
color: #fff;
text-align: center;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .daynames { /* Row <TR> containing the day names */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #000;
padding: 2px;
text-align: center;
background: #e8f0f4;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
padding: 0px;
background-color: #d8e0e4;
}
.calendar thead .active { /* Active (pressed) buttons in header */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
background-color: #b8c0c4;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #e8f4f0;
}
.calendar tbody .rowhilite td {
background: #d8e4e0;
}
.calendar tbody .rowhilite td.wn {
background: #c8d4d0;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
padding: 1px 3px 1px 1px;
border: 1px solid;
border-color: #fff #000 #000 #fff;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
padding: 2px 2px 0px 2px;
border: 1px solid;
border-color: #000 #fff #fff #000;
}
.calendar tbody td.selected { /* Cell showing selected date */
font-weight: bold;
padding: 2px 2px 0px 2px;
border: 1px solid;
border-color: #000 #fff #fff #000;
background: #d8e0e4;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { /* Cell showing today date */
font-weight: bold;
color: #00f;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #e8f0f4;
padding: 1px;
border: 1px solid #000;
background: #788084;
color: #fff;
text-align: center;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
padding: 1px;
background: #d8e0e4;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
width: 4em;
top: 0px;
left: 0px;
cursor: default;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
background: #d8e0e4;
font-size: 90%;
padding: 1px;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .active {
background: #c8d0d4;
padding: 0px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar .combo .hilite {
background: #048;
color: #aef;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #e8f0f4;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #667;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -1,271 +0,0 @@
/* The main calendar widget. DIV containing a table. */
.calendar {
position: relative;
display: none;
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
font-size: 11px;
color: #000;
cursor: default;
background: #c8d4d0;
font-family: tahoma,verdana,sans-serif;
}
.calendar table {
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
font-size: 11px;
color: #000;
cursor: default;
background: #c8d4d0;
font-family: tahoma,verdana,sans-serif;
}
/* Header part -- contains navigation buttons and day names. */
.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
text-align: center;
padding: 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar .nav {
background: transparent url(menuarrow.gif) no-repeat 100% 100%;
}
.calendar thead .title { /* This holds the current "month, year" */
font-weight: bold;
padding: 1px;
border: 1px solid #000;
background: #788480;
color: #fff;
text-align: center;
}
.calendar thead .headrow { /* Row <TR> containing navigation buttons */
}
.calendar thead .daynames { /* Row <TR> containing the day names */
}
.calendar thead .name { /* Cells <TD> containing the day names */
border-bottom: 1px solid #000;
padding: 2px;
text-align: center;
background: #e8f4f0;
}
.calendar thead .weekend { /* How a weekend day name shows in header */
color: #f00;
}
.calendar thead .hilite { /* How do the buttons in header appear when hover */
border-top: 2px solid #fff;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 2px solid #fff;
padding: 0px;
background-color: #d8e4e0;
}
.calendar thead .active { /* Active (pressed) buttons in header */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
background-color: #b8c4c0;
}
/* The body part -- contains all the days in month. */
.calendar tbody .day { /* Cells <TD> containing month days dates */
width: 2em;
text-align: right;
padding: 2px 4px 2px 2px;
}
.calendar tbody .day.othermonth {
font-size: 80%;
color: #aaa;
}
.calendar tbody .day.othermonth.oweekend {
color: #faa;
}
.calendar table .wn {
padding: 2px 3px 2px 2px;
border-right: 1px solid #000;
background: #e8f4f0;
}
.calendar tbody .rowhilite td {
background: #d8e4e0;
}
.calendar tbody .rowhilite td.wn {
background: #c8d4d0;
}
.calendar tbody td.hilite { /* Hovered cells <TD> */
padding: 1px 3px 1px 1px;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
}
.calendar tbody td.active { /* Active (pressed) cells <TD> */
padding: 2px 2px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar tbody td.selected { /* Cell showing selected date */
font-weight: bold;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
padding: 2px 2px 0px 2px;
background: #d8e4e0;
}
.calendar tbody td.weekend { /* Cells showing weekend days */
color: #f00;
}
.calendar tbody td.today { /* Cell showing today date */
font-weight: bold;
color: #00f;
}
.calendar tbody .disabled { color: #999; }
.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
visibility: hidden;
}
.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
display: none;
}
/* The footer part -- status bar and "Close" button */
.calendar tfoot .footrow { /* The <TR> in footer (only one right now) */
}
.calendar tfoot .ttip { /* Tooltip (status bar) cell <TD> */
background: #e8f4f0;
padding: 1px;
border: 1px solid #000;
background: #788480;
color: #fff;
text-align: center;
}
.calendar tfoot .hilite { /* Hover style for buttons in footer */
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
padding: 1px;
background: #d8e4e0;
}
.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
padding: 2px 0px 0px 2px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
/* Combo boxes (menus that display months/years for direct selection) */
.calendar .combo {
position: absolute;
display: none;
width: 4em;
top: 0px;
left: 0px;
cursor: default;
border-top: 1px solid #fff;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #fff;
background: #d8e4e0;
font-size: 90%;
padding: 1px;
z-index: 100;
}
.calendar .combo .label,
.calendar .combo .label-IEfix {
text-align: center;
padding: 1px;
}
.calendar .combo .label-IEfix {
width: 4em;
}
.calendar .combo .active {
background: #c8d4d0;
padding: 0px;
border-top: 1px solid #000;
border-right: 1px solid #fff;
border-bottom: 1px solid #fff;
border-left: 1px solid #000;
}
.calendar .combo .hilite {
background: #048;
color: #aef;
}
.calendar td.time {
border-top: 1px solid #000;
padding: 1px 0px;
text-align: center;
background-color: #e8f0f4;
}
.calendar td.time .hour,
.calendar td.time .minute,
.calendar td.time .ampm {
padding: 0px 3px 0px 4px;
border: 1px solid #889;
font-weight: bold;
background-color: #fff;
}
.calendar td.time .ampm {
text-align: center;
}
.calendar td.time .colon {
padding: 0px 2px 0px 3px;
font-weight: bold;
}
.calendar td.time span.hilite {
border-color: #000;
background-color: #667;
color: #fff;
}
.calendar td.time span.active {
border-color: #f00;
background-color: #000;
color: #0f0;
}

View File

@ -12,7 +12,7 @@
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*/ */
// $Id: calendar.js,v 1.2 2005/10/09 11:16:50 wurley Exp $ // $Id$
/** The Calendar object constructor. */ /** The Calendar object constructor. */
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) { Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {

View File

@ -1,119 +0,0 @@
<?php
/**
* File: calendar.php | (c) dynarch.com 2004
* Distributed as part of "The Coolest DHTML Calendar"
* under the same terms.
* -----------------------------------------------------------------
* This file implements a simple PHP wrapper for the calendar. It
* allows you to easily include all the calendar files and setup the
* calendar by instantiating and calling a PHP object.
*/
define('NEWLINE', "\n");
class DHTML_Calendar {
var $calendar_lib_path;
var $calendar_file;
var $calendar_lang_file;
var $calendar_setup_file;
var $calendar_theme_file;
var $calendar_options;
function DHTML_Calendar($calendar_lib_path = '/calendar/',
$lang = 'en',
$theme = 'calendar-win2k-1',
$stripped = true) {
if ($stripped) {
$this->calendar_file = 'calendar_stripped.js';
$this->calendar_setup_file = 'calendar-setup_stripped.js';
} else {
$this->calendar_file = 'calendar.js';
$this->calendar_setup_file = 'calendar-setup.js';
}
$this->calendar_lang_file = 'lang/calendar-' . $lang . '.js';
$this->calendar_theme_file = $theme.'.css';
$this->calendar_lib_path = preg_replace('/\/+$/', '/', $calendar_lib_path);
$this->calendar_options = array('ifFormat' => '%Y/%m/%d',
'daFormat' => '%Y/%m/%d');
}
function set_option($name, $value) {
$this->calendar_options[$name] = $value;
}
function load_files() {
echo $this->get_load_files_code();
}
function get_load_files_code() {
$code = ( '<link rel="stylesheet" type="text/css" media="all" href="' .
$this->calendar_lib_path . $this->calendar_theme_file .
'" />' . NEWLINE );
$code .= ( '<script type="text/javascript" src="' .
$this->calendar_lib_path . $this->calendar_file .
'"></script>' . NEWLINE );
$code .= ( '<script type="text/javascript" src="' .
$this->calendar_lib_path . $this->calendar_lang_file .
'"></script>' . NEWLINE );
$code .= ( '<script type="text/javascript" src="' .
$this->calendar_lib_path . $this->calendar_setup_file .
'"></script>' );
return $code;
}
function _make_calendar($other_options = array()) {
$js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
$code = ( '<script type="text/javascript">Calendar.setup({' .
$js_options .
'});</script>' );
return $code;
}
function make_input_field($cal_options = array(), $field_attributes = array()) {
$id = $this->_gen_id();
$attrstr = $this->_make_html_attr(array_merge($field_attributes,
array('id' => $this->_field_id($id),
'type' => 'text')));
echo '<input ' . $attrstr .'/>';
echo '<a href="#" id="'. $this->_trigger_id($id) . '">' .
'<img align="middle" border="0" src="' . $this->calendar_lib_path . 'img.gif" alt="" /></a>';
$options = array_merge($cal_options,
array('inputField' => $this->_field_id($id),
'button' => $this->_trigger_id($id)));
echo $this->_make_calendar($options);
}
/// PRIVATE SECTION
function _field_id($id) { return 'f-calendar-field-' . $id; }
function _trigger_id($id) { return 'f-calendar-trigger-' . $id; }
function _gen_id() { static $id = 0; return ++$id; }
function _make_js_hash($array) {
$jstr = '';
reset($array);
while (list($key, $val) = each($array)) {
if (is_bool($val))
$val = $val ? 'true' : 'false';
else if (!is_numeric($val))
$val = '"'.$val.'"';
if ($jstr) $jstr .= ',';
$jstr .= '"' . $key . '":' . $val;
}
return $jstr;
}
function _make_html_attr($array) {
$attrstr = '';
reset($array);
while (list($key, $val) = each($array)) {
$attrstr .= $key . '="' . $val . '" ';
}
return $attrstr;
}
};
?>

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

View File

@ -8,7 +8,7 @@
// Bjoern Schotte <bjoern@rent-a-phpwizard.de> (PEARification) // Bjoern Schotte <bjoern@rent-a-phpwizard.de> (PEARification)
// Martin Jansen <mj@php.net> (PEAR conformance) // Martin Jansen <mj@php.net> (PEAR conformance)
// //
// $Id: PHPLIB.php,v 1.3 2006/09/17 06:22:04 wurley Exp $ // $Id$
// //
//require_once "PEAR.php"; //require_once "PEAR.php";

View File

@ -1,4 +1,4 @@
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/js/pla_ajax.js,v 1.2 2007/12/15 07:50:31 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * @package phpLDAPadmin
@ -7,6 +7,7 @@
*/ */
// current request // current request
var http_div = '';
var http_request = null; var http_request = null;
var http_request_success_callback = ''; var http_request_success_callback = '';
var http_request_error_callback = ''; var http_request_error_callback = '';
@ -46,7 +47,7 @@ function alertHttpRequest() {
http_request = null; http_request = null;
//alert(response); //alert(response);
if (http_request_success_callback) { if (http_request_success_callback) {
eval(http_request_success_callback + '(response)'); eval(http_request_success_callback + '(response,http_div)');
} }
} else { } else {
alert('There was a problem with the request.'); alert('There was a problem with the request.');
@ -59,31 +60,33 @@ function cancelHttpRequest() {
if (http_request) { if (http_request) {
http_request = null; http_request = null;
if (http_request_error_callback) { if (http_request_error_callback) {
eval(http_request_error_callback + '()'); eval(http_request_error_callback + '(http_div)');
} }
} }
} }
// resquest // request
function makeGETRequest(url, parameters, successCallbackFunctionName, errorCallbackFunctionName) { function makeGETRequest(url,parameters,successCallbackFunctionName,errorCallbackFunctionName,div) {
makeHttpRequest(url, parameters, 'GET', successCallbackFunctionName, errorCallbackFunctionName); makeHttpRequest(url,parameters,'GET',successCallbackFunctionName,errorCallbackFunctionName,div);
} }
function makePOSTRequest(url, parameters, successCallbackFunctionName, errorCallbackFunctionName) { function makePOSTRequest(url,parameters,successCallbackFunctionName,errorCallbackFunctionName,div) {
makeHttpRequest(url, parameters, 'POST', successCallbackFunctionName, errorCallbackFunctionName); makeHttpRequest(url,parameters,'POST',successCallbackFunctionName,errorCallbackFunctionName,div);
} }
function makeHttpRequest(url, parameters, meth, successCallbackFunctionName, errorCallbackFunctionName) { function makeHttpRequest(url,parameters,meth,successCallbackFunctionName,errorCallbackFunctionName,div) {
cancelHttpRequest(); cancelHttpRequest(div);
http_request_success_callback = successCallbackFunctionName; http_request_success_callback = successCallbackFunctionName;
http_request_error_callback = errorCallbackFunctionName; http_request_error_callback = errorCallbackFunctionName;
http_div = div;
if (window.XMLHttpRequest) { // Mozilla, Safari,... if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest(); http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) { if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html'); http_request.overrideMimeType('text/html');
} }
} else if (window.ActiveXObject) { // IE } else if (window.ActiveXObject) { // IE
try { try {
http_request = new ActiveXObject("Msxml2.XMLHTTP"); http_request = new ActiveXObject("Msxml2.XMLHTTP");

View File

@ -3,7 +3,7 @@
// This JavaScript file defines some functions used by the two search forms for // This JavaScript file defines some functions used by the two search forms for
// auto-populating the base DN dynamically when a server is selected from the // auto-populating the base DN dynamically when a server is selected from the
// drop-down. // drop-down.
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/js/search_util.js,v 1.2 2004/03/19 20:17:51 i18phpldapadmin Exp $ // $Header$
//the array to store the server //the array to store the server
var servers = new Array(); var servers = new Array();

View File

@ -0,0 +1,84 @@
function pla_getComponentById(id) {
return document.getElementById(id);
}
function pla_getComponentsByName(name) {
return document.getElementsByName(name);
}
function pla_getComponentValue(component) {
if (component.type == "checkbox") {
if (component.checked) return component.value;
} else if (component.type == "select-one") {
if (component.selectedIndex >= 0) return component.options[component.selectedIndex].value;
} else if (component.type == "select-multiple") {
if (component.selectedIndex >= 0) return component.options[component.selectedIndex].value;
} else if (component.type == undefined) { // option
if (component.selected) return component.value;
} else {
return component.value;
}
return "";
}
function pla_setComponentValue(component,value) {
if (component.type == "checkbox") {
if (component.value == value) component.checked = true;
else component.checked = false;
} else if (component.type == "select-one") {
for (var i = 0; i < component.options.length; i++) {
if (component.options[i].value == value) component.options[i].selected = true;
}
} else if (component.type == "select-multiple") {
for (var i = 0; i < component.options.length; i++) {
if (component.options[i].value == value) component.options[i].selected = true;
}
} else if (component.type == undefined) { // option
if (component.value == value) component.selected = true;
else component.selected = false;
} else {
component.value = value;
}
}
function getAttributeComponents(prefix,name) {
var components = new Array();
var i = 0;
var j = 0;
var c = pla_getComponentsByName(prefix + "_values[" + name + "][" + j + "]");
while (c && (c.length > 0)) {
for (var k = 0; k < c.length; k++) {
components[i++] = c[k];
}
++j;
c = pla_getComponentsByName(prefix + "_values[" + name + "][" + j + "]");
}
c = pla_getComponentsByName(prefix + "_values[" + name + "][]");
if (c && (c.length > 0)) {
for (var k = 0; k < c.length; k++) {
components[i++] = c[k];
}
}
return components;
}
function getAttributeValues(prefix,name) {
var components = getAttributeComponents(prefix,name);
var values = new Array();
for (var k = 0; k < components.length; k++) {
var val = pla_getComponentValue(components[k]);
if (val) values[values.length] = val;
}
return values;
}
function submitForm(form) {
for (var i = 0; i < form.elements.length; i++) {
form.elements[i].blur();
}
return validateForm(true);
}
function alertError(err,silence) {
if (!silence) alert(err);
}

View File

@ -2,13 +2,13 @@ var current;
function tree_unhide(whichLayer,old) { function tree_unhide(whichLayer,old) {
if (current == null) current = old; if (current == null) current = old;
var oldtree = document.getElementById('SID_'+current).style; var oldtree = document.getElementById('ajSID_'+current).style;
oldtree.display = 'none'; oldtree.display = 'none';
if (document.getElementById) { if (document.getElementById) {
// this is the way the standards work // this is the way the standards work
var newtree = document.getElementById(whichLayer).value; var newtree = document.getElementById(whichLayer).value;
var newtree_div = document.getElementById('SID_'+newtree).style; var newtree_div = document.getElementById('ajSID_'+newtree).style;
newtree_div.display = 'block'; newtree_div.display = 'block';
/* /*

View File

@ -1,202 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/ldif_import.php,v 1.35.2.4 2008/12/12 12:20:22 wurley Exp $
/**
* Imports an LDIF file to the specified server_id.
*
* Variables that come in as POST vars:
* - ldif_file (as an uploaded file)
* - server_id
*
* @package phpLDAPadmin
*/
/**
*/
require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('import'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('import')),'error','index.php');
$entry = array();
$entry['continuous_mode'] = get_request('continuous_mode') ? true : false;
$entry['ldif'] = get_request('ldif');
if ($entry['ldif']) {
$entry['remote_file'] = 'STDIN';
$entry['size'] = strlen($entry['ldif']);
} elseif (isset($_FILES['ldif_file'])) {
$file = $_FILES['ldif_file']['tmp_name'];
$entry['remote_file'] = $_FILES['ldif_file']['name'];
$entry['size'] = $_FILES['ldif_file']['size'];
if (! is_array($_FILES['ldif_file'])) {
error(_('Missing uploaded file.'),'error');
return;
}
if (! file_exists($file)) {
error(_('No LDIF file specified. Please try again.'),'error');
return;
}
if ($entry['size'] <= 0) {
error(_('Uploaded LDIF file is empty.'),'error');
return;
}
} else {
error(_('You must either upload a file or provide an LDIF in the text box.'),'error');
return;
}
printf('<h3 class="title">%s</h3>',_('Import LDIF File'));
printf('<h3 class="subtitle">%s: <b>%s</b> %s: <b>%s (%s %s)</b></h3>',
_('Server'),htmlspecialchars($ldapserver->name),
_('File'),htmlspecialchars($entry['remote_file']),number_format($entry['size']),_('bytes'));
echo '<br /><br />';
require LIBDIR.'ldif_functions.php';
@set_time_limit(0);
# String associated to the operation on the ldap server
$actionString = array();
$actionString['add'] = _('Adding...');
$actionString['delete'] = _('Deleting...');
$actionString['modrdn'] = _('Renaming...');
$actionString['moddn'] = _('Renaming...');
$actionString['modify'] = _('Modifying...');
# String associated with error
$actionErrorMsg =array();
$actionErrorMsg['add'] = _('Could not add object:');
$actionErrorMsg['delete']= _('Could not delete object:');
$actionErrorMsg['modrdn']= _('Could not rename object:');
$actionErrorMsg['moddn']= _('Could not rename object:');
$actionErrorMsg['modify']= _('Could not modify object:');
# instantiate the reader
if (isset($entry['ldif']))
$ldifReader = new LdifReaderStdIn($entry['ldif'],$entry['continuous_mode']);
else
$ldifReader = new LdifReader($file,$entry['continuous_mode']);
# instantiate the writer
$ldapWriter = new LdapWriter($ldapserver);
# if ldif file has no version number, just display a warning
if (!$ldifReader->hasVersionNumber())
display_warning($ldifReader->getWarningMessage());
$i=0;
# if .. else not mandatory but should be easier to maintain
if ($entry['continuous_mode']) {
while ($ldifReader->readEntry()) {
$i++;
# get the entry.
$currentEntry = $ldifReader->fetchEntryObject();
$edit_href = sprintf('cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s',$ldapserver->server_id,
rawurlencode($currentEntry->dn));
$changeType = $currentEntry->getChangeType();
printf('<small>%s <a href="%s">%s</a>',$actionString[$changeType],$edit_href,$currentEntry->dn);
if ($ldifReader->hasRaisedException()) {
printf(' <span style="color:red;">%s</span></small><br />',_('Failed'));
$exception = $ldifReader->getLdapLdifReaderException();
printf(' <small><span style="color:red;">%s: %s</span></small><br />',
_('Line Number'),$exception->lineNumber);
printf(' <small><span style="color:red;">%s: %s</span></small><br />',
_('Line'),$exception->currentLine);
printf(' <small><span style="color:red;">%s: %s</span></small><br />',
_('Description'),$exception->message);
} else {
if ($ldapWriter->ldapModify($currentEntry))
printf(' <span style="color:green;">%s</span></small><br />',_('Success'));
else {
printf(' <span style="color:red;">%s</span></small><br />',_('Failed'));
printf(' <small><span style="color:red;">%s: %s</span></small><br />',
_('Error code'),$ldapserver->errno());
printf(' <small><span style="color:red;">%s: %s</span></small><br />',
_('Description'),$ldapserver->error());
}
}
} # end while
} else {
# while we have a valid entry,
while ($entry = $ldifReader->readEntry()) {
$i++;
$edit_href = sprintf('cmd.php?cmd=template_engine&amp;server_id=%s&amp;dn=%s',$ldapserver->server_id,
rawurlencode($entry->dn));
$changeType = $entry->getChangeType();
printf('<small>%s <a href="%s">%s</a>',$actionString[$changeType],$edit_href,$entry->dn);
if ($ldapWriter->ldapModify($entry)) {
printf(' <span style="color:green;">%s</span></small><br />',_('Success'));
} else {
printf(' <span style="color:red;">%s</span></small><br /><br />',_('Failed'));
$ldap_err_no = ('0x'.str_pad(dechex($ldapserver->errno()),2,0,STR_PAD_LEFT));
$verbose_error = pla_verbose_error($ldap_err_no);
$errormsg = sprintf('%s <b>%s</b>',$actionErrorMsg[$changeType],htmlspecialchars($entry->dn));
$errormsg .= sprintf('<br />%s: <b>%s</b>',_('LDAP said'),$verbose_error['title']);
$errormsg .= sprintf('<br />%s',$verbose_error['desc']);
system_message(array(
'title'=>_('LDIF text import'),
'body'=>$errormsg,
'type'=>'warn'));
break;
}
}
# if any errors occurs during reading file ,"catch" the exception and display it here.
if ($ldifReader->hasRaisedException()) {
# get the entry which raise the exception,quick hack here
$currentEntry = $ldifReader->fetchEntryObject();
if ($currentEntry->dn != '') {
printf('<small>%s %s <span style="color:red;">%s</span></small><br />',
$actionString[$currentEntry->getChangeType()],$currentEntry->dn,_('Failed'));
}
# get the exception wich was raised
$exception = $ldifReader->getLdapLdifReaderException();
echo '<br /><br />';
display_pla_parse_error($exception,$currentEntry);
}
}
# close the file
$ldifReader->done();
function display_warning($warning){
printf('<div style="color:orange"><small>%s</small></div>',$warning);
}
function display_pla_parse_error($exception,$faultyEntry) {
global $actionErrorMsg;
$errorMessage = $actionErrorMsg[$faultyEntry->getChangeType()];
echo '<center>';
printf('<table class="error"><tr><td class="img"><img src="%s/warning.png" /></td>',IMGDIR);
echo '<td>';
printf('<center><h2>%s</h2></center>',_('LDIF Parse Error'));
echo '<br />';
printf('%s %s',$errorMessage,$faultyEntry->dn);
printf('<p><b>%s</b>: %s</p>',_('Description'),$exception->message);
printf('<p><b>%s</b>: %s</p>',_('Line'),$exception->currentLine);
printf('<p><b>%s</b>: %s</p>',_('Line Number'),$exception->lineNumber);
echo '<br />';
printf('<p><center><small>%s %s</small></center></p>',
_('Is this a phpLDAPadmin bug?'),sprintf(_('If so, please <a href="%s">report it</a>.'),get_href('add_bug')));
echo '</td>';
echo '</tr>';
echo '<center>';
}
?>

View File

@ -1,167 +1,39 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/login.php,v 1.56.2.5 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* For servers whose auth_type is set to 'cookie' or 'session'. Pass me the * Log the user in.
* login info and I'll write two cookies, pla_login_dn_X and pla_pass_X where X
* is the server_id. The cookie_time comes from config.php
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$login['val'] = get_request($ldapserver->getLoginAttr()); $user = array();
$login['pass'] = get_request('login_pass'); $user['login'] = get_request('login');
$user['password'] = get_request('login_pass');
if ($ldapserver->isAnonBindAllowed()) if ($user['login'] && ! strlen($user['password']))
$anon_bind = get_request('anonymous_bind') == 'on' ? true : false;
else
$anon_bind = false;
if (! $anon_bind && ! strlen($login['pass']))
system_message(array( system_message(array(
'title'=>_('Authenticate to server'), 'title'=>_('Authenticate to server'),
'body'=>_('You left the password blank.'), 'body'=>_('You left the password blank.'),
'type'=>'warn'), 'type'=>'warn'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id)); sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
$save_auth_type = $ldapserver->auth_type; if ($app['server']->login($user['login'],$user['password'],'user'))
if ($anon_bind) {
if (DEBUG_ENABLED)
debug_log('Anonymous Login was posted [%s].',64,__FILE__,__LINE__,__METHOD__,$anon_bind);
$login['dn'] = null;
$login['pass'] = null;
/* Checks if the login_attr option is enabled for this host,
which allows users to login with a simple username like 'jdoe' rather
than the fully qualified DN, 'uid=jdoe,ou=people,,dc=example,dc=com'. */
} elseif ($ldapserver->isLoginAttrEnabled()) {
# Is this a login string (printf-style)
if ($ldapserver->isLoginStringEnabled()) {
$login['dn'] = str_replace('<username>',$login['val'],$ldapserver->getLoginString());
if (DEBUG_ENABLED)
debug_log('LoginStringDN: [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']);
} else {
# This is a standard login_attr
/* Fake the auth_type of config to do searching. This way, the admin can specify
the DN to use when searching for the login_attr user. */
$ldapserver->auth_type = 'config';
if ($ldapserver->login_dn)
$ldapserver->connect();
else
$ldapserver->connect(true,'anonymous');
if (! empty($ldapserver->login_class))
$filter = sprintf('(&(objectClass=%s)(%s=%s))',$ldapserver->login_class,$ldapserver->getLoginAttr(),$login['val']);
else
$filter = sprintf('%s=%s',$ldapserver->getLoginAttr(),$login['val']);
# Got through each of the BASE DNs and test the login.
foreach ($ldapserver->getBaseDN() as $base_dn) {
if (DEBUG_ENABLED)
debug_log('Searching LDAP with base [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn);
$result = $ldapserver->search(null,$base_dn,$filter,array('dn'));
$result = array_pop($result);
$login['dn'] = $result['dn'];
if ($login['dn']) {
if (DEBUG_ENABLED)
debug_log('Got DN [%s] for user ID [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn'],$login['val']);
break;
}
}
# If we got here then we werent able to find a DN for the login filter.
if (! $login['dn'])
if ($ldapserver->login_fallback_dn)
$login['dn'] = $login['val'];
else
system_message(array( system_message(array(
'title'=>_('Authenticate to server'), 'title'=>_('Authenticate to server'),
'body'=>_('Bad username or password. Please try again.'), 'body'=>_('Successfully logged into server.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id));
# Restore the original auth_type
$ldapserver->auth_type = $save_auth_type;
}
} else {
$login['dn'] = $login['val'];
}
# We fake a 'config' server auth_type to omit duplicated code
if (DEBUG_ENABLED)
debug_log('Setting login type to CONFIG with DN [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']);
$save_auth_type = $ldapserver->auth_type;
$ldapserver->auth_type = 'config';
$ldapserver->login_dn = $login['dn'];
$ldapserver->login_pass = $login['pass'];
# Verify that dn is allowed to login
if (! $ldapserver->userIsAllowedLogin($login['dn']))
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Sorry, you are not allowed to use phpLDAPadmin with this LDAP server.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id));
if (DEBUG_ENABLED)
debug_log('User is not prohibited from logging in - now bind with DN [%s]',64,__FILE__,__LINE__,__METHOD__,$login['dn']);
# Verify that the login is good
if (is_null($login['dn']) && is_null($login['pass']))
$ds = $ldapserver->connect(false,'anonymous',true);
else
$ds = $ldapserver->connect(false,'user',true);
if (DEBUG_ENABLED)
debug_log('Connection returned [%s]',64,__FILE__,__LINE__,__METHOD__,$ds);
if (! is_resource($ds)) {
if ($anon_bind)
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Could not bind anonymously to server.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id));
else
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Bad username or password. Please try again.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',$ldapserver->server_id));
syslog_notice(sprintf('Authentification FAILED for %s',$login['dn']));
}
$ldapserver->auth_type = $save_auth_type;
$ldapserver->setLoginDN($login['dn'],$login['pass'],$anon_bind) or error(_('Could not set cookie.'),'error','index.php');
set_lastactivity($ldapserver);
if (! $anon_bind) {
syslog_notice(sprintf('Authentification successful for %s',$login['dn']));
}
# Since we were successful, clear the cache so that it will be refreshed with the new creditentials.
del_cached_item($ldapserver->server_id,'tree','null');
system_message(array(
'title'=>_('Authenticate to server'),
'body'=>_('Successfully logged into server.').($anon_bind ? sprintf(' (%s)',_('Anonymous Bind')) : ''),
'type'=>'info'), 'type'=>'info'),
sprintf('index.php?server_id=%s',$ldapserver->server_id)); sprintf('cmd.php?server_id=%s',get_request('server_id','REQUEST')));
else
system_message(array(
'title'=>_('Failed to Authenticate to server'),
'body'=>_('Invalid Username or Password.'),
'type'=>'error'),
sprintf('cmd.php?cmd=login_form&server_id=%s',get_request('server_id','REQUEST')));
?> ?>

View File

@ -1,26 +1,24 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/login_form.php,v 1.29.2.7 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays the login form for a server for users who specify 'cookie' or 'session' for their auth_type. * Displays the login form for a server for users who specify 'cookie' or 'session' for their auth_type.
* *
* @package phpLDAPadmin
* @author The phpLDAPadmin development team * @author The phpLDAPadmin development team
* @package phpLDAPadmin
* @see login.php * @see login.php
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if (! in_array($ldapserver->auth_type, array('cookie','session'))) printf('<h3 class="title">%s %s</h3>',_('Authenticate to server'),$app['server']->getName());
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($ldapserver->auth_type)),'error','index.php'); echo '<br />';
printf('<h3 class="title">%s %s</h3>',_('Authenticate to server'),$ldapserver->name);
# Check for a secure connection # Check for a secure connection
if (! isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on') { if (! isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on') {
echo '<br />';
echo '<center>'; echo '<center>';
echo '<span style="color:red">'; echo '<span style="color:red">';
printf('<acronym title="%s"><b>%s: %s.</b></acronym>', printf('<acronym title="%s"><b>%s: %s.</b></acronym>',
@ -28,13 +26,13 @@ if (! isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on') {
_('Warning'),_('This web connection is unencrypted')); _('Warning'),_('This web connection is unencrypted'));
echo '</span>'; echo '</span>';
echo '</center>'; echo '</center>';
echo '<br />';
} }
echo '<br />';
# Login form. # Login form.
echo '<form action="cmd.php" method="post" name="login_form">'; echo '<form action="cmd.php" method="post" name="login_form">';
echo '<input type="hidden" name="cmd" value="login" />'; echo '<input type="hidden" name="cmd" value="login" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
if (get_request('redirect','GET',false,false)) if (get_request('redirect','GET',false,false))
printf('<input type="hidden" name="redirect" value="%s" />',rawurlencode(get_request('redirect','GET'))); printf('<input type="hidden" name="redirect" value="%s" />',rawurlencode(get_request('redirect','GET')));
@ -43,11 +41,11 @@ echo '<center>';
echo '<table class="forminput">'; echo '<table class="forminput">';
printf('<tr><td><b>%s:</b></td></tr>', printf('<tr><td><b>%s:</b></td></tr>',
$ldapserver->login_attr == 'dn' ? _('Login DN') : $_SESSION[APPCONFIG]->getFriendlyName($ldapserver->login_attr)); $app['server']->getValue('login','auth_text') ? $app['server']->getValue('login','auth_text') :
($app['server']->getValue('login','attr') == 'dn' ? _('Login DN') : $_SESSION[APPCONFIG]->getFriendlyName($app['server']->getValue('login','attr'))));
printf('<tr><td><input type="text" id="login" name="%s" size="40" value="%s" /></td></tr>', printf('<tr><td><input type="text" id="login" name="login" size="40" value="%s" /></td></tr>',
$ldapserver->login_attr, $app['server']->getValue('login','attr') == 'dn' ? $app['server']->getValue('login','bind_id') : '');
$ldapserver->login_attr == 'dn' ? $ldapserver->login_dn : '');
echo '<tr><td colspan=2>&nbsp;</td></tr>'; echo '<tr><td colspan=2>&nbsp;</td></tr>';
printf('<tr><td><b>%s:</b></td></tr>',_('Password')); printf('<tr><td><b>%s:</b></td></tr>',_('Password'));
@ -55,7 +53,7 @@ echo '<tr><td><input type="password" id="password" size="40" value="" name="logi
echo '<tr><td colspan=2>&nbsp;</td></tr>'; echo '<tr><td colspan=2>&nbsp;</td></tr>';
# If Anon bind allowed, then disable the form if the user choose to bind anonymously. # If Anon bind allowed, then disable the form if the user choose to bind anonymously.
if ($ldapserver->isAnonBindAllowed()) if ($app['server']->isAnonBindAllowed())
printf('<tr><td colspan="2"><small><b>%s</b></small> <input type="checkbox" name="anonymous_bind" onclick="toggle_disable_login_fields(this)" id="anonymous_bind_checkbox" /></td></tr>', printf('<tr><td colspan="2"><small><b>%s</b></small> <input type="checkbox" name="anonymous_bind" onclick="toggle_disable_login_fields(this)" id="anonymous_bind_checkbox" /></td></tr>',
_('Anonymous')); _('Anonymous'));
@ -68,19 +66,20 @@ echo '</form>';
echo '<script type="text/javascript" language="javascript">document.getElementById(\'login\').focus()</script>'; echo '<script type="text/javascript" language="javascript">document.getElementById(\'login\').focus()</script>';
if( $ldapserver->isAnonBindAllowed() ) { ?> if ($app['server']->isAnonBindAllowed() ) {
?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- function toggle_disable_login_fields(anon_checkbox) {
function toggle_disable_login_fields(anon_checkbox) {
if (anon_checkbox.checked) { if (anon_checkbox.checked) {
anon_checkbox.form.<?php echo $ldapserver->login_attr; ?>.disabled = true; anon_checkbox.form.login.disabled = true;
anon_checkbox.form.login_pass.disabled = true; anon_checkbox.form.password.disabled = true;
} else { } else {
anon_checkbox.form.<?php echo $ldapserver->login_attr; ?>.disabled = false; anon_checkbox.form.login.disabled = false;
anon_checkbox.form.<?php echo $ldapserver->login_attr; ?>.focus(); anon_checkbox.form.login.focus();
anon_checkbox.form.login_pass.disabled = false; anon_checkbox.form.password.disabled = false;
} }
} }
-->
</script> </script>
<?php } <?php
}
?>

View File

@ -1,37 +1,28 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/logout.php,v 1.20.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* For servers whose auth_type is set to 'cookie' or 'session'. Pass me * Log the user out of the application.
* the server_id and I will log out the user (delete the cookie)
*
* Variables that come in via common.php
* - server_id
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if (! $ldapserver->haveAuthInfo()) if ($app['server']->logout())
error(_('No one is logged in to that server.'),'error','index.php'); system_message(array(
'title'=>_('Authenticate to server'),
if (in_array($ldapserver->auth_type, array('cookie','session','http'))) { 'body'=>_('Successfully logged out of server.'),
syslog_notice (sprintf('Logout for %s',$ldapserver->getLoggedInDN()));
if($ldapserver->auth_type!='http')
$ldapserver->unsetLoginDN() or error(_('Could not logout.'),'error','index.php');
unset_lastactivity($ldapserver);
@session_destroy();
} else
error(sprintf(_('Unknown auth_type: %s'),htmlspecialchars($ldapserver->auth_type)),'error','index.php');
system_message(array(
'title'=>_('Logout'),
'body'=>('Logged out successfully from server.'),
'type'=>'info'), 'type'=>'info'),
sprintf('index.php?server_id=%s',$ldapserver->server_id)); sprintf('index.php?server_id=%s',$app['server']->getIndex()));
else
system_message(array(
'title'=>_('Failed to Logout of server'),
'body'=>_('Please report this error to the admins.'),
'type'=>'error'),
sprintf('index.php?server_id=%s',$app['server']->getIndex()));
?> ?>

View File

@ -1,5 +1,5 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/mass_delete.php,v 1.17.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Enables user to mass delete multiple entries using checkboxes. * Enables user to mass delete multiple entries using checkboxes.

View File

@ -1,112 +1,90 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/modify_member_form.php,v 1.5.2.6 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays a form to allow the user to modify group members. * Displays a form to allow the user to modify group members.
* *
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
* - attr (rawurlencoded) the attribute to which we are adding a value
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
if (! $ldapserver->haveAuthInfo()) $request['dn'] = get_request('dn','GET');
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php'); $request['attr'] = get_request('attr','GET');
$attr = get_request('attr','GET'); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$dn = get_request('dn','GET'); $request['page']->setDN($request['dn']);
$encoded_dn = rawurlencode($dn); $request['page']->accept(true);
$encoded_attr = rawurlencode($attr); $request['template'] = $request['page']->getTemplate();
if (! is_null($dn)) if (! is_null($request['dn']))
$rdn = get_rdn($dn); $rdn = get_rdn($request['dn']);
else else
$rdn = null; $rdn = null;
# Get all current group members # Get all current group members
$current_members = $ldapserver->getDNAttr($dn,$attr); $current_members = $app['server']->getDNAttrValue($request['dn'],$request['attr']);
if ($current_members)
$num_current_members = (is_array($current_members) ? count($current_members) : 1);
else
$num_current_members = 0;
usort($current_members,'pla_compare_dns'); usort($current_members,'pla_compare_dns');
# Loop through all base dn's and search possible member entries # Loop through all base dn's and search possible member entries
foreach ($ldapserver->getBaseDN() as $base_dn) { $query = array();
# Get all entries that can be added to the group # Get all entries that can be added to the group
if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr'))) {
$query['filter'] = $_SESSION[APPCONFIG]->getValue('modify_member','posixfilter');
$attr = $_SESSION[APPCONFIG]->getValue('modify_member','posixattr');
if (preg_match("/^$attr$/i",$_SESSION[APPCONFIG]->GetValue('modify_member','posixgroupattr'))) } else {
$possible_values = array_merge($ldapserver->search(null,$base_dn, $query['filter'] = $_SESSION[APPCONFIG]->getValue('modify_member','filter');
$_SESSION[APPCONFIG]->GetValue('modify_member','posixfilter'), $attr = $_SESSION[APPCONFIG]->getValue('modify_member','attr');
array($_SESSION[APPCONFIG]->GetValue('modify_member','posixattr'))));
else
$possible_values = array_merge($ldapserver->search(null,$base_dn,
$_SESSION[APPCONFIG]->GetValue('modify_member','filter'),
array($_SESSION[APPCONFIG]->GetValue('modify_member','attr'))));
} }
if ($possible_values) $query['attrs'] = array($attr);
$num_possible_values = (is_array($possible_values) ? count($possible_values) : 1);
else
$num_possible_values = 0;
sort($possible_values); $possible_values = array();
foreach ($app['server']->getBaseDN() as $base) {
$query['base'] = $base;
include './header.php'; $possible_values = array_merge($possible_values,$app['server']->query($query,null));
}
echo '<body>'; usort($possible_values,'pla_compare_dns');
printf('<h3 class="title">%s <b>%s</b></h3>',_('Modify group'),htmlspecialchars($rdn));
printf('<h3 class="subtitle">%s <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>', $request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Modify group'),get_rdn($request['dn'])));
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn)); $request['page']->drawSubTitle();
printf('%s <b>%s</b> %s <b>%s</b>:', printf('%s <b>%s</b> %s <b>%s</b>:',
_('There are'),$num_current_members,_('members in group'),htmlspecialchars($rdn)); _('There are'),count($current_members),_('members in group'),htmlspecialchars(get_rdn($request['dn'])));
$possible_members = array(); $possible_members = array();
for ($i=0; $i<count($possible_values); $i++) { for ($i=0;$i<count($possible_values);$i++) {
if (preg_match("/^$attr$/i",$_SESSION[APPCONFIG]->GetValue('modify_member','posixgroupattr'))) if (preg_match("/^".$request['attr']."$/i",$_SESSION[APPCONFIG]->getValue('modify_member','posixgroupattr')))
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->GetValue('modify_member','posixattr')]; $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member','posixattr')];
else else
$possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->GetValue('modify_member','attr')]; $possible_members[$i] = $possible_values[$i][$_SESSION[APPCONFIG]->getValue('modify_member','attr')];
} }
# Show only user that are not already in group.
$possible_members = array_diff($possible_members,$current_members);
usort($possible_members,'pla_compare_dns'); usort($possible_members,'pla_compare_dns');
/* /* Draw form with select boxes, left for all possible members and
* Show only user that are not already in group. * right one for those that belong to group */
* This loop removes existing users from possible members
*/
foreach ($possible_members as $pkey => $possible) {
foreach ($current_members as $current) {
if (preg_match("/^$current$/i","$possible_members[$pkey]")) {
unset($possible_members[$pkey]);
break;
}
}
}
/*
* Draw form with select boxes, left for all possible members and
* right one for those that belong to group
*/
# Modifications will be sent to update_confirm which takes care of rest of the processing # Modifications will be sent to update_confirm which takes care of rest of the processing
echo '<br />'; echo '<br />';
echo '<br />'; echo '<br />';
echo '<form action="cmd.php" method="post" class="add_value" name="member">'; echo '<form action="cmd.php" method="post" class="add_value" name="member">';
echo '<input type="hidden" name="cmd" value="update_confirm" />'; if ($_SESSION[APPCONFIG]->getValue('confirm','update'))
echo '<input type="hidden" name="cmd" value="update_confirm" />';
else
echo '<input type="hidden" name="cmd" value="update" />';
echo '<table class="modify_members">'; echo '<table class="modify_members">';
@ -153,28 +131,25 @@ echo '</tr>';
echo '<tr><td colspan="2">'; echo '<tr><td colspan="2">';
# Hidden attributes for update_confirm.php # Hidden attributes for update_confirm.php
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',$dn); printf('<input type="hidden" name="dn" value="%s" />',rawurlencode($request['dn']));
printf('<input type="hidden" name="attr" value="%s" />',$encoded_attr); printf('<input type="hidden" name="attr" value="%s" />',$request['attr']);
/* /* Generate array of input text boxes from current members.
* Generate array of input text boxes from current members. * update_confirm.php will see this as old_values[member-attribute][item] */
* update_confirm.php will see this as old_values[member-attribute][item] for ($i=0; $i<count($current_members); $i++)
*/
for ($i=0; $i<$num_current_members; $i++)
printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />', printf('<input type="hidden" name="old_values[%s][%s]" value="%s" />',
htmlspecialchars($attr),$i,htmlspecialchars($current_members[$i])); htmlspecialchars($request['attr']),$i,htmlspecialchars($current_members[$i]));
/*
* Javascript generates array of input text boxes from new members. /* Javascript generates array of input text boxes from new members.
* update_confirm.php will see this as new_values[member-attribute][item] * update_confirm.php will see this as new_values[member-attribute][item]
* Input text boxes will be generated to div=dnu * Input text boxes will be generated to div=dnu */
*/
echo '<div id="dnu">'; echo '<div id="dnu">';
printf('<input type="hidden" name="new_values[%s][]" value="" />',htmlspecialchars($attr)); printf('<input type="hidden" name="new_values[%s][]" value="" />',htmlspecialchars($request['attr']));
echo '</div>'; echo '</div>';
# Submit values to update_confirm.php and when clicked, run addSelected # Submit values to update_confirm.php and when clicked, run addSelected
printf('<input type="submit" name="save" value="%s" onClick="update_new_values(\'%s\',\'modifymember\')" />',_('Save changes'),$attr); printf('<input type="submit" name="save" value="%s" onClick="update_new_values(\'%s\',\'modifymember\')" />',_('Save changes'),$request['attr']);
echo '</td></tr>'; echo '</td></tr>';
echo '</table>'; echo '</table>';
@ -185,6 +160,7 @@ echo '<script type="text/javascript" language="javascript">';
echo 'var m1 = document.member.notmembers;'; echo 'var m1 = document.member.notmembers;';
echo 'var m2 = document.member.members;'; echo 'var m2 = document.member.members;';
echo '</script>'; echo '</script>';
printf('<script type="text/javascript" src="%smodify_member.js"></script>',JSDIR);
echo '</body></html>'; echo '</body></html>';
?> ?>

266
htdocs/monitor.php Normal file
View File

@ -0,0 +1,266 @@
<?php
// $Header$
/**
* Displays the information from the monitor context
*
* @package phpLDAPadmin
* @subpackage Page
*/
/**
*/
require './common.php';
# Fetch basic RootDSE attributes using the + and *.
$query = array();
$query['base'] = '';
$query['scope'] = 'base';
$query['attrs'] = $app['server']->getValue('server','root_dse_attributes');
$query['baseok'] = true;
$results = $app['server']->query($query,null);
$attrs = array_change_key_case(array_pop($results));
$query['base'] = $attrs['monitorcontext'];
$query['scope'] = 'sub';
$results = $app['server']->query($query,null);
if (! isset($attrs['monitorcontext']) || ! count($results))
system_message(array(
'title'=>_('Monitoring context does not exist'),
'body'=>sprintf('%s: <b>%s</b>',_('Could not optain the monitor context for this server'),$app['server']->getName()),
'type'=>'warn'),'index.php');
printf('<h3 class="title">%s%s</h3>',_('Monitor info for: '),$app['server']->getName());
printf('<h3 class="subtitle">%s</h3>',_('Server reports the following information about itself'));
echo '<table class="result" border=0>';
# cn=Monitor
printf('<tr class="list_item"><td class="heading" rowspan=2>%s</td></tr>',_('LDAP Server'));
printf('<tr class="list_item"><td class="value">');
echo '<table class="result" border=0>';
printf('<tr><td>%s</td></tr>',$results['cn=Monitor']['monitoredInfo']);
echo '</table>';
echo '</td></tr>';
foreach (array(
'cn=Backends,cn=Monitor' => 'cn=Backend %s,%s',
'cn=Overlays,cn=Monitor' => 'cn=Overlay %s,%s'
) as $dn => $child) {
if (is_array($results[$dn]['description']))
$description = implode(' ',$results[$dn]['description']);
else
$description = $results[$dn]['description'];
$description = preg_replace('/"/','\'',$description);
printf('<tr class="list_item"><td class="heading" rowspan=2><acronym title="%s">%s</acronym></td></tr>',$description,$dn);
echo '<tr class="list_item"><td class="value">';
echo '<table class="result"><tr><td>';
echo '<table class="result_table" border=0>';
$attrs = array(
'monitorRuntimeConfig',
'supportedControl'
);
echo '<tr class="highlight">';
printf('<td>%s</td><td>%s</td>',_('Type'),'namingContext');
foreach ($attrs as $attr)
printf('<td>%s</td>',$attr);
echo '</tr>';
$counter = 0;
foreach ($results[$dn]['monitoredInfo'] as $index => $backend) {
printf('<tr class="%s">',$counter++%2==0?'even':'odd');
printf('<td>%s</td>',$backend);
$key = sprintf($child,$index,$dn);
echo '<td>';
if (isset($results[$key]['seeAlso'])) {
$seealso = is_array($results[$key]['seeAlso']) ? $results[$key]['seeAlso'] : array($results[$key]['seeAlso']);
foreach ($seealso as $db)
if (isset($results[$db]['namingContexts']))
printf('<acronym title="%s">%s</acronym><br/>',isset($results[$db]['labeledURI']) ? $results[$db]['labeledURI'] : _('Internal'),$results[$db]['namingContexts']);
else
printf('%s ',$results[$db]['monitoredInfo']);
} else {
echo '&nbsp;';
}
echo '</td>';
foreach ($attrs as $attr) {
echo '<td>';
if (isset($results[$key][$attr])) {
if (! is_array($results[$key][$attr]))
$sc = array($results[$key][$attr]);
else
$sc = $results[$key][$attr];
if (strcasecmp('supportedControl',$attr) == 0)
foreach ($sc as $control) {
$oidtotext = support_oid_to_text($control);
printf('<acronym title="%s">%s</acronym><br/>',
$control,$oidtotext['title']);
}
else
printf('%s ',implode('<br/>',$sc));
} else {
echo '&nbsp;';
}
echo '</td>';
}
echo '</tr>';
}
echo '</table></td></tr>';
echo '</table>';
echo '</td></tr>';
}
# cn=Connections,cn=Monitor
printf('<tr class="list_item"><td class="heading" rowspan=2><acronym title="%s">%s</acronym></td></tr>',$results['cn=Connections,cn=Monitor']['description'],_('LDAP Connections'));
printf('<tr class="list_item"><td class="value">');
echo '<table class="result"><tr><td>';
echo '<table class="result_table" border=0>';
printf('<tr class="highlight"><td>%s</td><td class="value">%s</td></tr>',
_('Total Connections'),$results['cn=Total,cn=Connections,cn=Monitor']['monitorCounter']);
printf('<tr class="highlight"><td>%s</td><td class="value">%s</td></tr>',
_('Current Connections'),$results['cn=Current,cn=Connections,cn=Monitor']['monitorCounter']);
# Look for some connections
foreach ($results as $key => $value) {
if (preg_match('/^cn=Connection.*,cn=Connections,cn=Monitor$/',$key)) {
echo '<tr class="highlight">';
printf('<td>%s</td>',$results[$key]['cn']);
echo '<td class="value">';
echo '<table class="result_table" border=0>';
$counter = 0;
foreach (array(
'monitorConnectionActivityTime',
'monitorConnectionAuthzDN',
'monitorConnectionGet',
'monitorConnectionListener',
'monitorConnectionLocalAddress',
'monitorConnectionMask',
'monitorConnectionNumber',
'monitorConnectionOpsCompleted',
'monitorConnectionOpsExecuting',
'monitorConnectionOpsPending',
'monitorConnectionOpsReceived',
'monitorConnectionPeerAddress',
'monitorConnectionPeerDomain',
'monitorConnectionProtocol',
'monitorConnectionRead',
'monitorConnectionStartTime',
'monitorConnectionWrite'
) as $metric) {
printf('<tr class="%s">',$counter++%2==0?'even':'odd');
printf('<td class="title">%s</td><td>%s</td>',
$metric,isset($results[$key][$metric]) ? $results[$key][$metric] : '&nbsp;');
echo '</tr>';
}
echo '</table>';
echo '</td>';
echo '</tr>';
}
}
echo '</table></td></tr>';
echo '</table>';
echo '</td></tr>';
foreach (array(
'cn=Listeners,cn=Monitor',
'cn=Log,cn=Monitor',
'cn=Operations,cn=Monitor',
'cn=SASL,cn=Monitor',
'cn=TLS,cn=Monitor',
'cn=Statistics,cn=Monitor',
'cn=Threads,cn=Monitor',
'cn=Time,cn=Monitor',
'cn=Waiters,cn=Monitor'
) as $dn ) {
if (is_array($results[$dn]['description']))
$description = implode(' ',$results[$dn]['description']);
else
$description = $results[$dn]['description'];
$description = preg_replace('/"/','\'',$description);
printf('<tr class="list_item"><td class="heading" rowspan=2><acronym title="%s">%s</acronym></td></tr>',$description,$dn);
echo '<tr class="list_item"><td class="value">';
echo '<table class="result"><tr><td>';
echo '<table class="result_table" border=0>';
if (isset($results[$dn]['monitorOpInitiated']))
printf('<tr class="highlight"><td>%s</td><td class="value">%s</td></tr>',
'monitorOpInitiated',$results[$dn]['monitorOpInitiated']);
if (isset($results[$dn]['monitorOpCompleted']))
printf('<tr class="highlight"><td>%s</td><td class="value">%s</td></tr>',
'monitorOpCompleted',$results[$dn]['monitorOpCompleted']);
if (isset($results[$dn]['monitoredInfo']))
printf('<tr class="highlight"><td>%s</td><td class="value">%s</td></tr>',
'monitoredInfo',$results[$dn]['monitoredInfo']);
# Look for some connecitons
foreach ($results as $key => $value) {
if (preg_match('/^.*,'.$dn.'$/',$key)) {
echo '<tr class="highlight">';
printf('<td>%s</td>',$results[$key]['cn']);
echo '<td class="value">';
echo '<table class="result_table" border=0>';
foreach (array(
'labeledURI',
'monitorConnectionLocalAddress',
'monitoredInfo',
'monitorCounter',
'monitorOpInitiated',
'monitorOpCompleted',
'monitorTimestamp'
) as $metric) {
if (isset($results[$key][$metric])) {
printf('<tr class="%s">',$counter++%2==0?'even':'odd');
printf('<td class="title">%s</td><td>%s</td>',
$metric,$results[$key][$metric]);
echo '</tr>';
}
}
echo '</table>';
echo '</td>';
echo '</tr>';
}
}
echo '</table></td></tr>';
echo '</table>';
echo '</td></tr>';
}
echo '</table>';
?>

View File

@ -1,30 +1,33 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/password_checker.php,v 1.10.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Check the password used by an entry.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
include HTDOCDIR.'header.php';
echo '<body>'; $www['page'] = new page();
$entry = array();
$entry['hash'] = get_request('hash','REQUEST'); $request = array();
$entry['password'] = get_request('check_password','REQUEST'); $request['componentid'] = get_request('componentid','REQUEST');
$entry['action'] = get_request('action','REQUEST'); $request['hash'] = get_request('hash','REQUEST');
$entry['componentid'] = get_request('componentid','REQUEST'); $request['password'] = get_request('check_password','REQUEST');
$request['action'] = get_request('action','REQUEST');
if (get_request('base64','REQUEST')) { if (get_request('base64','REQUEST')) {
$entry['hash'] = base64_decode($entry['hash']); $request['hash'] = base64_decode($request['hash']);
$entry['password'] = base64_decode($entry['password']); $request['password'] = base64_decode($request['password']);
} }
$entry['enc_type'] = get_enc_type($entry['hash']); $request['enc_type'] = get_enc_type($request['hash']);
echo '<div class="popup">';
printf('<h3 class="subtitle">%s</h3>',_('Password Checker Tool')); printf('<h3 class="subtitle">%s</h3>',_('Password Checker Tool'));
echo '<form action="password_checker.php" method="post">'; echo '<form action="password_checker.php" method="post">';
@ -35,13 +38,13 @@ echo '<table class="forminput" width=100% border=0>';
echo '<tr>'; echo '<tr>';
printf('<td class="heading">%s</td>',_('Compare')); printf('<td class="heading">%s</td>',_('Compare'));
printf('<td><input type="%s" name="hash" id="hash" value="%s" /></td>', printf('<td><input type="%s" name="hash" id="hash" value="%s" /></td>',
(obfuscate_password_display($entry['enc_type']) ? 'password' : 'text'),htmlspecialchars($entry['hash'])); (obfuscate_password_display($request['enc_type']) ? 'password' : 'text'),htmlspecialchars($request['hash']));
echo '</tr>'; echo '</tr>';
echo '<tr>'; echo '<tr>';
printf('<td class="heading">%s</td>',_('To')); printf('<td class="heading">%s</td>',_('To'));
printf('<td><input type="password" name="check_password" value="%s" /></td>', printf('<td><input type="password" name="check_password" value="%s" /></td>',
htmlspecialchars($entry['password'])); htmlspecialchars($request['password']));
echo '</tr>'; echo '</tr>';
echo '<tr>'; echo '<tr>';
@ -49,10 +52,10 @@ echo '<td>&nbsp;</td>';
echo '<td><input type="submit" value="Compare" />'; echo '<td><input type="submit" value="Compare" />';
if ($entry['action'] == 'compare') { if ($request['action'] == 'compare') {
echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>'; echo '&nbsp;&nbsp;&nbsp;&nbsp;<b>';
if (password_check($entry['hash'],$entry['password'])) if (password_check($request['hash'],$request['password']))
printf('<span class="good">%s</span>',_('Passwords match!')); printf('<span class="good">%s</span>',_('Passwords match!'));
else else
printf('<span class="bad">%s</span>',_('Passwords do not match!')); printf('<span class="bad">%s</span>',_('Passwords do not match!'));
@ -64,14 +67,22 @@ echo '</td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo '</form>'; echo '</form>';
echo '</div>';
echo '</body>';
if ($entry['componentid']) { # Pull our password from the form that opened this window.
echo '<script language="javascript">'; if ($request['componentid']) {
printf('var c = window.opener.document.getElementById(\'%s\');',$entry['componentid']); echo '<script type="text/javascript">';
printf('var h = document.getElementById(\'%s\');', 'hash'); printf('var c = window.opener.document.getElementById(\'%s\');',$request['componentid']);
printf('var h = document.getElementById(\'%s\');','hash');
echo 'if (c && h) { h.value = c.value; }'; echo 'if (c && h) { h.value = c.value; }';
echo '</script>'; echo '</script>';
} }
# Capture the output and put into the body of the page.
$www['body'] = new block();
$www['body']->SetBody(ob_get_contents());
$www['page']->block_add('body',$www['body']);
ob_end_clean();
# Render the popup.
$www['page']->display(array('CONTROL'=>false,'FOOT'=>false,'HEAD'=>false,'TREE'=>false));
?> ?>

View File

@ -1,26 +1,26 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/purge_cache.php,v 1.9.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Purge our session cache details
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('purge')) $purge_session_keys = array('app_initialized','backtrace','cache',APPCONFIG);
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('purge')),'error','index.php');
$purge_session_keys = array('cache');
$size = 0; $size = 0;
foreach ($purge_session_keys as $key) { foreach ($purge_session_keys as $key)
if (isset($_SESSION[$key])) { if (isset($_SESSION[$key])) {
$size += strlen(serialize($_SESSION[$key])); $size += strlen(serialize($_SESSION[$key]));
unset($_SESSION[$key]); unset($_SESSION[$key]);
} }
}
if (! $size) if (! $size)
$body = _('No cache to purge.'); $body = _('No cache to purge.');
@ -31,5 +31,5 @@ system_message(array(
'title'=>_('Purge cache'), 'title'=>_('Purge cache'),
'body'=>$body, 'body'=>$body,
'type'=>'info'), 'type'=>'info'),
'index.php'); get_request('meth','REQUEST') == 'ajax' ? null : 'index.php');
?> ?>

21
htdocs/query_engine.php Normal file
View File

@ -0,0 +1,21 @@
<?php
// $Header$
/**
* Query render engine.
*
* @package phpLDAPadmin
* @subpackage Page
* @author The phpLDAPadmin development team
*/
/**
*/
require './common.php';
require LIBDIR.'query_functions.php';
$request = array();
$request['page'] = new QueryRender($app['server']->getIndex(),get_request('query','REQUEST',false,null));
$request['page']->accept();
?>

View File

@ -1,90 +1,80 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rdelete.php,v 1.28.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Recursively deletes the specified DN and all of its children * Recursively deletes the specified DN and all of its children
* *
* Variables that come in as POST vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete','simple_delete')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_delete','simple_delete'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete entry')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('delete entry')),'error','index.php');
$entry = array(); $request = array();
$entry['dn'] = get_request('dn'); $request['dn'] = get_request('dn','REQUEST',true);
if (! $entry['dn'])
error(_('You must specify a DN'),'error','index.php');
if (! $ldapserver->dnExists($entry['dn'])) if (! $app['server']->dnExists($request['dn']))
error(sprintf('%s (%s)',_('No such entry.'),htmlspecialchars($entry['dn'])),'error','index.php'); error(sprintf('%s (%s)',_('No such entry.'),$request['dn']),'error','index.php');
printf('<h3 class="title">'._('Deleting %s').'</h3>',htmlspecialchars(get_rdn($entry['dn']))); printf('<h3 class="title">%s %s</h3>',_('Deleting'),get_rdn($request['dn']));
printf('<h3 class="subtitle">%s</h3>',_('Recursive delete progress')); printf('<h3 class="subtitle">%s</h3>',_('Recursive delete progress'));
echo '<br /><br />';
echo '<small>';
# Prevent script from bailing early on a long delete # Prevent script from bailing early on a long delete
@set_time_limit(0); @set_time_limit(0);
$result = pla_rdelete($ldapserver,$entry['dn']); echo '<br /><br />';
echo '<small>';
$result = pla_rdelete($app['server'],$request['dn']);
echo '</small><br />'; echo '</small><br />';
if ($result) { if ($result) {
printf(_('Entry %s and sub-tree deleted successfully.'),'<b>'.htmlspecialchars($entry['dn']).'</b>'); printf(_('Entry %s and sub-tree deleted successfully.'),'<b>'.$request['dn'].'</b>');
} else { } else {
system_message(array( system_message(array(
'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($entry['dn'])), 'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($request['dn'])),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()), 'body'=>ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null)),
'type'=>'error')); 'type'=>'error'));
} }
function pla_rdelete($ldapserver,$dn) { function pla_rdelete($server,$dn) {
# we delete all children, not only the visible children in the tree # We delete all children, not only the visible children in the tree
$children = $ldapserver->getContainerContents($dn); $children = $server->getContainerContents($dn,null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
if (! is_array($children) || count($children) == 0) { if (! is_array($children) || count($children) == 0) {
printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),htmlspecialchars($dn)); printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),$dn);
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn))) if ($server->delete($dn)) {
if ($ldapserver->delete($dn)) {
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
printf(' <span style="color:green">%s</span></span><br />',_('Success')); printf(' <span style="color:green">%s</span></span><br />',_('Success'));
return true; return true;
} else { } else {
system_message(array( system_message(array(
'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($entry['dn'])), 'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($request['dn'])),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()), 'body'=>ldap_error_msg($server->getErrorMessage(null),$server->getErrorNum(null)),
'type'=>'error')); 'type'=>'error'));
} }
} else { } else {
foreach ($children as $child_dn) foreach ($children as $child_dn)
pla_rdelete($ldapserver,$child_dn); pla_rdelete($server,$child_dn);
printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),htmlspecialchars($dn)); printf('<span style="white-space: nowrap;">%s %s...',_('Deleting'),$dn);
if (run_hook('pre_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn))) if ($server->delete($dn)) {
if ($ldapserver->delete($dn)) {
run_hook('post_entry_delete',array('server_id'=>$ldapserver->server_id,'dn'=>$dn));
printf(' <span style="color:green">%s</span></span><br />',_('Success')); printf(' <span style="color:green">%s</span></span><br />',_('Success'));
return true; return true;
} else { } else {
system_message(array( system_message(array(
'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($entry['dn'])), 'title'=>_('Could not delete the entry.').sprintf(' (%s)',pretty_print_dn($request['dn'])),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()), 'body'=>ldap_error_msg($server->getErrorMessage(null),$server->getErrorNum(null)),
'type'=>'error')); 'type'=>'error'));
} }
} }

View File

@ -1,23 +1,48 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/refresh.php,v 1.18.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* This script alters the session variable 'tree', by re-querying * This script deletes the session variable 'tree', which will result in re-querying
* the LDAP server to grab the contents of every expanded container. * the LDAP server to grab the contents of all LDAP entries starting from the base.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
* @todo: Change this to just refresh all the open entries.
*/ */
require './common.php'; require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('server_refresh')) if (get_request('purge','REQUEST')) {
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('refresh server')),'error','index.php'); $tree = get_cached_item($app['server']->getIndex(),'tree');
del_cached_item($app['server']->getIndex(),'tree');
unset($_SESSION['cache'][$ldapserver->server_id]['tree']); if ($tree)
$openDNs = $tree->listOpenItems();
else
$openDNs = array();
$tree = Tree::getInstance($app['server']->getIndex());
foreach ($openDNs as $value) {
$entry = $tree->getEntry($value);
if (! $entry) {
$tree->addEntry($value);
$entry = $tree->getEntry($value);
}
$tree->readChildren($value);
$entry->open();
}
set_cached_item($app['server']->getIndex(),'tree','null',$tree);
}
if (get_request('meth','REQUEST') == 'ajax')
header(sprintf('Location: cmd.php?cmd=draw_tree_node&noheader=%s&server_id=%s&meth=ajax&frame=TREE',get_request('noheader','REQUEST',false,0),$app['server']->getIndex()));
else
header(sprintf('Location: cmd.php?server_id=%s',$app['server']->getIndex()));
header(sprintf('Location: cmd.php?server_id=%s',$ldapserver->server_id));
die(); die();
?> ?>

View File

@ -1,76 +1,69 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename.php,v 1.33.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Renames a DN to a different name. * Renames a DN to a different name.
* *
* Variables that come in via common.php
* - server_id
* Variables that come in as POST vars:
* - dn (rawurlencoded)
* - new_rdn
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
$request['dnSRC'] = get_request('dn','REQUEST');
$request['rdnDST'] = get_request('new_rdn','REQUEST');
$request['container'] = $app['server']->getContainer($request['dnSRC']);
# Error checking
if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_rename')) if (! $_SESSION[APPCONFIG]->isCommandAvailable('entry_rename'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('rename entry')),'error','index.php'); error(sprintf('%s: %s',_('This operation is not permitted by the configuration'),_('rename entry')),'error','index.php');
if (! $app['server']->isBranchRenameEnabled()) {
# We search all children, not only the visible children in the tree
$children = $app['server']->getContainerContents($request['dnSRC'],null,0,'(objectClass=*)',LDAP_DEREF_NEVER);
$dn = get_request('dn');
if (! $ldapserver->isBranchRenameEnabled()) {
# we search all children, not only the visible children in the tree
$children = $ldapserver->getContainerContents($dn);
if (count($children) > 0) if (count($children) > 0)
error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'),'error','index.php'); error(_('You cannot rename an entry which has children entries (eg, the rename operation is not allowed on non-leaf entries)'),'error','index.php');
} }
$new_rdn = get_request('new_rdn'); $request['dnDST'] = sprintf('%s,%s',$request['rdnDST'],$request['container']);
$container = get_container($dn);
$new_dn = sprintf('%s,%s',$new_rdn,$container);
if ($new_dn == $dn) if ($request['dnDST'] == $request['dnSRC'])
error(_('You did not change the RDN'),'error','index.php'); error(_('You did not change the RDN'),'error','index.php');
$old_dn_attr = explode('=',$dn); $rdnattr = array();
$old_dn_attr = $old_dn_attr[0]; $rdnattr['SRC'] = explode('=',$request['dnSRC']);
$rdnattr['SRC'] = $rdnattr['SRC'][0];
$new_dn_value = explode('=',$new_rdn,2); $new_dn_value = explode('=',$request['rdnDST'],2);
$rdnattr['DST'] = $new_dn_value[0];
if (count($new_dn_value) != 2 || ! isset($new_dn_value[1])) if (count($new_dn_value) != 2 || ! isset($new_dn_value[1]))
error(_('Invalid RDN value'),'error','index.php'); error(_('Invalid RDN value'),'error','index.php');
$new_dn_attr = $new_dn_value[0]; $deleteoldrdn = $rdnattr['SRC'] == $rdnattr['DST'];
$new_dn_value = $new_dn_value[1]; $success = $app['server']->rename($request['dnSRC'],$request['rdnDST'],$request['container'],$deleteoldrdn);
$success = run_hook('pre_rename_entry',array('server_id'=>$ldapserver->server_id,'old_dn'=>$dn,'new_dn'=>$new_dn_value));
if ($success) { if ($success) {
$success = false;
$deleteoldrdn = $old_dn_attr == $new_dn_attr;
$success = $ldapserver->rename($dn,$new_rdn,$container,$deleteoldrdn);
} else {
error(_('Could not rename the entry'),'error','index.php');
}
if ($success) {
run_hook('post_rename_entry',array('server_id'=>$ldapserver->server_id,'old_dn'=>$dn,'new_dn'=>$new_dn_value));
$rename_message = sprintf('%s',_('Rename successful!')); $rename_message = sprintf('%s',_('Rename successful!'));
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$ldapserver->server_id,rawurlencode($new_dn)); $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s&template=%s',
$app['server']->getIndex(),rawurlencode($request['dnDST']),get_request('template','REQUEST'));
system_message(array( system_message(array(
'title'=>_('Rename Entry'), 'title'=>_('Rename Entry'),
'body'=>$rename_message, 'body'=>$rename_message,
'type'=>'info'), 'type'=>'info'),
$redirect_url); $redirect_url);
} else {
system_message(array(
'title'=>_('Could not rename the entry.'),
'body'=>ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null)),
'type'=>'error'));
} }
?> ?>

View File

@ -1,37 +1,42 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/rename_form.php,v 1.11.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays a form for renaming an LDAP entry. * Displays a form for renaming an LDAP entry.
* *
* Variables that come in via common.php
* - server_id
* Variables that come in as GET vars:
* - dn (rawurlencoded)
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) # The DN we are working with
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request = array();
if (! $ldapserver->haveAuthInfo()) $request['dn'] = get_request('dn','GET');
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php'); $request['template'] = get_request('template','GET');
$dn = $_GET['dn']; $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$rdn = get_rdn($dn); $request['page']->setDN($request['dn']);
$request['page']->accept();
printf('<h3 class="title">%s <b>%s</b></h3>',_('Rename Entry'),htmlspecialchars($rdn)); # Render the form
printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>', $request['page']->drawTitle(sprintf('%s <b>%s</b>',_('Rename'),get_rdn($request['dn'])));
_('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn)); $request['page']->drawSubTitle();
echo '<br /><center><form action="cmd.php?cmd=rename" method="post" />'; echo '<center>';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('%s <b>%s</b> %s:<br /><br />',_('Rename'),get_rdn($request['dn']),_('to a new object'));
printf('<input type="hidden" name="dn" value="%s" />',htmlspecialchars($dn));
printf('<input type="text" name="new_rdn" size="30" value="%s" />',htmlspecialchars($rdn)); echo '<form action="cmd.php?cmd=rename" method="post" />';
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
printf('<input type="hidden" name="dn" value="%s" />',rawurlencode($request['dn']));
printf('<input type="hidden" name="template" value="%s" />',$request['template']);
printf('<input type="text" name="new_rdn" size="30" value="%s" />',get_rdn($request['dn']));
printf('<input type="submit" value="%s" />',_('Rename')); printf('<input type="submit" value="%s" />',_('Rename'));
echo '</form></center>'; echo '</form>';
echo '</center>';
echo "\n";
?> ?>

View File

@ -1,26 +1,28 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/schema.php,v 1.67.2.7 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Displays the schema for the specified server_id * Displays the schema for the specified server
* *
* Variables that come in as GET vars: * Variables that come in as GET vars:
* - view (optional: can be 'attr' or empty. If 'attr', show that attribute) * - view (optional)
* - attr (optional) * Shows attribute, objectclass or matching rule
* - viewvalue (optional)
* Shows the attribute, objectclass or matching rule
* - highlight_oid (optional) * - highlight_oid (optional)
* Use to higlight the oid in the syntaxes view.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if (! $_SESSION[APPCONFIG]->isCommandAvailable('schema'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('view schema')),'error','index.php');
$entry = array(); $entry = array();
$entry['view'] = get_request('view','GET','false','objectClasses'); $entry['view'] = get_request('view','GET','false','objectclasses');
$entry['value'] = get_request('viewvalue','GET'); $entry['value'] = get_request('viewvalue','GET');
if (! is_null($entry['value'])) { if (! is_null($entry['value'])) {
@ -29,17 +31,15 @@ if (! is_null($entry['value'])) {
} }
$schema_error_str = sprintf('%s <b>%s</b>.<br /><br /></center>%s<ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>', $schema_error_str = sprintf('%s <b>%s</b>.<br /><br /></center>%s<ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>',
_('Could not retrieve schema from'),htmlspecialchars($ldapserver->name), _('Could not retrieve schema from'),$app['server']->getName(),
_('This could happen for several reasons, the most probable of which are:'),_('The server does not fully support the LDAP protocol.'), _('This could happen for several reasons, the most probable of which are:'),_('The server does not fully support the LDAP protocol.'),
_('Your version of PHP does not correctly perform the query.'),_('phpLDAPadmin doesn\'t know how to fetch the schema for your server.'), _('Your version of PHP does not correctly perform the query.'),_('phpLDAPadmin doesn\'t know how to fetch the schema for your server.'),
_('Or lastly, your LDAP server doesnt provide this information.')); _('Or lastly, your LDAP server doesnt provide this information.'));
printf('<h3 class="title">%s <b>%s</b></h3>', printf('<h3 class="title">%s <b>%s</b></h3>',_('Schema for server'),$app['server']->getName());
_('Schema for server'),
htmlspecialchars($ldapserver->name));
$entry['schema_types'] = array( $entry['schema_types'] = array(
'objectClasses'=>_('ObjectClasses'), 'objectclasses'=>_('ObjectClasses'),
'attributes'=>_('Attribute Types'), 'attributes'=>_('Attribute Types'),
'syntaxes'=>_('Syntaxes'), 'syntaxes'=>_('Syntaxes'),
'matching_rules'=>_('Matching Rules')); 'matching_rules'=>_('Matching Rules'));
@ -52,34 +52,99 @@ foreach ($entry['schema_types'] as $item => $value) {
if ($counter++) if ($counter++)
echo ' | '; echo ' | ';
$entry['href'][$item] = sprintf('?cmd=schema&server_id=%s&view=%s&viewvalue=%%s',$ldapserver->server_id,$item); $entry['href'][$item] = sprintf('cmd=schema&server_id=%s&view=%s',$app['server']->getIndex(),$item);
$href = htmlspecialchars(sprintf($entry['href'][$item],'')); if ($entry['view'] == $item) {
echo ($entry['view'] == $item ? _($value) : sprintf('<a href="%s">%s</a>',$href,_($value))); echo _($value);
} else {
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return displayAJ(\'BODY\',\'%s\',\'Loading %s\');" title="Loading %s">%s</a>',
htmlspecialchars($entry['href'][$item]),htmlspecialchars($entry['href'][$item]),$value,$value,$value);
else
printf('<a href="cmd.php?%s">%s</a>',htmlspecialchars($entry['href'][$item]),_($value));
}
} }
echo '</center>'; echo '</center>';
echo '<br />'; echo '<br />';
switch($entry['view']) { if (isAjaxEnabled()) {
echo '<script type="text/javascript" language="javascript">'."\n";
echo "function showthis(type,key,value) {
select = document.getElementById(type);
if (value != null) {
attr = value;
select.value = value;
} else {
attr = select.value;
}
if (! attr) {
showall(key);
} else {
objectclass = document.getElementById(key+attr);
objectclass.style.display = '';
hideall(key,attr);
};
return false;
};
function showall(key) {
items = items();
for (x in items) {
if (! isNaN(x)) {
item = document.getElementById(key+items[x]);
item.style.display = '';
}
}
}
function hideall(key,except) {
items = items();
for (x in items) {
if (! isNaN(x) && except != items[x]) {
item = document.getElementById(key+items[x]);
item.style.display = 'none';
} else if (! isNaN(x) && except == items[x]) {
item = document.getElementById(key+items[x]);
item.style.display = '';
}
}
}
function ajJump(html,title,index,prefix) {
if (prefix)
attr = document.getElementById('vv'+index).value;
else
attr = index;
if (attr)
html = html+'&viewvalue='+attr;
return displayAJ('BODY',html,'Loading '+title);
}";
echo '</script>';
}
switch($entry['view']) {
case 'syntaxes': case 'syntaxes':
$highlight_oid = get_request('highlight_oid','GET',false,false); $highlight_oid = get_request('highlight_oid','GET',false,false);
echo '<center>'; echo '<center>';
print '<table class="result_table" border=0>'; echo '<table class="result_table" border=0>';
printf('<tr class="heading"><td>%s</td><td>%s</td></tr>',_('Syntax OID'),_('Description')); printf('<tr class="heading"><td>%s</td><td>%s</td></tr>',_('Syntax OID'),_('Description'));
$counter = 1; $counter = 1;
$schema_syntaxes = $ldapserver->SchemaSyntaxes(null,true); $schema_syntaxes = $app['server']->SchemaSyntaxes();
if (! $schema_syntaxes) if (! $schema_syntaxes)
error($schema_error_str,'error','index.php'); error($schema_error_str,'error','index.php');
foreach ($schema_syntaxes as $syntax) { foreach ($schema_syntaxes as $syntax) {
$counter++; $counter++;
$oid = htmlspecialchars($syntax->getOID()); $oid = $syntax->getOID();
$desc = htmlspecialchars($syntax->getDescription()); $desc = $syntax->getDescription();
if ($highlight_oid && $highlight_oid == $oid) if ($highlight_oid && $highlight_oid == $oid)
echo '<tr class="highlight">'; echo '<tr class="highlight">';
@ -90,7 +155,7 @@ switch($entry['view']) {
printf('<td>%s</td><td>%s</td></tr>',$oid,$desc); printf('<td>%s</td><td>%s</td></tr>',$oid,$desc);
} }
print '</table>'; echo '</table>';
echo '</center>'; echo '</center>';
break; break;
@ -113,44 +178,67 @@ switch($entry['view']) {
'force_as_may' => _('Force as MAY by config') 'force_as_may' => _('Force as MAY by config')
); );
$schema_attrs = $ldapserver->SchemaAttributes(); $sattrs = $app['server']->SchemaAttributes();
$schema_object_classes = $ldapserver->SchemaObjectClasses();
if (! $schema_attrs || ! $schema_object_classes) if (! $sattrs || ! $app['server']->SchemaObjectClasses())
error($schema_error_str,'error','index.php'); error($schema_error_str,'error','index.php');
printf('<small>%s:</small>',_('Jump to an attribute type')); printf('<small>%s:</small>',_('Jump to an attribute type'));
echo '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
echo '<input type="hidden" name="cmd" value="schema" />'; echo '<input type="hidden" name="cmd" value="schema" />';
printf('<input type="hidden" name="view" value="%s" />',$entry['view']); printf('<input type="hidden" name="view" value="%s" />',$entry['view']);
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
if (isAjaxEnabled()) {
echo '<script type="text/javascript" language="javascript">'."\n";
echo "function items() {
var \$items = new Array();";
$counter = 0;
foreach ($sattrs as $attr) {
printf(' items[%s] = "%s";',$counter++,$attr->getName());
echo "\n";
}
echo '
return items;
}';
echo '</script>';
echo '<select name="viewvalue" onChange="showthis(\'attributes\',\'at\')" id="attributes">';
} else
echo '<select name="viewvalue" onChange="submit()">'; echo '<select name="viewvalue" onChange="submit()">';
echo '<option value=""> - all -</option>'; echo '<option value=""> - all -</option>';
foreach ($schema_attrs as $name => $attr) foreach ($sattrs as $name => $attr)
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$name,$name == $entry['value'] ? 'selected ': '',$attr->getName()); $name,$name == $entry['value'] ? 'selected ': '',$attr->getName(false));
echo '</select>'; echo '</select>';
printf('<input type="submit" value="%s" /></form>',_('Go')); if (isAjaxEnabled())
printf('<input type="button" value="%s" onClick="showthis(\'attributes\',\'at\')"/>',_('Go'));
else
printf('<input type="submit" value="%s" />',_('Go'));
echo '</form>';
echo '<br />'; echo '<br />';
foreach ($schema_attrs as $attr) { foreach ($sattrs as $attr) {
if (is_null($entry['value']) || ! strcasecmp($entry['value'],$attr->getName())) { if (isAjaxEnabled() || (is_null($entry['value']) || ! strcasecmp($entry['value'],$attr->getName()))) {
if (! is_null($entry['value'])) if (! is_null($entry['value']) && strcasecmp($entry['value'],$attr->getName()))
$entry['viewed'] = true; $entry['viewed'] = true;
if (isAjaxEnabled() && $entry['value'])
printf('<div id="at%s" style="display: %s">',$attr->getName(),strcasecmp($entry['value'],$attr->getName()) ? 'none' : '');
else
printf('<div id="at%s">',$attr->getName());
echo '<table class="result_table" width=100% border=0>'; echo '<table class="result_table" width=100% border=0>';
printf('<tr class="heading"><td colspan=2><a name="%s">%s</a></td></tr>', printf('<tr class="heading"><td colspan=2><a name="%s">%s</a></td></tr>',
strtolower($attr->getName()),$attr->getName()); $attr->getName(),$attr->getName(false));
$counter = 0; $counter = 0;
foreach ($entry['attr_types'] as $item => $value) { foreach ($entry['attr_types'] as $item => $value) {
printf('<tr class="%s">',++$counter%2 ? 'odd' : 'even'); printf('<tr class="%s">',++$counter%2 ? 'odd' : 'even');
printf('<td class="title">%s</td>',$value); printf('<td class="title" width=30%%>%s</td>',$value);
switch ($item) { switch ($item) {
case 'desc': case 'desc':
@ -158,7 +246,7 @@ switch($entry['view']) {
is_null($attr->getDescription()) ? is_null($attr->getDescription()) ?
'('._('no description').')' : $attr->getDescription()); '('._('no description').')' : $attr->getDescription());
print '</tr>'; echo '</tr>';
printf('<tr class="%s">',++$counter%2 ? 'odd' : 'even'); printf('<tr class="%s">',++$counter%2 ? 'odd' : 'even');
echo '<td class="title"><acronym title="Object Identier">OID</acronym></td>'; echo '<td class="title"><acronym title="Object Identier">OID</acronym></td>';
printf('<td>%s</td>',$attr->getOID()); printf('<td>%s</td>',$attr->getOID());
@ -170,31 +258,39 @@ switch($entry['view']) {
break; break;
case 'inherits': case 'inherits':
print '<td>'; echo '<td>';
if (is_null($attr->getSupAttribute())) if (is_null($attr->getSupAttribute()))
printf('(%s)',_('none')); printf('(%s)',_('none'));
else { else {
$href = htmlspecialchars(sprintf($entry['href']['attributes'],strtolower($attr->getSupAttribute()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($attr->getSupAttribute())));
printf('<a href="%s">%s</a>',$href,$attr->getSupAttribute()); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return showthis(\'attributes\',\'at\',\'%s\');">%s</a>',
$href,strtolower($attr->getSupAttribute()),$attr->getSupAttribute());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSupAttribute());
} }
print '</td>'; echo '</td>';
break; break;
case 'equality': case 'equality':
print '<td>'; echo '<td>';
if (is_null($attr->getEquality())) if (is_null($attr->getEquality()))
printf('(%s)',_('not specified')); printf('(%s)',_('not specified'));
else { else {
$href = htmlspecialchars(sprintf($entry['href']['matching_rules'],$attr->getEquality())); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['matching_rules'],$attr->getEquality()));
printf('<a href="%s">%s</a>',$href,$attr->getEquality()); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return ajJump(\'%s\',\'%s\',\'%s\');">%s</a>',
$href,$href,_('Matching Rules'),$attr->getEquality(),$attr->getEquality());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getEquality());
} }
print '</td>'; echo '</td>';
break; break;
case 'ordering': case 'ordering':
@ -208,18 +304,21 @@ switch($entry['view']) {
break; break;
case 'syntax': case 'syntax':
print '<td>'; echo '<td>';
if (is_null($attr->getType())) { if (is_null($attr->getType())) {
echo $attr->getSyntaxOID(); echo $attr->getSyntaxOID();
} else { } else {
$href = htmlspecialchars(sprintf($entry['href']['syntaxes'].'&highlight_oid=%s#%s','', $href = htmlspecialchars(sprintf('%s&highlight_oid=%s',$entry['href']['syntaxes'],$attr->getSyntaxOID()));
$attr->getSyntaxOID(),$attr->getSyntaxOID())); if (isAjaxEnabled())
printf('<a href="%s">%s (%s)</a>',$href,$attr->getType(),$attr->getSyntaxOID()); printf('<a href="cmd.php?%s" onClick="return ajJump(\'%s\',\'%s\',\'%s\');">%s (%s)</a>',
$href,$href,_('Syntaxes'),'',$attr->getType(),$attr->getSyntaxOID());
else
printf('<a href="cmd.php?%s">%s (%s)</a>',$href,$attr->getType(),$attr->getSyntaxOID());
} }
print '</td>'; echo '</td>';
break; break;
case 'single_valued': case 'single_valued':
@ -239,7 +338,7 @@ switch($entry['view']) {
break; break;
case 'maximum_length': case 'maximum_length':
print '<td>'; echo '<td>';
if ( is_null($attr->getMaxLength())) if ( is_null($attr->getMaxLength()))
echo '('._('not applicable').')'; echo '('._('not applicable').')';
@ -248,78 +347,109 @@ switch($entry['view']) {
printf('%s %s',number_format($attr->getMaxLength()), printf('%s %s',number_format($attr->getMaxLength()),
$attr->getMaxLength()>1 ? _('characters') : _('character')); $attr->getMaxLength()>1 ? _('characters') : _('character'));
print '</td>'; echo '</td>';
break; break;
case 'aliases': case 'aliases':
print '<td>'; echo '<td>';
if (count($attr->getAliases()) == 0) if (count($attr->getAliases()) == 0)
printf('(%s)',_('none')); printf('(%s)',_('none'));
else else
foreach ($attr->getAliases() as $alias_attr_name) { foreach ($attr->getAliases() as $alias) {
$href = htmlspecialchars(sprintf($entry['href']['attributes'],strtolower($alias_attr_name))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($alias)));
printf('<a href="%s">%s</a>',$href,$alias_attr_name); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return showthis(\'attributes\',\'at\',\'%s\');">%s</a>',
$href,strtolower($alias),$alias);
else
printf('<a href="cmd.php?%s">%s</a>',$href,$alias);
} }
print '</td>'; echo '</td>';
break; break;
case 'used_by_objectclasses': case 'used_by_objectclasses':
print '<td>'; echo '<td>';
if (count($attr->getUsedInObjectClasses()) == 0) if (count($attr->getUsedInObjectClasses()) == 0)
printf('(%s)',_('none')); printf('(%s)',_('none'));
else else
foreach ($attr->getUsedInObjectClasses() as $used_in_oclass) { foreach ($attr->getUsedInObjectClasses() as $objectclass) {
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],strtolower($used_in_oclass))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($objectclass)));
printf('<a href="%s">%s</a> ',$href,$used_in_oclass); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return ajJump(\'%s\',\'%s\',\'%s\');">%s</a> ',
$href,$href,_('ObjectClasses'),strtolower($objectclass),$objectclass);
else
printf('<a href="cmd.php?%s">%s</a> ',$href,$objectclass);
} }
print '</td>'; echo '</td>';
break; break;
case 'force_as_may': case 'force_as_may':
printf('<td>%s</td>',$attr->forced_as_may ? _('Yes') : _('No')); printf('<td>%s</td>',$attr->isForceMay() ? _('Yes') : _('No'));
break; break;
} }
print '</tr>'; echo '</tr>';
} }
print '</table>'; echo '</table>';
echo '<br />'; echo '<br />';
echo '</div>';
} }
} }
break; break;
case 'matching_rules': case 'matching_rules':
$schema_matching_rules = $ldapserver->MatchingRules(null,true); $schema_matching_rules = $app['server']->MatchingRules();
if (! $schema_matching_rules) if (! $schema_matching_rules)
error($schema_error_str,'error','index.php'); error($schema_error_str,'error','index.php');
printf('<small>%s</small><br />',_('Jump to a matching rule')); printf('<small>%s</small><br />',_('Jump to a matching rule'));
print '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
print '<input type="hidden" name="cmd" value="schema" />'; echo '<input type="hidden" name="cmd" value="schema" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
print '<input type="hidden" name="view" value="matching_rules" />'; echo '<input type="hidden" name="view" value="matching_rules" />';
print '<select name="viewvalue" onChange="submit()">'; if (isAjaxEnabled()) {
print '<option value=""> - all -</option>'; echo '<script type="text/javascript" language="javascript">'."\n";
echo "function items() {
var \$items = new Array();";
$counter = 0;
foreach ($schema_matching_rules as $rule) {
printf(' items[%s] = "%s";',$counter++,$rule->getName());
echo "\n";
}
echo '
return items;
}
';
echo '</script>';
echo '<select name="viewvalue" onChange="showthis(\'matchingrules\',\'mr\')" id="matchingrules">';
} else
echo '<select name="viewvalue" onChange="submit()">';
echo '<option value=""> - all -</option>';
foreach ($schema_matching_rules as $rule) foreach ($schema_matching_rules as $rule)
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$rule->getName(), $rule->getName(),
($rule->getName() == $entry['value'] ? 'selected': ''), ($rule->getName() == $entry['value'] ? 'selected': ''),
$rule->getName()); $rule->getName(false));
print '</select>';
echo '</select>';
if (isAjaxEnabled())
printf('<input type="button" value="%s" onClick="showthis(\'matchingrules\',\'mr\')"/>',_('Go'));
else
printf('<input type="submit" value="%s" />',_('Go')); printf('<input type="submit" value="%s" />',_('Go'));
print '</form>'; echo '</form>';
echo '<br />';
print '<table class="result_table" width=100% border=0>'; echo '<table class="result_table" width=100% border=0>';
printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td></tr>', printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td></tr>',
_('Matching Rule OID'),_('Name'),_('Used by Attributes')); _('Matching Rule OID'),_('Name'),_('Used by Attributes'));
@ -327,12 +457,11 @@ switch($entry['view']) {
foreach ($schema_matching_rules as $rule) { foreach ($schema_matching_rules as $rule) {
$counter++; $counter++;
$oid = htmlspecialchars($rule->getOID()); $oid = $rule->getOID();
$desc = htmlspecialchars($rule->getName()); $desc = $rule->getName(false);
if ( is_null($entry['value']) || $entry['value'] == strtolower($rule->getName())) { if (isAjaxEnabled() || (is_null($entry['value']) || ! strcasecmp($entry['value'],$rule->getName()))) {
if (! is_null($entry['value']) && strcasecmp($entry['value'],$rule->getName()))
if (! is_null($entry['value']))
$entry['viewed'] = true; $entry['viewed'] = true;
if (null != $rule->getDescription()) if (null != $rule->getDescription())
@ -341,42 +470,50 @@ switch($entry['view']) {
if ( $rule->getIsObsolete()) if ( $rule->getIsObsolete())
$desc .= sprintf(' <span style="color:red">%s</span>',_('Obsolete')); $desc .= sprintf(' <span style="color:red">%s</span>',_('Obsolete'));
printf('<tr class="%s">',$counter%2 ? 'odd' : 'even'); if (isAjaxEnabled() && $entry['value'])
printf('<tr class="%s" id="mr%s" style="display: %s">',$counter%2 ? 'odd' : 'even',$rule->getName(),
strcasecmp($entry['value'],$rule->getName()) ? 'none' : '');
else
printf('<tr class="%s" id="mr%s">',$counter%2 ? 'odd' : 'even',$rule->getName());
printf('<td>%s</td>',$oid); printf('<td>%s</td>',$oid);
printf('<td>%s</td>',$desc); printf('<td>%s</td>',$desc);
print '<td>'; echo '<td>';
if (count($rule->getUsedByAttrs()) == 0) { if (count($rule->getUsedByAttrs()) == 0) {
printf('<center>(%s)</center><br /><br />',_('none')); printf('<center>(%s)</center><br /><br />',_('none'));
} else { } else {
print '<table width=100% border=0><tr><td>'; echo '<table width=100% border=0><tr><td>';
print '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
print '<input type="hidden" name="cmd" value="schema" />'; echo '<input type="hidden" name="cmd" value="schema" />';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
print '<input type="hidden" name="view" value="attributes" />'; echo '<input type="hidden" name="view" value="attributes" />';
print '<select size="4" name="viewvalue">'; printf('<select size="4" name="viewvalue" id="vv%s">',$rule->getName());
foreach ($rule->getUsedByAttrs() as $attr) foreach ($rule->getUsedByAttrs() as $attr)
printf('<option>%s</option>',$attr); printf('<option>%s</option>',$attr);
print '</select><br />'; echo '</select><br />';
if (isAjaxEnabled())
printf('<input type="button" value="%s" onClick="return ajJump(\'cmd=schema&amp;view=attributes&amp;server_id=%s\',\'%s\',\'%s\',\'vv\');"/>',
_('Go'),$app['server']->getIndex(),_('Attributes'),$rule->getName());
else
printf('<input type="submit" value="%s" />',_('Go')); printf('<input type="submit" value="%s" />',_('Go'));
print '</form>'; echo '</form>';
print '</td></tr></table>'; echo '</td></tr></table>';
} }
print '</td>'; echo '</td>';
print '</tr>'; echo '</tr>';
} }
} }
print '</table>'; echo '</table>';
break; break;
case 'objectClasses': case 'objectclasses':
$schema_oclasses = $ldapserver->SchemaObjectClasses(); $socs = $app['server']->SchemaObjectClasses();
if (! $schema_oclasses) if (! $socs)
error($schema_error_str,'error','index.php'); error($schema_error_str,'error','index.php');
printf('<small>%s:</small>',_('Jump to an objectClass')); printf('<small>%s:</small>',_('Jump to an objectClass'));
@ -384,27 +521,51 @@ switch($entry['view']) {
echo '<form action="cmd.php" method="get">'; echo '<form action="cmd.php" method="get">';
echo '<input type="hidden" name="cmd" value="schema" />'; echo '<input type="hidden" name="cmd" value="schema" />';
printf('<input type="hidden" name="view" value="%s" />',$entry['view']); printf('<input type="hidden" name="view" value="%s" />',$entry['view']);
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id); printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
if (isAjaxEnabled()) {
echo '<script type="text/javascript" language="javascript">'."\n";
echo "function items() {
var \$items = new Array();";
$counter = 0;
foreach ($socs as $oclass) {
printf(' items[%s] = "%s";',$counter++,$oclass->getName());
echo "\n";
}
echo '
return items;
}';
echo '</script>';
echo '<select name="viewvalue" onChange="showthis(\'objectclasses\',\'oc\')" id="objectclasses">';
} else
echo '<select name="viewvalue" onChange="submit()">'; echo '<select name="viewvalue" onChange="submit()">';
echo '<option value=""> - all - </option>'; echo '<option value=""> - all - </option>';
foreach ($schema_oclasses as $name => $oclass) foreach ($socs as $name => $oclass)
printf('<option value="%s" %s>%s</option>', printf('<option value="%s" %s>%s</option>',
$name,$name == $entry['value'] ? 'selected ': '',$oclass->getName()); $name,$name == $entry['value'] ? 'selected ': '',$oclass->getName(false));
echo '</select>'; echo '</select>';
if (isAjaxEnabled())
printf('<input type="button" value="%s" onClick="showthis(\'objectclasses\',\'oc\')"/>',_('Go'));
else
printf('<input type="submit" value="%s" />',_('Go')); printf('<input type="submit" value="%s" />',_('Go'));
echo '</form>'; echo '</form>';
echo '<br />'; echo '<br />';
foreach ($schema_oclasses as $name => $oclass) { foreach ($socs as $name => $oclass) {
if (is_null($entry['value']) || ($entry['value'] == $name)) { if (isAjaxEnabled() || (is_null($entry['value']) || ! strcasecmp($entry['value'],$oclass->getName()))) {
if (! is_null($entry['value'])) if (! is_null($entry['value']) && strcasecmp($entry['value'],$oclass->getName()))
$entry['viewed'] = true; $entry['viewed'] = true;
if (isAjaxEnabled() && $entry['value'])
printf('<div id="oc%s" style="display: %s">',$oclass->getName(),strcasecmp($entry['value'],$oclass->getName()) ? 'none' : '');
else
printf('<div id="oc%s">',$oclass->getName());
echo '<table class="result_table" width=100% border=0>'; echo '<table class="result_table" width=100% border=0>';
printf('<tr class="heading"><td colspan=4><a name="%s">%s</a></td></tr>',$name,$oclass->getName()); printf('<tr class="heading"><td colspan=4><a name="%s">%s</a></td></tr>',$name,$oclass->getName(false));
printf('<tr class="odd"><td colspan=4>%s: <b>%s</b></td></tr>',_('OID'),$oclass->getOID()); printf('<tr class="odd"><td colspan=4>%s: <b>%s</b></td></tr>',_('OID'),$oclass->getOID());
if ($oclass->getDescription()) if ($oclass->getDescription())
@ -421,10 +582,13 @@ switch($entry['view']) {
else else
foreach ($oclass->getSupClasses() as $i => $object_class) { foreach ($oclass->getSupClasses() as $i => $object_class) {
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],strtolower($object_class))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
if (isAjaxEnabled())
printf('<a title="%s" href="%s">%s</a>', printf('<a href="cmd.php?%s" onClick="return showthis(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
_('Jump to this objectClass definition'),$href,$object_class); $href,strtolower($object_class),$object_class);
else
printf('<a href="cmd.php?%s&viewvalue=%s" title="%s">%s</a>',
$href,$object_class,_('Jump to this objectClass definition'),$object_class);
if ($i < count($oclass->getSupClasses()) - 1) if ($i < count($oclass->getSupClasses()) - 1)
echo ', '; echo ', ';
@ -433,40 +597,58 @@ switch($entry['view']) {
printf('<tr class="odd"><td colspan=4>%s: <b>',_('Parent to')); printf('<tr class="odd"><td colspan=4>%s: <b>',_('Parent to'));
if (strcasecmp($oclass->getName(),'top') == 0) { if (strcasecmp($oclass->getName(),'top') == 0) {
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],'')); $href = htmlspecialchars($entry['href']['objectclasses']);
printf('(<a href="%s">all</a>)',$href); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return showthis(\'objectclasses\',\'oc\',\'\');">all</a>',
$href);
else
printf('(<a href="cmd.php?%s">all</a>)',$href);
} elseif (count($oclass->getChildObjectClasses()) == 0) } elseif (count($oclass->getChildObjectClasses()) == 0)
printf('(%s)',_('none')); printf('(%s)',_('none'));
else else
foreach ($oclass->getChildObjectClasses() as $i => $object_class) { foreach ($oclass->getChildObjectClasses() as $i => $object_class) {
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],strtolower($object_class))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
printf('<a title="%s" href="%s">%s</a>',_('Jump to this objectClass definition'),$href,$object_class); if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onClick="return showthis(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href,_('Jump to this objectClass definition'),strtolower($object_class),$object_class);
else
printf('<a href="cmd.php?%s" title="%s">%s</a>',$href,_('Jump to this objectClass definition'),$object_class);
if ( $i < count($oclass->getChildObjectClasses()) - 1) if ( $i < count($oclass->getChildObjectClasses()) - 1)
echo ', '; echo ', ';
} }
echo '</b></td></tr>'; echo '</b></td></tr>';
printf('<tr class="even"><td class="blank" rowspan=2>&nbsp;</td><td><b>%s</b></td><td><b>%s</b></td><td class="blank" rowspan=2>&nbsp;</td></tr>', printf('<tr class="even"><td class="blank" rowspan=2 width=5%%>&nbsp;</td><td width=45%%><b>%s</b></td><td width=45%%><b>%s</b></td><td class="blank" rowspan=2 width=5%%>&nbsp;</td></tr>',
_('Required Attributes'),_('Optional Attributes')); _('Required Attributes'),_('Optional Attributes'));
echo '<tr class="odd">'; echo '<tr class="odd">';
echo '<td>'; echo '<td>';
if (count($oclass->getMustAttrs($schema_oclasses)) > 0) { if ($attrs = $oclass->getMustAttrs(true)) {
echo '<ul class="list">'; echo '<ul class="list">';
foreach ($oclass->getMustAttrs($schema_oclasses) as $attr) {
echo '<li>';
$href = htmlspecialchars(sprintf($entry['href']['attributes'],strtolower($attr->getName())));
printf('<a href="%s">%s</a>',$href,$attr->getName());
if ($attr->getSource() != $oclass->getName()) { foreach ($attrs as $attr) {
echo '<li>';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName()));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return ajJump(\'%s\',\'%s\',\'%s\');">%s</a>',
$href,$href,_('Attributes'),$attr->getName(),$attr->getName(false));
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getName(false));
if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />'; echo '<br />';
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],strtolower($attr->getSource()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
printf('<small>(%s <a href="%s">%s</a>)</small>',_('Inherited from'),$href,$attr->getSource()); printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onClick="return showthis(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
echo ')</small>';
} }
echo '</li>'; echo '</li>';
} }
@ -478,18 +660,28 @@ switch($entry['view']) {
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
if (count($oclass->getMayAttrs($schema_oclasses)) > 0) { if ($attrs = $oclass->getMayAttrs(true)) {
echo '<ul class="list">'; echo '<ul class="list">';
foreach ($oclass->getMayAttrs($schema_oclasses) as $attr) {
echo '<li>';
$href = htmlspecialchars(sprintf($entry['href']['attributes'],strtolower($attr->getName())));
printf('<a href="%s">%s</a>',$href,$attr->getName());
if ($attr->getSource() != $oclass->getName()) { foreach ($attrs as $attr) {
echo '<li>';
$href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],$attr->getName()));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onClick="return ajJump(\'%s\',\'%s\',\'%s\');">%s</a>',
$href,$href,_('Attributes'),$attr->getName(),$attr->getName(false));
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getName(false));
if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />'; echo '<br />';
$href = htmlspecialchars(sprintf($entry['href']['objectClasses'],strtolower($attr->getSource()))); $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
printf('<small>(%s <a href="%s">%s</a>)</small>',_('Inherited from'),$href,$attr->getSource()); printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onClick="return showthis(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
$href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
echo ')</small>';
} }
if ($oclass->isForceMay($attr->getName())) { if ($oclass->isForceMay($attr->getName())) {
@ -507,11 +699,12 @@ switch($entry['view']) {
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo '<br />'; echo '<br />';
echo '</div>';
}
} }
} /* End foreach objectClass */
break; break;
} }
if (! is_null($entry['value']) && ! $entry['viewed']) if (! is_null($entry['value']) && ! $entry['viewed'])
error(sprintf(_('No such schema item: "%s"'),htmlspecialchars($entry['value'])),'error','index.php'); error(sprintf(_('No such schema item: "%s"'),$entry['value']),'error','index.php');
?> ?>

View File

@ -1,396 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/search.php,v 1.78.2.8 2008/12/12 12:20:22 wurley Exp $
/**
* Perform LDAP searches and draw the advanced/simple search forms
*
* Variables that come in as GET vars:
* - search (true if performing a search, empty to just draw form)
* For simple searches:
* - attribute, criterion, filter
* For advanced searches:
* - base_dn, scope, filter
*
* @package phpLDAPadmin
* @todo Search is probably broken, since base_dn is now an array
* @todo Order doesnt Order properly - probably case related.
*/
/**
*/
define('SIZE_LIMIT_EXCEEDED',4);
# Output format, table or list?
$result_formats = array('list','table');
# Our incoming variables
$entry = array();
$entry['format'] = get_request('format','GET','false',$_SESSION[APPCONFIG]->GetValue('search','display'));
$entry['form'] = get_request('form','GET',false,get_request('form','SESSION'));
$entry['orderby']['raw'] = get_request('orderby','GET');
$entry['orderby']['string'] = rawurldecode($entry['orderby']['raw']);
$entry['orderby']['array'] = $entry['orderby']['raw'] ? explode(',',preg_replace('/\s+/','',$entry['orderby']['string'])) : true;
$entry['display']['raw'] = get_request('display_attrs','GET');
$entry['display']['string'] = rawurldecode($entry['display']['raw']);
$entry['display']['array'] = $entry['display']['raw'] ? explode(',',preg_replace('/\s+/','',$entry['display']['string'])) : array();
$entry['filter']['string'] = get_request('filter','GET');
$entry['filter']['clean'] = $entry['filter']['string'] ? clean_search_vals($entry['filter']['string']) : null;
$entry['attr'] = get_request('attribute','GET');
$entry['base_dn']['string'] = get_request('base_dn','GET');
$entry['criterion'] = get_request('criterion','GET');
$entry['scope'] = get_request('scope','GET','false','sub');
$entry['search'] = get_request('search','GET');
$entry['predefined'] = get_request('predefined','GET');
$entry['page'] = get_request('page','GET',false,0);
if (! in_array($entry['format'],$result_formats))
$entry['format'] = 'list';
$_SESSION['form'] = $entry['form'];
# build the server drop-down html and JavaScript array (for base_dns)
$js_on_change_string = '';
if ($entry['form'] == 'advanced')
$js_on_change_string = 'onChange="document.forms[0].base_dn.value=servers[document.forms[0].server_id.value].base_dn"';
if (isset($ldapserver)) {
$server_menu_html = server_select_list($ldapserver->server_id,true,'server_id',$js_on_change_string);
$server_info_list = server_info_list();
}
# grab the base dn for the search
if ($entry['base_dn']['string']) {
$entry['base_dn']['invalid'] = false;
$entry['base_dn']['exist'] = false;
if (! is_dn_string($entry['base_dn']['string']))
$entry['base_dn']['invalid'] = true;
elseif (! $ldapserver->dnExists($entry['base_dn']['string']))
$entry['base_dn']['exist'] = true;
$base_dns = array($entry['base_dn']['string']);
} else
if (isset($ldapserver))
$base_dns = $ldapserver->getBaseDN();
printf('<script type="text/javascript" src="%ssearch_util.js"></script>',JSDIR);
echo '<center>';
$entry['command']['as'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','advanced_search');
$entry['command']['ps'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','predefined_search');
$entry['command']['ss'] = $_SESSION[APPCONFIG]->isCommandAvailable('search','simple_search');
if ($entry['form'] == 'advanced') {
if ($entry['command']['as'])
require LIBDIR.'search_form_advanced.php';
} elseif ($entry['form'] == 'predefined') {
if ($entry['command']['ps'])
require LIBDIR.'search_form_predefined.php';
} elseif ($entry['form'] == 'simple') {
# Draw simple search form
if ($entry['command']['ss'])
require LIBDIR.'search_form_simple.php';
} elseif ($entry['command']['as']) {
require LIBDIR.'search_form_advanced.php';
} elseif ($entry['command']['ss']) {
require LIBDIR.'search_form_simple.php';
} elseif ($entry['command']['ps']) {
require LIBDIR.'search_form_predefined.php';
} else {
echo _('Searching is not permitted');
}
echo '</center>';
echo '<br />';
if ($entry['search']) {
if ($entry['form'] == 'advanced') {
if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','advanced_search'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('advanced search')),'error','index.php');
} elseif ($entry['form'] == 'predefined') {
if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','predefined_search'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('predefined search')),'error','index.php');
} elseif ($entry['form'] == 'simple') {
if (! $_SESSION[APPCONFIG]->isCommandAvailable('search','simple_search'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('simple search')),'error','index.php');
}
if ($entry['form'] == 'advanced') {
if ($entry['display'])
$search_result_attributes = $entry['display']['array'];
else
$search_result_attributes = $_SESSION[APPCONFIG]->GetValue('search','result_attributes');
} else {
$search_result_attributes = $_SESSION[APPCONFIG]->GetValue('search','result_attributes');
}
# do we have enough authentication information for the specified server_id
# @todo: redirect isnt working
if (! $ldapserver->haveAuthInfo()) {
$login_url = sprintf('cmd.php?cmd=login_form&amp;server_id=%s&amp;redirect=%s',
$ldapserver->server_id,rawurlencode($_SERVER['REQUEST_URI']));
system_message(array(
'title'=>_('Search'),
'body'=>_('You have not logged into the selected server yet, so you cannot perform searches on it.'),
'type'=>'warn'),
$login_url);
}
if (is_numeric($entry['predefined'])) {
$query = get_cleaned_up_predefined_search($entry['predefined']);
$search_result_attributes = explode(', ',$query['attributes']);
$search_attributes_display = $search_result_attributes;
$search_attributes = $search_result_attributes;
$entry['filter']['clean'] = $query['filter'];
$entry['scope'] = $query['scope'];
if (! trim($query['base']))
$query['base'] = $ldapserver->getBaseDN();
elseif (is_array($query['base']))
$base_dns = $query['base'];
else
$base_dns = array($query['base']);
} else {
$entry['predefined'] = '';
}
if ($entry['filter']['clean']) {
# if they are using the simple search form, build an LDAP search filter from their input
if ($entry['form'] == 'simple' & ! is_numeric($entry['predefined'])) {
switch ($entry['criterion']) {
case 'starts with':
if ($entry['filter']['clean'] == '*')
$entry['filter']['clean'] = '';
$entry['filter']['clean'] = sprintf('(%s=%s*)',$entry['attr'],$entry['filter']['clean']);
break;
case 'contains':
if ($entry['filter']['clean'] == '*')
$entry['filter']['clean'] = sprintf('(%s=*)',$entry['attr']);
else
$entry['filter']['clean'] = sprintf('(%s=*%s*)',$entry['attr'],$entry['filter']['clean']);
break;
case 'ends with':
if ($entry['filter']['clean'] == '*')
$entry['filter']['clean'] = '';
$entry['filter']['clean'] = sprintf('(%s=*%s)',$entry['attr'],$entry['filter']['clean']);
break;
case 'equals':
$entry['filter']['clean'] = sprintf('(%s=%s)',$entry['attr'],$entry['filter']['clean']);
break;
case 'sounds like':
$entry['filter']['clean'] = sprintf('(%s~=%s)',$entry['attr'],$entry['filter']['clean']);
break;
default:
system_message(array(
'title'=>_('Unrecognized criteria option: ').htmlspecialchars($entry['criterion']),
'body'=>_('If you want to add your own criteria to the list. Be sure to edit search.php to handle them. Quitting.'),
'type'=>'warn'),
sprintf('cmd.php?cmd=search&server_id=%s',$ldapserver->server_id));
}
}
# prevent script from bailing early on a long delete
@set_time_limit(0);
$size_limit = $_SESSION[APPCONFIG]->GetValue('search','size_limit');
# Sanity check
if ($size_limit < 1)
$size_limit = 1;
$time_start = utime();
$time_elapsed = 0;
foreach ($base_dns as $base_dn) {
if (! $ldapserver->dnExists($base_dn)) {
if (DEBUG_ENABLED)
debug_log('BaseDN [%s] skipped as it doesnt exist in [%s].',64,__FILE__,__LINE__,__METHOD__,
$base_dn,$ldapserver->server_id);
continue;
} else {
if (DEBUG_ENABLED)
debug_log('Search with base DN [%s]',64,__FILE__,__LINE__,__METHOD__,$base_dn);
}
$results = $ldapserver->search(null,dn_escape($base_dn),$entry['filter']['clean'],$search_result_attributes,
$entry['scope'],$entry['orderby']['array'],$_SESSION[APPCONFIG]->GetValue('deref','search'));
if ((! $results) && $ldapserver->errno())
system_message(array(
'title'=>_('Encountered an error while performing search.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
$errno = $ldapserver->errno();
$time_end = utime();
$time_elapsed += round($time_end-$time_start,2);
$count = count($results);
$start_entry = $entry['page'] * $size_limit;
$end_entry = min($start_entry+$size_limit+1,$count+1);
# Search Results Table
echo '<table class="result" border=0>';
echo '<tr class="heading">';
printf('<td>%s%s <b>%s</b><div class="execution_time">(%s %s)</div></td>',_('Entries found'),_(':'),
number_format($count),$time_elapsed,_('seconds'));
if ($_SESSION[APPCONFIG]->isCommandAvailable('export')) {
$href = htmlspecialchars(sprintf('cmd.php?cmd=export_form&server_id=%s&scope=%s&dn=%s&filter=%s&attributes=%s',
$ldapserver->server_id,$entry['scope'],$base_dn,rawurlencode($entry['filter']['clean']),rawurlencode(join(', ',$search_result_attributes))));
printf('<td style="text-align: right"><small>[ <a href="%s"><img src="%s/save.png" alt="Save" /> %s</a> ]',
$href,IMGDIR,_('export results'));
}
printf('[ <img src="%s/rename.png" alt="rename" /> %s%s',IMGDIR,_('Format'),_(':'));
foreach ($result_formats as $f) {
echo '&nbsp;';
if ($entry['format'] == $f) {
printf('<b>%s</b>',_($f));
} else {
$query_string = array_to_query_string($_GET,array('format','cmd'));
$query_string .= sprintf('&amp;format=%s',$f);
printf('<a href="cmd.php?cmd=search&amp;%s">%s</a>',$query_string,_($f));
}
}
echo ' ]</small>';
if ($_SESSION[APPCONFIG]->isCommandAvailable('schema')) {
echo '<br />';
printf('<small>%s%s <b>%s</b></small>',_('Base DN'),_(':'),htmlspecialchars($base_dn));
if ($entry['form'] == 'simple' || $entry['form'] == 'predefined') {
echo '<br />';
printf('<small>%s%s <b>%s</b></small>',_('Filter performed'),_(':'),htmlspecialchars($entry['filter']['clean']));
}
}
echo '</td>';
echo '</tr>';
echo '</table>';
# The LDAP error code for the size limit exceeded error.
# @todo: test this with system_message
if ($errno && $errno == SIZE_LIMIT_EXCEEDED)
printf('<br /><center><small style="color:red; white-space: nowrap">%s</small></center><br />',_('Notice, search size limit exceeded.'));
# Draw the paging links
$pager_html = '';
$total_pages = $count / $size_limit;
$results_per_page = $size_limit;
if ($count > $size_limit) {
printf(_('Showing results %s through %s.').'<br />',
'<b>'.number_format($start_entry+1).'</b>','<b>'.number_format($end_entry-1).'</b>');
if ($entry['page'] != 0) {
$query_string = array_to_query_string($_GET,array('page','cmd'));
$query_string .= '&page=' . ($entry['page']-1);
$pager_html .= sprintf('<a title="'._('Page %d').'" href="cmd.php?cmd=search&amp;%s">&lsaquo;&lsaquo;</a>',$entry['page'],$query_string);
} else {
$pager_html .= '&lsaquo;&lsaquo;';
}
$pager_html .= '&nbsp;&nbsp;';
/* For large search results where we page beyond the first 20 pages,
* print elipsis instead of making the pager be super wide. */
$elipsis_printed = false;
for ($i=0;$i<$count;$i+=$size_limit) {
$page_num = $i/$size_limit;
if ($count > $size_limit * 20 && abs($page_num-$entry['page']) > 10) {
if (! $elipsis_printed) {
$pager_html .= '...&nbsp;&nbsp;';
$elipsis_printed = true;
}
} elseif ($entry['page'] == $page_num) {
$pager_html .= '<b>' . ($page_num + 1) . '</b>';
$pager_html .= '&nbsp;&nbsp;';
$elipsis_printed = false;
} else {
$query_string = array_to_query_string($_GET,array('page','cmd'));
$query_string .= '&page=' . $page_num;
$pager_html .= "<a href=\"cmd.php?cmd=search&amp;$query_string\">" . ($page_num+1) . "</a>";
$pager_html .= '&nbsp;&nbsp;';
$elipsis_printed = false;
}
}
if ($entry['page']+1 < $total_pages) {
$query_string = array_to_query_string($_GET,array('page','cmd'));
$query_string .= '&page=' . ($entry['page']+1);
$pager_html .= "<a title=\"" . sprintf(_('Page %d'),($entry['page']+2))."\" href=\"cmd.php?cmd=search&amp;$query_string\">&rsaquo;&rsaquo;</a>";
} else {
$pager_html .= "&rsaquo;&rsaquo;";
}
}
if (0 == $count)
printf('<center><h2>%s</h2></center>',_('The search found no results.'));
else {
if (trim($pager_html))
printf('<center>%s</center>',$pager_html);
echo '<br />';
if ($entry['format'] == 'list')
require LIBDIR.'search_results_list.php';
elseif ($entry['format'] == 'table')
require LIBDIR.'search_results_table.php';
else
error(sprintf(_('Unrecognized search result format: %s'),htmlspecialchars($entry['format'])),'error','index.php');
echo '<br />';
if (trim($pager_html))
printf('<center>%s</center>',$pager_html);
}
}
}
}
?>

View File

@ -1,87 +1,46 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/server_info.php,v 1.27.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Fetches and displays all information that it can from the specified server * Fetches and displays all information that it can from the specified server
* *
* Variables that come in via common.php
* - server_id
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
if (! $_SESSION[APPCONFIG]->isCommandAvailable('server_info')) require './common.php';
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('view server information')),'error','index.php');
# The attributes we'll examine when searching the LDAP server's RootDSE
$root_dse_attributes = array(
'namingContexts',
'subschemaSubentry',
'altServer',
'supportedExtension',
'supportedControl',
'supportedSASLMechanisms',
'supportedLDAPVersion',
'currentTime',
'dsServiceName',
'defaultNamingContext',
'schemaNamingContext',
'configurationNamingContext',
'rootDomainNamingContext',
'supportedLDAPPolicies',
'highestCommittedUSN',
'dnsHostName',
'ldapServiceName',
'serverName',
'supportedCapabilities',
'changeLog',
'tlsAvailableCipherSuites',
'tlsImplementationVersion',
'supportedSASLMechanisms',
'dsaVersion',
'myAccessPoint',
'dseType',
'+',
'*'
);
# Fetch basic RootDSE attributes using the + and *. # Fetch basic RootDSE attributes using the + and *.
$attrs = $ldapserver->search(null,'','objectClass=*',array('+','*'),'base'); $query = array();
$attrs = array_pop($attrs); $query['base'] = '';
$query['scope'] = 'base';
$query['attrs'] = $app['server']->getValue('server','root_dse_attributes');
$query['baseok'] = true;
$results = $app['server']->query($query,null);
$attrs = array_pop($results);
/* After fetching the "basic" attributes from the RootDSE, try fetching the printf('<h3 class="title">%s%s</h3>',_('Server info for: '),$app['server']->getName());
more advanced ones (from ths list). Add them to the list of attrs to display
if they weren't already fetched. (this was added as a work-around for OpenLDAP
on RHEL 3. */
$attrs2 = $ldapserver->search(null,'','objectClass=*',$root_dse_attributes,'base');
$attrs2 = array_pop($attrs2);
if (is_array($attrs2))
foreach ($attrs2 as $attr => $values)
if (! isset($attrs[$attr]))
$attrs[$attr] = $attrs2[$attr];
printf('<h3 class="title">%s%s</h3>',_('Server info for: '),htmlspecialchars($ldapserver->name));
printf('<h3 class="subtitle">%s</h3>',_('Server reports the following information about itself')); printf('<h3 class="subtitle">%s</h3>',_('Server reports the following information about itself'));
if (count($attrs) == 0) { if (! count($attrs)) {
echo '<br /><br />'; echo '<br /><br />';
printf('<center>%s</center>',_('This server has nothing to report.')); printf('<center>%s</center>',_('This server has nothing to report.'));
return; return;
} }
echo '<table class="result" border=0>'; echo '<table class="result" border=0>';
foreach ($attrs as $attr => $values) { foreach ($attrs as $key => $values) {
if ($attr == 'dn') if ($key == 'dn')
continue; continue;
$schema_href = sprintf('cmd.php?cmd=schema&amp;server_id=%s&amp;view=attributes&amp;viewvalue=%s',$ldapserver->server_id,$attr); $href = sprintf('cmd.php?cmd=schema&amp;server_id=%s&amp;view=attributes&amp;viewvalue=%s',$app['server']->getIndex(),$key);
echo '<tr class="list_item"><td class="heading" rowspan=2>'; echo '<tr class="list_item"><td class="heading" rowspan=2>';
printf('<a title="'._('Click to view the schema definition for attribute type \'%s\'').'" href="%s">%s</a>', printf('<a href="%s" title="%s: %s" >%s</a>',
$attr,$schema_href,htmlspecialchars($attr)); $href,_('Click to view the schema definition for attribute type'),$key,$key);
echo '</td></tr>'; echo '</td></tr>';
echo '<tr class="list_item"><td class="blank">&nbsp;</td><td class="value">'; echo '<tr class="list_item"><td class="blank">&nbsp;</td><td class="value">';
@ -89,13 +48,12 @@ foreach ($attrs as $attr => $values) {
if (is_array($values)) if (is_array($values))
foreach ($values as $value) { foreach ($values as $value) {
$oidtext = ''; $oidtext = '';
print '<tr>'; print '<tr>';
if (preg_match('/^[0-9]+\.[0-9]+/',$value)) { if (preg_match('/^[0-9]+\.[0-9]+/',$value)) {
printf('<td width=5%%><img src="%s/rfc.png" title="%s" alt="%s" /></td>', printf('<td width=5%% rowspan=2 style="vertical-align: top"><img src="%s/rfc.png" title="%s" alt="%s"/></td>',
IMGDIR,htmlspecialchars($value), htmlspecialchars($value)); IMGDIR,$value,htmlspecialchars($value));
if ($oidtext = support_oid_to_text($value)) if ($oidtext = support_oid_to_text($value))
if (isset($oidtext['ref'])) if (isset($oidtext['ref']))
@ -108,17 +66,23 @@ foreach ($attrs as $attr => $values) {
printf('<td><small>%s</small></td>',$value); printf('<td><small>%s</small></td>',$value);
} else { } else {
printf('<td>%s</td>',htmlspecialchars($value)); printf('<td rowspan=2 colspan=2>%s</td>',$value);
} }
print '</tr>'; print '</tr>';
if (isset($oidtext['desc']) && trim($oidtext['desc'])) if (isset($oidtext['desc']) && trim($oidtext['desc']))
printf('<tr><td colspan=2><small>%s</small></td></tr>',$oidtext['desc']); printf('<tr><td><small>%s</small></td></tr>',$oidtext['desc']);
else
echo '<tr><td>&nbsp;</td></tr>';
if ($oidtext)
echo '<tr><td colspan=2>&nbsp;</td></tr>';
} }
else else
printf('<tr><td>%s&nbsp;</td></tr>',htmlspecialchars($values)); printf('<tr><td colspan=2>%s&nbsp;</td></tr>',$values);
echo '</table>'; echo '</table>';
echo '</td></tr>'; echo '</td></tr>';

View File

@ -1,33 +1,42 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/show_cache.php,v 1.3.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* This script shows the contents of the cache for debugging purposes * This script shows the contents of the cache for debugging purposes
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$entry = array(); $request = array();
$entry['key'] = get_request('key','REQUEST'); $request['key'] = get_request('key','REQUEST');
$entry['index'] = get_request('index','REQUEST'); $request['index'] = get_request('index','REQUEST');
if (isset($entry['index']) && isset($entry['key'])) { if (get_request('global','REQUEST'))
list($entry['server'],$entry['x']) = split(':',$entry['index']); $request['dumpvar'] = &$GLOBALS;
debug_dump($_SESSION[$entry['key']][$entry['server']][$entry['x']],1); else
$request['dumpvar'] = &$_SESSION;
if (isset($request['index']) && isset($request['key'])) {
list($request['server'],$request['x']) = explode(':',$request['index']);
debug_dump($request['dumpvar'][$request['key']][$request['server']][$request['x']],1);
} }
if ($entry['key'])
debug_dump($_SESSION[$entry['key']],1);
if (! $_SESSION[APPCONFIG]->GetValue('appearance','hide_debug_info')) { if ($request['key'])
debug_dump($request['dumpvar'][$request['key']],1);
if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_debug_info')) {
echo '<div style="font-size: 11px"><ul>'; echo '<div style="font-size: 11px"><ul>';
foreach (array_keys($_SESSION) as $key) {
if (($key == 'cache') && is_array($_SESSION[$key])) foreach (array_keys($request['dumpvar']) as $key) {
foreach (array_keys($_SESSION['cache']) as $server) { if ((in_array($key,array('cache'))) && is_array($request['dumpvar'][$key]))
foreach (array_keys($_SESSION['cache'][$server]) as $x) { foreach (array_keys($request['dumpvar'][$key]) as $server) {
foreach (array_keys($request['dumpvar'][$key][$server]) as $x) {
$index = sprintf('%s:%s',$server,$x); $index = sprintf('%s:%s',$server,$x);
printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'%s\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'%s\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>',
@ -35,7 +44,7 @@ if (! $_SESSION[APPCONFIG]->GetValue('appearance','hide_debug_info')) {
} }
} }
else else
printf('<li><span id="%s"><a href="javascript:get(\'%s\', \'\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>', printf('<li><span id="%s"><a href="javascript:get(\'%s\',\'\');">%s</a></span><div id="%sloading" style="display: none" ></div></li>',
$key,$key,$key,$key); $key,$key,$key,$key);
} }
echo '</ul></div>'; echo '</ul></div>';
@ -81,7 +90,10 @@ if (! $_SESSION[APPCONFIG]->GetValue('appearance','hide_debug_info')) {
poststr += "&index=" + encodeURI(xx); poststr += "&index=" + encodeURI(xx);
} }
obj.innerHTML = '<img src="<?php echo IMGDIR ?>/ajax-spinner.gif" /> Loading...'; <?php if (get_request('global','REQUEST')) { ?>
poststr += "&global=on" + encodeURI(xx);
<?php } ?>
obj.innerHTML = '<img src="<?php echo IMGDIR ?>/ajax-spinner.gif" /> <?php echo _('Loading') ?>...';
makePOSTRequest('cmd.php',poststr,'alertCacheContents','cancelCacheContents'); makePOSTRequest('cmd.php',poststr,'alertCacheContents','cancelCacheContents');
} }

View File

@ -1,70 +1,59 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/template_engine.php,v 1.45.2.2 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Template render engine. * Template render engine.
* @param dn $dn DN of the object being edited. (For editing existing entries) *
* @param dn $container DN where the new object will be created. (For creating new entries)
* @param string $template to use for new entry. (For creating new entries)
* @todo schema attr keys should be in lowercase.
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
* @author The phpLDAPadmin development team * @author The phpLDAPadmin development team
*/ */
/** /**
The template engine has the following responsibilities:
* If we are passed a DN, then we are editing an existing entry
* If we are not passed a DN, then we are passed a container (and creating a new entry in that container)
In both cases, we are optionally passed a template ID.
* If we have a template ID, then we'll render the creation/editing using that template
* If we are not passed a template ID, then we'll either:
* Present a list of available templates,
* Present the default template, because there are non available (due to hidden,regexp or non-existant)
* Present the only template, if there is only one.
Creating and editing entries use two objects:
* A template object which describes how the template should be rendered (and what values should asked for, etc)
* A page object, which is responsible for actually sending out the HTML to the browser.
So:
* we init a new TemplateRender object
* we init a new Template object
* set the DN or container on the template object
* If setting the DN, this in turn should read the "old values" from the LDAP server
* If we are not on the first page (ie: 2nd, 3rd, 4th step, etc), we should accept the post values that we have obtained thus far
* Finally submit the update to "update_confirm", or the create to "create", when complete.
*/ */
require_once './common.php'; require './common.php';
$entry = array(); $request = array();
$entry['dn']['encode'] = get_request('dn','REQUEST'); $request['dn'] = get_request('dn','REQUEST');
$entry['dn']['string'] = rawurldecode($entry['dn']['encode']); $request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
$entry['template'] = get_request('template','REQUEST',false,'');
# If we have a DN, then this is to edit the entry. # If we have a DN, then this is to edit the entry.
if ($entry['dn']['string']) { if ($request['dn']) {
$ldapserver->dnExists($entry['dn']['string']) $app['server']->dnExists($request['dn'])
or error(sprintf('%s (%s)',_('No such entry'),pretty_print_dn($entry['dn']['string'])),'error','index.php'); or error(sprintf('%s (%s)',_('No such entry'),pretty_print_dn($request['dn'])),'error','index.php');
$tree = get_cached_item($ldapserver->server_id,'tree'); $request['page']->setDN($request['dn']);
$request['page']->accept();
if ($tree) {
$entry['dn']['tree'] = $tree->getEntry($entry['dn']['string']);
if (! $entry['dn']['tree']) {
/*
* The entry doesn't exists in the tree because it
* may be filtered ; as we ask for its display, we
* add all the same the entry in the tree
*/
$tree->addEntry($entry['dn']['string']);
$entry['dn']['tree'] = $tree->getEntry($entry['dn']['string']);
}
if ($entry['dn']['tree']) {
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);');
$entry['dn']['tree']->accept($reader);
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);');
$entry['dn']['tree']->accept($writer);
}
}
} else { } else {
if ($ldapserver->isReadOnly()) if ($app['server']->isReadOnly())
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
# Create a new empty entry $request['page']->setContainer(get_request('container','REQUEST'));
$entryfactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','entry_factory'); $request['page']->accept();
eval('$entry_factory = new '.$entryfactoryclass.'();');
$entry['dn']['tree'] = $entry_factory->newCreatingEntry('');
# Init the entry with incoming data
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_reader').'($ldapserver);');
$entry['dn']['tree']->accept($reader);
# Display the creating entry
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance', 'entry_writer').'($ldapserver);');
$entry['dn']['tree']->accept($writer);
} }
?> ?>

View File

@ -1,155 +1,60 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/update.php,v 1.29.2.4 2009/01/05 14:25:48 wurley Exp $ // $Header$
/** /**
* Updates or deletes a value from a specified attribute for a specified dn. * Updates or deletes a value from a specified attribute for a specified dn.
* *
* Variables that come in on the query string:
* - dn (rawurlencoded)
* - update_array (an array in the form expected by PHP's ldap_modify, except for deletions)
* (will never be empty: update_confirm.php ensures that)
*
* Attribute deletions:
* To specify that an attribute is to be deleted (whether multi- or single-valued),
* enter that attribute in the update array like this: attr => ''. For example, to
* delete the 'sn' attribute from an entry, the update array would look like this:
* Array (
* sn => ''
* )
*
* On success, redirect to template_engine.php. On failure, echo an error.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
* @see update_confirm.php
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$entry = array(); $request = array();
$entry['dn']['string'] = get_request('dn'); $request['dn'] = get_request('dn','REQUEST',true);
$entry['dn']['encode'] = rawurlencode($entry['dn']['string']);
# If cancel was submited, got back to the edit display. # If cancel was submited, got back to the edit display.
if (get_request('cancel','REQUEST')) { if (get_request('cancel','REQUEST')) {
header(sprintf('Location: cmd.php?cmd=template_engine&server_id=%s&dn=%s',$ldapserver->server_id,$entry['dn']['encode'])); header(sprintf('Location: cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn'])));
die(); die();
} }
if ($ldapserver->isReadOnly()) if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
$entry['update'] = get_request('update_array','POST',false,array()); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$entry['skip'] = get_request('skip_array','POST',false,array()); $request['page']->setDN($request['dn']);
$failed_attrs = array(); $request['page']->accept();
$request['template'] = $request['page']->getTemplate();
if (! is_array($entry['update']))
error(_('update_array is malformed. This might be a phpLDAPadmin bug. Please report it.'),'error','index.php');
run_hook ('pre_update',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'update_array'=>$entry['update']));
# Check for delete attributes (indicated by the attribute entry appearing like this: attr => ''
foreach ($entry['update'] as $attr => $val) {
if (! is_array($val)) {
if (array_key_exists($attr,$entry['skip'])) {
unset($entry['update'][$attr]);
} elseif ($val == '') {
$entry['update'][$attr] = array();
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('delete attribute')),'error','index.php');
} else { # Skip change
$entry['update'][$attr] = $val;
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')
&& ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('modify attribute values')),'error','index.php');
}
} else {
if (array_key_exists($attr,$entry['skip'])) {
unset($entry['update'][$attr]);
} else {
foreach ($val as $i => $v)
$entry['update'][$attr][$i] = $v;
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add_value')
&& ! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_delete_value'))
error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('modify attribute values')),'error','index.php');
}
}
}
# Call the custom callback for each attribute modification and verify that it should be modified.
foreach ($entry['update'] as $attr_name => $val) {
# Check to see if this is a unique Attribute
if ($badattr = $ldapserver->checkUniqueAttr($entry['dn']['string'],$attr_name,$val)) {
$href['search'] = sprintf('cmd.php?cmd=search&search=true&form=advanced&server_id=%s&filter=%s=%s',
$ldapserver->server_id,$attr_name,$badattr);
error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),
$attr_name,$badattr,$entry['dn']['string'],$href['search']),'error','index.php');
}
if (run_hook('pre_attr_modify',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'attr_name'=>$attr_name,'new_value'=>$val)) !== true) {
unset($entry['update'][$attr_name]);
$failed_attrs[$attr_name] = $val;
} elseif ($ldapserver->isAttrReadOnly($attr)) {
error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'),
htmlspecialchars($attr_name)),'error','index.php');
} else {
// binary values
if (isset($_SESSION['submitform'][$attr_name])) {
foreach ($val as $i => $v) {
if (isset($_SESSION['submitform'][$attr_name][$v])) {
foreach ($_SESSION['submitform'][$attr_name][$v] as $file) {
foreach ($file as $data) {
$entry['update'][$attr_name][$i] = $data;
}
}
}
}
}
}
}
# Perform the modification # Perform the modification
$result = $ldapserver->modify($entry['dn']['string'],$entry['update']); $result = $app['server']->modify($request['dn'],$request['template']->getLDAPmodify());
if ($result) { if ($result) {
# Fire the post modification event to the user's custom callback function. # Fire the post modification event to the user's custom callback function.
$mustRelogin = false; $mustRelogin = false;
foreach ($entry['update'] as $attr_name => $val) {
run_hook('post_attr_modify',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'attr_name'=>$attr_name,'new_value'=>$val));
foreach ($request['template']->getLDAPmodify() as $attr_name => $val) {
/* Was this a user's password modification who is currently /* Was this a user's password modification who is currently
* logged in? If so, they need to logout and log back in * logged in? If so, they need to logout and log back in
* with the new password. * with the new password. */
*/ if (($attr_name == 'userpassword') &&
if (0 === strcasecmp($attr_name,'userPassword') && in_array($app['server']->getValue('login','auth_type'),array('cookie','session')) &&
in_array($ldapserver->auth_type,array('cookie','session')) && pla_compare_dns($app['server']->getLogin(),$request['dn']) === 0)
pla_compare_dns($ldapserver->getLoggedInDN(),$entry['dn']['string']) === 0)
$mustRelogin = true; $mustRelogin = true;
} }
run_hook('post_update',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'update_array'=>$entry['update']));
# If the user password was changed, not tell the to relogin. # If the user password was changed, not tell the to relogin.
if ($mustRelogin) { if ($mustRelogin) {
$ldapserver->unsetLoginDN(); $app['server']->logout('user');
unset_lastactivity($ldapserver); unset_lastactivity($app['server']);
include './header.php';
echo '<body>'; echo '<body>';
echo '<br />'; echo '<br />';
@ -158,7 +63,7 @@ if ($result) {
echo '<br /><br />'; echo '<br /><br />';
echo _('Since you changed your password, you must now login again with your new password.'); echo _('Since you changed your password, you must now login again with your new password.');
echo '<br />'; echo '<br />';
printf('<a href="cmd.php?cmd=login_form&server_id=%s">%s...</a>',$ldapserver->server_id, _('Login')); printf('<a href="cmd.php?cmd=login_form&server_id=%s">%s...</a>',$app['server']->getIndex(), _('Login'));
echo '</center>'; echo '</center>';
echo '</body>'; echo '</body>';
echo '</html>'; echo '</html>';
@ -166,21 +71,13 @@ if ($result) {
exit; exit;
} }
$redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$ldapserver->server_id,$entry['dn']['encode']); $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$app['server']->getIndex(),rawurlencode($request['dn']));
foreach ($entry['update'] as $attr => $junk) foreach ($request['template']->getLDAPmodify() as $attr => $junk)
$redirect_url .= "&modified_attrs[]=$attr"; $redirect_url .= sprintf('&modified_attrs[]=%s',$attr);
foreach ($failed_attrs as $attr => $junk)
$redirect_url .= "&failed_attrs[]=$attr";
header("Location: $redirect_url"); header("Location: $redirect_url");
die(); die();
} else {
system_message(array(
'title'=>_('Could not perform ldap_modify operation.'),
'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
'type'=>'error'));
} }
?> ?>

View File

@ -1,321 +1,161 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/update_confirm.php,v 1.49.2.4 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* Takes the results of clicking "Save" in template_engine.php and determines which * Takes the results of clicking "Save" in template_engine.php and determines
* attributes need to be updated (ie, which ones actually changed). Then, * which attributes need to be updated (ie, which ones actually changed). Then,
* we present a confirmation table to the user outlining the changes they * we present a confirmation table to the user outlining the changes they are
* are about to make. That form submits directly to update.php, which * about to make. That form submits directly to update.php, which makes the
* makes the change. * change.
* *
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
* @see update.php
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
if ($ldapserver->isReadOnly()) $request = array();
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php'); $request['dn'] = get_request('dn','REQUEST',true);
/***************/ if (! $request['dn'] || ! $app['server']->dnExists($request['dn']))
/* get entry */ error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
/***************/
$entry = array(); $request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$entry['dn']['string'] = get_request('dn'); $request['page']->setDN($request['dn']);
$entry['dn']['encode'] = rawurlencode($entry['dn']['string']); $request['page']->accept();
$request['template'] = $request['page']->getTemplate();
if (! $entry['dn']['string'] || ! $ldapserver->dnExists($entry['dn']['string'])) $request['page']->drawTitle(get_rdn($request['template']->getDN()));
error(sprintf(_('The entry (%s) does not exist.'),htmlspecialchars($entry['dn']['string'])),'error','index.php'); $request['page']->drawSubTitle();
$tree = get_cached_item($ldapserver->server_id,'tree'); # Confirm the updates
$entry['ldap'] = null; if (count($request['template']->getLDAPmodify(true))) {
if ($tree) {
$entry['ldap'] = $tree->getEntry($entry['dn']['string']);
if (! $entry['ldap'])
$tree->addEntry($entry['dn']['string']);
$entry['ldap'] = $tree->getEntry($entry['dn']['string']);
}
if (! $entry['ldap'] || $entry['ldap']->isReadOnly())
error(sprintf(_('The entry (%s) is in readonly mode.'),htmlspecialchars($entry['dn']['string'])),'error','index.php');
/***************/
/* old values */
/***************/
$entry['values']['old'] = array();
foreach ($entry['ldap']->getAttributes() as $old_attr) {
$name = $old_attr->getName();
$entry['values']['old'][$name] = array();
foreach ($old_attr->getValues() as $old_val) {
if (strlen($old_val) > 0)
$entry['values']['old'][$name][] = $old_val;
}
}
/***************/
/* new values */
/***************/
eval('$reader = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_reader').'($ldapserver);');
$entry['ldap']->accept($reader);
$entry['values']['new'] = array();
foreach ($entry['ldap']->getAttributes() as $new_attr) {
if ($new_attr->hasBeenModified()) {
$name = $new_attr->getName();
if (!isset($entry['values']['old'][$name]))
$entry['values']['old'][$name] = array();
$entry['values']['new'][$name] = array();
foreach ($new_attr->getValues() as $i => $new_val) {
if ($new_attr instanceof BinaryAttribute) {
$n = $new_attr->getFileName($i);
$p = $new_attr->getFilePath($i);
$new_val = md5("$n|$p");
}
if (strlen($new_val) > 0)
$entry['values']['new'][$name][] = $new_val;
}
}
}
/************************/
/* objectClass deletion */
/************************/
$oc_to_delete = array();
$attr_to_delete = array();
// if objectClass attribute is modified
if (isset($entry['values']['new']['objectClass'])) {
if (!isset($entry['values']['old']['objectClass']))
error(_('An entry should have one structural objectClass.'),'error','index.php');
// deleted objectClasses
foreach ($entry['values']['old']['objectClass'] as $oldOC) {
if (!in_array($oldOC, $entry['values']['new']['objectClass'])) {
$oc_to_delete[] = $oldOC;
}
}
// search the attributes used by each deleted objecClass
// we must maybe delete these attributes
foreach ($oc_to_delete as $oc) {
$soc = $ldapserver->getSchemaObjectClass($oc);
if ($soc) {
$ocs = $ldapserver->SchemaObjectClasses();
$ma = $soc->getMustAttrs($ocs);
foreach ($ma as $a) {
if (!isset($attr_to_delete[$a->getName()])) {
$attr_to_delete[$a->getName()] = $a;
}
}
$ma = $soc->getMayAttrs($ocs);
foreach ($ma as $a) {
if (!isset($attr_to_delete[$a->getName()])) {
$attr_to_delete[$a->getName()] = $a;
}
}
}
}
// if an attribute is still used by an objectClass we don't delete,
// we don't delete this attribute
foreach ($attr_to_delete as $name => $ad) {
$found = false;
$at = $ldapserver->getSchemaAttribute($name);
foreach ($at->getUsedInObjectClasses() as $oc) {
if (in_array($oc, $entry['values']['new']['objectClass'])) {
$found = true;
break;
}
}
if (!$found) {
foreach ($at->getRequiredByObjectClasses() as $oc) {
if (in_array($oc, $entry['values']['new']['objectClass'])) {
$found = true;
break;
}
}
}
if ($found) {
unset($attr_to_delete[$name]);
} else {
if (isset($entry['values']['old'][$name]) && (count($entry['values']['old'][$name]) > 0)) {
$found = true;
} else {
foreach ($entry['values']['new'] as $attr_name => $attr_values) {
if ($name == $attr_name) {
$found = true;
break;
}
}
}
if (!$found) {
unset($attr_to_delete[$name]);
} else {
$entry['values']['new'][$name] = array();
$attr_to_delete[$name] = $name;
}
}
}
}
/****************/
/* update array */
/****************/
eval('$writer = new '.$_SESSION[APPCONFIG]->GetValue('appearance','entry_writer').'($ldapserver);');
$writer->draw('Title',$entry['ldap']);
$writer->draw('Subtitle',$entry['ldap']);
echo "\n\n";
run_hook('pre_update_array_processing',
array('server_id'=>$ldapserver->server_id,'dn'=>$entry['dn']['string'],'old_values'=>$entry['values']['old'],'new_values'=>$entry['values']['new']));
/***************/
/* confirm */
/***************/
if (count($entry['values']['new']) > 0) {
echo '<br />';
echo '<center>'; echo '<center>';
echo _('Do you want to make these changes?'); echo _('Do you want to make these changes?');
echo '<br /><br />'; echo '<br /><br />';
# <!-- Commit button and acompanying form -->
echo "\n\n"; echo "\n\n";
echo '<form action="cmd.php" method="post">'; echo '<form action="cmd.php" method="post">';
echo '<input type="hidden" name="cmd" value="update" />'; 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 "\n"; echo "\n";
$request['page']->drawHiddenAttributes();
echo '<table class="result_table">'; echo '<table class="result_table">';
echo "\n"; echo "\n";
printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', printf('<tr class="heading"><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
_('Attribute'),_('Old Value'),_('New Value'),_('Skip')); _('Attribute'),_('Old Value'),_('New Value'),_('Skip'));
echo "\n\n"; echo "\n\n";
$counter = 0;
foreach ($entry['values']['new'] as $attr => $new_val) { $counter = 0;
foreach ($request['template']->getLDAPmodify(true) as $attribute) {
$counter++; $counter++;
printf('<tr class="%s">',$counter%2 ? 'even' : 'odd'); printf('<tr class="%s">',$counter%2 ? 'even' : 'odd');
echo '<td><b>'; printf('<td><b>%s</b></td>',$attribute->getFriendlyName());
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attr);
echo '</b></td>'; # Show OLD Values
echo '<td><span style="white-space: nowrap;">'; echo '<td><span style="white-space: nowrap;">';
if (strcasecmp($attr,'userPassword') == 0) { if (! $attribute->getOldValues())
foreach ($entry['values']['old'][$attr] as $key => $value) { printf('<span style="color: green">[%s]</span>',_('attribute doesnt exist'));
if (obfuscate_password_display(get_enc_type($entry['values']['old'][$attr][$key])))
echo preg_replace('/./','*',$entry['values']['old'][$attr][$key]).'<br />'; foreach ($attribute->getOldValues() as $key => $value) {
else # For multiple values, we'll highlight the changed ones
echo nl2br(htmlspecialchars($entry['values']['old'][$attr][$key])).'<br />'; if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
echo '<span style="color:#880000; background:#FFFFA0">';
$request['page']->draw('OldValue',$attribute,$key);
# For multiple values, close the highlighting
if ((count($attribute->getOldValues()) > 5) && in_array($value,$attribute->getRemovedValues()) && count($attribute->getValues()))
echo '</span>';
echo '<br />';
} }
} elseif (is_array($entry['values']['old'][$attr]))
foreach ($entry['values']['old'][$attr] as $v)
echo nl2br(htmlspecialchars($v)).'<br />';
else
echo nl2br(htmlspecialchars($entry['values']['old'][$attr])).'<br />';
echo '</span></td>';
echo '<td><span style="white-space: nowrap;">';
# Is this a multi-valued attribute?
if (is_array($new_val)) {
if (strcasecmp($attr,'userPassword') == 0) {
foreach ($entry['values']['new'][$attr] as $key => $value) {
if (isset($new_val[$key])) {
if (obfuscate_password_display(get_enc_type($new_val[$key])))
echo preg_replace('/./','*',$new_val[$key]).'<br />';
else
echo htmlspecialchars($new_val[$key]).'<br />';
}
}
} else {
foreach ($new_val as $i => $v) {
echo nl2br(htmlspecialchars($v)).'<br />';
}
}
if (! $new_val) {
printf('<span style="color: red">%s</span>',_('[attribute deleted]'));
}
} elseif ($new_val == '')
printf('<span style="color: red">%s</span>',_('[attribute deleted]'));
echo '</span></td>'; echo '</span></td>';
# Show NEW Values
echo '<td><span style="white-space: nowrap;">';
if (! $attribute->getValueCount() || $attribute->isForceDelete())
printf('<span style="color: red">[%s]</span>',_('attribute deleted'));
foreach ($attribute->getValues() as $key => $value) {
# For multiple values, we'll highlight the changed ones
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
echo '<span style="color:#004400; background:#FFFFA0">';
$request['page']->draw('CurrentValue',$attribute,$key);
# For multiple values, close the highlighting
if ((count($attribute->getValues()) > 5) && in_array($value,$attribute->getAddedValues()))
echo '</span>';
echo '<br />';
}
echo '</span></td>';
# Show SKIP Option
$input_disabled = ''; $input_disabled = '';
if (in_array($attr, $attr_to_delete)) $input_disabled = 'disabled="disabled"';
$input_onclick = ''; $input_onclick = '';
if ($attr == 'objectClass' && (count($attr_to_delete) > 0)) {
if ($attribute->isForceDelete())
$input_disabled = 'disabled="disabled"';
if ($attribute->getName() == 'objectclass' && (count($request['template']->getForceDeleteAttrs()) > 0)) {
$input_onclick = 'onclick="if (this.checked) {'; $input_onclick = 'onclick="if (this.checked) {';
foreach ($attr_to_delete as $ad_name) {
$input_onclick .= "document.forms[0].elements['skip_array[$ad_name]'].disabled = false;"; foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
$input_onclick .= "document.forms[0].elements['skip_array[$ad_name]'].checked = true;"; $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = false;",$ad_name->getName());
$input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = true;",$ad_name->getName());
} }
$input_onclick .= '} else {'; $input_onclick .= '} else {';
foreach ($attr_to_delete as $ad_name) { foreach ($request['template']->getForceDeleteAttrs() as $ad_name) {
$input_onclick .= "document.forms[0].elements['skip_array[$ad_name]'].checked = false;"; $input_onclick .= sprintf("document.getElementById('skip_array_%s').checked = false;",$ad_name->getName());
$input_onclick .= "document.forms[0].elements['skip_array[$ad_name]'].disabled = true;"; $input_onclick .= sprintf("document.getElementById('skip_array_%s').disabled = true;",$ad_name->getName());
} }
$input_onclick .= '}"'; $input_onclick .= '}"';
} }
printf('<td><input name="skip_array[%s]" type="checkbox" %s %s/></td>',htmlspecialchars($attr),$input_disabled,$input_onclick);
echo '</tr>'."\n\n"; printf('<td><input name="skip_array[%s]" id="skip_array_%s" type="checkbox" %s %s/></td>',
htmlspecialchars($attribute->getName()),htmlspecialchars($attribute->getName()),$input_disabled,$input_onclick);
echo '</tr>';
echo "\n\n";
} }
echo '</table>'; echo '</table>';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
printf('<input type="hidden" name="dn" value="%s" />',$entry['dn']['string']);
foreach ($entry['values']['new'] as $attr => $val) {
if (count($val) > 0) {
if (is_array($val)) {
foreach($val as $i => $v)
printf('<input type="hidden" name="update_array[%s][%s]" value="%s" />',
htmlspecialchars($attr),$i,htmlspecialchars($v));
} else {
printf('<input type="hidden" name="update_array[%s]" value="%s" />',
htmlspecialchars($attr),htmlspecialchars($val));
}
} else {
printf('<input type="hidden" name="update_array[%s]" value="" />',
htmlspecialchars($attr));
}
}
echo '<br />'; echo '<br />';
printf('<input type="submit" value="%s" />',_('Commit')); printf('<input type="submit" value="%s" />',_('Commit'));
printf('<input type="submit" name="cancel" value="%s" />',_('Cancel')); printf('<input type="submit" name="cancel" value="%s" />',_('Cancel'));
echo '</form>'; echo '</form>';
echo '<br />';
if (count($attr_to_delete) > 0) { if (count($request['template']->getForceDeleteAttrs()) > 0) {
echo '<table class="result_table"><tr>'; echo '<table class="result_table"><tr>';
printf('<td class="heading">%s%s</td>',_('The deletion of objectClass(es)'),_(':')); printf('<td class="heading">%s:</td>',_('The deletion of objectClass(es)'));
printf('<td class="value"><b>%s</b></td>',implode('</b>, <b>', $oc_to_delete)); printf('<td class="value"><b>%s</b></td>',implode('</b>, <b>',$request['template']->getAttribute('objectclass')->getRemovedValues()));
echo '</tr><tr>'; echo '</tr><tr>';
printf('<td class="heading">%s%s</td>',_('will delete the attribute(s)'),_(':')); printf('<td class="heading">%s:</td>',_('will delete the attribute(s)'));
echo '<td class="value"><b>'; echo '<td class="value"><b>';
$i = 0; $i = 0;
foreach ($attr_to_delete as $attr) { foreach ($request['template']->getForceDeleteAttrs() as $attribute) {
if ($i++ != 0) echo '</b>, <b>'; if ($i++ != 0)
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attr); echo '</b>, <b>';
echo $_SESSION[APPCONFIG]->getFriendlyHTML($attribute);
} }
echo '</b></td></tr></table>'; echo '</b></td></tr></table>';
} }
@ -326,7 +166,7 @@ if (count($entry['values']['new']) > 0) {
echo '<center>'; echo '<center>';
echo _('You made no changes'); echo _('You made no changes');
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',
$ldapserver->server_id,$entry['dn']['encode']); $app['server']->getIndex(),rawurlencode($request['dn']));
printf(' <a href="%s">%s</a>.',htmlspecialchars($href),_('Go back')); printf(' <a href="%s">%s</a>.',htmlspecialchars($href),_('Go back'));
echo '</center>'; echo '</center>';

View File

@ -1,39 +1,79 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/view_jpeg_photo.php,v 1.11.2.3 2008/12/12 12:20:22 wurley Exp $ // $Header$
/** /**
* This script will display the contents of the jpegPhoto attribute to the browser.
* A server ID and DN must be provided in the GET attributes.
* Optionally an attr name, index, type and filename can be supplied.
*
* @package phpLDAPadmin * @package phpLDAPadmin
* @subpackage Page
*/ */
/** /**
*/ */
require './common.php'; require './common.php';
$file = array(); $request = array();
$file['name'] = get_request('file','GET'); $request['dn'] = get_request('dn','GET');
$request['attr'] = strtolower(get_request('attr','GET',false,'jpegphoto'));
$request['index'] = get_request('index','GET',false,0);
$request['type'] = get_request('type','GET',false,'image/jpeg');
$request['filename'] = get_request('filename','GET',false,sprintf('%s.jpg',get_rdn($request['dn'],true)));
$request['location'] = get_request('location','GET',false,'ldap');
/* Security check (we don't want anyone tryting to get at /etc/passwd or something) switch ($request['location']) {
* Slashes and dots are not permitted in these names. case 'session':
*/ if (isset($_SESSION['tmp'][$request['attr']][$request['index']])) {
if (! preg_match('/^pla/',$file['name']) || preg_match('/[\.\/\\\\]/',$file['name'])) $jpeg_data = $_SESSION['tmp'];
error(sprintf('%s: %s',_('Unsafe file name'),htmlspecialchars($file['name'])),'error','index.php'); unset($_SESSION['tmp'][$request['attr']][$request['index']]);
}
/* Little security measure here (prevents users from accessing break;
files, like /etc/passwd for example).*/
$file['name'] = basename(addcslashes($file['name'],'/\\'));
$file['name'] = sprintf('%s/%s',$_SESSION[APPCONFIG]->GetValue('jpeg','tmpdir'),$file['name']);
if (! file_exists($file['name']))
error(sprintf('%s%s %s',_('No such file'),_(':'),htmlspecialchars($file['name'])),'error','index.php');
$file['handle'] = fopen($file['name'],'r'); case 'ldap':
$file['data'] = fread($file['handle'],filesize($file['name'])); default:
fclose($file['handle']); $jpeg_data = $app['server']->getDNAttrValues($request['dn'],null,LDAP_DEREF_NEVER,array($request['attr']));
break;
}
if (! isset($jpeg_data[$request['attr']][$request['index']])) {
if (function_exists('imagecreate')) {
$im = imagecreate(160,30);
if (is_resource($im)) {
header('Content-type: image/png');
# Set the background
imagecolorallocatealpha($im,0xFC,0xFC,0xFE,127);
$text_color = imagecolorallocate($im,0,0,0);
imagestring($im,4,3,5,_('Image not available'),$text_color);
imagepng($im);
imagedestroy($im);
die();
}
}
# We cant display an error, but we can set a system message, which will be display on the next page render.
system_message(array(
'title'=>_('No image available'),
'body'=>sprintf(_('Could not fetch jpeg data from LDAP server for attribute [%s].'),$request['attr']),
'type'=>'warn'));
die();
}
if (! is_array($jpeg_data[$request['attr']]))
$jpeg_data[$request['attr']] = array($jpeg_data[$request['attr']]);
$obStatus = ob_get_status(); $obStatus = ob_get_status();
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status']) if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
ob_end_clean(); ob_end_clean();
Header('Content-type: image/jpeg'); header(sprintf('Content-type: %s',$request['type']));
Header('Content-disposition: inline; filename=jpeg_photo.jpg'); header(sprintf('Content-disposition: inline; filename="%s"',$request['filename']));
echo $file['data']; echo $jpeg_data[$request['attr']][$request['index']];
die();
?> ?>

View File

@ -1,12 +1,14 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/welcome.php,v 1.26.2.4 2008/12/12 08:41:30 wurley Exp $ // $Header$
/**
* @package phpLDAPadmin
*/
/** /**
* Show a simple welcome page. * Show a simple welcome page.
*
* @package phpLDAPadmin
* @subpackage Page
*/
/**
*/ */
require './common.php'; require './common.php';
@ -20,20 +22,17 @@ echo '<br /><br />';
$links = ''; $links = '';
if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links')) { if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links','credits'))
if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'credits')) { $links .= sprintf('<a href="%s" target="_blank">%s</a>',get_href('credits'),_('Credits'));
$links .= sprintf('<a href="%s" target="new">%s</a>',get_href('credits'),_('Credits'));
}
if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'help')) { if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links','help')) {
if ($links) $links .= ' | '; if ($links) $links .= ' | ';
$links .= sprintf('<a href="%s" target="new">%s</a>',get_href('documentation'),_('Documentation')); $links .= sprintf('<a href="%s" target="_blank">%s</a>',get_href('documentation'),_('Documentation'));
} }
if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links', 'donation')) { if ($_SESSION[APPCONFIG]->isCommandAvailable('external_links','donation')) {
if ($links) $links .= ' | '; if ($links) $links .= ' | ';
$links .= sprintf('<a href="%s" target="new">%s</a>',get_href('donate'),_('Donate')); $links .= sprintf('<a href="%s" target="_blank">%s</a>',get_href('donate'),_('Donate'));
}
} }
if ($links) { if ($links) {

View File

@ -1,5 +1,5 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/index.php,v 1.2.2.1 2007/12/21 12:11:55 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * @package phpLDAPadmin

View File

@ -1,135 +1,163 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/AJAXTree.php,v 1.2.2.2 2008/12/12 06:46:15 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * Classes and functions for the LDAP tree.
*
* @author The phpLDAPadmin development team * @author The phpLDAPadmin development team
* @author Xavier Bruyet * @package phpLDAPadmin
*/ */
class AJAXTree extends PLMTree {
/**
* This class implements an AJAX based tree.
*
* @package phpLDAPadmin
* @subpackage Tree
* @see HTMLTree Tree
*/
class AJAXTree extends HTMLTree {
/** /**
* draw a node of the tree * Draw a node of the tree
* @param $level a string of 0 and 1 ; $level == "000101" will draw " | |<node>" *
* @param $first_child is this the first child ? * @param dn The Base DN to draw
* @param $last_child is this the last child ? * @param string $level a string of 0 and 1 ; $level == "000101" will draw " | |<node>"
* @param boolean $first_child is the first child entry, which is normally the "Create New Entry" option
* @param boolean $last_child is the last child entry, which is normally the "Create New Entry" option
*/ */
protected function draw_dn($dn,$level=0,$first_child=true,$last_child=true) { protected function draw_dn($dn,$level,$first_child=true,$last_child=true) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$dn,$level); debug_log('Entered with (%s,%s,%s,%s)',33,__FILE__,__LINE__,__METHOD__,$dn,$level,$first_child,$last_child);
$ldapserver = $this->getLdapServer(); $server = $this->getServer();
# level pre-treatment # Level pre-treatment
$code = ''; $code = '';
if (is_string($level)) { if (is_string($level)) {
for ($i=0; $i<strlen($level); $i++) { for ($i=0; $i<strlen($level); $i++) {
if ($level[$i] == '0') { if ($level[$i] == '0')
$code .= '0'; $code .= '0';
elseif ($level[$i] == '1')
} elseif ($level[$i] == '1') {
$code .= '1'; $code .= '1';
} }
}
} elseif ($level > 0) { } elseif ($level > 0)
$code = '0' * $level; $code = '0' * $level;
}
$level = strlen($code); $level = strlen($code);
# get entry to display as node # Get entry to display as node
$entry = $this->getEntry($dn); $entry = $this->getEntry($dn);
# If the entry doesnt exist, we'll add it.
if (! $entry) { if (! $entry) {
$this->addEntry($dn); $this->addEntry($dn);
$entry = $this->getEntry($dn); $entry = $this->getEntry($dn);
} }
# If the entry doesnt exist in the server, then return here with an empty string.
if (! $entry) if (! $entry)
return ''; return '';
# some informations # Get our children.
$rdn = $entry->getRdn(); $child_count = $this->readChildrenNumber($dn);
$encoded_dn = rawurlencode($dn);
$formatted_dn = $this->get_formatted_dn($entry,$level-1);
$child_count = $this->get_children_number($entry);
$nb = 0; $nb = 0;
if ($first_child) $nb += 1; if ($first_child)
if ($last_child) $nb += 2; $nb += 1;
if ($last_child)
$nb += 2;
# informations array[$nb] $imgs['expand'] = array(JSDIR.'phplayersmenu/menuimages/tree_expand.png',
# nb == 1 => the node is the first child JSDIR.'phplayersmenu/menuimages/tree_expand.png',
# nb == 2 => the node is the last child JSDIR.'phplayersmenu/menuimages/tree_expand_corner.png',
# nb == 3 => the node is the unique child ($level > 0) ? JSDIR.'phplayersmenu/menuimages/tree_expand_corner.png' : JSDIR.'phplayersmenu/menuimages/tree_expand_corner_first.png');
# nb == 0 => the node is a child
$expand_imgs = array('js/phplayersmenu/menuimages/tree_expand.png', 'js/phplayersmenu/menuimages/tree_expand.png', 'js/phplayersmenu/menuimages/tree_expand_corner.png', ($level > 0) ? 'js/phplayersmenu/menuimages/tree_expand_corner.png' : 'js/phplayersmenu/menuimages/tree_expand_corner_first.png');
$collapse_imgs = array('js/phplayersmenu/menuimages/tree_collapse.png', 'js/phplayersmenu/menuimages/tree_collapse.png', 'js/phplayersmenu/menuimages/tree_collapse_corner.png', ($level > 0) ? 'js/phplayersmenu/menuimages/tree_collapse_corner.png' : 'js/phplayersmenu/menuimages/tree_collapse_corner_first.png');
$tree_imgs = array('js/phplayersmenu/menuimages/tree_split.png', 'js/phplayersmenu/menuimages/tree_split.png', 'js/phplayersmenu/menuimages/tree_corner.png', 'js/phplayersmenu/menuimages/tree_corner.png');
$new_code = array('1', '1', '0', '0');
# links $imgs['collapse'] = array(JSDIR.'phplayersmenu/menuimages/tree_collapse.png',
$edit_href_params = htmlspecialchars(sprintf('cmd=template_engine&server_id=%s&dn=%s',$this->server_id,$encoded_dn)); JSDIR.'phplayersmenu/menuimages/tree_collapse.png',
$edit_href = "cmd.php?$edit_href_params"; JSDIR.'phplayersmenu/menuimages/tree_collapse_corner.png',
$openclose_params = htmlspecialchars(sprintf('server_id=%s&dn=%s&code=%s',$this->server_id,$encoded_dn,$code.$new_code[$nb])); ($level > 0) ? JSDIR.'phplayersmenu/menuimages/tree_collapse_corner.png' : JSDIR.'phplayersmenu/menuimages/tree_collapse_corner_first.png');
# each node has a unique id based on dn $imgs['tree'] = array(JSDIR.'phplayersmenu/menuimages/tree_split.png',
$node_id = 'node'.base64_encode($ldapserver->server_id.'-'.$dn); JSDIR.'phplayersmenu/menuimages/tree_split.png',
JSDIR.'phplayersmenu/menuimages/tree_corner.png',
JSDIR.'phplayersmenu/menuimages/tree_corner.png');
/** Information on array[$nb]
* nb == 1 => the node is the first child
* nb == 2 => the node is the last child
* nb == 3 => the node is the unique child
* nb == 0 => the node is a child */
$new_code = array('1','1','0','0');
# Links
$parms['openclose'] = htmlspecialchars(sprintf('server_id=%s&dn=%s&code=%s%s',$this->getServerID(),rawurlencode($dn),$code,$new_code[$nb]));
$parms['edit'] = htmlspecialchars(sprintf('cmd=template_engine&server_id=%s&dn=%s',$this->getServerID(),rawurlencode($dn)));
$href = sprintf('cmd.php?%s',$parms['edit']);
# Each node has a unique id based on dn
$node_id = sprintf('node%s',base64_encode(sprintf('%s-%s',$server->getIndex(),$dn)));
$node_id = str_replace('=','_',$node_id); $node_id = str_replace('=','_',$node_id);
if ($level == 0) if ($level == 0)
printf('<tr><td class="spacer"></td><td colspan="%s">',$this->getDepth()+3-1); printf('<tr><td class="spacer"></td><td colspan="%s">',$this->getDepth()+3-1);
printf('<div id="jt%s" class="treemenudiv">',$node_id); printf('<div id="jt%s" class="treemenudiv">',$node_id);
echo $this->get_indentation($code); echo $this->get_indentation($code);
if ($entry->isOpened()) { if (! $child_count)
if (! $child_count) { printf('<img align="top" border="0" class="imgs" id="jt%snode" src="%s" alt="--" />',$node_id,$imgs['tree'][$nb]);
echo '<img align="top" border="0" class="imgs" id="jt'.$node_id.'node" src="'.$tree_imgs[$nb].'" alt="--" />';
} else { else {
echo '<a href="#" onclick="return opencloseTreeNode(\''.$node_id.'\',\''.$openclose_params.'\');">'; printf('<a href="#" onclick="return opencloseTreeNode(\'%s\',\'%s\');">',$node_id,$parms['openclose']);
echo '<img align="top" border="0" class="imgs" id="jt'.$node_id.'node" src="'.$collapse_imgs[$nb].'" alt="+-" />';
if ($entry->isOpened())
printf('<img align="top" border="0" class="imgs" id="jt%snode" src="%s" alt="+-" />',$node_id,$imgs['collapse'][$nb]);
else
printf('<img align="top" border="0" class="imgs" id="jt%snode" src="%s" alt="+-" />',$node_id,$imgs['expand'][$nb]);
echo '</a>'; echo '</a>';
} }
} else { printf('<a href="%s" onclick="return displayAJ(\'BODY\',\'%s\',\'%s\');" title="%s" >',$href,$parms['edit'],_('Retrieving DN'),htmlspecialchars($dn));
if (($child_count !== false) && (!$child_count)/* && (!$ldapserver->isShowCreateEnabled())*/) { printf('<span class="dnicon"><img align="top" border="0" class="imgs" id="jt%sfolder" src="%s/%s" alt="->" /></span>',$node_id,IMGDIR,$entry->getIcon($server));
echo '<img align="top" border="0" class="imgs" id="jt'.$node_id.'node" src="'.$tree_imgs[$nb].'" alt="--" />';
} else {
echo '<a href="#" onclick="return opencloseTreeNode(\''.$node_id.'\',\''.$openclose_params.'\');">';
echo '<img align="top" border="0" class="imgs" id="jt'.$node_id.'node" src="'.$expand_imgs[$nb].'" alt="+-" />';
echo '</a>'; echo '</a>';
}
}
echo '<a href="'.$edit_href.'" onclick="return displayMainPage(\''.$edit_href_params.'\');" title="'.$dn.'" >';
printf('<img align="top" border="0" class="imgs" id="jt%sfolder" src="%s/%s" alt="->" />',$node_id,IMGDIR,$entry->getIcon($ldapserver));
echo '</a>';
echo '&nbsp;'; echo '&nbsp;';
echo '<a href="'.$edit_href.'" onclick="return displayMainPage(\''.$edit_href_params.'\');" title="'.$dn.'" class="phplm">'; printf('<a href="%s" onclick="return displayAJ(\'BODY\',\'%s\',\'%s\');" title="%s" class="phplm">',$href,$parms['edit'],_('Retrieving DN'),htmlspecialchars($dn));
echo $formatted_dn; echo $this->get_formatted_dn($entry,$level-1);
echo ($child_count ? ' ('.$child_count.')' : ''); echo ($child_count ? (sprintf(' (%s%s)',$child_count,($entry->isSizeLimited() ? '+' : ''))) : '');
echo '</a>'; echo '</a>';
echo '</div>';
echo '<div id="jt'.$node_id.'son" style="display: '.($entry->isOpened() ? 'block' : 'none').'" class="treemenudiv">';
if ($entry->isOpened()) {
$this->draw_children($entry,$code.$new_code[$nb]);
}
echo '</div>'; echo '</div>';
if ($level == 0) { printf('<div id="jt%sson" style="display: %s" class="treemenudiv">',$node_id,($entry->isOpened() ? 'block' : 'none'));
if ($entry->isOpened())
$this->draw_children($entry,$code.$new_code[$nb]);
echo '</div>';
if ($level == 0)
echo '</td></tr>'; echo '</td></tr>';
} }
}
/**
* Expand and draw a child entry, when it is clicked on. This is using AJAX just to render this section of the tree.
*/
public function draw_children($parent_entry,$code) { public function draw_children($parent_entry,$code) {
if (DEBUG_ENABLED) if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$parent_entry,$code); debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$parent_entry,$code);
$children = array(); $children = array();
foreach($parent_entry->getChildren() as $childDn) foreach ($parent_entry->getChildren() as $child) {
$children[] = $this->getEntry($childDn); if (! $this->getEntry($child))
$this->addEntry($child);
$first_child = $this->get_plm_before_first_child($parent_entry,$code); array_push($children,$this->getEntry($child));
$last_child = $this->get_plm_after_last_child($parent_entry,$code); }
$first_child = $this->create_before_child($parent_entry,$code);
$last_child = $this->create_after_child($parent_entry,$code);
# If compression is on, we need to compress this output - but only if called by draw_tree_node # If compression is on, we need to compress this output - but only if called by draw_tree_node
if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node') if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node')
@ -141,7 +169,12 @@ class AJAXTree extends PLMTree {
$first = ($i == 0) && (! $first_child); $first = ($i == 0) && (! $first_child);
$last = ($i == (count($children)-1)) && (! $last_child); $last = ($i == (count($children)-1)) && (! $last_child);
$this->draw_dn($children[$i]->getDn(),$code,$first,$last); if (is_object($children[$i]))
$this->draw_dn($children[$i]->getDN(),$code,$first,$last);
else
echo '<br/>problem getting DN entry from ldap';
echo "\n";
} }
echo $last_child; echo $last_child;
@ -154,232 +187,110 @@ class AJAXTree extends PLMTree {
} }
/** /**
* return the indentation bafore a node * Return the indentation before a node
*
* @param $code a string of 0 and 1 ; $code == "000101" will return " | |" * @param $code a string of 0 and 1 ; $code == "000101" will return " | |"
*/ */
protected function get_indentation($code) { protected function get_indentation($code) {
$indent = ''; $indent = '';
for ($i=0; $i<strlen($code); $i++) {
if ($code[$i] == '0') {
$indent .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_space.png" alt=" " />';
} elseif ($code[$i] == '1') { for ($i=0; $i<strlen($code); $i++) {
$indent .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_vertline.png" alt="| " />'; switch ($code[$i]) {
case '0':
$indent .= sprintf('<img align="top" border="0" class="imgs" src="%s/phplayersmenu/menuimages/tree_space.png" alt=" " />',JSDIR);
break;
case '1':
$indent .= sprintf('<img align="top" border="0" class="imgs" src="%s/phplayersmenu/menuimages/tree_vertline.png" alt="| " />',JSDIR);
break;
} }
} }
return $indent; return $indent;
} }
/**
* Draw the javascript to support the tree.
*/
protected function draw_javascript() { protected function draw_javascript() {
echo ' printf('<script type="text/javascript" language="javascript" src="%sphplayersmenu/libjs/layersmenu-browser_detection.js"></script>',JSDIR);
<script type="text/javascript" language="javascript" src="js/phplayersmenu/libjs/layersmenu-browser_detection.js"></script> printf('<script type="text/javascript" language="javascript" src="%sajaxtree.js"></script>',JSDIR);
<script type="text/javascript" language="javaScript">
<!--
var collapsedNodes = new Array();
var nodeLayer = null;
var sonLayer = null;
var oldstyle = \'\';
var newstyle = \'\';
var oldimg = \'\';
var newimg = \'\';
function readCollapsedNodes() {
collapsedNodes = new Array();
cn = document.cookie.split(\'collapsedNodes=\');
if (cn.length < 2) return;
vl = cn[1];
if (vl.indexOf(\';\') != -1) {
vl = vl.split(\';\');
vl = vl[0];
}
if (vl) {
collapsed = vl.split(\'|\');
for (i = 0; i < collapsed.length; i++) {
collapsedNodes[i] = collapsed[i];
}
}
}
function writeCollapsedNodes() {
document.cookie = \'collapsedNodes=\' + collapsedNodes.join(\'|\') + \';path=/\';
}
function addCollapsedNode(nodeId) {
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] == nodeId) return;
}
collapsedNodes[collapsedNodes.length] = nodeId;
writeCollapsedNodes();
}
function delCollapsedNode(nodeId) {
newCollapsedNodes = new Array();
j = 0;
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] != nodeId) {
newCollapsedNodes[j++] = collapsedNodes[i];
}
}
collapsedNodes = newCollapsedNodes;
writeCollapsedNodes();
}
function updateNewStyle() {
nodeLayer.src = newimg;
sonLayer.style.display = newstyle;
}
function cancelNewStyle() {
nodeLayer.src = oldimg;
sonLayer.style.display = oldstyle;
}
function alertTreeNodeContents(html) {
//alert(html);
if (html.replace(/(^\s*)|(\s*$)/g, \'\')) {
includeHTML(sonLayer, html);
}
updateNewStyle();
}
function opencloseTreeNode(nodeid, params) {
cancelHttpRequest(); // cancel last request
// get the node element
if ((!DOM || Opera56 || Konqueror22) && !IE4) return;
if (!IE4) {
sonLayer = document.getElementById(\'jt\' + nodeid + \'son\');
nodeLayer = document.getElementById(\'jt\' + nodeid + \'node\');
//folderLayer = document.getElementById(\'jt\' + nodeid + \'folder\');
} else {
sonLayer = document.all(\'jt\' + nodeid + \'son\');
nodeLayer = document.all(\'jt\' + nodeid + \'node\');
//folderLayer = document.all(\'jt\' + nodeid + \'folder\');
}
if (!sonLayer || !nodeLayer) return false;
// update global variables
oldstyle = sonLayer.style.display;
oldimg = nodeLayer.src;
var action = 0; // (action = 1) => expand ; (action = 2) => collapse
if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_expand.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_collapse.png\';
action = 1;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_expand_first.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_collapse_first.png\';
action = 1;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_expand_corner.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_collapse_corner.png\';
action = 1;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_expand_corner_first.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_collapse_corner_first.png\';
action = 1;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_collapse.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_expand.png\';
action = 2;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_collapse_first.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_expand_first.png\';
action = 2;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_collapse_corner.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_expand_corner.png\';
action = 2;
} else if (oldimg.indexOf(\'js/phplayersmenu/menuimages/tree_collapse_corner_first.png\') > -1) {
newimg = \'js/phplayersmenu/menuimages/tree_expand_corner_first.png\';
action = 2;
}
//folderLayer.src = \'js/phplayersmenu/menuimages/tree_folder_open.png\';
//folderLayer.src = \'js/phplayersmenu/menuimages/tree_folder_closed.png\';
nodeLayer.src = \''.IMGDIR.'ajax-spinner.gif\';
// perform action
if (action == 2) {
newstyle = \'none\';
//makeGETRequest(\'cmd.php\', params+\'&cmd=draw_tree_node&action=0\', \'alertTreeNodeContents\', \'cancelNewStyle\');
updateNewStyle();
addCollapsedNode(nodeid);
} else if (action == 1) {
newstyle = \'block\';
if (sonLayer.innerHTML == \'\') {
makeGETRequest(\'cmd.php\', params+\'&cmd=draw_tree_node&action=1\', \'alertTreeNodeContents\', \'cancelNewStyle\');
} else {
//makeGETRequest(\'cmd.php\', params+\'&cmd=draw_tree_node&action=2\', \'alertTreeNodeContents\', \'cancelNewStyle\');
updateNewStyle();
}
delCollapsedNode(nodeid);
}
return false;
}
function getMainPageDiv() {
if (!IE4) {
return document.getElementById(\'main_page\');
} else {
return document.all(\'main_page\');
}
}
function alertMainPage(html) {
//alert(html);
var mainPageDiv = getMainPageDiv();
if (mainPageDiv) includeHTML(mainPageDiv, html);
}
function cancelMainPage() {
var mainPageDiv = getMainPageDiv();
if (mainPageDiv) includeHTML(mainPageDiv, \'\');
}
function displayMainPage(urlParameters) {
var mainPageDiv = getMainPageDiv();
if (mainPageDiv) includeHTML(mainPageDiv, \'<img src="'.IMGDIR.'ajax-progress.gif"><br><small>'._('Retrieving DN').'...<\/small>\');
makeGETRequest(\'cmd.php\', urlParameters+\'&meth=get_body\', \'alertMainPage\', \'cancelMainPage\');
return false;
} }
// close initial collapsed nodes /**
readCollapsedNodes(); * Draw the "Create New Entry" item before the children.
for (k = 0; k < collapsedNodes.length; k++) { */
opencloseTreeNode(collapsedNodes[k], \'#\'); private function create_before_child($entry,$level) {
} if (strlen($level) == 0)
// --> return '';
</script>';
}
protected function get_plm_before_first_child($entry,$level) { $server = $this->getServer();
if (strlen($level) == 0) return '';
$ldapserver = $this->getLdapServer();
$output = ''; $output = '';
if (!$ldapserver->isReadOnly() && ($entry->getChildrenNumber() > 10) && ($ldapserver->isShowCreateEnabled())) { if (! $server->isReadOnly() && ! $entry->isLeaf() && (count($entry->getChildren()) > 10) && $this->getServer()->isShowCreateEnabled()
$encoded_dn = rawurlencode($entry->getDn()); && $_SESSION[APPCONFIG]->getValue('appearance','show_top_create'))
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$ldapserver->server_id,$encoded_dn); $output = $this->draw_create_new_entry($entry,$level,JSDIR.'phplayersmenu/menuimages/tree_split.png');
$output .= $this->get_indentation($level);
$output .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_split.png" alt="--" />';
$output .= '<a href="'.htmlspecialchars($href).'" title="'.$entry->getDn().'">';
$output .= sprintf('<img align="top" border="0" class="imgs" src="%s/star.png" alt="->" />',IMGDIR);
$output .= '</a>';
$output .= '&nbsp;';
$output .= '<a href="'.htmlspecialchars($href).'" title="'._('Create new entry here').'" class="phplm">';
$output .= _('Create new entry here');
$output .= '</a>';
}
return $output; return $output;
} }
protected function get_plm_after_last_child($entry,$level) { /**
if (strlen($level) == 0) return ''; * Draw the "Create New Entry" item after the children.
*/
private function create_after_child($entry,$level) {
if (strlen($level) == 0)
return '';
$ldapserver = $this->getLdapServer(); $server = $this->getServer();
$output = ''; $output = '';
if (!$ldapserver->isReadOnly() && !$entry->isLeaf() && $ldapserver->isShowCreateEnabled()) { if (! $server->isReadOnly() && ! $entry->isLeaf() && $this->getServer()->isShowCreateEnabled())
$encoded_dn = rawurlencode($entry->getDn()); $output = $this->draw_create_new_entry($entry,$level,JSDIR.'phplayersmenu/menuimages/tree_corner.png');
$href = sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$ldapserver->server_id,$encoded_dn);
return $output;
}
/**
* Draw the "Create New Entry" item.
*/
private function draw_create_new_entry($entry,$level,$img) {
$output = '';
$href = sprintf('cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),rawurlencode($entry->getDN()));
$output .= $this->get_indentation($level); $output .= $this->get_indentation($level);
$output .= '<img align="top" border="0" class="imgs" src="js/phplayersmenu/menuimages/tree_corner.png" alt="--" />'; $output .= sprintf('<img align="top" border="0" class="imgs" src="%s" alt="--" />',$img);
$output .= '<a href="'.htmlspecialchars($href).'" title="'.$entry->getDn().'">'; $output .= sprintf('<a href="%s" title="%s">',htmlspecialchars($href),$entry->getDN());
$output .= sprintf('<img align="top" border="0" class="imgs" src="%s/star.png" alt="->" />',IMGDIR); $output .= sprintf('<img align="top" border="0" class="imgs" src="%s/star.png" alt="->" />',IMGDIR);
$output .= '</a>'; $output .= '</a>';
$output .= '&nbsp;'; $output .= '&nbsp;';
$output .= '<a href="'.htmlspecialchars($href).'" title="'._('Create new entry here').'" class="phplm">';
if (isAjaxEnabled())
$output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm" onclick="return displayAJ(\'BODY\',\'%s\',\'%s\');">',
htmlspecialchars($href),_('Create new entry here'),
htmlspecialchars($href),_('Loading'));
else
$output .= sprintf('<a href="cmd.php?%s" title="%s" class="phplm">',htmlspecialchars($href),_('Create new entry here'));
$output .= _('Create new entry here'); $output .= _('Create new entry here');
$output .= '</a>'; $output .= '</a>';
}
return $output; return $output;
} }
/**
* List the items in the tree that are open
*
* @return array List of open nodes
*/
public function listOpenItems() {
$result = array();
foreach ($this->entries as $dn => $value)
if ($value->isOpened())
array_push($result,$value->getDN());
return $result;
}
} }
?> ?>

View File

@ -1,95 +1,227 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Attribute.php,v 1.2.2.3 2008/11/28 23:26:51 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * Classes and functions for the template engine.
* @author Xavier Bruyet
* *
* Represents an attribute of a entry * @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/**
* Represents an attribute of a template.
*
* @package phpLDAPadmin
* @subpackage Templates
*/ */
class Attribute { class Attribute {
private $name; # Attribute Name
private $values; public $name;
# Source of this attribute definition
protected $source;
# min/max number of values # Current and Old Values
protected $min_value_count; protected $oldvalues = array();
protected $max_value_count; protected $values = array();
# The entry in which the attribute is # MIN/MAX number of values
protected $entry; protected $min_value_count = -1;
protected $max_value_count = -1;
# Is the attribute internal # Is the attribute internal
protected $internal; protected $internal = false;
# Has the attribute been modified # Has the attribute been modified
protected $modified; protected $modified = false;
# Is the attribute being deleted because of an object class removal
protected $forcedelete = false;
# Is the attribute visible # Is the attribute visible
protected $visible; protected $visible = false;
protected $forcehide = false;
# Is the attribute modifiable # Is the attribute modifiable
protected $readonly; protected $readonly = false;
# LDAP attribute type MUST/MAY
protected $ldaptype = null;
# Attribute property type (eg password, select, multiselect)
protected $type = '';
# Attribute value to keep unique
protected $unique = false;
# Display parameters # Display parameters
protected $friendly_name; protected $display = '';
protected $description; protected $icon = '';
protected $icon; protected $hint = '';
protected $hint; # Helper details
protected $helper = array();
protected $helpervalue = array();
# Onchange details
protected $onchange = array();
# Show spacer after this attribute is rendered
protected $spacer = false;
protected $verify = false;
protected $size; # Component size # Component size
protected $maxlength; # Value max length protected $size = 0;
# Value max length
protected $maxlength = 0;
# Text Area sizings
protected $cols = 0;
protected $rows = 0;
protected $properties; # Public for sorting
public $page = 1;
public $order = 255;
public $ordersort = 255;
public $rdn = false;
public function __construct($name, $values) { # Schema Aliases for this attribute (stored in lowercase)
protected $aliases = array();
# Configuration for automatically generated values
protected $autovalue = array();
protected $postvalue = array();
public function __construct($name,$values,$server_id,$source=null) {
$server = $_SESSION[APPCONFIG]->getServer($server_id);
$sattr = $server->getSchemaAttribute($name);
if ($sattr) {
$this->name = $sattr->getName(false);
$this->setLDAPdetails($sattr);
} else
$this->name = $name; $this->name = $name;
if (is_string($values) && (strlen($values) > 0)) $this->values = array($values); $this->source = $source;
elseif (is_array($values)) $this->values = $values;
else $this->values = array();
$this->min_value_count = -1; # XML attributes are shown by default
$this->max_value_count = -1; switch ($source) {
case 'XML': $this->show();
$this->setXML($values);
$this->entry = null; break;
$this->internal = false;
$this->modified = false;
$this->visible = true;
$this->readonly = false;
$this->friendly_name = ''; default:
$this->description = ''; if (! isset($values['values']))
$this->icon = ''; debug_dump_backtrace('no index "values"',1);
$this->hint = '';
$this->size = 0; $this->initValue($values['values']);
$this->maxlength = 0;
$this->properties = array();
} }
public function getName() { # Should this attribute be hidden
return $this->name; if ($server->isAttrHidden($this->name))
$this->forcehide = true;
# Should this attribute value be read only
if ($server->isAttrReadOnly($this->name))
$this->readonly = true;
# Should this attribute value be unique
if ($server->isAttrUnique($this->name))
$this->unique = true;
}
/**
* Return the name of the attribute.
*
* @param boolean $lower - Return the attribute in normal or lower case (default lower)
* @param boolean $real - Return the real attribute name (with ;binary, or just the name)
* @return string Attribute name
*/
public function getName($lower=true,$real=false) {
if ($real)
return $lower ? strtolower($this->name) : $this->name;
else
return $lower ? strtolower($this->real_attr_name()) : $this->real_attr_name();
} }
public function getValues() { public function getValues() {
return $this->values; return $this->values;
} }
public function getOldValues() {
return $this->oldvalues;
}
public function getValueCount() { public function getValueCount() {
return count($this->values); return count($this->values);
} }
public function addValue($new_val, $i = -1) { /**
if ($i < 0) $i = $this->getValueCount(); * Autovalue is called after the attribute is initialised, and thus the values from the ldap server will be set.
*/
public function autoValue($new_val) {
if ($this->values)
return;
$this->values = $new_val;
}
public function initValue($new_val) {
if ($this->values || $this->oldvalues) {
debug_dump(array('new_val'=>$new_val,'this'=>$this));
debug_dump_backtrace('new and/or old values are set',1);
}
$this->values = $new_val;
}
public function clearValue() {
$this->values = array();
}
public function setValue($new_val) {
if ($this->values) {
if ($this->oldvalues && ($new_val != $this->values)) {
debug_dump($this);
debug_dump_backtrace('old values are set',1);
} else
$this->oldvalues = $this->values;
}
if ($new_val == $this->values)
return;
$this->values = $new_val;
$this->justModified();
}
public function addValue($new_val,$i=-1) {
if ($i < 0)
$i = $this->getValueCount();
$old_val = $this->getValue($i); $old_val = $this->getValue($i);
if (is_null($old_val) || ($old_val != $new_val)) $this->justModified(); if (is_null($old_val) || ($old_val != $new_val))
$this->justModified();
$this->values[$i] = $new_val; $this->values[$i] = $new_val;
} }
public function delValue($i=-1) {
if ($i < 0)
$this->setValue(array());
if (! $this->hasBeenModified())
$this->oldvalues = $this->values;
if (isset($this->values[$i])) {
unset($this->values[$i]);
$this->values = array_values($this->values);
$this->justModified();
}
}
public function getValue($i) { public function getValue($i) {
if (isset($this->values[$i])) return ''.$this->values[$i]; if (isset($this->values[$i]))
else return null; return $this->values[$i];
else
return null;
}
public function getOldValue($i) {
if (isset($this->oldvalues[$i]))
return $this->oldvalues[$i];
else
return null;
} }
public function getMinValueCount() { public function getMinValueCount() {
@ -108,21 +240,11 @@ class Attribute {
$this->max_value_count = $max; $this->max_value_count = $max;
} }
public function getEntry() { public function haveMoreValues() {
return $this->entry; if ($this->getMaxValueCount() < 0 || ($this->getValueCount() < $this->getMaxValueCount()))
} return true;
else
public function setEntry($entry) { return false;
$this->entry = $entry;
global $ldapserver;
$schema_attr = null;
if ($entry) {
$schema_attr = $ldapserver->getSchemaAttribute($this->getName(), $entry->getDn());
}
if ($schema_attr && $schema_attr->getIsSingleValue()) {
$this->setMaxValueCount(1);
}
} }
public function justModified() { public function justModified() {
@ -133,6 +255,17 @@ class Attribute {
return $this->modified; return $this->modified;
} }
public function isForceDelete() {
return $this->forcedelete;
}
public function setForceDelete() {
$this->forcedelete = true;
$this->oldvalues = $this->values;
$this->values = array();
$this->justModified();
}
public function isInternal() { public function isInternal() {
return $this->internal; return $this->internal;
} }
@ -142,20 +275,75 @@ class Attribute {
} }
public function isRequired() { public function isRequired() {
if ($this->getMinValueCount() > 0) { if ($this->getMinValueCount() > 0)
return true; return true;
} elseif ($this->isRdn()) { elseif ($this->ldaptype == 'must')
return true; return true;
} else { elseif ($this->isRDN())
return true;
else
return false; return false;
} }
public function isMay() {
if (($this->ldaptype == 'may') && ! $this->isRequired())
return true;
else
return false;
}
public function setType($type) {
$this->type = strtolower($type);
}
public function getType() {
return $this->type;
}
public function setLDAPtype($type) {
$this->ldaptype = strtolower($type);
}
public function getLDAPtype() {
return $this->ldaptype;
}
public function setProperties($properties) {
foreach ($properties as $index => $value) {
if ($index == 'maxvalnb') {
$this->setMaxValueCount($value);
continue;
} elseif ($index == 'minvalnb') {
$this->setMinValueCount($value);
continue;
} elseif ($index == 'maxlength') {
$this->setMinValueCount($value);
continue;
} elseif ($index == 'hidden') {
$this->visible = $value;
continue;
} elseif (in_array($index,array('cols','rows'))) {
# @todo To be implemented
continue;
}
if (isset($this->$index))
$this->$index = $value;
else {
debug_dump($this);
debug_dump_backtrace(sprintf('Unknown property (%s) with value (%s) for (%s)',$index,$value,$this->getName()),1);
}
}
} }
public function setRequired() { public function setRequired() {
if ($this->getMinValueCount() <= 0) { if ($this->getMinValueCount() <= 0)
$this->setMinValueCount(1); $this->setMinValueCount(1);
} }
}
public function setOptional() { public function setOptional() {
$this->setMinValueCount(0); $this->setMinValueCount(0);
@ -170,7 +358,7 @@ class Attribute {
} }
public function isVisible() { public function isVisible() {
return $this->visible; return $this->visible && (! $this->forcehide);
} }
public function hide() { public function hide() {
@ -181,17 +369,15 @@ class Attribute {
$this->visible = true; $this->visible = true;
} }
public function setFriendlyName($name) { public function haveFriendlyName() {
if ($name != $this->name) { return $_SESSION[APPCONFIG]->haveFriendlyName($this);
$this->friendly_name = $name;
}
} }
public function getFriendlyName() { public function getFriendlyName() {
if ($this->friendly_name) if ($this->display)
return $this->friendly_name; return $this->display;
else else
return $_SESSION[APPCONFIG]->getFriendlyName(real_attr_name($this->name)); return $_SESSION[APPCONFIG]->getFriendlyName($this);
} }
public function setDescription($description) { public function setDescription($description) {
@ -234,36 +420,267 @@ class Attribute {
$this->size = $size; $this->size = $size;
} }
public function setProperty($name, $value) { public function getSpacer() {
$this->properties[$name] = $value; return $this->spacer;
} }
public function delProperty($name) { public function getPage() {
if ($this->hasProperty($name)) unset($this->properties[$name]); return $this->page;
}
public function setPage($page) {
$this->page = $page;
} }
public function hasProperty($name) { public function getOnChange() {
return isset($this->properties[$name]); return $this->onchange;
} }
public function getProperty($name) { public function getHelper() {
if ($this->hasProperty($name)) return $this->properties[$name]; return $this->helper;
else return null;
} }
public function isRdn() { public function getHelperValue() {
if ($this->entry) { return $this->helpervalue;
return (preg_grep('/'.$this->name.'/',$this->entry->getRdnAttributeName()));
} else {
return false;
} }
public function getVerify() {
return $this->verify;
}
public function setRDN($rdn) {
$this->rdn = $rdn;
} }
/** /**
* Visit the attribute * Return if this attribute is an RDN attribute
*
* @return boolean
*/ */
public function accept($visitor) { public function isRDN() {
$visitor->visit('', $this); return $this->rdn;
}
/**
* Capture all the LDAP details we are interested in
*
* @param sattr Schema Attribute
*/
private function setLDAPdetails($sattr) {
# By default, set this as a MAY attribute, later processing should make it a MUST attribute if it is.
if (! $this->ldaptype)
$this->ldaptype = 'may';
# Store our Aliases
foreach ($sattr->getAliases() as $alias)
array_push($this->aliases,strtolower($alias));
if ($sattr->getIsSingleValue())
$this->setMaxValueCount(1);
}
/**
* Return a list of aliases for this Attribute (as defined by the schema)
* This list will be lowercase.
*/
public function getAliases() {
return $this->aliases;
}
public function getAutoValue() {
return $this->autovalue;
}
public function getPostValue() {
return $this->postvalue;
}
public function setPostValue($postvalue) {
$this->postvalue = $postvalue;
}
public function setXML($values) {
# Mostly all the time, this should be an array
if (is_array($values))
foreach ($values as $index => $value)
switch ($index) {
# Helpers should be accompanied with a <post> attribute.
case 'helper':
if (! isset($values['post']))
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Missing [post] setting in XML file'),$index),
'body'=>_('[helper] needs an accompanying [post] action.'),
'type'=>'warn'));
if (isset($value['value']) && ! is_array($value['value']) && preg_match('/^=php\.(\w+)\((.*)\)$/',$value['value'],$matches)) {
$this->helpervalue['function'] = $matches[1];
$this->helpervalue['args'] = $matches[2];
unset ($value['value']);
}
foreach ($value as $i => $detail) {
if (! in_array($i,array('default','display','id','value'))) {
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$i),
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting for helper will be ignored.'),$detail),
'type'=>'warn'));
unset($value[$i]);
}
}
$this->$index = $value;
break;
case 'hidden': $value ? $this->visible = false : $this->visible = true;
break;
case 'spacer': $value ? $this->$index = true : $this->$index = false;
break;
# Essentially, we ignore type, it is used to select an Attribute type in the Factory. But we'll generated a warning if there is an unknown type.
case 'type':
if (! in_array($value,array('password','multiselect','select','textarea')))
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting will be ignored.'),$value),
'type'=>'warn'));
break;
case 'post':
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$value,$matches)) {
$this->postvalue['function'] = $matches[1];
$this->postvalue['args'] = $matches[2];
} else
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown XML type setting will be ignored.'),$value),
'type'=>'warn'));
case 'value':
if (is_array($value))
$this->values = $value;
else
# Check to see if the value is auto generated.
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$value,$matches)) {
$this->autovalue['function'] = $matches[1];
$this->autovalue['args'] = $matches[2];
# We'll add a hint too
if (! $this->hint)
$this->hint = _('Automatically determined');
} else
$this->values = array($value);
break;
# Queries
case 'ordersort':
# Creation/Editing Templates
case 'cols':
case 'default':
case 'display':
case 'hint':
case 'icon':
case 'maxlength':
case 'onchange':
case 'order':
case 'page':
case 'readonly':
case 'rows':
case 'size':
case 'verify': $this->$index = $value;
break;
default:
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown XML setting'),$index),
'body'=>sprintf('%s <small>[%s]</small>',_('Unknown attribute setting will be ignored.'),serialize($value)),
'type'=>'warn'));
}
elseif (is_string($values) && (strlen($values) > 0))
$this->values = array($values);
}
/**
* Display the values removed in an attribute.
*/
public function getRemovedValues() {
$return = array();
foreach ($this->getOldValues() as $value)
if (! in_array($value,$this->getValues()))
array_push($return,$value);
return $return;
}
/**
* Display the values removed in an attribute.
*/
public function getAddedValues() {
$return = array();
foreach ($this->getValues() as $value)
if (! in_array($value,$this->getOldValues()))
array_push($return,$value);
return $return;
}
/**
* Prunes off anything after the ";" in an attr name. This is useful for
* attributes that may have ";binary" appended to their names. With
* real_attr_name(), you can more easily fetch these attributes' schema
* with their "real" attribute name.
*
* @param string $attr_name The name of the attribute to examine.
* @return string
*/
private function real_attr_name() {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$attr_name);
return preg_replace('/;.*$/U','',$this->name);
}
/**
* Does this attribute need supporting JS
*/
public function needJS($type=null) {
if (is_null($type)) {
foreach (array('focus','blur','validate') as $type)
if ($this->needJS($type))
return true;
return false;
} elseif ($type == 'focus') {
# We dont have any focus javascript routines.
return false;
} elseif ($type == 'blur') {
if ($this->onchange || $this->isRequired())
return true;
else
return false;
} elseif ($type == 'validate') {
if ($this->isRequired())
return true;
else
return false;
} else
debug_dump_backtrace(sprintf('Unknown JS request %s',$type),1);
} }
} }
?> ?>

View File

@ -1,104 +1,183 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/AttributeFactory.php,v 1.2.2.1 2007/12/26 09:26:33 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin
* @author Xavier Bruyet
*
* Allows to create new attributes * Allows to create new attributes
*
* @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/**
* AttributeFactory Class
*
* @package phpLDAPadmin
* @subpackage Templates
*/ */
class AttributeFactory { class AttributeFactory {
public function newAttribute($name,$values) { public function newAttribute($name,$values,$server_id,$source=null) {
global $ldapserver; global $app;
# Check to see if the value is auto generated, our attribute type is dependant on the function called.
if (isset($values['post']) && ! is_array($values['post'])) {
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$values['post'],$matches)) {
switch ($matches[1]) {
case 'Join':
case 'PasswordEncrypt':
break;
default:
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown template [post] function'),$matches[1]),
'body'=>sprintf('%s <small>[%s]</small>',_('The template function is not known and will be ignored.'),$values['post']),
'type'=>'warn'));
unset($values['post']);
}
}
}
# Check our helper functions exists
if (isset($values['helper']['value']) && ! is_array($values['helper']['value']))
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$values['helper']['value'],$matches))
if (! in_array($matches[1],array('GetNextNumber','PasswordEncryptionTypes'))) {
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown template helper function'),$matches[1]),
'body'=>sprintf('%s <small>[%s]</small>',_('The template helper function is not known and will be ignored.'),$values['helper']['value']),
'type'=>'warn'));
unset($values['helper']['value']);
}
# Check to see if the value is auto generated, our attribute type is dependant on the function called.
if (isset($values['value']) && ! is_array($values['value'])) {
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$values['value'],$matches)) {
switch ($matches[1]) {
case 'MultiList':
if (! isset($values['type']))
$values['type'] = 'multiselect';
case 'PickList':
return $this->newSelectionAttribute($name,$values,$server_id,$source);
case 'RandomPassword':
return $this->newRandomPasswordAttribute($name,$values,$server_id,$source);
# Fall through and determine the attribute using other methods.
case 'GetNextNumber':
case 'Function' :
break;
default:
system_message(array(
'title'=>sprintf('%s [<i>%s</i>]',_('Unknown template function'),$matches[1]),
'body'=>sprintf('%s <small>[%s]</small>',_('The template function is not known and will be ignored.'),$values['value']),
'type'=>'warn'));
unset($values['value']);
}
}
}
if (isset($values['type']))
switch ($values['type']) {
case 'password':
return $this->newPasswordAttribute($name,$values,$server_id,$source);
case 'select':
return $this->newSelectionAttribute($name,$values,$server_id,$source);
case 'textarea':
return $this->newMultiLineAttribute($name,$values,$server_id,$source);
}
if (! strcasecmp($name,'objectClass')) { if (! strcasecmp($name,'objectClass')) {
return $this->newObjectClassAttribute($name,$values); return $this->newObjectClassAttribute($name,$values,$server_id,$source);
} elseif ($ldapserver->isJpegPhoto($name)) { } elseif ($app['server']->isJpegPhoto($name)) {
return $this->newJpegAttribute($name,$values); return $this->newJpegAttribute($name,$values,$server_id,$source);
} else if ($ldapserver->isAttrBinary($name)) { } elseif ($app['server']->isAttrBinary($name)) {
return $this->newBinaryAttribute($name,$values); return $this->newBinaryAttribute($name,$values,$server_id,$source);
} else if (! strcasecmp($name,'userPassword')) { } elseif (! strcasecmp($name,'userPassword')) {
return $this->newPasswordAttribute($name,$values); return $this->newPasswordAttribute($name,$values,$server_id,$source);
} else if (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword')) { } elseif (! strcasecmp($name,'sambaLMPassword') || ! strcasecmp($name,'sambaNTPassword')) {
return $this->newSambaPasswordAttribute($name,$values); return $this->newSambaPasswordAttribute($name,$values,$server_id,$source);
} elseif (in_array_ignore_case($name,array_keys($_SESSION[APPCONFIG]->GetValue('appearance','date_attrs')))) { } elseif (in_array(strtolower($name),array_keys(array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs'))))) {
return $this->newDateAttribute($name,$values); return $this->newDateAttribute($name,$values,$server_id,$source);
} elseif (in_array(strtolower($name),array('shadowlastchange','shadowmin', } elseif (in_array(strtolower($name),array('shadowlastchange','shadowmin','shadowmax','shadowexpire','shadowwarning','shadowinactive'))) {
'shadowmax','shadowexpire','shadowwarning','shadowinactive'))) { return $this->newShadowAttribute($name,$values,$server_id,$source);
return $this->newShadowAttribute($name,$values);
} elseif ($ldapserver->isAttrBoolean($name)) { } elseif ($app['server']->isAttrBoolean($name)) {
$attribute = $this->newSelectionAttribute($name,$values); $attribute = $this->newSelectionAttribute($name,$values,$server_id,$source);
$attribute->addOption('TRUE',_('true')); $attribute->addOption('TRUE',_('true'));
$attribute->addOption('FALSE',_('false')); $attribute->addOption('FALSE',_('false'));
return $attribute; return $attribute;
} elseif ($ldapserver->isDNAttr($name)) { } elseif ($app['server']->isDNAttr($name)) {
return $this->newDnAttribute($name,$values); return $this->newDnAttribute($name,$values,$server_id,$source);
} elseif ($ldapserver->isMultiLineAttr($name)) { } elseif ($app['server']->isMultiLineAttr($name)) {
return $this->newMultiLineAttribute($name,$values); return $this->newMultiLineAttribute($name,$values,$server_id,$source);
} elseif (! strcasecmp($name,'gidNumber')) { } elseif (! strcasecmp($name,'gidNumber')) {
return $this->newGidAttribute($name,$values); return $this->newGidAttribute($name,$values,$server_id,$source);
} else { } else {
return new Attribute($name,$values); return new Attribute($name,$values,$server_id,$source);
} }
} }
public function newJpegAttribute($name,$values) { private function newJpegAttribute($name,$values,$server_id,$source) {
return new JpegAttribute($name,$values); return new JpegAttribute($name,$values,$server_id,$source);
} }
public function newBinaryAttribute($name,$values) { private function newBinaryAttribute($name,$values,$server_id,$source) {
return new BinaryAttribute($name,$values); return new BinaryAttribute($name,$values,$server_id,$source);
} }
public function newPasswordAttribute($name,$values) { private function newPasswordAttribute($name,$values,$server_id,$source) {
return new PasswordAttribute($name,$values); return new PasswordAttribute($name,$values,$server_id,$source);
} }
public function newSambaPasswordAttribute($name,$values) { private function newSambaPasswordAttribute($name,$values,$server_id,$source) {
return new SambaPasswordAttribute($name,$values); return new SambaPasswordAttribute($name,$values,$server_id,$source);
} }
public function newRandomPasswordAttribute($name,$values) { private function newRandomPasswordAttribute($name,$values,$server_id,$source) {
return new RandomPasswordAttribute($name,$values); return new RandomPasswordAttribute($name,$values,$server_id,$source);
} }
public function newShadowAttribute($name,$values) { private function newShadowAttribute($name,$values,$server_id,$source) {
return new ShadowAttribute($name,$values); return new ShadowAttribute($name,$values,$server_id,$source);
} }
public function newSelectionAttribute($name,$values) { private function newSelectionAttribute($name,$values,$server_id,$source) {
return new SelectionAttribute($name,$values); return new SelectionAttribute($name,$values,$server_id,$source);
} }
public function newMultiLineAttribute($name,$values) { private function newMultiLineAttribute($name,$values,$server_id,$source) {
return new MultiLineAttribute($name,$values); return new MultiLineAttribute($name,$values,$server_id,$source);
} }
public function newDateAttribute($name,$values) { private function newDateAttribute($name,$values,$server_id,$source) {
return new DateAttribute($name,$values); return new DateAttribute($name,$values,$server_id,$source);
} }
public function newObjectClassAttribute($name,$values) { private function newObjectClassAttribute($name,$values,$server_id,$source) {
return new ObjectClassAttribute($name,$values); return new ObjectClassAttribute($name,$values,$server_id,$source);
} }
public function newDnAttribute($name,$values) { private function newDnAttribute($name,$values,$server_id,$source) {
return new DnAttribute($name,$values); return new DnAttribute($name,$values,$server_id,$source);
} }
public function newGidAttribute($name,$values) { private function newGidAttribute($name,$values,$server_id,$source) {
return new GidAttribute($name,$values); return new GidAttribute($name,$values,$server_id,$source);
} }
} }
?> ?>

View File

@ -1,18 +1,25 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/BinaryAttribute.php,v 1.2 2007/12/15 07:50:32 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * Classes and functions for the template engine.
* @author Xavier Bruyet
* *
* Represents an attribute whose values are binaries * @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/**
* Represents an attribute whose values are binary
*
* @package phpLDAPadmin
* @subpackage Templates
*/ */
class BinaryAttribute extends Attribute { class BinaryAttribute extends Attribute {
protected $filepaths; protected $filepaths;
protected $filenames; protected $filenames;
public function __construct($name, $values) { public function __construct($name,$values,$server_id,$source=null) {
parent::__construct($name, $values); parent::__construct($name,$values,$server_id,$source);
$this->filepaths = array(); $this->filepaths = array();
$this->filenames = array(); $this->filenames = array();

View File

@ -1,11 +1,18 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DateAttribute.php,v 1.2 2007/12/15 07:50:32 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * Classes and functions for the template engine.
* @author Xavier Bruyet
* *
* @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/**
* Represents an attribute whose values are dates * Represents an attribute whose values are dates
*
* @package phpLDAPadmin
* @subpackage Templates
*/ */
class DateAttribute extends Attribute { class DateAttribute extends Attribute {
} }

View File

@ -1,211 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultCreatingEntry.php,v 1.2.2.3 2008/11/29 01:35:47 wurley Exp $
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Represent a tree node
*/
class DefaultCreatingEntry extends Entry {
protected $objectClasses;
protected $mustattrs;
protected $mayattrs;
private $container;
private $rdn;
public function __construct() {
parent::__construct('');
$this->objectClasses = array();
$this->mustattrs = array();
$this->mayattrs = array();
$this->container = '';
$this->rdn = null;
}
public function addObjectClass($objectClass) {
global $ldapserver;
if (!$objectClass || in_array($objectClass,$this->objectClasses)) return;
$this->objectClasses[] = $objectClass;
/* add the required and optional attributes of the objectclass */
$schema_oclass = $ldapserver->getSchemaObjectClass($objectClass);
assert($schema_oclass);
// get the required attributes
$schema_oclasses = $ldapserver->SchemaObjectClasses();
$schema_attrs = $schema_oclass->getMustAttrs($schema_oclasses);
if (!$schema_attrs) $schema_attrs = array();
elseif (!is_array($schema_attrs)) $schema_attrs = array($schema_attrs);
// for each required attribute
foreach ($schema_attrs as $schema_attr) {
$attr_name = $schema_attr->getName();
if (isset($this->mustattrs[$attr_name])) {
$this->mustattrs[$attr_name][] = $objectClass;
continue;
}
if (isset($this->mayattrs[$attr_name])) {
unset($this->mayattrs[$attr_name]);
$this->mustattrs[$attr_name] = array($objectClass);
continue;
}
// get attribute aliases
$aliases = ($schema_attr = $ldapserver->getSchemaAttribute($attr_name)) ? $schema_attr->aliases : null;
if (!$aliases) $aliases = array();
if (!is_array($aliases)) $aliases = array($aliases);
// check if we doesn't already add the alias
$found = false;
foreach ($aliases as $alias) {
if (isset($this->mustattrs[$alias])) {
$this->mustattrs[$alias][] = $objectClass;
$found = true;
break;
} elseif (isset($this->mayattrs[$alias])) {
unset($this->mayattrs[$alias]);
$this->mustattrs[$alias] = array($objectClass);
$found = true;
break;
}
}
if ($found) continue;
$this->mustattrs[$attr_name] = array($objectClass);
}
// get the optional attributes
$schema_attrs = $schema_oclass->getMayAttrs($schema_oclasses);
if (!$schema_attrs) $schema_attrs = array();
elseif (!is_array($schema_attrs)) $schema_attrs = array($schema_attrs);
// for each optional attribute
foreach ($schema_attrs as $schema_attr) {
$attr_name = $schema_attr->getName();
if (isset($this->mustattrs[$attr_name])) {
continue;
}
if (isset($this->mayattrs[$attr_name])) {
$this->mayattrs[$attr_name][] = $objectClass;
continue;
}
// get attribute aliases
$aliases = ($schema_attr = $ldapserver->getSchemaAttribute($attr_name)) ? $schema_attr->aliases : null;
if (!$aliases) $aliases = array();
if (!is_array($aliases)) $aliases = array($aliases);
// check if we doesn't already add the alias
$found = false;
foreach ($aliases as $alias) {
if (isset($this->mustattrs[$alias])) {
$found = true;
break;
} elseif (isset($this->mayattrs[$alias])) {
$this->mayattrs[$alias][] = $objectClass;
$found = true;
break;
}
}
if ($found) continue;
$this->mayattrs[$attr_name] = array($objectClass);
}
}
public function setContainer($dn) {
$this->container = $dn;
}
public function getContainer() {
return $this->container;
}
public function setRdnAttributeName($attribute_name) {
$this->rdn = null;
if (!$attribute_name) return;
$attrs = $this->getAttributes();
foreach ($attrs as $attr) {
if ($attr->getName() == $attribute_name) {
$this->rdn = $attr;
return;
}
}
}
public function getRdnAttributeName() {
$attr = $this->getRdnAttribute();
if ($attr) return array($attr->getName());
else return array('');
}
public function getRdnAttribute() {
return $this->rdn;
}
public function getDn() {
if (!$this->container || !$this->rdn) return '';
$vals = $this->rdn->getValues();
$val = ($vals && $vals[0]) ? $vals[0] : '';
if (strlen($val) <= 0) return '';
return $this->rdn->getName()."=$val,".$this->container;
}
public function getAttributes() {
global $ldapserver;
# we can use a static variable if there is only one instance of this class
static $attrs = null;
if (DEBUG_ENABLED)
debug_log('Entered with () for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$this->getDn());
if (! $attrs) {
$attrs = array();
$attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory');
eval('$attribute_factory = new '.$attributefactoryclass.'();');
if ($this->objectClasses) {
$attribute = $attribute_factory->newAttribute('objectClass',$this->objectClasses);
$attribute->setEntry($this);
$attribute->setRequired();
$attribute->hide();
$attrs[] = $attribute;
}
foreach ($this->mustattrs as $attr_name => $objectclasses) {
if ($attr_name == 'objectClass') continue;
$attribute = $attribute_factory->newAttribute($attr_name,null);
$attribute->setEntry($this);
$attribute->setRequired();
$attrs[] = $attribute;
}
foreach ($this->mayattrs as $attr_name => $objectclasses) {
if ($attr_name == 'objectClass') continue;
$attribute = $attribute_factory->newAttribute($attr_name,null);
$attribute->setEntry($this);
$attrs[] = $attribute;
}
usort($attrs,'attrcmp'); # Sort optional attributes
}
return $attrs;
}
}
?>

View File

@ -1,101 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultEditingEntry.php,v 1.2.2.3 2008/03/01 02:13:03 wurley Exp $
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Represent a tree node
*/
class DefaultEditingEntry extends Entry {
public function __construct($dn) {
parent::__construct($dn);
}
public function getAttributes() {
global $ldapserver;
static $attrs = array();
$dn = $this->getDn();
if (DEBUG_ENABLED)
debug_log('Entered with () for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$dn);
if (! isset($attrs[$dn])) {
$attrs[$dn] = array();
$attributefactoryclass = $_SESSION[APPCONFIG]->GetValue('appearance','attribute_factory');
eval('$attribute_factory = new '.$attributefactoryclass.'();');
$int_attrs_vals = $ldapserver->getDNSysAttrs($this->getDn());
if (!$int_attrs_vals) $int_attrs_vals = array();
elseif (!is_array($int_attrs_vals)) $int_attrs_vals = array($int_attrs_vals);
$custom_int_attrs_vals = $ldapserver->getCustomDNSysAttrs($this->getDn());
if (! $custom_int_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_int_attrs_vals)) $custom_int_attrs_vals = array($custom_int_attrs_vals);
$attrs_vals = $ldapserver->getDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
if (! $attrs_vals) $attrs_vals = array();
elseif (! is_array($attrs_vals)) $attrs_vals = array($attrs_vals);
$custom_attrs_vals = $ldapserver->getCustomDNAttrs($this->getDn(),false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
if (! $custom_attrs_vals) $attrs_vals = array();
elseif (! is_array($custom_attrs_vals)) $custom_attrs_vals = array($custom_attrs_vals);
$int_attrs_vals = array_merge($int_attrs_vals,$custom_int_attrs_vals);
$attrs_vals = array_merge($attrs_vals,$custom_attrs_vals);
$attrs_vals = array_merge($attrs_vals, $int_attrs_vals);
uksort($attrs_vals,'sortAttrs'); # Sort these entries
$objectclasses = null;
foreach ($attrs_vals as $attr => $vals) {
$attribute = $attribute_factory->newAttribute($attr,$vals);
$attribute->setEntry($this);
if (isset($int_attrs_vals[$attr])) {
$attribute->setInternal();
$attribute->setReadOnly();
}
if ($attr == 'objectClass') $objectclasses = $attribute->getValues();
if ($this->isReadOnly() || $ldapserver->isAttrReadOnly($attr)) {
$attribute->setReadOnly();
}
if ($ldapserver->isAttrHidden($attr)/* || ! strcasecmp($attr,'dn')*/) {
$attribute->hide();
}
$attrs[$dn][] = $attribute;
}
if ($objectclasses) {
$schema_oclasses = $ldapserver->SchemaObjectClasses();
foreach ($objectclasses as $oclass) {
$schema_oclass = $ldapserver->getSchemaObjectClass($oclass);
assert($schema_oclass);
$mustattrs = $schema_oclass->getMustAttrs($schema_oclasses);
if (!$mustattrs) $mustattrs = array();
if (!is_array($mustattrs)) $mustattrs = array($mustattrs);
foreach ($mustattrs as $mustattr) {
foreach ($attrs[$dn] as $attr) {
if ($attr->getName() == $mustattr->getName()) {
$attr->setRequired();
break;
}
}
}
}
}
}
return $attrs[$dn];
}
}
?>

View File

@ -1,19 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DefaultEntryFactory.php,v 1.2 2007/12/15 07:50:32 wurley Exp $
/**
* @package phpLDAPadmin
* @author Xavier Bruyet
*
* Allows to create new entries
*/
class DefaultEntryFactory extends EntryFactory {
public function newEditingEntry($dn) {
return new DefaultEditingEntry($dn);
}
public function newCreatingEntry($dn) {
return new DefaultCreatingEntry();
}
}
?>

View File

@ -1,11 +1,18 @@
<?php <?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/DnAttribute.php,v 1.2 2007/12/15 07:50:32 wurley Exp $ // $Header$
/** /**
* @package phpLDAPadmin * Classes and functions for the template engine.
* @author Xavier Bruyet
* *
* Represents an attribute whose values are dn * @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/**
* Represents an attribute whose values are DNs
*
* @package phpLDAPadmin
* @subpackage Templates
*/ */
class DnAttribute extends Attribute { class DnAttribute extends Attribute {
} }

View File

@ -1,316 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/Entry.php,v 1.2.2.5 2009/03/20 07:33:34 wurley Exp $
define('TMPDEBUG',0);
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Represent a tree node
*/
abstract class Entry {
protected $dn;
# the server_id to which the entry belongs
protected $server_id;
# is the entry a leaf ?
private $leaf;
# is the node open ?
private $open;
# array of dn
private $children;
# allow to test if addChild() is called by readChildren()
private $reading_children;
# is the size of children limited ?
private $size_limited;
# is the entry modifiable ?
private $readonly;
# an icon file path
protected $icon;
protected $properties;
public function __construct($dn) {
$this->dn = $dn;
$this->leaf = false;
$this->open = false;
$this->children = array();
$this->reading_children = false;
$this->size_limited = true;
$this->readonly = false;
$this->icon = '';
$this->properties = array();
}
public function getDn() {
return $this->dn;
}
public function getRdn() {
return get_rdn($this->getDn(), 0, true);
}
public function getRdnAttributeName() {
$attr = array();
if ($this->dn) {
$i = strpos($this->dn, ',');
if ($i !== false) {
$attrs = split('\+',substr($this->dn, 0, $i));
foreach ($attrs as $id => $attr) {
list ($name,$value) = split('=',$attr);
$attrs[$id] = $name;
}
$attr = array_unique($attrs);
}
}
return $attr;
}
public function setTree($index) {
$this->server_id = $index;
}
private function readChildren($nolimit=false) {
if (DEBUG_ENABLED)
debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__);
$ldapserver = (isset($this->server_id) ? $_SESSION[APPCONFIG]->ldapservers->Instance($this->server_id) : null);
if (DEBUG_ENABLED)
debug_log('LdapServer (%s)',1,__FILE__,__LINE__,__METHOD__, $ldapserver ? $ldapserver->server_id : -1);
$ldap['child_limit'] = $nolimit ? 0 : $_SESSION[APPCONFIG]->GetValue('search','size_limit');
$ldap['filter'] = $_SESSION[APPCONFIG]->GetValue('appearance','tree_filter');
$ldap['deref'] = $_SESSION[APPCONFIG]->GetValue('deref','view');
$ldap['children'] = $ldapserver->getContainerContents($this->getDn(),$ldap['child_limit'],$ldap['filter'],$ldap['deref']);
if (DEBUG_ENABLED)
debug_log('Children of (%s) are (%s)',64,__FILE__,__LINE__,__METHOD__,$this->getDn(),$ldap['children']);
if (isset($this->server_id)) {
$this->reading_children = true;
$tree = get_cached_item($ldapserver->server_id,'tree');
foreach ($ldap['children'] as $dn) {
if (DEBUG_ENABLED)
debug_log('Adding (%s)',64,__FILE__,__LINE__,__METHOD__,$dn);
if (! $tree->getEntry($dn))
$tree->addEntry($dn);
}
set_cached_item($ldapserver->server_id,'tree','null',$tree);
usort($this->children,'pla_compare_dns');
$this->reading_children = false;
}
if (count($this->children) == $ldap['child_limit'])
$this->size_limited = true;
else
$this->size_limited = false;
if (DEBUG_ENABLED)
debug_log('Entered with (), Returning ()',1,__FILE__,__LINE__,__METHOD__);
}
/**
* Returns null if the children have never be defined
* or an array of the dn of the children
*/
public function getChildren() {
if (! $this->children)
$this->readChildren();
return $this->children;
}
public function getChildrenNumber() {
if (! $this->children)
$this->readChildren();
if ($this->children)
return count($this->children);
else
return 0;
}
/**
* Called by Tree::addEntry() only
*/
public function addChild($dn) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn);
if (! $this->children) {
if (DEBUG_ENABLED)
debug_log('this->children is FALSE',64,__FILE__,__LINE__,__METHOD__);
if (! $this->reading_children) {
if (DEBUG_ENABLED)
debug_log('this->reading_children is FALSE',64,__FILE__,__LINE__,__METHOD__,$dn);
$this->readChildren();
}else {
$this->children = array();
}
}
$index = array_search($dn,$this->children);
if (DEBUG_ENABLED)
debug_log('array_search of (%s) in (%s) returned (%s)',64,__FILE__,__LINE__,__METHOD__,$dn,$this->children,$index);
if ($index === false) {
$this->children[] = $dn;
if (! $this->reading_children) usort($this->children,'pla_compare_dns');
}
if (DEBUG_ENABLED)
debug_log('Entered with (%s), Leaving ()',1,__FILE__,__LINE__,__METHOD__,$dn);
}
/**
* Called by Tree::delEntry() only
*/
public function delChild($dn) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn);
if ($this->children) {
# If the parent hasnt been opened in the tree, then there wont be any children.
$index = array_search($dn,$this->children);
if ($index !== false) unset($this->children[$index]);
}
}
public function rename($newDn) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$newDn);
$this->dn = $newDn;
}
public function isOpened() {
return $this->open;
}
public function close() {
if (DEBUG_ENABLED)
debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__);
$this->open = false;
}
/**
* Opens the node ; the children of the node must have been defined
*/
public function open() {
if (DEBUG_ENABLED)
debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__);
$this->open = true;
if ($this->isSizeLimited()) {
$this->readChildren(true);
}
}
public function setLeaf($is_leaf) {
$this->leaf = $is_leaf;
}
public function isLeaf() {
return $this->leaf;
}
public function isReadOnly() {
return $this->readonly;
}
public function setReadOnly() {
$this->readonly = true;
}
public function setReadWrite() {
$this->readonly = false;
}
/**
* Returns the path of the icon file used to represent this node ;
* returns the result of get_icon() function
*/
public function getIcon($ldapserver) {
if ($this->icon) return $this->icon;
else return get_icon($ldapserver,$this->dn);
}
public function isSizeLimited() {
return $this->size_limited;
}
public function setProperty($name, $value) {
$this->properties[$name] = $value;
}
public function delProperty($name) {
if ($this->hasProperty($name)) unset($this->properties[$name]);
}
public function hasProperty($name) {
return isset($this->properties[$name]);
}
public function getProperty($name) {
if ($this->hasProperty($name)) return $this->properties[$name];
else return null;
}
public function getTemplateName() {
if (isset($this->selected_template))
return $this->selected_template;
else
return '';
}
public function getTemplateTitle() {
if (isset($this->selected_template['title']))
return $this->templates[$this->selected_template]['title'];
else
return _('No Template');
}
/**
* Visit the entry and its attributes
*
* The visitor must implement these methods :
* - visit<Entry>Start($entry)
* - visit<Entry>End($entry)
* where <Entry> is the entry class name.
*/
public function accept($visitor) {
$visitor->visit('Start', $this);
$attrs = $this->getAttributes();
foreach ($attrs as $attribute) {
$attribute->accept($visitor);
}
$visitor->visit('End', $this);
}
public function getAttribute($name) {
foreach ($this->getAttributes() as $attr) {
if ($attr->getName() == $name) return $attr;
}
return null;
}
/**
* Return an array of Attribute objects
*/
abstract public function getAttributes();
}
?>

View File

@ -1,24 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryFactory.php,v 1.2 2007/12/15 07:50:32 wurley Exp $
/**
* @package phpLDAPadmin
* @author Xavier Bruyet
*
* Allows to create new entries
*/
abstract class EntryFactory {
public function newEntry($dn) {
global $ldapserver;
if ($dn && $ldapserver->dnExists($dn)) {
return $this->newEditingEntry($dn);
} else {
return $this->newCreatingEntry($dn);
}
}
abstract public function newEditingEntry($dn);
abstract public function newCreatingEntry($dn);
}
?>

View File

@ -1,394 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryReader.php,v 1.2.2.5 2008/12/12 12:20:22 wurley Exp $
define('ENTRY_READER_CREATION_CONTEXT', '1');
define('ENTRY_READER_EDITING_CONTEXT', '2');
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Visit an entry and its attributes to initialize their values
*/
class EntryReader extends Visitor {
protected $index;
protected $context;
public function __construct($ldapserver) {
$this->index = $ldapserver->server_id;
$this->context = 0;
}
/**************************/
/* Visit an Entry */
/**************************/
public function visitEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
}
public function visitEntryEnd($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
}
/**************************/
/* Visit a EditingEntry */
/**************************/
public function visitDefaultEditingEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
$this->context = ENTRY_READER_EDITING_CONTEXT;
$this->visit('Entry::Start', $entry);
}
public function visitTemplateEditingEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
$this->visit('DefaultEditingEntry::Start', $entry);
if (isset($_REQUEST['template'])) {
$entry->setSelectedTemplateName(trim($_REQUEST['template']));
} elseif (($entry->getTemplatesCount() == 1) && !$entry->hasDefaultTemplate()) {
$templates = &$entry->getTemplates();
$template_names = array_keys($templates);
$entry->setSelectedTemplateName($template_names[0]);
}
}
/**************************/
/* Visit a CreatingEntry */
/**************************/
public function visitDefaultCreatingEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
$this->context = ENTRY_READER_CREATION_CONTEXT;
$this->visit('Entry::Start', $entry);
if (isset($_POST['new_values']['objectClass'])) {
$ocs = $_POST['new_values']['objectClass'];
if (is_string($ocs) && (strlen($ocs) > 0)) $ocs = array($ocs);
elseif (!$ocs) $ocs = array();
foreach ($ocs as $oc) $entry->addObjectClass(trim($oc));
}
if (isset($_REQUEST['container'])) {
$entry->setContainer(trim($_REQUEST['container']));
}
}
public function visitTemplateCreatingEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for dn (%s)',1,__FILE__,__LINE__,__METHOD__,$entry,$entry->getDn());
$this->visit('DefaultCreatingEntry::Start', $entry);
if (isset($_REQUEST['template'])) {
$entry->setSelectedTemplateName(trim($_REQUEST['template']));
} elseif (($entry->getTemplatesCount() == 1) && !$entry->hasDefaultTemplate()) {
$templates = &$entry->getTemplates();
$template_names = array_keys($templates);
$entry->setSelectedTemplateName($template_names[0]);
}
}
/**************************/
/* Visit an Attribute */
/**************************/
public function visitAttribute($attribute) {
if (DEBUG_ENABLED)
debug_log('Enter with (%s) for attribute (%s)',1,__FILE__,__LINE__,__METHOD__,$attribute,$attribute->getName());
$name = $attribute->getName();
// @todo editing objectclasses
if (($this->context == ENTRY_READER_CREATION_CONTEXT) && ($name == 'objectClass')) return;
if ($this->context == ENTRY_READER_EDITING_CONTEXT)
$old_vals = $this->get('OldValues', $attribute);
else
$old_vals = array();
$new_vals = $this->get('NewValues', $attribute);
if (isset($_POST['old_values'][$name])) {
$post_old_vals = $_POST['old_values'][$name];
if (is_string($post_old_vals) && (strlen($post_old_vals) > 0)) $post_old_vals = array($post_old_vals);
elseif (!$post_old_vals) $post_old_vals = array();
// delete last empty values
for ($i = count($post_old_vals)-1; $i >= 0; $i--) {
if (! strlen($post_old_vals[$i])) unset($post_old_vals[$i]);
else break;
}
// attribute modified by someone else ?
if (count($old_vals) != count($post_old_vals)) {
$attribute->justModified();
} else {
foreach ($post_old_vals as $i => $old_val) {
if (!isset($old_vals[$i]) || ($old_vals[$i] != $old_val)) {
$attribute->justModified();
break;
}
}
}
}
foreach ($new_vals as $i => $new_val) {
// if the attribute has not been already modified by a post of a previous page
if (!$attribute->hasBeenModified()) {
// if the value has changed (added or modified/deleted)
if ((!isset($old_vals[$i]) && (strlen($new_val) > 0)) || (isset($old_vals[$i]) && ($old_vals[$i] != $new_val))) {
$new_val = $this->get('PostValue', $attribute, $i, $new_val);
}
}
if ((!isset($old_vals[$i]) && (strlen($new_val) > 0)) || (isset($old_vals[$i]) && ($old_vals[$i] != $new_val))) {
$attribute->justModified();
$attribute->addValue($new_val, $i);
}
}
// old value deletion
if (isset($_POST['old_values'][$name]) && !$attribute->isInternal()) {
for ($i = count($new_vals); $i < count($old_vals); $i++) {
$attribute->addValue('', $i);
}
}
// modified attributes
$modified_attrs = isset($_REQUEST['modified_attrs']) ? $_REQUEST['modified_attrs'] : false;
if (is_array($modified_attrs) && in_array($name, $modified_attrs)) {
$attribute->justModified();
}
}
public function getAttributeOldValues($attribute) {
$old_vals = $attribute->getValues();
return $old_vals;
}
public function getAttributeNewValues($attribute) {
$name = $attribute->getName();
$new_vals = isset($_POST['new_values'][$name]) ? $_POST['new_values'][$name] : null;
if (is_string($new_vals) && (strlen($new_vals) > 0)) $new_vals = array($new_vals);
elseif (!$new_vals) $new_vals = array();
$i = count($new_vals) - 1;
$j = $attribute->getValueCount();
while (($i >= 0) && ($i >= $j) && !$new_vals[$i]) {
if ($i > $j) unset($new_vals[$i]);
$i--;
}
return $new_vals;
}
public function getAttributeRequestValue($attribute, $i, $val, $request) {
if ($request == $attribute->getName()) return $val;
$val = null;
$entry = $attribute->getEntry();
$request_attribute = ($entry ? $entry->getAttribute($request) : null);
if ($request_attribute) {
$val = $request_attribute->getValue($i);
} elseif (isset($_REQUEST[$request][$attribute->getName()][$i])) {
$val = $_REQUEST[$request][$attribute->getName()][$i];
}
if (is_null($val)) {
error(sprintf(_('Your template is missing variable (%s)'),$request),'error','index.php');
}
return $val;
}
public function getAttributePostValue($attribute, $i, $val) {
if (!$attribute->hasProperty('post')) return trim($val);
if (preg_match('/^=php\.(\w+)\((.*)\)$/', $attribute->getProperty('post'), $matches)) {
switch ($matches[1]) {
case 'Password' :
preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall);
$enc = $this->get('RequestValue', $attribute, $i, $val, $matchall[1][0]);
$password = $val;
if ($password) {
$val = password_hash($password, $enc);
}
break;
case 'SambaPassword' :
$matchall = explode(',',$matches[2]);
# If we have no password, then dont hash nothing!
if (strlen($val) <= 0)
break;
$sambapassword = new smbHash;
switch ($matchall[0]) {
case 'LM' : $val = $sambapassword->lmhash($val); break;
case 'NT' : $val = $sambapassword->nthash($val); break;
default : $val = '';
}
break;
case 'Join' :
preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$matches[2],$matchall);
$matchattrs = explode(',',$matches[2]);
$char = $matchattrs[0];
$values = array();
foreach ($matchall[1] as $joinattr) {
$values[] = $this->get('RequestValue', $attribute, $i, $val, $joinattr);
}
$val = implode($char, $values);
break;
default :
if (function_exists($matches[1])) {
$val = call_user_func($matches[1], $matches[2], $attribute, $i, $val);
} else {
error(sprintf(_('Your template has an unknown post function (%s).'),$matches[1]),'error','index.php');
}
}
}
return $val;
}
/*******************************/
/* Visit a BinaryAttribute */
/*******************************/
public function getBinaryAttributeOldValues($attribute) {
$old_vals = array();
return $old_vals;
}
/**
* If there is binary post data, save them in
* $_SESSION['submitform'][$attribute_name][$key][$file_name][$file_path]
* with key = md5("$file_name|$file_path")
*
* return binary values
*/
public function getBinaryAttributeNewValues($attribute) {
$name = $attribute->getName();
$new_vals = $this->get('Attribute::NewValues', $attribute);
$i = 0;
$vals = array();
foreach ($new_vals as $new_val) {
if (isset($_SESSION['submitform'][$name][$new_val])) {
$bin = '';
foreach ($_SESSION['submitform'][$name][$new_val] as $filename => $file) {
$attribute->addFileName($filename, $i);
foreach ($file as $filepath => $binaries) {
$attribute->addFilePath($filepath, $i);
$bin = $binaries;
}
}
$vals[] = $bin;
$i++;
}
}
$new_files = isset($_FILES['new_values']['name'][$name]) ? $_FILES['new_values']['name'][$name] : null;
if (!$new_files) $new_files = array();
elseif (!is_array($new_files)) $new_files = array($new_files);
foreach ($new_files as $j => $file_name) {
$file_path = $_FILES['new_values']['tmp_name'][$name][$j];
if (is_uploaded_file($file_path)) {
$f = fopen($file_path, 'r');
$binary_data = fread($f, filesize($file_path));
fclose($f);
$attribute->addFileName($file_name, $i);
$attribute->addFilePath($file_path, $i);
$key = md5("$file_name|$file_path");
$_SESSION['submitform'][$name][$key][$file_name][$file_path] = $binary_data;
$vals[] = $binary_data;
$i++;
}
}
return $vals;
}
public function getBinaryAttributePostValue($attribute, $i, $val) {
return $val;
}
/*********************************/
/* Visit a PasswordAttribute */
/*********************************/
public function getPasswordAttributePostValue($attribute, $i, $val) {
$name = $attribute->getName();
if ($attribute->hasProperty('verify') && $attribute->getProperty('verify')) {
$verif_val = isset($_POST['new_values_verify'][$name][$i]) ? $_POST['new_values_verify'][$name][$i] : null;
if (!$verif_val || ($verif_val != $val)) {
system_message(array(
'title'=>_('Checking passwords'),
'body'=>_('You have specified two different passwords'),
'type'=>'error'));
return $attribute->getValue($i);
}
}
if ($attribute->hasProperty('post')) {
$val = $this->get('Attribute::PostValue', $attribute, $i, $val);
} elseif (strlen($val) > 0) {
if (isset($_REQUEST['enc'][$attribute->getName()][$i]))
$enc = $_REQUEST['enc'][$attribute->getName()][$i];
else
$enc = get_default_hash($this->index);
$val = password_hash($val, $enc);
}
return $val;
}
public function getSambaPasswordAttributePostValue($attribute, $i, $val) {
$name = $attribute->getName();
if ($attribute->hasProperty('verify') && $attribute->getProperty('verify')) {
$verif_val = isset($_POST['new_values_verify'][$name][$i]) ? $_POST['new_values_verify'][$name][$i] : null;
if (!$verif_val || ($verif_val != $val)) {
system_message(array(
'title'=>_('Checking passwords'),
'body'=>_('You have specified two different passwords'),
'type'=>'error'));
return $attribute->getValue($i);
}
}
if ($attribute->hasProperty('post')) {
$val = $this->get('Attribute::PostValue', $attribute, $i, $val);
} elseif (strlen($val) > 0) {
$sambapassword = new smbHash;
if ($name == 'sambaLMPassword')
$val = $sambapassword->lmhash($val);
elseif ($name == 'sambaNTPassword')
$val = $sambapassword->nthash($val);
}
return $val;
}
}
?>

View File

@ -1,109 +0,0 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/EntryWriter.php,v 1.2.2.1 2008/01/27 06:48:59 wurley Exp $
define('ENTRY_WRITER_CREATION_CONTEXT', '1');
define('ENTRY_WRITER_EDITING_CONTEXT', '2');
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @author Xavier Bruyet
*
* Visit an entry and its attributes to draw them
*/
class EntryWriter extends Visitor {
# Ldapserver from context
protected $index;
# Context : creation or editing
protected $context;
# visited attributes
protected $internal_attributes;
protected $shown_attributes;
protected $hidden_attributes;
# are we visiting the attributes of an entry
protected $visit_attributes;
public function __construct($ldapserver) {
$this->index = $ldapserver->server_id;
$this->visit_attributes = true;
$this->context = 0;
}
public function getLDAPServer() {
static $CACHE;
if (! isset($CACHE[$this->index]))
$CACHE[$this->index] = $_SESSION[APPCONFIG]->ldapservers->Instance($this->index);
return $CACHE[$this->index];
}
/**************************/
/* Paint an Entry */
/**************************/
public function visitEntryStart($entry) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());
// init
$this->init('Visit', $entry);
}
public function visitEntryEnd($entry) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$entry->getDn());
}
protected function initEntryVisit($entry) {
$this->internal_attributes = array();
$this->shown_attributes = array();
$this->hidden_attributes = array();
}
/********************************/
/* Paint a DefaultCreatingEntry */
/********************************/
protected function initDefaultCreatingEntryVisit($entry) {
$this->context = ENTRY_WRITER_CREATION_CONTEXT;
$this->init('Entry::Visit', $entry);
}
/*******************************/
/* Paint a DefaultEditingEntry */
/*******************************/
protected function initDefaultEditingEntryVisit($entry) {
$this->context = ENTRY_WRITER_EDITING_CONTEXT;
$this->init('Entry::Visit', $entry);
}
/*********************************/
/* Paint a TemplateCreatingEntry */
/*********************************/
/********************************/
/* Paint a TemplateEditingEntry */
/********************************/
/**************************/
/* Paint an Attribute */
/**************************/
public function visitAttribute($attribute) {
if (DEBUG_ENABLED)
debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$attribute->getName(),$this->visit_attributes);
if (!$this->visit_attributes) return;
if ($attribute->isInternal()) $this->internal_attributes[] = $attribute;
elseif ($attribute->isVisible()) $this->shown_attributes[] = $attribute;
else $this->hidden_attributes[] = $attribute;
}
}
?>

Some files were not shown because too many files have changed in this diff Show More