RELEASE 1.0.2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.78 2006/01/03 20:39:59 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.79 2006/09/17 07:22:09 wurley Exp $
|
||||
|
||||
/**
|
||||
* Contains code to be executed at the top of each phpLDAPadmin page.
|
||||
@@ -105,6 +105,7 @@ if ($language == 'auto') {
|
||||
|
||||
# Set language
|
||||
putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE
|
||||
$HTTP_LANG .= '.UTF-8';
|
||||
setlocale(LC_ALL,$HTTP_LANG); # set LC_ALL to de_DE
|
||||
bindtextdomain('messages',LANGDIR);
|
||||
bind_textdomain_codeset('messages','UTF-8');
|
||||
@@ -125,6 +126,7 @@ if ($language == 'auto') {
|
||||
|
||||
# Set language
|
||||
putenv('LANG='.$language); # e.g. LANG=de_DE
|
||||
$language .= '.UTF-8';
|
||||
setlocale(LC_ALL,$language); # set LC_ALL to de_DE
|
||||
bindtextdomain('messages',LANGDIR);
|
||||
bind_textdomain_codeset('messages','UTF-8');
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.17 2005/12/10 10:34:55 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/config_default.php,v 1.25 2007/01/18 21:03:58 wurley Exp $
|
||||
|
||||
/**
|
||||
* Configuration processing and defaults.
|
||||
@@ -9,11 +9,11 @@
|
||||
*/
|
||||
|
||||
# The minimum version of PHP required to run phpLDAPadmin.
|
||||
define('REQUIRED_PHP_VERSION','4.1.0');
|
||||
define('REQUIRED_PHP_VERSION','5.0.0');
|
||||
|
||||
class Config {
|
||||
var $custom;
|
||||
var $default;
|
||||
public $custom;
|
||||
protected $default;
|
||||
|
||||
function Config() {
|
||||
|
||||
@@ -46,6 +46,10 @@ class Config {
|
||||
'desc'=>'Array of attributes that should show a jscalendar',
|
||||
'default'=>array('shadowExpire'=>'%es','shadowLastChange'=>'%es'));
|
||||
|
||||
$this->default->appearance['date_attrs_showtime'] = array(
|
||||
'desc'=>'Array of attributes that should show a the time when showing the jscalendar',
|
||||
'default'=>array(''));
|
||||
|
||||
$this->default->appearance['hide_configuration_management'] = array(
|
||||
'desc'=>'Hide the Sourceforge related links',
|
||||
'default'=>false);
|
||||
@@ -94,7 +98,7 @@ class Config {
|
||||
*/
|
||||
$this->default->appearance['obfuscate_password_display'] = array(
|
||||
'desc'=>'Obfuscate the display of passwords',
|
||||
'default'=>false);
|
||||
'default'=>true);
|
||||
|
||||
$this->default->appearance['show_clear_password'] = array(
|
||||
'desc'=>'Whether to show clear passwords if we dont obfuscate them',
|
||||
@@ -108,6 +112,18 @@ class Config {
|
||||
'desc'=>'Show helpful hints',
|
||||
'default'=>true);
|
||||
|
||||
$this->default->appearance['show_top_create'] = array(
|
||||
'desc'=>'Show a additional create link on the top of the list if there are more than 10 entries',
|
||||
'default'=>true);
|
||||
|
||||
$this->default->appearance['show_schema_link'] = array(
|
||||
'desc'=>'Show the schema link for each attribute',
|
||||
'default'=>true);
|
||||
|
||||
$this->default->appearance['show_attribute_notes'] = array(
|
||||
'desc'=>'Show notes for each attribute',
|
||||
'default'=>true);
|
||||
|
||||
/** Tree display
|
||||
* A format string used to display enties in the tree viewer (left-hand side)
|
||||
* You can use special tokens to draw the entries as you wish. You can even mix in HTML to format the string
|
||||
@@ -141,6 +157,14 @@ class Config {
|
||||
'desc'=>'Whether to enable the PHPLayersMenu for the tree',
|
||||
'default'=>false);
|
||||
|
||||
/**
|
||||
* Tree display filter
|
||||
* LDAP filter used to search entries for the tree viewer (left-hand side)
|
||||
*/
|
||||
$this->default->appearance['tree_filter'] = array(
|
||||
'desc'=>'LDAP search filter for the tree entries',
|
||||
'default'=>'(objectClass=*)');
|
||||
|
||||
/** Caching
|
||||
*/
|
||||
$this->default->cache['schema'] = array(
|
||||
@@ -209,6 +233,56 @@ class Config {
|
||||
'desc'=>'Time in seconds to keep jpegPhoto temporary files in the temp directory',
|
||||
'default'=>120);
|
||||
|
||||
## Modify members feature
|
||||
/**
|
||||
* Search filter setting for new members. This is used to search possible members that can be added
|
||||
* to the group. See modify_member_form.php
|
||||
*/
|
||||
$this->default->modify_member['filter'] = array(
|
||||
'desc'=>'Search filter for member searches',
|
||||
'default'=>'(objectclass=Person)');
|
||||
|
||||
/**
|
||||
* Group attributes. When these attributes are seen in template_engine.php, add "modify group members"
|
||||
* link to the attribute
|
||||
* See template_engine.php
|
||||
*/
|
||||
$this->default->modify_member['groupattr'] = array(
|
||||
'desc'=>'Group member attributes',
|
||||
'default'=>array('member','uniqueMember','memberUid'));
|
||||
|
||||
/**
|
||||
* Attribute that is added to the group member attribute. For groupOfNames or groupOfUniqueNames this is dn,
|
||||
* for posixGroup it's uid. See modify_member_form.php
|
||||
*/
|
||||
$this->default->modify_member['attr'] = array(
|
||||
'desc'=>'Default attribute that is added to the group member attribute',
|
||||
'default'=>'dn');
|
||||
|
||||
/**
|
||||
* Attribute that is added to the group member attribute.
|
||||
* For posixGroup it's uid. See modify_member_form.php
|
||||
*/
|
||||
$this->default->modify_member['posixattr'] = array(
|
||||
'desc'=>'Contents of the group member attribute',
|
||||
'default'=>'uid');
|
||||
|
||||
/**
|
||||
* Search filter setting for new members to group. This is used to search possible members that can be added
|
||||
* to the posixGroup. See modify_member_form.php
|
||||
*/
|
||||
$this->default->modify_member['posixfilter'] = array(
|
||||
'desc'=>'Search filter for posixmember searches',
|
||||
'default'=>'(uid=*)');
|
||||
|
||||
/**
|
||||
* posixGroup attribute. When this attribute are seen in modify_member_form.php, only posixGroup members are shown
|
||||
* See modify_member_form.php
|
||||
*/
|
||||
$this->default->modify_member['posixgroupattr'] = array(
|
||||
'desc'=>'posixGroup member attribute',
|
||||
'default'=>'memberUid');
|
||||
|
||||
## Session Attributes
|
||||
/** Cookie Encryption
|
||||
* phpLDAPadmin can encrypt the content of sensitive cookies if you set this to a big random string.
|
||||
@@ -250,6 +324,10 @@ class Config {
|
||||
'desc'=>'Whether to use similiar characters',
|
||||
'default'=>true);
|
||||
|
||||
$this->default->password['no_random_crypt_salt'] = array(
|
||||
'descr'=>'Disable random salt for crypt()',
|
||||
'default'=>false);
|
||||
|
||||
/** Search display
|
||||
* By default, when searching you may display a list or a table of results.
|
||||
* Set this to 'table' to see table formatted results.
|
||||
@@ -289,7 +367,7 @@ class Config {
|
||||
'default'=>array('cn','sn','uid','postalAddress','telephoneNumber'));
|
||||
}
|
||||
|
||||
function GetValue($key,$index) {
|
||||
public function GetValue($key,$index) {
|
||||
|
||||
$value = null;
|
||||
|
||||
@@ -321,7 +399,7 @@ class Config {
|
||||
/**
|
||||
* Function to check and warn about any unusual defined variables.
|
||||
*/
|
||||
function CheckCustom() {
|
||||
public function CheckCustom() {
|
||||
if (isset($this->custom)) {
|
||||
foreach ($this->custom as $masterkey => $masterdetails) {
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.292 2006/05/13 12:52:27 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/functions.php,v 1.302 2006/10/29 11:44:36 wurley Exp $
|
||||
|
||||
/**
|
||||
* A collection of functions used throughout phpLDAPadmin.
|
||||
@@ -400,9 +400,10 @@ function real_attr_name($attr_name) {
|
||||
*
|
||||
* @todo Must turn off auto_uid|gid in template if config is disabled.
|
||||
*/
|
||||
function get_next_number(&$ldapserver,$startbase='',$type='uid') {
|
||||
function get_next_number(&$ldapserver,$startbase='',$type='uid',$increment=false,$filter=false) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('get_next_number(): Entered with (%s,%s,%s)',1,$ldapserver->server_id,$startbase,$type);
|
||||
debug_log('get_next_number(): Entered with (%s,%s,%s,%s)',1,
|
||||
$ldapserver->server_id,$startbase,$type,$filter);
|
||||
|
||||
global $config,$ldapservers;
|
||||
|
||||
@@ -420,15 +421,16 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid') {
|
||||
|
||||
if (is_null($base_dn))
|
||||
pla_error(sprintf(_('You specified the "auto_uid_number_mechanism" as "search" in your
|
||||
configuration for server <b>%s</b>, but you did not specify the
|
||||
"auto_uid_number_search_base". Please specify it before proceeding.'),$ldapserver->name));
|
||||
configuration for server <b>%s</b>, but you did not specify the
|
||||
"auto_uid_number_search_base". Please specify it before proceeding.'),$ldapserver->name));
|
||||
|
||||
} else {
|
||||
$base_dn = $startbase;
|
||||
}
|
||||
|
||||
if (! $ldapserver->dnExists($base_dn))
|
||||
pla_error(sprintf(_('Your phpLDAPadmin configuration specifies an invalid auto_uid_search_base for server %s'),$ldapserver->name));
|
||||
pla_error(sprintf(_('Your phpLDAPadmin configuration specifies an invalid auto_uid_search_base for server %s'),
|
||||
$ldapserver->name));
|
||||
|
||||
$filter = '(|(uidNumber=*)(gidNumber=*))';
|
||||
$results = array();
|
||||
@@ -497,11 +499,80 @@ function get_next_number(&$ldapserver,$startbase='',$type='uid') {
|
||||
|
||||
break;
|
||||
|
||||
case 'uidpool':
|
||||
$con = $ldapserver->connect(false,'auto_search',false,
|
||||
$ldapservers->GetValue($ldapserver->server_id,'auto_number','dn'),
|
||||
$ldapservers->GetValue($ldapserver->server_id,'auto_number','pass'));
|
||||
|
||||
if (! $con)
|
||||
pla_error(sprintf(_('Unable to bind to <b>%s</b> with your with auto_uid credentials. Please check your configuration file.'),$ldapserver->name));
|
||||
|
||||
# assume that uidpool dn is set in config file if no filter given
|
||||
if (empty($filter))
|
||||
$uidpool_dn = $ldapservers->GetValue($ldapserver->server_id,'auto_number','uidpool_dn');
|
||||
|
||||
else {
|
||||
$filter = str_replace(array('&',':::'),array('&',','),$filter);
|
||||
$dns = $ldapserver->search($con,$startbase,$filter,array('dn'),'sub');
|
||||
|
||||
switch (count($dns)) {
|
||||
case '1':
|
||||
break;
|
||||
|
||||
case '0':
|
||||
pla_error(_('Uidpool dn not found, please change filter parameter'));
|
||||
|
||||
default:
|
||||
pla_error(_('There is more than one dn for uidpool,please change filter parameter'));
|
||||
}
|
||||
|
||||
list ($key,$attrs) = each($dns);
|
||||
$attrs = array_change_key_case($attrs);
|
||||
$uidpool_dn = $attrs['dn'];
|
||||
}
|
||||
|
||||
if (empty($uidpool_dn))
|
||||
pla_error(_('uidpool_dn not found. Please check filter (arg 3) or set up uidpool_dn in config file'));
|
||||
|
||||
switch ($type) {
|
||||
case 'uid':
|
||||
$attrs = array('sambaNextUserRid');
|
||||
$key = 'sambanextuserrid';
|
||||
$realkey = 'sambaNextUserRid';
|
||||
break;
|
||||
|
||||
case 'gid':
|
||||
$attrs = array('sambaNextGroupRid');
|
||||
$key = 'sambanextgrouprid';
|
||||
$realkey = 'sambaNextGroupRid';
|
||||
break;
|
||||
|
||||
default:
|
||||
// It might exists other attributes types...
|
||||
$attrs = array($type);
|
||||
$key = strtolower($type);
|
||||
$realkey = $type;
|
||||
break;
|
||||
}
|
||||
|
||||
$number = $ldapserver->search($con,$uidpool_dn,$filter,$attrs,'base');
|
||||
list($rkey,$number) = each($number);
|
||||
$number = array_change_key_case($number);
|
||||
$number = $number[$key];
|
||||
|
||||
if (isset($increment) && ($increment == 'true')) {
|
||||
$updatedattr = array ($key => $number + 1);
|
||||
$ldapserver->modify($uidpool_dn,$updatedattr);
|
||||
}
|
||||
|
||||
return $number;
|
||||
break;
|
||||
|
||||
# No other cases allowed. The user has an error in the configuration
|
||||
default :
|
||||
pla_error( sprintf( _('You specified an invalid value for auto_uid_number_mechanism ("%s")
|
||||
in your configration. Only "uidpool" and "search" are valid.
|
||||
Please correct this problem.') , $mechanism) );
|
||||
in your configration. Only "uidpool" and "search" are valid.
|
||||
Please correct this problem.') , $mechanism) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,67 +1077,91 @@ function support_oid_to_text($oid_id) {
|
||||
* @see ldap_errno
|
||||
* @see pla_verbose_error
|
||||
*/
|
||||
function pla_error( $msg, $ldap_err_msg=null, $ldap_err_no=-1, $fatal=true ) {
|
||||
function pla_error($msg,$ldap_err_msg=null,$ldap_err_no=-1,$fatal=true,$backtrace=null) {
|
||||
if (defined('DEBUG_ENABLED') && (DEBUG_ENABLED))
|
||||
debug_log('pla_error(): Entered with (%s,%s,%s,%s)',1,$msg,$ldap_err_msg,$ldap_err_no,$fatal);
|
||||
|
||||
@include_once HTDOCDIR.'header.php';
|
||||
include_once HTDOCDIR.'header.php';
|
||||
$server = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'undefined';
|
||||
global $config;
|
||||
|
||||
?>
|
||||
<center>
|
||||
<table class="error"><tr><td class="img"><img src="images/warning.png" alt="Warning" /></td>
|
||||
<td><center><h2><?php echo _('Error');?></h2></center>
|
||||
<?php echo $msg; ?>
|
||||
<br />
|
||||
<br />
|
||||
<?php
|
||||
echo '<center>';
|
||||
echo '<table class="error">';
|
||||
|
||||
printf('<tr><th colspan="4">%s</th></tr>',_('Error'));
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td rowspan="99" width="10%"><img src="images/warning.png" alt="Warning" /></td>';
|
||||
printf('<td colspan="3"><b>%s</b></td>',$msg);
|
||||
echo '</tr>';
|
||||
|
||||
echo '<tr><td colspan="3"> </td></tr>';
|
||||
|
||||
if (function_exists('syslog_err'))
|
||||
syslog_err($msg);
|
||||
|
||||
if( $ldap_err_msg ) {
|
||||
echo sprintf(_('LDAP said: %s'), htmlspecialchars( $ldap_err_msg ));
|
||||
echo '<br />';
|
||||
}
|
||||
if ($ldap_err_msg)
|
||||
printf('<tr><td colspan="3"><b>%s</b>: %s</td></tr>',_('LDAP said'),htmlspecialchars($ldap_err_msg));
|
||||
|
||||
if( $ldap_err_no != -1 ) {
|
||||
$ldap_err_no = ( '0x' . str_pad( dechex( $ldap_err_no ), 2, 0, STR_PAD_LEFT ) );
|
||||
$verbose_error = pla_verbose_error( $ldap_err_no );
|
||||
if ($ldap_err_no != -1) {
|
||||
$ldap_err_no = ('0x'.str_pad(dechex($ldap_err_no),2,0,STR_PAD_LEFT));
|
||||
$verbose_error = pla_verbose_error($ldap_err_no);
|
||||
|
||||
if( $verbose_error ) {
|
||||
echo sprintf( _('Error number: %s (%s)'), $ldap_err_no, $verbose_error['title']);
|
||||
echo '<br />';
|
||||
echo sprintf( _('Description: %s <br /><br />'), $verbose_error['desc']);
|
||||
if ($verbose_error) {
|
||||
printf('<tr><td colspan="2"><b>%s</b>: %s (%s)</td></tr>',_('Error number'),$ldap_err_no,$verbose_error['title']);
|
||||
printf('<tr><td colspan="2"><b>%s</b>: %s</td></tr>',_('Description'),$verbose_error['desc']);
|
||||
} else {
|
||||
echo sprintf(_('Error number: %s<br /><br />'), $ldap_err_no);
|
||||
echo '<br />';
|
||||
echo _('Description: (no description available)<br />');
|
||||
printf('<tr><td colspan="2"><b>%s</b>: %s</td></tr>',_('Error number'),$ldap_err_no);
|
||||
printf('<tr><td colspan="2"><b>%s</b>: (%s)</td></tr>',_('Description'),_('no description available'));
|
||||
}
|
||||
|
||||
echo '<tr><td colspan="3"> </td></tr>';
|
||||
|
||||
if (function_exists('syslog_err'))
|
||||
syslog_err(sprintf(_('Error number: %s<br /><br />'),$ldap_err_no));
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
<!-- Commented out due to too many false bug reports. :)
|
||||
<br />
|
||||
<center>
|
||||
<small>
|
||||
<?php echo sprintf(_('Is this a phpLDAPadmin bug? If so, please <a href=\'%s\'>report it</a>.') , get_href( 'add_bug' ));?>
|
||||
<?php
|
||||
if( function_exists( "debug_print_backtrace" ) )
|
||||
debug_print_backtrace();
|
||||
?>
|
||||
</small>
|
||||
</center>
|
||||
-->
|
||||
</td></tr></table>
|
||||
</center>
|
||||
<?php
|
||||
syslog_err(sprintf('%s %s',_('Error number'),$ldap_err_no));
|
||||
|
||||
if( $fatal ) {
|
||||
echo "</body>\n</html>";
|
||||
} elseif ((defined('DEBUG_ENABLED') && DEBUG_ENABLED && function_exists('debug_backtrace')) || $backtrace) {
|
||||
printf('<tr><td colspan="3"><b>%s</b></td></tr>',_('Backtrace'));
|
||||
|
||||
if (is_null($backtrace))
|
||||
$backtrace = debug_backtrace();
|
||||
|
||||
printf('<tr><td> </td><td><b><small><span style="white-space: nowrap;">%s</span></small></b></td><td>%s</td></tr>',
|
||||
'PHP Version',phpversion());
|
||||
printf('<tr><td> </td><td><b><small><span style="white-space: nowrap;">%s</span></small></b></td><td>%s</td></tr>',
|
||||
'PLA Version',pla_version());
|
||||
printf('<tr><td> </td><td><b><small><span style="white-space: nowrap;">%s</span></small></b></td><td>%s</td></tr>',
|
||||
'PHP SAPI',php_sapi_name());
|
||||
printf('<tr><td> </td><td><b><small><span style="white-space: nowrap;">%s</span></small></b></td><td>%s</td></tr>',
|
||||
'Web Server',$server);
|
||||
|
||||
echo '<tr><td colspan="3"> </td></tr>';
|
||||
|
||||
foreach ($backtrace as $error => $line) {
|
||||
printf('<tr><td rowspan="2"> </td><td><b><small>%s</small></b></td><td>%s (%s)</td></tr>',_('File'),$line['file'],$line['line']);
|
||||
printf('<tr><td><b><small>%s</small></b></td><td><small>%s<br /><pre>',_('Function'),$line['function']);
|
||||
print_r($line['args']);
|
||||
echo '</pre></small></td></tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
<br />
|
||||
<!-- Commented out due to too many false bug reports. :)
|
||||
<br />
|
||||
<center>
|
||||
<small>
|
||||
<?php printf(_('Is this a phpLDAPadmin bug? If so, please <a href=\'%s\'>report it</a>.'),get_href('add_bug'));?>
|
||||
</small>
|
||||
</center>
|
||||
-->
|
||||
*/
|
||||
}
|
||||
echo '</table>';
|
||||
echo '</center>';
|
||||
|
||||
if ($fatal) {
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -1088,69 +1183,66 @@ function pla_error( $msg, $ldap_err_msg=null, $ldap_err_no=-1, $fatal=true ) {
|
||||
*
|
||||
* @see set_error_handler
|
||||
*/
|
||||
function pla_error_handler( $errno, $errstr, $file, $lineno ) {
|
||||
function pla_error_handler($errno,$errstr,$file,$lineno) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('pla_error_handler(): Entered with (%s,%s,%s,%s)',1,$errno,$errstr,$file,$lineno);
|
||||
|
||||
// error_reporting will be 0 if the error context occurred
|
||||
// within a function call with '@' preprended (ie, @ldap_bind() );
|
||||
// So, don't report errors if the caller has specifically
|
||||
// disabled them with '@'
|
||||
if( 0 == ini_get( 'error_reporting' ) || 0 == error_reporting() )
|
||||
/* error_reporting will be 0 if the error context occurred
|
||||
* within a function call with '@' preprended (ie, @ldap_bind() );
|
||||
* So, don't report errors if the caller has specifically
|
||||
* disabled them with '@'
|
||||
*/
|
||||
if (ini_get('error_reporting') == 0 || error_reporting() == 0)
|
||||
return;
|
||||
|
||||
$file = basename( $file );
|
||||
$caller = basename( $_SERVER['PHP_SELF'] );
|
||||
$errtype = "";
|
||||
switch( $errno ) {
|
||||
case E_STRICT: $errtype = "E_STRICT"; break;
|
||||
case E_ERROR: $errtype = "E_ERROR"; break;
|
||||
case E_WARNING: $errtype = "E_WARNING"; break;
|
||||
case E_PARSE: $errtype = "E_PARSE"; break;
|
||||
case E_NOTICE: $errtype = "E_NOTICE"; break;
|
||||
case E_CORE_ERROR: $errtype = "E_CORE_ERROR"; break;
|
||||
case E_CORE_WARNING: $errtype = "E_CORE_WARNING"; break;
|
||||
case E_COMPILE_ERROR: $errtype = "E_COMPILE_ERROR"; break;
|
||||
case E_COMPILE_WARNING: $errtype = "E_COMPILE_WARNING"; break;
|
||||
case E_USER_ERROR: $errtype = "E_USER_ERROR"; break;
|
||||
case E_USER_WARNING: $errtype = "E_USER_WARNING"; break;
|
||||
case E_USER_NOTICE: $errtype = "E_USER_NOTICE"; break;
|
||||
case E_ALL: $errtype = "E_ALL"; break;
|
||||
default: $errtype = _('Unrecognized error number: ') . $errno;
|
||||
$file = basename($file);
|
||||
$caller = basename($_SERVER['PHP_SELF']);
|
||||
$errtype = '';
|
||||
|
||||
switch ($errno) {
|
||||
case E_STRICT: $errtype = 'E_STRICT'; break;
|
||||
case E_ERROR: $errtype = 'E_ERROR'; break;
|
||||
case E_WARNING: $errtype = 'E_WARNING'; break;
|
||||
case E_PARSE: $errtype = 'E_PARSE'; break;
|
||||
case E_NOTICE: $errtype = 'E_NOTICE'; break;
|
||||
case E_CORE_ERROR: $errtype = 'E_CORE_ERROR'; break;
|
||||
case E_CORE_WARNING: $errtype = 'E_CORE_WARNING'; break;
|
||||
case E_COMPILE_ERROR: $errtype = 'E_COMPILE_ERROR'; break;
|
||||
case E_COMPILE_WARNING: $errtype = 'E_COMPILE_WARNING'; break;
|
||||
case E_USER_ERROR: $errtype = 'E_USER_ERROR'; break;
|
||||
case E_USER_WARNING: $errtype = 'E_USER_WARNING'; break;
|
||||
case E_USER_NOTICE: $errtype = 'E_USER_NOTICE'; break;
|
||||
case E_ALL: $errtype = 'E_ALL'; break;
|
||||
|
||||
default: $errtype = sprintf('%s: %s',_('Unrecognized error number'),$errno);
|
||||
}
|
||||
|
||||
$errstr = preg_replace("/\s+/"," ",$errstr);
|
||||
if( $errno == E_NOTICE ) {
|
||||
echo sprintf(_('<center><table class=\'notice\'><tr><td colspan=\'2\'><center><img src=\'images/warning.png\' height=\'12\' width=\'13\' alt="Warning" />
|
||||
<b>You found a non-fatal phpLDAPadmin bug!</b></td></tr><tr><td>Error:</td><td><b>%s</b> (<b>%s</b>)</td></tr><tr><td>File:</td>
|
||||
<td><b>%s</b> line <b>%s</b>, caller <b>%s</b></td></tr><tr><td>Versions:</td><td>PLA: <b>%s</b>, PHP: <b>%s</b>, SAPI: <b>%s</b>
|
||||
</td></tr><tr><td>Web server:</td><td><b>%s</b></td></tr>
|
||||
<tr><td colspan=\'2\'><center><a target=\'new\' href=\'%s\'>Please check and see if this bug has been reported here</a>.</center></td></tr>
|
||||
<tr><td colspan=\'2\'><center><a target=\'new\' href=\'%s\'>If it hasnt been reported, you may report this bug by clicking here</a>.</center></td></tr>
|
||||
</table></center><br />'), $errstr, $errtype, $file,
|
||||
$lineno, $caller, pla_version(), phpversion(), php_sapi_name(),
|
||||
$_SERVER['SERVER_SOFTWARE'], get_href('search_bug',"&summary_keyword=".htmlspecialchars($errstr)),get_href('add_bug'));
|
||||
$errstr = preg_replace('/\s+/',' ',$errstr);
|
||||
|
||||
if ($errno == E_NOTICE) {
|
||||
echo '<center>';
|
||||
|
||||
echo '<table class="notice">';
|
||||
printf('<tr><td colspan="2"><center><img src="images/warning.png" height="12" width="13" alt="Warning" /> <b>%s</b></center></td></tr>',
|
||||
_('You found a non-fatal phpLDAPadmin bug!'));
|
||||
|
||||
printf('<tr><td>%s:</td><td><b>%s</b> (<b>%s</b>)</td></tr>',_('Error'),$errstr,$errtype);
|
||||
printf('<tr><td>%s:</td><td><b>%s</b> %s <b>%s</b>, %s <b>%s</b></td></tr>',_('File'),$file,_('line'),$lineno,_('caller'),$caller);
|
||||
printf('<tr><td>Versions:</td><td>PLA: <b>%s</b>, PHP: <b>%s</b>, SAPI: <b>%s</b></td></tr>',
|
||||
pla_version(),phpversion(),php_sapi_name());
|
||||
printf('<tr><td>Web server:</td><td><b>%s</b></td></tr>',$_SERVER['SERVER_SOFTWARE']);
|
||||
|
||||
printf('<tr><td colspan="2"><a target="new" href="%s"><center>%s.</center></a></td></tr>',
|
||||
get_href('search_bug',"&summary_keyword=".htmlspecialchars($errstr)),
|
||||
_('Please check and see if this bug has been reported'));
|
||||
echo '</table>';
|
||||
|
||||
echo '</center>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$server = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'undefined';
|
||||
$phpself = isset( $_SERVER['PHP_SELF'] ) ? basename( $_SERVER['PHP_SELF'] ) : 'undefined';
|
||||
pla_error( sprintf(_('Congratulations! You found a bug in phpLDAPadmin.<br /><br />
|
||||
<table class=\'bug\'>
|
||||
<tr><td>Error:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>Level:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>File:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>Line:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>Caller:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>PLA Version:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>PHP Version:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>PHP SAPI:</td><td><b>%s</b></td></tr>
|
||||
<tr><td>Web server:</td><td><b>%s</b></td></tr>
|
||||
</table>
|
||||
<br />
|
||||
Please report this bug by clicking below!'), $errstr, $errtype, $file,
|
||||
$lineno, $phpself, pla_version(),
|
||||
phpversion(), php_sapi_name(), $server ));
|
||||
pla_error(sprintf('%s: %s',$errtype,$errstr),null,-1,true,debug_backtrace());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1216,7 +1308,8 @@ function draw_jpeg_photos($ldapserver,$dn,$attr_name='jpegPhoto',$draw_delete_bu
|
||||
if (isset($table_html_attrs) && trim($table_html_attrs) )
|
||||
printf('<table %s><tr><td><center>',$table_html_attrs);
|
||||
|
||||
$jpeg_data = array_pop($ldapserver->search(null,$dn,'objectClass=*',array($attr_name),'base'));
|
||||
$jpeg_data = $ldapserver->search(null,$dn,'objectClass=*',array($attr_name),'base');
|
||||
$jpeg_data = array_pop($jpeg_data);
|
||||
if (! $jpeg_data) {
|
||||
printf(_('Could not fetch jpeg data from LDAP server for attribute %s.'),htmlspecialchars($attr_name));
|
||||
return;
|
||||
@@ -1311,7 +1404,13 @@ function password_hash( $password_clear, $enc_type ) {
|
||||
|
||||
switch( $enc_type ) {
|
||||
case 'crypt':
|
||||
$new_value = '{CRYPT}' . crypt( $password_clear, random_salt(2) );
|
||||
global $config;
|
||||
|
||||
if ($config->GetValue('password','no_random_crypt_salt') == true)
|
||||
$new_value = '{CRYPT}' . crypt($password_clear,substr($password_clear,0,2));
|
||||
else
|
||||
$new_value = '{CRYPT}' . crypt($password_clear,random_salt(2));
|
||||
|
||||
break;
|
||||
|
||||
case 'ext_des':
|
||||
@@ -1719,7 +1818,7 @@ function dn_unescape($dn) {
|
||||
*/
|
||||
function get_href($type,$extra_info='') {
|
||||
$sf = 'https://sourceforge.net';
|
||||
$pla = 'http://wiki.pldapadmin.com';
|
||||
$pla = 'http://wiki.phpldapadmin.info';
|
||||
$group_id = '61828';
|
||||
$bug_atid = '498546';
|
||||
$rfe_atid = '498549';
|
||||
@@ -2575,12 +2674,15 @@ function masort(&$data,$sortby,$rev=0) {
|
||||
* @param array $attrs LDAP attributes to use as values.
|
||||
* @return array $results Array of values keyed by $key.
|
||||
*/
|
||||
function return_ldap_hash($ldapserver,$base_dn,$filter,$key,$attrs) {
|
||||
function return_ldap_hash($ldapserver,$base_dn,$filter,$key,$attrs,$sort=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('return_ldap_hash(): Entered with (%s,%s,%s,%s,%s)',0,
|
||||
$ldapserver->server_id,$base_dn,$filter,$key,count($attrs));
|
||||
|
||||
$ldapquery = $ldapserver->search(null,$base_dn,$filter,$attrs);
|
||||
if (is_array($sort))
|
||||
$ldapquery = $ldapserver->search(null,$base_dn,$filter,$attrs,'sub',false,LDAP_DEREF_NEVER,0,$sort);
|
||||
else
|
||||
$ldapquery = $ldapserver->search(null,$base_dn,$filter,$attrs);
|
||||
|
||||
$results = array();
|
||||
|
||||
@@ -2666,7 +2768,7 @@ function password_generate() {
|
||||
$leftover = array_merge($leftover,$llower,$lupper,$numbers,$punc);
|
||||
|
||||
shuffle($leftover);
|
||||
$outarray = array_merge($outarray, a_array_rand($leftover, $criteria['num'] - $num_spec));
|
||||
$outarray = array_merge($outarray, a_array_rand($leftover,$length-$num_spec));
|
||||
}
|
||||
|
||||
shuffle($outarray);
|
||||
@@ -2800,4 +2902,14 @@ function no_expire_header() {
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for Opera. By putting "random junk" in the query string, it thinks
|
||||
* that it does not have a cached version of the page, and will thus
|
||||
* fetch the page rather than display the cached version
|
||||
*/
|
||||
function random_junk() {
|
||||
$time = gettimeofday();
|
||||
return md5(strtotime('now').$time['usec']);
|
||||
}
|
||||
?>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.7 2006/02/25 13:12:05 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/hooks.php,v 1.8 2006/10/28 06:03:30 wurley Exp $
|
||||
|
||||
/**
|
||||
* Functions related to hooks management.
|
||||
@@ -171,13 +171,13 @@ function clear_hooks ( $hook_name ) {
|
||||
}
|
||||
|
||||
/* Evaluating user-made hooks */
|
||||
if ( is_dir(HOOKSDIR) ) {
|
||||
$dir = dir (HOOKSDIR);
|
||||
if (is_dir(HOOKSDIR)) {
|
||||
$dir = dir(HOOKSDIR);
|
||||
|
||||
while (false !== ($entry = $dir -> read() ) ) {
|
||||
if ( is_file ("hooks/$entry") and eregi ('php[0-9]?$', $entry) ) {
|
||||
require_once "hooks/$entry";
|
||||
}
|
||||
while (false !== ($entry = $dir->read())) {
|
||||
$filename = sprintf('%s/%s',HOOKSDIR,$entry);
|
||||
if (is_file($filename) and eregi('php[0-9]?$',$entry))
|
||||
require_once "hooks/$entry";
|
||||
}
|
||||
|
||||
$dir -> close();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_advanced.php,v 1.24 2005/12/10 10:34:55 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/search_form_advanced.php,v 1.25 2007/03/18 01:48:39 wurley Exp $
|
||||
|
||||
/**
|
||||
* @package phpLDAPadmin
|
||||
@@ -87,6 +87,12 @@ if( isset( $base_dn_does_not_exist ) && $base_dn_does_not_exist )
|
||||
join(', ',$config->GetValue('search','result_attributes')); ?>" />
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><small><acronym title="<?php echo htmlspecialchars(_('Order by').'...'); ?>">
|
||||
<?php echo _('Order by'); ?></acronym></small></td>
|
||||
|
||||
<td><input type="text" name="orderby" id="orderby" style="width: 200px" value="<?php echo $filter ? htmlspecialchars($orderby) : ''; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><br /><center><input type="submit" value="<?php echo _('Search'); ?>" /></center></td>
|
||||
</tr>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.45 2006/05/13 12:52:27 wurley Exp $ */
|
||||
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/server_functions.php,v 1.50 2006/10/28 16:33:32 wurley Exp $ */
|
||||
|
||||
/**
|
||||
* Classes and functions for LDAP server configuration and capability
|
||||
@@ -158,7 +158,7 @@ class LDAPserver {
|
||||
|
||||
# Quick return if we have already connected.
|
||||
$resource = $this->_connect($connect_id);
|
||||
if ($resource && ! $reconnect)
|
||||
if (is_resource($resource) && ! $reconnect)
|
||||
return $resource;
|
||||
|
||||
if (DEBUG_ENABLED)
|
||||
@@ -243,7 +243,7 @@ class LDAPserver {
|
||||
|
||||
# Now that we have worked out the connect_id, lets just check and see if we have already connected.
|
||||
$resource = $this->_connect($connect_id);
|
||||
if ($resource && ! $reconnect)
|
||||
if (is_resource($resource) && ! $reconnect)
|
||||
return $resource;
|
||||
|
||||
run_hook('pre_connect',array('server_id'=>$this->server_id,'connect_id'=>$connect_id));
|
||||
@@ -419,7 +419,8 @@ class LDAPserver {
|
||||
debug_log('%s::getBaseDN(): Connect to LDAP to find BaseDN',80,get_class($this));
|
||||
|
||||
if ($this->connect()) {
|
||||
$r = array_pop($this->search(null,'','objectClass=*',array('namingContexts'),'base'));
|
||||
$r = $this->search(null,'','objectClass=*',array('namingContexts'),'base');
|
||||
$r = array_pop($r);
|
||||
if (is_array($r))
|
||||
$r = array_change_key_case($r);
|
||||
|
||||
@@ -1219,11 +1220,7 @@ class LDAPserver {
|
||||
/* foreach of the attribute's aliases, create a new entry in the attrs array
|
||||
with its name set to the alias name, and all other data copied.*/
|
||||
foreach ($aliases as $alias_attr_name) {
|
||||
# clone is a PHP5 function and must be used.
|
||||
if (version_compare(PHP_VERSION,'5.0') > 0 )
|
||||
$new_attr = clone($attr);
|
||||
else
|
||||
$new_attr = $attr;
|
||||
$new_attr = clone $attr;
|
||||
|
||||
$new_attr->setName($alias_attr_name);
|
||||
$new_attr->addAlias($attr->getName());
|
||||
@@ -1276,11 +1273,7 @@ class LDAPserver {
|
||||
|
||||
/* clone the SUP attributeType and populate those values
|
||||
that were set by the child attributeType */
|
||||
# clone is a PHP5 function and must be used.
|
||||
if (function_exists('clone'))
|
||||
$attr = clone($sup_attr);
|
||||
else
|
||||
$attr = $sup_attr;
|
||||
$attr = clone $sup_attr;
|
||||
|
||||
$attr->setOID($tmp_oid);
|
||||
$attr->setName($tmp_name);
|
||||
@@ -1754,13 +1747,13 @@ class LDAPserver {
|
||||
* @param array $attrs An array of attributes to include in the search result (example: array( "objectClass", "uid", "sn" )).
|
||||
* @param string $scope The LDAP search scope. Must be one of "base", "one", or "sub". Standard LDAP search scope.
|
||||
* @param bool $sort_results Specify false to not sort results by DN or true to have the
|
||||
* returned array sorted by DN (uses ksort)
|
||||
* returned array sorted by DN (uses ksort)
|
||||
* @param int $deref When handling aliases or referrals, this specifies whether to follow referrals. Must be one of
|
||||
* LDAP_DEREF_ALWAYS, LDAP_DEREF_NEVER, LDAP_DEREF_SEARCHING, or LDAP_DEREF_FINDING. See the PHP LDAP API for details.
|
||||
* LDAP_DEREF_ALWAYS, LDAP_DEREF_NEVER, LDAP_DEREF_SEARCHING, or LDAP_DEREF_FINDING. See the PHP LDAP API for details.
|
||||
* @param int $size_limit Size limit for search
|
||||
* @todo: Add entries to tree cache.
|
||||
*/
|
||||
function search($resource=null,$base_dn=null,$filter,$attrs=array(),$scope='sub',$sort_results=true,$deref=LDAP_DEREF_NEVER,$size_limit=0) {
|
||||
function search($resource=null,$base_dn=null,$filter,$attrs=array(),$scope='sub',$sort_results=true,$deref=LDAP_DEREF_NEVER,$size_limit=0,$sort_by=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s::search(): Entered with (%s,%s,%s,%s,%s,%s,%s)',17,
|
||||
get_class($this),is_resource($this),$base_dn,$filter,$attrs,$scope,$sort_results,$deref);
|
||||
@@ -1802,6 +1795,10 @@ class LDAPserver {
|
||||
return array();
|
||||
|
||||
$return = array();
|
||||
if (is_array($sort_by))
|
||||
foreach ($sort_by as $sort)
|
||||
if (in_array($sort,$attrs))
|
||||
ldap_sort($resource,$search,$sort);
|
||||
|
||||
# Get the first entry identifier
|
||||
if ($entry_id = ldap_first_entry($resource,$search))
|
||||
@@ -2524,7 +2521,8 @@ class LDAPserver {
|
||||
debug_log('%s:getDNAttrs(): Entered with (%s,%s,%s)',17,
|
||||
get_class($this),$dn,$lower_case_attr_names,$deref);
|
||||
|
||||
$attrs = array_pop($this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref));
|
||||
$attrs = $this->search(null,dn_escape($dn),'(objectClass=*)',array(),'base',false,$deref);
|
||||
$attrs = array_pop($attrs);
|
||||
|
||||
if (is_array($attrs)) {
|
||||
if ($lower_case_attr_names)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.35 2006/04/29 06:49:32 wurley Exp $ */
|
||||
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/template_functions.php,v 1.41 2006/10/28 16:38:36 wurley Exp $ */
|
||||
|
||||
/**
|
||||
* Classes and functions for the template engine.ation and capability
|
||||
@@ -94,14 +94,14 @@ class xml2array {
|
||||
}
|
||||
|
||||
class Templates {
|
||||
var $_template = array();
|
||||
var $_creation_template = array();
|
||||
var $_js_hash = array();
|
||||
|
||||
function Templates($server_id) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s::__construct(): Entered with ()',5,get_class($this));
|
||||
|
||||
if ($this->_template = get_cached_item($server_id,'template','all')) {
|
||||
if ($this->_creation_template = get_cached_item($server_id,'template','creation')) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s::init(): Using CACHED [%s]',5,get_class($this),'templates');
|
||||
|
||||
@@ -119,19 +119,19 @@ class Templates {
|
||||
|
||||
$this->storeTemplate($template_name,$xmldata);
|
||||
}
|
||||
masort($this->_template,'title');
|
||||
set_cached_item($server_id,'template','all',$this->_template);
|
||||
masort($this->_creation_template,'title');
|
||||
set_cached_item($server_id,'template','creation',$this->_creation_template);
|
||||
}
|
||||
}
|
||||
|
||||
function storeTemplate($template,$xmldata) {
|
||||
function storeTemplate($xtemplate,$xmldata) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s::storeTemplate(): Entered with (%s,%s)',5,
|
||||
get_class($this),$template,$xmldata);
|
||||
|
||||
global $ldapserver;
|
||||
|
||||
$this->_template[$template]['objectclass'] = array();
|
||||
$template['objectclass'] = array();
|
||||
foreach ($xmldata['template'] as $xml_key => $xml_value) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('%s::storeTemplate(): Foreach loop Key [%s] Value [%s]',4,
|
||||
@@ -149,10 +149,10 @@ class Templates {
|
||||
if ($schema = $ldapserver->getSchemaObjectClass($details['ID'])) {
|
||||
|
||||
# If we havent recorded this objectclass already, do so now.
|
||||
if (! isset($this->_template[$template]['objectclass']) ||
|
||||
! in_array($schema->getName(),$this->_template[$template]['objectclass'])) {
|
||||
if (! isset($template['objectclass']) ||
|
||||
! in_array($schema->getName(),$template['objectclass'])) {
|
||||
|
||||
$this->_template[$template]['objectclass'][] = $schema->getName();
|
||||
$template['objectclass'][] = $schema->getName();
|
||||
}
|
||||
|
||||
# This objectClass doesnt exist.
|
||||
@@ -161,10 +161,10 @@ class Templates {
|
||||
|
||||
} else {
|
||||
if ($schema = $ldapserver->getSchemaObjectClass($details)) {
|
||||
if (! isset($this->_template[$template]['objectclass']) ||
|
||||
! in_array($details,$this->_template[$template]['objectclass'])) {
|
||||
|
||||
$this->_template[$template]['objectclass'][] = $schema->getName();
|
||||
if (! isset($template['objectclass']) ||
|
||||
! in_array($details,$template['objectclass'])) {
|
||||
|
||||
$template['objectclass'][] = $schema->getName();
|
||||
}
|
||||
|
||||
# This objectClass doesnt exist.
|
||||
@@ -182,7 +182,7 @@ class Templates {
|
||||
debug_log('%s::storeTemplate(): Case [%s]',4,get_class($this),'attributes');
|
||||
|
||||
if (isset($xmldata['template']['attributes']) && is_array($xmldata['template']['attributes'])) {
|
||||
$this->_template[$template]['attribute'] = array();
|
||||
$template['attribute'] = array();
|
||||
|
||||
foreach ($xmldata['template']['attributes'] as $tattrs) {
|
||||
foreach ($tattrs as $index => $attr_details) {
|
||||
@@ -194,7 +194,7 @@ class Templates {
|
||||
# Single attribute XML files are not indexed.
|
||||
if (is_numeric($index)) {
|
||||
if ($attr = $ldapserver->getSchemaAttribute($attr_details['ID']))
|
||||
$this->_template[$template]['attribute'][$attr->getName()] = $this->_parseXML($index,$attr_details);
|
||||
$template['attribute'][$attr->getName()] = $this->_parseXML($index,$attr_details);
|
||||
|
||||
} else {
|
||||
if (! strcmp($index,'ID'))
|
||||
@@ -203,12 +203,12 @@ class Templates {
|
||||
if ($attr = $ldapserver->getSchemaAttribute($tattrs['ID'])) {
|
||||
foreach ($attr_details as $key => $values) {
|
||||
if (is_array($values) && isset($values['ID'])) {
|
||||
$this->_template[$template]['attribute'][$attr->getName()][$index]['_KEY:'.$values['ID']] = $this->_parseXML($key,$values);
|
||||
$template['attribute'][$attr->getName()][$index]['_KEY:'.$values['ID']] = $this->_parseXML($key,$values);
|
||||
} elseif (is_array($values) && isset($values['#text'])) {
|
||||
$this->_template[$template]['attribute'][$attr->getName()][$index][] = $values['#text'];
|
||||
|
||||
$template['attribute'][$attr->getName()][$index][] = $values['#text'];
|
||||
|
||||
} else {
|
||||
$this->_template[$template]['attribute'][$attr->getName()][$index] = $this->_parseXML($key,$values);
|
||||
$template['attribute'][$attr->getName()][$index] = $this->_parseXML($key,$values);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,11 +217,11 @@ class Templates {
|
||||
}
|
||||
|
||||
# Do we have an override parameter?
|
||||
foreach ($this->_template[$template]['attribute'] as $key => $data) {
|
||||
foreach ($template['attribute'] as $key => $data) {
|
||||
if (isset($data['override'])) {
|
||||
$this->_template[$template]['attribute'][$data['override']] = $data;
|
||||
unset($this->_template[$template]['attribute'][$key]);
|
||||
$this->_template[$template]['attribute'][$key] = $data['override'];
|
||||
$template['attribute'][$data['override']] = $data;
|
||||
unset($template['attribute'][$key]);
|
||||
$template['attribute'][$key] = $data['override'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,23 +229,23 @@ class Templates {
|
||||
break;
|
||||
|
||||
default :
|
||||
$this->_template[$template][$xml_key] = $xml_value['#text'];
|
||||
$template[$xml_key] = $xml_value['#text'];
|
||||
}
|
||||
}
|
||||
|
||||
if (! count($this->_template[$template]['objectclass'])) {
|
||||
$this->_template[$template]['invalid'] = 1;
|
||||
$this->_template[$template]['invalid_reason'] = _('ObjectClasses in XML dont exist in LDAP server.');
|
||||
if (! count($template['objectclass'])) {
|
||||
$template['invalid'] = 1;
|
||||
$template['invalid_reason'] = _('ObjectClasses in XML dont exist in LDAP server.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# Collect our structural, must & may attributes.
|
||||
$this->_template[$template]['must'] = array();
|
||||
$this->_template[$template]['may'] = array();
|
||||
$this->_template[$template]['empty_attrs'] = array();
|
||||
$template['must'] = array();
|
||||
$template['may'] = array();
|
||||
$template['empty_attrs'] = array();
|
||||
|
||||
$superclasslist = array();
|
||||
foreach ($this->_template[$template]['objectclass'] as $oclass) {
|
||||
foreach ($template['objectclass'] as $oclass) {
|
||||
|
||||
# If we get some superclasses - then we'll need to go through them too.
|
||||
$supclass = true;
|
||||
@@ -257,27 +257,27 @@ class Templates {
|
||||
* Shouldnt be required now...
|
||||
# Test that this is a valid objectclass - disable if an invalid one found.
|
||||
if (! $schema_object) {
|
||||
$this->_template[$template]['invalid'] = 1;
|
||||
$template['invalid'] = 1;
|
||||
$supclass = false;
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
if ($schema_object->getType() == 'structural' && (! $enherited))
|
||||
$this->_template[$template]['structural'][] = $oclass;
|
||||
$template['structural'][] = $oclass;
|
||||
|
||||
if ($schema_object->getMustAttrs() )
|
||||
foreach ($schema_object->getMustAttrs() as $index => $detail) {
|
||||
$objectclassattr = $detail->getName();
|
||||
|
||||
if (! in_array($objectclassattr,$this->_template[$template]['must']) &&
|
||||
if (! in_array($objectclassattr,$template['must']) &&
|
||||
strcasecmp('objectClass',$objectclassattr) != 0) {
|
||||
|
||||
# Go through the aliases, and ignore any that are already defined.
|
||||
$ignore = false;
|
||||
$attr = $ldapserver->getSchemaAttribute($objectclassattr);
|
||||
foreach ($attr->aliases as $alias) {
|
||||
if (in_array($alias,$this->_template[$template]['must'])) {
|
||||
if (in_array($alias,$template['must'])) {
|
||||
$ignore = true;
|
||||
break;
|
||||
}
|
||||
@@ -286,14 +286,14 @@ class Templates {
|
||||
if ($ignore)
|
||||
continue;
|
||||
|
||||
if (isset($this->_template[$template]['attribute'][$objectclassattr]) &&
|
||||
! is_array($this->_template[$template]['attribute'][$objectclassattr]))
|
||||
if (isset($template['attribute'][$objectclassattr]) &&
|
||||
! is_array($template['attribute'][$objectclassattr]))
|
||||
|
||||
$this->_template[$template]['must'][] =
|
||||
$this->_template[$template]['attribute'][$objectclassattr];
|
||||
$template['must'][] =
|
||||
$template['attribute'][$objectclassattr];
|
||||
|
||||
else
|
||||
$this->_template[$template]['must'][] = $objectclassattr;
|
||||
$template['must'][] = $objectclassattr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,8 +301,8 @@ class Templates {
|
||||
foreach ($schema_object->getMayAttrs() as $index => $detail) {
|
||||
$objectclassattr = $detail->getName();
|
||||
|
||||
if (! in_array($objectclassattr,$this->_template[$template]['may']))
|
||||
$this->_template[$template]['may'][] = $objectclassattr;
|
||||
if (! in_array($objectclassattr,$template['may']))
|
||||
$template['may'][] = $objectclassattr;
|
||||
}
|
||||
|
||||
# Keep a list to objectclasses we have processed, so we dont get into a loop.
|
||||
@@ -327,65 +327,67 @@ class Templates {
|
||||
}
|
||||
|
||||
# Remove any must attributes in the may list.
|
||||
foreach ($this->_template[$template]['may'] as $index => $detail) {
|
||||
if (in_array($detail,$this->_template[$template]['must'])) {
|
||||
unset($this->_template[$template]['may'][$index]);
|
||||
foreach ($template['may'] as $index => $detail) {
|
||||
if (in_array($detail,$template['must'])) {
|
||||
unset($template['may'][$index]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
# Remove any attributes not in the xml file and not in the dn.
|
||||
foreach ($this->_template[$template]['may'] as $index => $detail) {
|
||||
if (isset($this->_template[$template]['attribute'])
|
||||
&& ! isset($this->_template[$template]['attribute'][$detail])) {
|
||||
foreach ($template['may'] as $index => $detail) {
|
||||
if (isset($template['attribute'])
|
||||
&& ! isset($template['attribute'][$detail])) {
|
||||
|
||||
unset($this->_template[$template]['may'][$index]);
|
||||
unset($template['may'][$index]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($attrs[$detail]))
|
||||
if (isset($this->_template[$template]['attribute'][$detail]))
|
||||
$this->_template[$template]['empty_attrs'][$detail] = $this->_template[$template]['attribute'][$detail];
|
||||
if (isset($template['attribute'][$detail]))
|
||||
$template['empty_attrs'][$detail] = $template['attribute'][$detail];
|
||||
else
|
||||
$this->_template[$template]['empty_attrs'][$detail]['display'] = $detail;
|
||||
$template['empty_attrs'][$detail]['display'] = $detail;
|
||||
|
||||
else
|
||||
$this->_template[$template]['attrs'][$detail] = $attrs[$detail];
|
||||
$template['attrs'][$detail] = $attrs[$detail];
|
||||
}
|
||||
|
||||
# Add the must attrs to the attributes key.
|
||||
foreach ($this->_template[$template]['must'] as $index => $detail) {
|
||||
foreach ($template['must'] as $index => $detail) {
|
||||
|
||||
if (! isset($attrs[$detail])) {
|
||||
if (isset($this->_template[$template]['attribute'][$detail]))
|
||||
$this->_template[$template]['empty_attrs'][$detail] = $this->_template[$template]['attribute'][$detail];
|
||||
if (isset($template['attribute'][$detail]))
|
||||
$template['empty_attrs'][$detail] = $template['attribute'][$detail];
|
||||
else
|
||||
$this->_template[$template]['empty_attrs'][$detail]['display'] = $detail;
|
||||
$template['empty_attrs'][$detail]['display'] = $detail;
|
||||
|
||||
$this->_template[$template]['empty_attrs'][$detail]['must'] = true;
|
||||
$template['empty_attrs'][$detail]['must'] = true;
|
||||
} else
|
||||
$this->_template[$template]['attrs'][$detail] = $attrs[$detail];
|
||||
$template['attrs'][$detail] = $attrs[$detail];
|
||||
}
|
||||
|
||||
# Check if there are any items without a page or order parameter, and make it 1 and 255.
|
||||
foreach ($this->_template[$template]['empty_attrs'] as $index => $detail) {
|
||||
foreach ($template['empty_attrs'] as $index => $detail) {
|
||||
if (! isset($detail['page']))
|
||||
$this->_template[$template]['empty_attrs'][$index]['page'] = 1;
|
||||
$template['empty_attrs'][$index]['page'] = 1;
|
||||
if (! isset($detail['order']))
|
||||
$this->_template[$template]['empty_attrs'][$index]['order'] = 255;
|
||||
$template['empty_attrs'][$index]['order'] = 255;
|
||||
}
|
||||
|
||||
# Check we have some manditory items.
|
||||
foreach (array('rdn','structural','visible') as $key) {
|
||||
if (! isset($this->_template[$template][$key])
|
||||
|| (! is_array($this->_template[$template][$key]) && ! trim($this->_template[$template][$key]))) {
|
||||
if (! isset($template[$key])
|
||||
|| (! is_array($template[$key]) && ! trim($template[$key]))) {
|
||||
|
||||
//unset($this->_template[$template]);
|
||||
$this->_template[$template]['invalid'] = 1;
|
||||
$this->_template[$template]['invalid_reason'] = sprintf(_('Missing %s in the XML file.'),$key);
|
||||
//unset($template);
|
||||
$template['invalid'] = 1;
|
||||
$template['invalid_reason'] = sprintf(_('Missing %s in the XML file.'),$key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_creation_template[$xtemplate] = $template;
|
||||
}
|
||||
|
||||
function _parseXML($index,$attr_details) {
|
||||
@@ -423,12 +425,12 @@ class Templates {
|
||||
return $parseXML;
|
||||
}
|
||||
|
||||
function getTemplate($template) {
|
||||
return isset($this->_template[$template]) ? $this->_template[$template] : null;
|
||||
function getCreationTemplate($template) {
|
||||
return isset($this->_creation_template[$template]) ? $this->_creation_template[$template] : null;
|
||||
}
|
||||
|
||||
function getTemplates() {
|
||||
return $this->_template;
|
||||
function getCreationTemplates() {
|
||||
return $this->_creation_template;
|
||||
}
|
||||
|
||||
function OnChangeAdd($ldapserver,$origin,$value) {
|
||||
@@ -438,7 +440,8 @@ class Templates {
|
||||
|
||||
global $_js_hash;
|
||||
|
||||
list($command,$arg) = split(':',$value);
|
||||
# limit to 2 fields because of 'C:\\my directory\\foobar'
|
||||
list($command,$arg) = split(':',$value,2);
|
||||
|
||||
switch ($command) {
|
||||
/*
|
||||
@@ -447,7 +450,7 @@ class Templates {
|
||||
to substitute values read from other fields.
|
||||
|start-end is optional, but must be present if the k flag is used.
|
||||
/flags is optional.
|
||||
|
||||
|
||||
flags may be:
|
||||
T: Read display text from selection item (drop-down list), otherwise, read the value of the field
|
||||
For fields that aren't selection items, /T shouldn't be used, and the field value will always be read.
|
||||
@@ -465,7 +468,7 @@ class Templates {
|
||||
*/
|
||||
case 'autoFill' :
|
||||
list($attr,$string) = preg_split('(([^,]+),(.*))',$arg,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%/U',$string,$matchall);
|
||||
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[klTUA]+)?%/U',$string,$matchall);
|
||||
//print"<PRE>";print_r($matchall); //0 = highlevel match, 1 = attr, 2 = subst, 3 = mod
|
||||
|
||||
if (! isset($_js_hash['autoFill'.$origin]))
|
||||
@@ -529,17 +532,20 @@ class Templates {
|
||||
if (strstr($match_mod,'U')) {
|
||||
$_js_hash['autoFill'.$origin] .= sprintf(" %s = %s.toUpperCase();\n",$match_attr,$match_attr);
|
||||
}
|
||||
if (strstr($match_mod,'A')) {
|
||||
$_js_hash['autoFill'.$origin] .= sprintf(" %s = toAscii(%s);\n",$match_attr,$match_attr);
|
||||
}
|
||||
|
||||
# Matchfor only entry without modifiers.
|
||||
$formula = preg_replace('/^%('.$match_attr.')%$/U','$1 + \'\'',$formula);
|
||||
# Matchfor only entry with modifiers.
|
||||
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','$1 + \'\'',$formula);
|
||||
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTUA]+)?%$/U','$1 + \'\'',$formula);
|
||||
# Matchfor begining entry.
|
||||
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%/U','$1 + \'',$formula);
|
||||
$formula = preg_replace('/^%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTUA]+)?%/U','$1 + \'',$formula);
|
||||
# Matchfor ending entry.
|
||||
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTU]+)?%$/U','\' + $1 ',$formula);
|
||||
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[klTUA]+)?%$/U','\' + $1 ',$formula);
|
||||
# Match for entries not at begin/end.
|
||||
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[:lTU]+)?%/U','\' + $1 + \'',$formula);
|
||||
$formula = preg_replace('/%('.$match_attr.')(\|[0-9]*-[0-9]*)?(\/[:lTUA]+)?%/U','\' + $1 + \'',$formula);
|
||||
}
|
||||
|
||||
$_js_hash['autoFill'.$origin] .= sprintf(" fillRec('%s', %s);\n",$attr,$formula);
|
||||
@@ -570,38 +576,319 @@ class Templates {
|
||||
|
||||
switch($matches[1]) {
|
||||
case 'GetNextNumber' :
|
||||
/*
|
||||
* mandatory arguments:
|
||||
* * arg 0
|
||||
* - "$" => 'auto_number','search_base' in config file
|
||||
* - "/","..","." => get container parent as usual
|
||||
* * arg 1
|
||||
* - "gid" or "uid" for autosearch
|
||||
* - idem or real attribute name for uidpool mechanism
|
||||
* (gid and uid are mapped to sambaNextGroupRid and sambaNextUserRid)
|
||||
* optional arguments:
|
||||
* * arg 2 (uidpool mechanism only)
|
||||
* - "true" increments attribute by 1
|
||||
* - "false" do nothing
|
||||
* * arg 3 (uidpool mechanism only)
|
||||
* ldap filter (must match one entry only in container)
|
||||
* * arg 4
|
||||
* calculus on number, eg:
|
||||
* *2;+1000 => number = (2*number) + 1000
|
||||
*/
|
||||
|
||||
if ($args[0] == '$')
|
||||
$args[0] = $ldapservers->GetValue($ldapserver->server_id,'auto_number','search_base');
|
||||
|
||||
$container = $ldapserver->getContainerParent($container,$args[0]);
|
||||
$detail['value'] = get_next_number($ldapserver,$container,$args[1],
|
||||
(!empty($args[2]) && ($args[2] == 'true')) ? true : false,(!empty($args[3])) ? $args[3] : false);
|
||||
|
||||
$detail['value'] = get_next_number($ldapserver,$container,$args[1]);
|
||||
# operate calculus on next number.
|
||||
if (!empty($args[4])) {
|
||||
$mod = split(';',$args[4]);
|
||||
|
||||
$next_number = $detail['value'];
|
||||
|
||||
foreach ($mod as $calc) {
|
||||
$operand = $calc{0};
|
||||
$operator = substr ($calc,1);
|
||||
|
||||
switch ($operand) {
|
||||
case '*':
|
||||
$next_number = $next_number * $operator;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
$next_number = $next_number + $operator;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
$next_number = $next_number - $operator;
|
||||
break;
|
||||
|
||||
case '/':
|
||||
$next_number = $next_number / $operator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$detail['value'] = $next_number;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PickList' :
|
||||
/*
|
||||
* PickList Syntax:
|
||||
* arg0: container, from current position
|
||||
* arg1: LDAP filter. must replace '&' by '&'
|
||||
* arg2: list attribute key
|
||||
* arg3: display, as usual
|
||||
optional arguments:
|
||||
* arg4: output attribute
|
||||
* arg5: container override
|
||||
* arg6: csv list (; separator) of added values. syntax key => display_attribute=value; key...
|
||||
* arg7: csv list (; separator) of sort attributes (less to more important)
|
||||
* example
|
||||
* <value>=php.PickList(/,(&(objectClass=sambaGroupMapping)(|(cn=domain administrator)(cn=domain users)(cn=domain guests))),sambaSID,%cn% (%sambaSID%),sambaPrimaryGroupSID,dmdname=users:::dmdName=groups:::dc=example:::dc=com, S-1-5-XX-YYY => cn=Administrators ; S-1-5-XX-YYY => cn=Users ; S-1-5-XX-YYY => cn=Guests ; S-1-5-XX-YYY => cn=power users,cn)</value>
|
||||
*/
|
||||
|
||||
$container = $ldapserver->getContainerParent($container,$args[0]);
|
||||
preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$args[3],$matchall);
|
||||
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
|
||||
|
||||
$ldap_attrs = $matchall[1];
|
||||
array_push($ldap_attrs,$args[2]);
|
||||
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs);
|
||||
|
||||
$args[1] = str_replace ('&','&',$args[1]);
|
||||
|
||||
# arg5 overrides container
|
||||
if (!empty($args[5]))
|
||||
$container = str_replace(':::',',',$args[5]);
|
||||
|
||||
if (!empty($args[7])) {
|
||||
$sort_attrs = split(';',$args[7]);
|
||||
$ldap_attrs = array_merge($ldap_attrs,$sort_attrs);
|
||||
}
|
||||
|
||||
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs,
|
||||
(isset($args[7])) ? $sort_attrs : false);
|
||||
|
||||
if (!empty($args[6])) {
|
||||
$args[6] = str_replace(':::',',',$args[6]);
|
||||
$fixedvalues = split(';',$args[6]);
|
||||
|
||||
foreach ($fixedvalues as $fixedvalue) {
|
||||
$fixedvalue = preg_split('#=\>#',$fixedvalue);
|
||||
$displayvalue = split('=',$fixedvalue[1]);
|
||||
$newvalue[trim($fixedvalue[0])] = array( $args[2] => trim($fixedvalue[0]),
|
||||
trim($displayvalue[0]) => trim($displayvalue[1]));
|
||||
$picklistvalues = array_merge($picklistvalues,$newvalue);
|
||||
}
|
||||
}
|
||||
|
||||
$detail['value'] = sprintf('<select name="form[%s]" id="%%s" %%s %%s>',(isset($args[4]) ? $args[4] : $args[2]));
|
||||
$counter = 0;
|
||||
foreach ($picklistvalues as $key => $values) {
|
||||
$display = $args[3];
|
||||
|
||||
foreach ($matchall[1] as $arg) {
|
||||
foreach ($matchall[1] as $arg)
|
||||
$display = preg_replace('/%('.$arg.')(\|.+)?(\/[lU])?%/U',$values[$arg],$display);
|
||||
|
||||
if (! isset($picklist[$values[$args[2]]])) {
|
||||
$detail['value'] .= sprintf('<option id="%s%s" value="%s" %s>%s</option>',
|
||||
(!empty($args[4]) ? $args[4] : $args[2]),++$counter,$values[$args[2]],
|
||||
($default == $values[$args[2]]) ? 'selected' : '',
|
||||
$display);
|
||||
|
||||
$picklist[$values[$args[2]]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$detail['value'] .= '</select>';
|
||||
|
||||
break;
|
||||
|
||||
case 'MultiList' :
|
||||
/*
|
||||
* MultiList Syntax:
|
||||
*/
|
||||
/**
|
||||
mandatory fields:
|
||||
arg 0: "/" ,"..","." - from container dn
|
||||
arg 1: search filter, may have values like '%gidNumber%, in case of it is replaced
|
||||
by the gidNumber setted in previous pages. '&' must be replaced by '&'
|
||||
because of xml...
|
||||
arg 2: the key of retrived values
|
||||
optional fields:
|
||||
arg 3: display, as usual (plus modifier /C: Capitalize). replaced by %arg 2% if not given
|
||||
arg 4: the value furnished in output - must be attribute id. replaced by arg 2 if not given
|
||||
arg 5: override of container (replace ',' by ':::' in dn)
|
||||
arg 6: csv (; separator) list of added values. syntax: value => display_key=display_value
|
||||
arg 7: csv (; separator) list of attributes which list must be sort by. less to more important
|
||||
arg 8: size of displayed list (default: 10lines)
|
||||
arg 9: preselected values filter. see arg 1.
|
||||
arg 10: key of preselected values. replaced by arg 4 if not given. replaced bty arg 2 if both are not given.
|
||||
arg 11: base dn override for preselected values
|
||||
|
||||
unusual exemple:)
|
||||
<value>=php.MultiList(/,(&(objectClass=posixAccount)(uid=groupA*)),uid,%cn/U% (%gidNumber%),memberUid,dmdName=users,root => cn=root; nobody => cn=nobody,gidNumber,10,(gidNuber=%gidNumber%),uid)</value>
|
||||
minimal exemple:
|
||||
<value>=php.MultiList(/,(objectClass=posixAccount),uid)</value>
|
||||
**/
|
||||
|
||||
$container = $ldapserver->getContainerParent($container,$args[0]);
|
||||
|
||||
/*
|
||||
* process filter (arg 1), eventually replace %attr% by it's value
|
||||
* setted in a previous page.
|
||||
*/
|
||||
$args[1] = str_replace('&','&',$args[1]);
|
||||
|
||||
preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$args[1],$filtermatchall);
|
||||
$formvalues = array_change_key_case($_REQUEST['form']);
|
||||
|
||||
foreach ($filtermatchall[1] as $arg) {
|
||||
$value=$formvalues[strtolower($arg)];
|
||||
$args[1] = preg_replace('/%('.$arg.')(\|.+)?(\/[lU])?%/U',$value,$args[1]);
|
||||
}
|
||||
|
||||
$args[3] = !empty($args[3]) ? $args[3] : "%{$args[2]}%";
|
||||
|
||||
preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$args[3],$matchall);
|
||||
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
|
||||
|
||||
$ldap_attrs = $matchall[1];
|
||||
array_push($ldap_attrs,$args[2]);
|
||||
|
||||
/*
|
||||
* container is arg 5 if set
|
||||
* with arg 5 = 'dc=thissubtree:::dc=thistree' stands for 'dc=subtree,dc=tree'
|
||||
* => 'dc=subtree,dc=tree,dc=container'
|
||||
*/
|
||||
if (isset($args[5]) && ($args[5]))
|
||||
$container = str_replace(':::',',',$args[5]);
|
||||
|
||||
/*
|
||||
* arg 7 is sort attributes
|
||||
* eg: 'sn;givenName'
|
||||
*/
|
||||
if (isset($args[7])) {
|
||||
$sort_attrs = split(';',$args[7]);
|
||||
$ldap_attrs = array_merge($ldap_attrs,$sort_attrs);
|
||||
}
|
||||
|
||||
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs,
|
||||
(isset($args[7]) && ($args[7])) ? $sort_attrs : false);
|
||||
|
||||
# arg 6 is a set of fixed values to add to search result
|
||||
if (isset($args[6])) {
|
||||
$args[6] = str_replace(':::',',',$args[6]);
|
||||
$fixedvalues = split(';',$args[6]);
|
||||
|
||||
foreach ($fixedvalues as $fixedvalue) {
|
||||
if (empty($fixedvalue))
|
||||
continue;
|
||||
|
||||
$fixedvalue = preg_split('#=\>#',$fixedvalue);
|
||||
$displayvalue = split('=',$fixedvalue[1]);
|
||||
$newvalue[trim($fixedvalue[0])] = array($args[2] => trim($fixedvalue[0]),
|
||||
trim($displayvalue[0]) => trim($displayvalue[1]));
|
||||
$picklistvalues = array_merge($picklistvalues,$newvalue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* arg 9 is the search filter for already selected values, with criteriai eventually
|
||||
* coming from previous pages (eg: %uid%)
|
||||
*/
|
||||
if (isset($args[9])) {
|
||||
$args[9] = str_replace('&','&',$args[9]);
|
||||
|
||||
preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$args[9],$matchallinlist);
|
||||
|
||||
foreach ($matchallinlist[1] as $arg) {
|
||||
$value=$formvalues[strtolower($arg)];
|
||||
|
||||
$args[9] = preg_replace('/%('.$arg.')(\|.+)?(\/[lU])?%/U',$value,$args[9]);
|
||||
}
|
||||
|
||||
if (! isset($picklist[$display])) {
|
||||
$detail['value'] .= sprintf('<option id="%s%s" value="%s" %s>%s</option>',
|
||||
(isset($args[4]) ? $args[4] : $args[2]),++$counter,$values[$args[2]],
|
||||
($default == $display ? 'selected' : ''),
|
||||
$display);
|
||||
$picklist[$display] = true;
|
||||
# arg 11 overrides container dn for selected values
|
||||
if (!empty($args[11]))
|
||||
$container = str_replace(':::',',',$args[11]);
|
||||
|
||||
$inpicklistvalues = return_ldap_hash($ldapserver,$container,$args[9],$args[2],$ldap_attrs);
|
||||
}
|
||||
|
||||
$detail['value'] = sprintf('<select name="form[%s][]" multiple="multiple" size="%s" id="%%s" %%s %%s>',
|
||||
(isset($args[4])) ? $args[4] : $args[2],
|
||||
# arg 8 is the size (nbr of displayed lines) of select
|
||||
(isset($args[8])) ? $args[8] : 10);
|
||||
|
||||
$counter = 0;
|
||||
foreach ($picklistvalues as $key => $values) {
|
||||
$display = $args[3];
|
||||
|
||||
foreach ($matchall[1] as $key => $arg) {
|
||||
$disp_val = $values[$arg];
|
||||
|
||||
if ($matchall[3][$key])
|
||||
switch ($matchall[3][$key]) {
|
||||
case '/l':
|
||||
# lowercase
|
||||
$disp_val = mb_convert_case($disp_val,MB_CASE_LOWER,'utf-8');
|
||||
break;
|
||||
|
||||
case '/U':
|
||||
# uppercase
|
||||
$disp_val = mb_convert_case($disp_val,MB_CASE_UPPER,'utf-8');
|
||||
break;
|
||||
|
||||
case '/C':
|
||||
# capitalize
|
||||
$disp_val = mb_convert_case($disp_val,MB_CASE_TITLE,'utf-8');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
# make value a substring of
|
||||
preg_match_all('/^\|([0-9]*)-([0-9]*)$/',trim($matchall[2][$key]),$substrarray);
|
||||
|
||||
if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
|
||||
$begin = $substrarray[1][0] ? $substrarray[1][0] : '0';
|
||||
$end = $substrarray[2][0] ? $substrarray[2][0] : strlen($disp_val);
|
||||
$disp_val = mb_substr($disp_val,$begin,$end,'utf-8');
|
||||
}
|
||||
|
||||
$display = preg_replace('/%('.$arg.')(\|.+)?(\/[lUC])?%/U',$disp_val,$display);
|
||||
}
|
||||
|
||||
if (! isset($picklist[$values[$args[2]]])) {
|
||||
if (!isset($args[9])) {
|
||||
|
||||
# there is no criteria filter for selected values
|
||||
$detail['value'] .= sprintf('<option id="%s%s" value="%s" %s>%s</option>',
|
||||
# arg 4 is the output criteria
|
||||
((isset($args[4]) && !empty($args[4])) ? $args[4] : $args[2]),
|
||||
++$counter,
|
||||
$values[$args[2]],
|
||||
# if the value the default, then select it
|
||||
(in_array($values[$args[2]],$default)) ? 'selected' : '',
|
||||
$display);
|
||||
|
||||
} else {
|
||||
# if default filter is given
|
||||
$detail['value'] .= sprintf('<option id="%s%s" value="%s" %s>%s</option>',
|
||||
(isset($args[4]) ? $args[4] : $args[2]),
|
||||
++$counter,
|
||||
$values[$args[2]],
|
||||
# arg 10 is the key for filter values
|
||||
(array_key_exists($values[(isset($args[10]) ? $args[10] : (isset($args[4]) ? $args[4] : $args[2]))],$inpicklistvalues)) ? 'selected' : '',
|
||||
$display);
|
||||
}
|
||||
|
||||
$picklist[$values[$args[2]]] = true;
|
||||
}
|
||||
}
|
||||
$detail['value'] .= '</select>';
|
||||
@@ -666,11 +953,12 @@ class Templates {
|
||||
|
||||
if ($container && $ldapserver && ! is_array($helper)) {
|
||||
if (preg_match('/^=php./',$helper))
|
||||
return $this->EvaluateDefault($ldapserver,$helper,$container,$counter);
|
||||
$html = sprintf('<input type="text" name="%s" value="%s" size="8" />',$id,
|
||||
$this->EvaluateDefault($ldapserver,$helper,$container,$counter));
|
||||
|
||||
else
|
||||
# @todo: Enable size and width configuration in template
|
||||
$html = sprintf('<input type="text" name="%s" size="8">',$id);
|
||||
$html = sprintf('<input type="text" name="%s" size="8" />',$id);
|
||||
|
||||
} else {
|
||||
if (is_array($helper)) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/tree_functions.php,v 1.25 2006/05/13 12:52:27 wurley Exp $
|
||||
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/tree_functions.php,v 1.29 2007/03/18 00:45:24 wurley Exp $
|
||||
|
||||
/**
|
||||
* @package phpLDAPadmin
|
||||
@@ -39,13 +39,13 @@ function draw_server_tree() {
|
||||
echo '<tr class="server">';
|
||||
printf('<td class="icon"><img src="images/server.png" alt="%s" /></td>',_('Server'));
|
||||
printf('<td colspan="99"><a name="%s"></a>',$ldapserver->server_id);
|
||||
printf('<nobr>%s ',htmlspecialchars($ldapserver->name));
|
||||
printf('<span style="white-space: nowrap;">%s ',htmlspecialchars($ldapserver->name));
|
||||
|
||||
if ($ldapserver->haveAuthInfo() && $ldapserver->auth_type != 'config')
|
||||
printf('<acronym title="%s"><img width=14 height=14 src="images/timeout.png" alt="timeout" /></acronym>',
|
||||
sprintf(_('Inactivity will log you off at %s'),strftime('%H:%M',time()+($ldapserver->session_timeout*60))));
|
||||
|
||||
echo '</nobr></td></tr>';
|
||||
echo '</span></td></tr>';
|
||||
|
||||
/* do we have what it takes to authenticate here, or do we need to
|
||||
present the user with a login link (for 'cookie' and 'session' auth_types)? */
|
||||
@@ -62,7 +62,7 @@ function draw_server_tree() {
|
||||
|
||||
# Draw the quick-links below the server name:
|
||||
echo '<tr><td colspan="100" class="links">';
|
||||
echo '<nobr>';
|
||||
echo '<span style="white-space: nowrap;">';
|
||||
echo '( ';
|
||||
printf('<a title="%s %s" href="%s">%s</a> | ',_('View schema for'),$ldapserver->name,$schema_href,_('schema'));
|
||||
printf('<a title="%s %s" href="%s">%s</a> | ',_('search'),$ldapserver->name,$search_href,_('search'));
|
||||
@@ -74,11 +74,11 @@ function draw_server_tree() {
|
||||
if ($ldapserver->auth_type != 'config')
|
||||
printf(' | <a title="%s" href="%s" target="right_frame">%s</a>',_('Logout of this server'),$logout_href,_('logout'));
|
||||
|
||||
echo ' )</nobr></td></tr>';
|
||||
echo ' )</span></td></tr>';
|
||||
|
||||
if ($ldapserver->auth_type != 'config') {
|
||||
$logged_in_dn = $ldapserver->getLoggedInDN();
|
||||
echo '<tr><td class="links" colspan="100"><nobr>'._('Logged in as: ');
|
||||
echo '<tr><td class="links" colspan="100"><span style="white-space: nowrap;">'._('Logged in as: ');
|
||||
|
||||
if ($ldapserver->getDNBase($logged_in_dn) == $logged_in_dn) {
|
||||
$logged_in_branch = '';
|
||||
@@ -86,7 +86,7 @@ function draw_server_tree() {
|
||||
|
||||
} else {
|
||||
$logged_in_branch = preg_replace('/,'.$ldapserver->getDNBase($logged_in_dn).'$/','',$logged_in_dn);
|
||||
$logged_in_dn_array = explode(',',$logged_in_branch);
|
||||
$logged_in_dn_array = pla_explode_dn($logged_in_branch);
|
||||
}
|
||||
|
||||
$bases = $ldapserver->getDNBase($logged_in_dn);
|
||||
@@ -110,11 +110,11 @@ function draw_server_tree() {
|
||||
} else
|
||||
echo 'Anonymous';
|
||||
|
||||
echo '</nobr></td></tr>';
|
||||
echo '</span></td></tr>';
|
||||
}
|
||||
|
||||
if ($ldapserver->isReadOnly())
|
||||
printf('<tr><td class="links" colspan="100"><nobr>(%s)</nobr></td></tr>',_('read only'));
|
||||
printf('<tr><td class="links" colspan="100"><span style="white-space: nowrap;">(%s)</span></td></tr>',_('read only'));
|
||||
|
||||
$javascript_forms = '';
|
||||
$javascript_id = 0;
|
||||
@@ -176,7 +176,8 @@ function draw_server_tree() {
|
||||
$child_count = null;
|
||||
|
||||
} else {
|
||||
$children = $ldapserver->getContainerContents($base_dn,$size_limit+1,'(objectClass=*)',
|
||||
$children = $ldapserver->getContainerContents($base_dn,$size_limit+1,
|
||||
$config->GetValue('appearance','tree_filter'),
|
||||
$config->GetValue('deref','tree'));
|
||||
|
||||
$child_count = count($children);
|
||||
@@ -206,12 +207,12 @@ function draw_server_tree() {
|
||||
|
||||
printf('<td class="expander"><a href="%s"><img src="%s" alt="%s" /></a></td>',$expand_href,$expand_img,$expand_alt);
|
||||
printf('<td class="icon"><a href="%s" target="right_frame"><img src="images/%s" alt="img" /></a></td>',$edit_href,$icon);
|
||||
printf('<td class="rdn" colspan="98"><nobr><a href="%s" target="right_frame">%s</a>',$edit_href,pretty_print_dn($base_dn));
|
||||
printf('<td class="rdn" colspan="98"><span style="white-space: nowrap;"><a href="%s" target="right_frame">%s</a>',$edit_href,pretty_print_dn($base_dn));
|
||||
|
||||
if ($child_count)
|
||||
printf(' <span class="count">(%s)</span>',$child_count);
|
||||
|
||||
echo '</nobr></td>';
|
||||
echo '</span></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
@@ -235,8 +236,9 @@ function draw_server_tree() {
|
||||
# Is the root of the tree expanded already?
|
||||
if (isset($tree['browser'][$base_dn]['open'] ) && $tree['browser'][$base_dn]['open']) {
|
||||
|
||||
if ($ldapserver->isShowCreateEnabled() && count($tree['browser'][$base_dn]['children']) > 10 )
|
||||
draw_create_link($ldapserver->server_id,$base_dn,-1,urlencode($base_dn));
|
||||
if ($config->GetValue('appearance', 'show_top_create'))
|
||||
if ($ldapserver->isShowCreateEnabled() && count($tree['browser'][$base_dn]['children']) > 10 )
|
||||
draw_create_link($ldapserver->server_id,$base_dn,-1,urlencode($base_dn));
|
||||
|
||||
foreach ($tree['browser'][$base_dn]['children'] as $child_dn)
|
||||
draw_tree_html($child_dn,$ldapserver,0);
|
||||
@@ -336,9 +338,9 @@ function draw_tree_html($dn,$ldapserver,$level=0) {
|
||||
$child_count = number_format(count($tree['browser'][$dn]['children']));
|
||||
|
||||
if ((! $child_count) && (! $ldapserver->isShowCreateEnabled()))
|
||||
echo '<td class="expander"><nobr><img src="images/minus.png" alt="-" /></nobr></td>';
|
||||
echo '<td class="expander"><span style="white-space: nowrap;"><img src="images/minus.png" alt="-" /></span></td>';
|
||||
else
|
||||
printf('<td class="expander"><nobr><a href="%s"><img src="images/minus.png" alt="-" /></a></nobr></td>',$collapse_href);
|
||||
printf('<td class="expander"><span style="white-space: nowrap;"><a href="%s"><img src="images/minus.png" alt="-" /></a></span></td>',$collapse_href);
|
||||
|
||||
} else {
|
||||
$size_limit = $config->GetValue('search','size_limit');
|
||||
@@ -354,28 +356,27 @@ function draw_tree_html($dn,$ldapserver,$level=0) {
|
||||
}
|
||||
|
||||
if ((! $child_count) && (! $ldapserver->isShowCreateEnabled()))
|
||||
echo '<td class="expander"><nobr><img src="images/minus.png" alt="-" /></nobr></td>';
|
||||
echo '<td class="expander"><span style="white-space: nowrap;"><img src="images/minus.png" alt="-" /></span></td>';
|
||||
else
|
||||
printf('<td class="expander"><nobr><a href="%s"><img src="images/plus.png" alt="+" /></a></nobr></td>',$expand_href);
|
||||
printf('<td class="expander"><span style="white-space: nowrap;"><a href="%s"><img src="images/plus.png" alt="+" /></a></span></td>',$expand_href);
|
||||
}
|
||||
|
||||
printf('<td class="icon"><a href="%s" target="right_frame" name="%s_%s"><img src="%s" alt="img" /></a></td>',
|
||||
$edit_href,$ldapserver->server_id,$encoded_dn,$img_src);
|
||||
|
||||
printf('<td class="rdn" colspan="%s"><nobr>',97-$level);
|
||||
printf('<td class="rdn" colspan="%s"><span style="white-space: nowrap;">',97-$level);
|
||||
printf('<a href="%s" target="right_frame">%s</a>',$edit_href,draw_formatted_dn($ldapserver,$dn));
|
||||
|
||||
if ($child_count)
|
||||
printf(' <span class="count">(%s)</span>',$child_count);
|
||||
|
||||
echo '</nobr></td></tr>';
|
||||
echo '</span></td></tr>';
|
||||
|
||||
if (isset($tree['browser'][$dn]['open']) && $tree['browser'][$dn]['open']) {
|
||||
/* Draw the "create new" link at the top of the tree list if there are more than 10
|
||||
entries in the listing for this node. */
|
||||
|
||||
if ((count($tree['browser'][$dn]['children']) > 10) && ($ldapserver->isShowCreateEnabled()))
|
||||
draw_create_link($ldapserver->server_id,$rdn,$level,$encoded_dn);
|
||||
|
||||
if ($config->GetValue('appearance', 'show_top_create'))
|
||||
if ((count($tree['browser'][$dn]['children']) > 10) && ($ldapserver->isShowCreateEnabled()))
|
||||
draw_create_link($ldapserver->server_id,$rdn,$level,$encoded_dn);
|
||||
|
||||
foreach ($tree['browser'][$dn]['children'] as $dn)
|
||||
draw_tree_html($dn,$ldapserver,$level+1);
|
||||
|
Reference in New Issue
Block a user