2009-06-30 08:12:47 +00:00
|
|
|
<?php
|
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/templates/modification/default.php,v 1.52 2004/04/23 13:26:31 uugdave Exp $
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* edit.php
|
|
|
|
* Displays the specified dn from the specified server for editing
|
|
|
|
*
|
|
|
|
* Variables that come in as GET vars:
|
|
|
|
* - dn (rawurlencoded)
|
|
|
|
* - server_id
|
|
|
|
* - modified_attrs (optional) an array of attributes to highlight as
|
|
|
|
* they were changed by the last operation
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** If an entry has more children than this, stop searching and display this amount with a '+' */
|
|
|
|
$max_children = 100;
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
$dn = isset( $_GET['dn'] ) ? $_GET['dn'] : null;
|
2009-06-30 08:09:20 +00:00
|
|
|
$encoded_dn = rawurlencode( $dn );
|
|
|
|
$modified_attrs = isset( $_GET['modified_attrs'] ) ? $_GET['modified_attrs'] : false;
|
|
|
|
$server_id = $_GET['server_id'];
|
|
|
|
$show_internal_attrs = isset( $_GET['show_internal_attrs'] ) ? true : false;
|
2009-06-30 08:12:47 +00:00
|
|
|
if( null != $dn ) {
|
|
|
|
$rdn = pla_explode_dn( $dn );
|
|
|
|
if( isset( $rdn[0] ) )
|
|
|
|
$rdn = $rdn[0];
|
|
|
|
else
|
|
|
|
$rdn = null;
|
|
|
|
} else {
|
|
|
|
$rdn = null;
|
|
|
|
}
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
|
|
|
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
|
|
|
pla_ldap_connect( $server_id ) or pla_error( "Coult not connect to LDAP server." );
|
|
|
|
$friendly_attrs = process_friendly_attr_table();
|
2009-06-30 08:12:47 +00:00
|
|
|
$attrs = get_object_attrs( $server_id, $dn, false, get_view_deref_setting() );
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
2009-06-30 08:12:47 +00:00
|
|
|
$system_attrs = get_entry_system_attrs( $server_id, $dn, get_view_deref_setting() );
|
|
|
|
dn_exists( $server_id, $dn ) or pla_error( sprintf( $lang['no_such_entry'], pretty_print_dn( $dn ) ) );
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
$server_name = $servers[$server_id]['name'];
|
|
|
|
|
|
|
|
include 'header.php'; ?>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h3 class="title"><?php echo htmlspecialchars( ( $rdn ) ); ?></h3>
|
|
|
|
<h3 class="subtitle"><?php echo $lang['server']; ?>: <b><?php echo $server_name; ?></b> <?php echo $lang['distinguished_name'];?>: <b><?php echo htmlspecialchars( ( $dn ) ); ?></b></h3>
|
|
|
|
|
|
|
|
<table class="edit_dn_menu">
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<?php $time = gettimeofday(); $random_junk = md5( strtotime( 'now' ) . $time['usec'] ); ?>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/refresh.png" /></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>&random=<?php
|
|
|
|
echo $random_junk; ?>"
|
|
|
|
title="<?php echo $lang['refresh_this_entry']; ?>"><?php echo $lang['refresh_entry']; ?></a></td>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/save.png" /></td>
|
|
|
|
<?php $export_url = "export_form.php?server_id=$server_id&dn=$encoded_dn&scope=base"; ?>
|
|
|
|
<td><a href="<?php echo $export_url; ?>" title="<?php echo $lang['export_tooltip']; ?>"><?php echo $lang['export']; ?></a></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/cut.png" /></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td><a href="copy_form.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn?>"
|
|
|
|
title="<?php echo $lang['copy_this_entry_tooltip']; ?>"><?php echo $lang['copy_this_entry']; ?></a></td>
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( $show_internal_attrs ) { ?>
|
|
|
|
<td class="icon"><img src="images/tools-no.png" /></td>
|
|
|
|
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>"><?php echo $lang['hide_internal_attrs']; ?></a></td>
|
|
|
|
<?php } else { ?>
|
|
|
|
<td class="icon"><img src="images/tools.png" /></td>
|
|
|
|
<td><a href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>&show_internal_attrs=true"><?php echo $lang['show_internal_attrs']; ?></a></td>
|
|
|
|
<?php } ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
|
|
|
<tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/trash.png" /></td>
|
|
|
|
<td><a href="delete_form.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>"
|
|
|
|
title="<?php echo $lang['delete_this_entry_tooltip']; ?>"><?php echo $lang['delete_this_entry']; ?></a></td>
|
|
|
|
<td class="icon"><img src="images/rename.png" /></td>
|
|
|
|
<td><a href="rename_form.php?server_id=<?php echo $server_id; ?>&dn=<?php echo $encoded_dn; ?>"><?php echo $lang['rename']; ?></a></td>
|
|
|
|
<?php if( show_hints() ) { ?>
|
|
|
|
<tr>
|
|
|
|
<td class="icon"><img src="images/light.png" /></td>
|
|
|
|
<td colspan="3"><span class="hint"><?php echo $lang['delete_hint']; ?></span></td>
|
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
</tr>
|
|
|
|
<td class="icon"><img src="images/star.png" /></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td><a href="<?php echo "create_form.php?server_id=$server_id&container=$encoded_dn"; ?>"><?php echo $lang['create_a_child_entry']; ?></a></td>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/add.png" /></td>
|
|
|
|
<td><a href="<?php echo "add_attr_form.php?server_id=$server_id&dn=$encoded_dn"; ?>"><?php echo $lang['add_new_attribute']; ?></a></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php flush(); ?>
|
|
|
|
<?php $children = get_container_contents( $server_id, $dn, $max_children );
|
|
|
|
|
|
|
|
if( ($children_count = count( $children ) ) > 0 ) {
|
|
|
|
if( $children_count == $max_children )
|
|
|
|
$children_count = $children_count . '+';
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/children.png" /></td>
|
|
|
|
<td><a href="search.php?search=true&server_id=<?php echo $server_id; ?>&filter=<?php echo rawurlencode('objectClass=*'); ?>&base_dn=<?php echo $encoded_dn; ?>&form=advanced&scope=one"><?php
|
|
|
|
if( $children_count == 1 )
|
|
|
|
echo $lang['view_one_child'];
|
|
|
|
else
|
|
|
|
echo sprintf( $lang['view_children'], $children_count ); ?></a></td>
|
|
|
|
<td class="icon"><img src="images/save.png" /></td>
|
|
|
|
<?php $export_url = "export_form.php?server_id=$server_id&dn=$encoded_dn&scope=sub"; ?>
|
|
|
|
<td><a href="<?php echo $export_url; ?>"
|
|
|
|
title="<?php echo $lang['export_subtree_tooltip']; ?>"><?php echo $lang['export_subtree']; ?></a>
|
2009-06-30 08:09:20 +00:00
|
|
|
</td>
|
2009-06-30 08:12:47 +00:00
|
|
|
</tr>
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php } ?> <?php if( show_hints() ) { ?>
|
|
|
|
<tr>
|
|
|
|
<td class="icon"><img src="images/light.png" /></td>
|
|
|
|
<td colspan="3"><span class="hint"><?php echo $lang['attr_schema_hint']; ?></span></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if( is_server_read_only( $server_id ) ) { ?>
|
|
|
|
<tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/light.png" /></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td><?php echo $lang['viewing_read_only']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php if( $modified_attrs ) { ?>
|
|
|
|
<tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="icon"><img src="images/light.png" /></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php if( count( $modified_attrs ) > 1 ) { ?>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td colspan="3"><?php echo sprintf( $lang['attrs_modified'], implode( ', ', $modified_attrs ) ); ?></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php } else { ?>
|
2009-06-30 08:12:47 +00:00
|
|
|
<td colspan="3"><?php echo sprintf( $lang['attr_modified'], implode( '', $modified_attrs ) ); ?></td>
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php } ?>
|
|
|
|
</tr>
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php
|
|
|
|
// lower-case all the modified attrs to remove ambiguity when searching the array later
|
|
|
|
foreach( $modified_attrs as $i => $attr ) {
|
|
|
|
$modified_attrs[$i] = strtolower( $attr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<?php flush(); ?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<br />
|
|
|
|
<table class="edit_dn">
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if( $show_internal_attrs ) {
|
|
|
|
$counter = 0;
|
|
|
|
foreach( get_entry_system_attrs( $server_id, $dn ) as $attr => $vals ) {
|
|
|
|
$counter++;
|
2009-06-30 08:10:17 +00:00
|
|
|
$schema_href = "schema.php?server_id=$server_id&view=attributes&viewvalue=" . real_attr_name($attr);
|
2009-06-30 08:09:20 +00:00
|
|
|
?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<tr>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td class="attr"><b><a title="<?php echo sprintf( $lang['attr_name_tooltip'], $attr ); ?>"
|
|
|
|
href="<?php echo $schema_href; ?>"><?php echo htmlspecialchars( $attr ); ?></b></td>
|
2009-06-30 08:12:47 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td class="val">
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php
|
|
|
|
if( is_attr_binary( $server_id, $attr ) ) {
|
|
|
|
$href = "download_binary_attr.php?server_id=$server_id&dn=$encoded_dn&attr=$attr";
|
|
|
|
?>
|
|
|
|
<small>
|
|
|
|
<?php echo $lang['binary_value']; ?><br />
|
|
|
|
<?php if( count( $vals ) > 1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?>
|
|
|
|
<a href="<?php echo $href . "&value_num=$i"; ?>"><img
|
|
|
|
src="images/save.png" /> <?php echo $lang['download_value']; ?>(<?php echo $i; ?>)</a><br />
|
|
|
|
<?php } } else { ?>
|
|
|
|
<a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a><br />
|
|
|
|
<?php }
|
|
|
|
} else {
|
|
|
|
foreach( $vals as $v ) {
|
|
|
|
echo htmlspecialchars( $v );
|
|
|
|
echo "<br />\n";
|
|
|
|
}
|
|
|
|
} ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php }
|
|
|
|
if( $counter == 0 )
|
2009-06-30 08:12:47 +00:00
|
|
|
echo "<tr><td colspan=\"2\">(" . $lang['no_internal_attributes'] . ")</td></tr>\n";
|
2009-06-30 08:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php flush(); ?>
|
|
|
|
|
|
|
|
<!-- Table of attributes/values to edit -->
|
|
|
|
|
|
|
|
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
2009-06-30 08:12:47 +00:00
|
|
|
<form action="update_confirm.php" method="post" name="edit_form">
|
2009-06-30 08:09:20 +00:00
|
|
|
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
|
|
|
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php $counter=0; ?>
|
|
|
|
|
|
|
|
<?php /* Prepare the hidden_attrs array by lower-casing it (hidden_attrs comes from config.php). */
|
|
|
|
if( isset( $hidden_attrs ) && is_array( $hidden_attrs ) && count( $hidden_attrs ) > 0 )
|
|
|
|
foreach( $hidden_attrs as $i => $attr_name )
|
|
|
|
$hidden_attrs[$i] = strtolower( $attr_name );
|
|
|
|
else
|
|
|
|
$hidden_attrs = array();
|
|
|
|
?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php
|
|
|
|
if( ! $attrs || ! is_array( $attrs ) ) {
|
|
|
|
echo "<tr><td colspan=\"2\">(" . $lang['no_attributes'] . ")</td></tr>\n";
|
|
|
|
echo "</table>";
|
|
|
|
echo "</html>";
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php foreach( $attrs as $attr => $vals ) {
|
|
|
|
|
|
|
|
flush();
|
|
|
|
|
|
|
|
if( ! is_server_read_only( $server_id ) ) {
|
|
|
|
$schema_attr = get_schema_attribute( $server_id, $attr, $dn );
|
|
|
|
if( $schema_attr )
|
|
|
|
$attr_syntax = $schema_attr->getSyntaxOID();
|
|
|
|
else
|
|
|
|
$attr_syntax = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( 0 == strcasecmp( $attr, 'dn' ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// has the config.php specified that this attribute is to be hidden?
|
|
|
|
if( in_array( strtolower( $attr ), $hidden_attrs ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// is there a user-friendly translation available for this attribute?
|
|
|
|
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) ) {
|
|
|
|
$attr_display = $friendly_attrs[ strtolower( $attr ) ];
|
|
|
|
$attr_note = "<acronym title=\"" . sprintf( $lang['alias_for'], $attr_display, $attr ) . "\">alias</acronym>";
|
|
|
|
} else {
|
|
|
|
$attr_note = "";
|
|
|
|
$attr_display = $attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php
|
|
|
|
if( is_array( $modified_attrs ) && in_array( strtolower($attr), $modified_attrs ) )
|
|
|
|
$is_modified_attr = true;
|
|
|
|
else
|
|
|
|
$is_modified_attr = false;
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if( $is_modified_attr ) { ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<tr class="updated_attr">
|
|
|
|
<?php } else { ?>
|
2009-06-30 08:12:47 +00:00
|
|
|
<tr>
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<td class="attr" colspan="2">
|
2009-06-30 08:10:17 +00:00
|
|
|
<?php $schema_href="schema.php?server_id=$server_id&view=attributes&viewvalue=" . real_attr_name($attr); ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<b><a title="<?php echo sprintf( $lang['attr_name_tooltip'], $attr ) ?>"
|
|
|
|
href="<?php echo $schema_href; ?>"><?php echo $attr_display; ?></a></b>
|
|
|
|
<sup><small><?php echo $attr_note; ?></small></sup>
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( is_attr_read_only( $attr ) ) { ?>
|
|
|
|
<small>(<acronym title="<?php echo $lang['read_only_tooltip']; ?>"><?php echo $lang['read_only']; ?></acronym>)</small>
|
|
|
|
<?php } ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
</td>
|
2009-06-30 08:12:47 +00:00
|
|
|
</tr>
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( $is_modified_attr ) { ?>
|
|
|
|
<tr class="updated_attr">
|
|
|
|
<?php } else { ?>
|
|
|
|
<tr>
|
|
|
|
<?php } ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<td class="val">
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this attribute a jpegPhoto?
|
|
|
|
*/
|
|
|
|
if( is_jpeg_photo( $server_id, $attr ) ) {
|
|
|
|
|
|
|
|
// Don't draw the delete buttons if there is more than one jpegPhoto
|
|
|
|
// (phpLDAPadmin can't handle this case yet)
|
2009-06-30 08:12:47 +00:00
|
|
|
if( is_server_read_only( $server_id ) || is_attr_read_only( $attr ) )
|
|
|
|
draw_jpeg_photos( $server_id, $dn, $attr, false );
|
2009-06-30 08:09:20 +00:00
|
|
|
else
|
2009-06-30 08:12:47 +00:00
|
|
|
draw_jpeg_photos( $server_id, $dn, $attr, true );
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
// proceed to the next attribute
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this attribute binary?
|
|
|
|
*/
|
|
|
|
if( is_attr_binary( $server_id, $attr ) ) {
|
|
|
|
$href = "download_binary_attr.php?server_id=$server_id&dn=$encoded_dn&attr=$attr";
|
|
|
|
?>
|
|
|
|
|
|
|
|
<small>
|
|
|
|
<?php echo $lang['binary_value']; ?><br />
|
|
|
|
<?php if( count( $vals ) > 1 ) { for( $i=1; $i<=count($vals); $i++ ) { ?>
|
|
|
|
<a href="<?php echo $href . "&value_num=$i"; ?>"><img
|
|
|
|
src="images/save.png" /> <?php echo $lang['download_value']; ?>(<?php echo $i; ?>)</a><br />
|
|
|
|
<?php } } else { ?>
|
|
|
|
<a href="<?php echo $href; ?>"><img src="images/save.png" /> <?php echo $lang['download_value']; ?></a><br />
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( ! is_server_read_only( $server_id ) && ! is_attr_read_only( $attr ) ) { ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
<a href="javascript:deleteAttribute( '<?php echo $attr; ?>' );"
|
|
|
|
style="color:red;"><img src="images/trash.png" /> <?php echo $lang['delete_attribute']; ?></a>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</small>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<?php continue;
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
/*
|
|
|
|
* Note: at this point, the attribute must be text-based (not binary or jpeg)
|
|
|
|
*/
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
/*
|
2009-06-30 08:12:47 +00:00
|
|
|
* If this server is in read-only mode or this attribute is configured as read_only,
|
|
|
|
* simply draw the attribute values and continue.
|
2009-06-30 08:09:20 +00:00
|
|
|
*/
|
2009-06-30 08:12:47 +00:00
|
|
|
if( is_server_read_only( $server_id ) || is_attr_read_only( $attr ) ) {
|
2009-06-30 08:09:20 +00:00
|
|
|
if( is_array( $vals ) ) {
|
|
|
|
foreach( $vals as $i => $val ) {
|
2009-06-30 08:12:47 +00:00
|
|
|
if( trim( $val ) == "" )
|
|
|
|
echo "<span style=\"color:red\">[" . $lang['empty'] . "]</span><br />\n";
|
|
|
|
elseif( 0 == strcasecmp( $attr, 'userPassword' ) && obfuscate_password_display() )
|
|
|
|
echo preg_replace( '/./', '*', $val ) . "<br />";
|
2009-06-30 08:09:20 +00:00
|
|
|
else
|
2009-06-30 08:12:47 +00:00
|
|
|
echo htmlspecialchars( $val ) . "<br />";
|
2009-06-30 08:09:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
2009-06-30 08:12:47 +00:00
|
|
|
if( 0 == strcasecmp( $attr, 'userPassword' ) && obfuscate_password_display() )
|
|
|
|
echo preg_replace( '/./', '*', $vals ) . "<br />";
|
|
|
|
else
|
|
|
|
echo $vals . "<br />";
|
2009-06-30 08:09:20 +00:00
|
|
|
}
|
2009-06-30 08:12:47 +00:00
|
|
|
echo "</td>";
|
|
|
|
echo "</tr>";
|
2009-06-30 08:09:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a userPassword attribute?
|
|
|
|
*/
|
|
|
|
if( 0 == strcasecmp( $attr, 'userpassword' ) ) {
|
|
|
|
$user_password = $vals[0];
|
|
|
|
|
|
|
|
/* Capture the stuff in the { } to determine if this is crypt, md5, etc. */
|
|
|
|
if( preg_match( "/{([^}]+)}/", $user_password, $enc_type) )
|
|
|
|
$enc_type = strtolower($enc_type[1]);
|
|
|
|
else
|
|
|
|
$enc_type = null;
|
|
|
|
|
|
|
|
// Set the default hashing type if the password is blank (must be newly created)
|
|
|
|
if( $val == '' ) {
|
|
|
|
$enc_type = $servers[$server_id]['default_hash'];
|
|
|
|
} ?>
|
|
|
|
|
|
|
|
<?php /* handle crypt types */
|
|
|
|
if($enc_type == "crypt") {
|
|
|
|
if( preg_match( "/{[^}]+}\\$(.)\\$/", $user_password, $salt) )
|
|
|
|
$salt = $salt[1];
|
|
|
|
else
|
|
|
|
$salt = null;
|
|
|
|
switch( $salt ) {
|
|
|
|
case '': // CRYPT_STD_DES
|
|
|
|
$enc_type = "crypt";
|
|
|
|
break;
|
|
|
|
case '1': // CRYPT_MD5
|
|
|
|
$enc_type = "md5crypt";
|
|
|
|
break;
|
|
|
|
case '2': // CRYPT_BLOWFISH
|
|
|
|
$enc_type = "blowfish";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$enc_type = "crypt";
|
|
|
|
}
|
|
|
|
} ?>
|
|
|
|
|
|
|
|
<input type="hidden"
|
|
|
|
name="old_values[userpassword]"
|
|
|
|
value="<?php echo htmlspecialchars($user_password); ?>" />
|
|
|
|
|
|
|
|
<!-- Special case of enc_type to detect changes when user changes enc_type but not the password value -->
|
|
|
|
<input size="38"
|
|
|
|
type="hidden"
|
|
|
|
name="old_enc_type"
|
|
|
|
value="<?php echo ($enc_type==''?'clear':$enc_type); ?>" />
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( obfuscate_password_display() ) {
|
|
|
|
echo htmlspecialchars( preg_replace( "/./", "*", $user_password ) );
|
|
|
|
} else {
|
|
|
|
echo htmlspecialchars( $user_password );
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<br />
|
|
|
|
<input style="width: 260px"
|
|
|
|
type="password"
|
|
|
|
name="new_values[userpassword]"
|
|
|
|
value="<?php echo htmlspecialchars( $user_password ); ?>" />
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
<select name="enc_type">
|
|
|
|
<option>clear</option>
|
|
|
|
<option<?php echo $enc_type=='crypt'?' selected':''; ?>>crypt</option>
|
|
|
|
<option<?php echo $enc_type=='md5'?' selected':''; ?>>md5</option>
|
|
|
|
<option<?php echo $enc_type=='smd5'?' selected':''; ?>>smd5</option>
|
|
|
|
<option<?php echo $enc_type=='md5crypt'?' selected':''; ?>>md5crypt</option>
|
|
|
|
<option<?php echo $enc_type=='blowfish'?' selected':''; ?>>blowfish</option>
|
|
|
|
<option<?php echo $enc_type=='sha'?' selected':''; ?>>sha</option>
|
|
|
|
<option<?php echo $enc_type=='ssha'?' selected':''; ?>>ssha</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<?php continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Is this a boolean attribute?
|
|
|
|
*/
|
2009-06-30 08:12:47 +00:00
|
|
|
if( is_attr_boolean( $server_id, $attr) ) {
|
2009-06-30 08:09:20 +00:00
|
|
|
$val = $vals[0];
|
|
|
|
?>
|
|
|
|
|
|
|
|
<input type="hidden"
|
|
|
|
name="old_values[<?php echo htmlspecialchars( $attr ); ?>]"
|
|
|
|
value="<?php echo htmlspecialchars($val); ?>" />
|
|
|
|
|
|
|
|
<select name="new_values[<?php echo htmlspecialchars( $attr ); ?>]">
|
|
|
|
<option value="TRUE"<?php echo ($val=='TRUE' ? ' selected' : ''); ?>>
|
|
|
|
<?php echo $lang['true']; ?></option>
|
|
|
|
<option value="FALSE"<?php echo ($val=='FALSE' ? ' selected' : ''); ?>>
|
|
|
|
<?php echo $lang['false']; ?></option>
|
|
|
|
<option value="">(<?php echo $lang['none_remove_value']; ?>)</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* End of special case attributes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a normal attribute, to be displayed and edited in plain text.
|
|
|
|
*/
|
2009-06-30 08:12:47 +00:00
|
|
|
foreach( $vals as $i => $val ) { ?>
|
2009-06-30 08:09:20 +00:00
|
|
|
|
|
|
|
<nobr>
|
|
|
|
<!-- 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. -->
|
|
|
|
<input type="hidden"
|
|
|
|
name="old_values[<?php echo htmlspecialchars( $attr ); ?>][<?php echo $i; ?>]"
|
|
|
|
value="<?php echo htmlspecialchars($val); ?>" />
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( is_dn_string( $val ) || is_dn_attr( $server_id, $attr ) ) { ?>
|
|
|
|
<a
|
|
|
|
title="<?php echo sprintf( $lang['go_to_dn'], htmlspecialchars($val) ); ?>"
|
|
|
|
href="edit.php?server_id=<?php echo $server_id; ?>&dn=<?php echo rawurlencode($val); ?>"><img
|
|
|
|
style="vertical-align: top" src="images/go.png" /></a>
|
|
|
|
<?php } elseif( is_mail_string( $val ) ) { ?>
|
|
|
|
<a
|
|
|
|
href="mailto:<?php echo htmlspecialchars($val); ?>"><img
|
|
|
|
style="vertical-align: center" src="images/mail.png" /></a>
|
|
|
|
<?php } elseif( is_url_string( $val ) ) { ?>
|
|
|
|
<a
|
|
|
|
href="<?php echo htmlspecialchars($val); ?>"
|
|
|
|
target="new"><img
|
|
|
|
style="vertical-align: center" src="images/dc.png" /></a>
|
|
|
|
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$input_name = "new_values[" . 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 = "new_values_" . htmlspecialchars($attr) . "_" . $i;
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if( is_multi_line_attr( $attr, $val, $server_id ) ) { ?>
|
|
|
|
<textarea
|
|
|
|
class="val"
|
|
|
|
rows="3"
|
|
|
|
cols="50"
|
|
|
|
name="<?php echo $input_name; ?>"
|
|
|
|
id="<?php echo $input_id; ?>"><?php echo htmlspecialchars($val); ?></textarea>
|
|
|
|
<?php } else { ?>
|
|
|
|
<input type="text"
|
|
|
|
class="val"
|
|
|
|
name="<?php echo $input_name; ?>"
|
|
|
|
id="<?php echo $input_id; ?>"
|
|
|
|
value="<?php echo htmlspecialchars($val); ?>" />
|
|
|
|
<?php } ?>
|
|
|
|
</nobr>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// draw a link for popping up the entry browser if this is the type of attribute
|
|
|
|
// that houses DNs.
|
|
|
|
if( is_dn_attr( $server_id, $attr ) )
|
|
|
|
draw_chooser_link( "edit_form.$input_id", false );
|
|
|
|
?>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php } /* end foreach value */ ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
/* Draw the "add value" link under the list of values for this attributes */
|
|
|
|
|
|
|
|
if( ! is_server_read_only( $server_id ) &&
|
|
|
|
( $schema_attr = get_schema_attribute( $server_id, $attr, $dn ) ) &&
|
|
|
|
! $schema_attr->getIsSingleValue() )
|
|
|
|
{
|
|
|
|
$add_href = "add_value_form.php?server_id=$server_id&" .
|
|
|
|
"dn=$encoded_dn&attr=" . rawurlencode( $attr );
|
|
|
|
echo "<div class=\"add_value\">(<a href=\"$add_href\"
|
|
|
|
title=\"" . sprintf( $lang['add_value_tooltip'], $attr ) . "\">" .
|
|
|
|
$lang['add_value'] . "</a>)</div>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
2009-06-30 08:12:47 +00:00
|
|
|
<?php if( $is_modified_attr ) { ?>
|
|
|
|
<tr class="updated_attr"><td class="bottom" colspan="2"></td></tr>
|
|
|
|
<?php } ?>
|
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
flush();
|
|
|
|
|
|
|
|
} /* End foreach( $attrs as $attr => $vals ) */ ?>
|
|
|
|
|
|
|
|
<?php if( ! is_server_read_only( $server_id ) ) { ?>
|
|
|
|
<tr><td colspan="2"><center><input type="submit" value="<?php echo $lang['save_changes']; ?>" /></center></form></td></tr>
|
|
|
|
<?php } ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<?php /* If this entry has a binary attribute, we need to provide a form for it to submit when deleting it. */ ?>
|
|
|
|
<script language="javascript">
|
|
|
|
//<!--
|
|
|
|
function deleteAttribute( attrName )
|
|
|
|
{
|
|
|
|
if( confirm( "<?php echo $lang['really_delete_attribute']; ?> '" + attrName + "'?" ) ) {
|
|
|
|
document.delete_attribute_form.attr.value = attrName;
|
|
|
|
document.delete_attribute_form.submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->
|
|
|
|
<form name="delete_attribute_form" action="delete_attr.php" method="post">
|
|
|
|
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
|
|
|
<input type="hidden" name="dn" value="<?php echo $dn; ?>" />
|
|
|
|
<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given an attribute $x, this returns true if it is NOT already specified
|
|
|
|
* in the current entry, returns false otherwise.
|
|
|
|
*/
|
|
|
|
function not_an_attr( $x )
|
|
|
|
{
|
|
|
|
global $attrs;
|
|
|
|
//return ! isset( $attrs[ strtolower( $x ) ] );
|
|
|
|
foreach( $attrs as $attr => $values )
|
|
|
|
if( 0 == strcasecmp( $attr, $x ) )
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|