2009-06-30 08:05:37 +00:00
|
|
|
<?php
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
require 'common.php';
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
$container = isset( $_GET['container'] ) ? rawurldecode( $_GET['container'] ) : false;
|
|
|
|
$server_id = isset( $_GET['server_id'] ) ? $_GET['server_id'] : false;
|
2009-06-30 08:10:17 +00:00
|
|
|
$return_form_element = isset( $_GET['form_element'] ) ? htmlspecialchars( $_GET['form_element'] ) : null;
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
include "header.php";
|
|
|
|
|
|
|
|
echo "<h3 class=\"subtitle\">Automagic Entry Chooser</h3>\n";
|
|
|
|
|
|
|
|
if( $container ) {
|
2009-06-30 08:09:20 +00:00
|
|
|
echo $lang['server_colon_pare'] . "<b>" . htmlspecialchars( $servers[ $server_id ][ 'name' ] ) . "</b><br />\n";
|
|
|
|
echo $lang['look_in'] . "<b>" . htmlspecialchars( $container ) . "</b><br />\n";
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
/* Has the use already begun to descend into a specific server tree? */
|
2009-06-30 08:05:37 +00:00
|
|
|
if( $server_id !== false && $container !== false )
|
|
|
|
{
|
2009-06-30 08:09:20 +00:00
|
|
|
check_server_id( $server_id ) or pla_error( $lang['bad_server_id'] );
|
|
|
|
have_auth_info( $server_id ) or pla_error( $lang['not_enough_login_info'] );
|
|
|
|
pla_ldap_connect( $server_id ) or pla_error( $lang['could_not_connect'] );
|
2009-06-30 08:05:37 +00:00
|
|
|
$dn_list = get_container_contents( $server_id, $container );
|
2009-06-30 08:09:20 +00:00
|
|
|
sort( $dn_list );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
$base_dn = $servers[ $server_id ][ 'base' ];
|
|
|
|
if( ! $base_dn )
|
|
|
|
$base_dn = try_to_get_root_dn( $server_id );
|
|
|
|
|
|
|
|
if( $container == $base_dn ) {
|
|
|
|
$parent_container = false;
|
|
|
|
$up_href = "entry_chooser.php?form_element=$return_form_element";
|
|
|
|
} else {
|
|
|
|
$parent_container = get_container( $container );
|
|
|
|
$up_href = "entry_chooser.php?form_element=$return_form_element&server_id=$server_id&container=" .
|
|
|
|
rawurlencode( $parent_container );
|
|
|
|
}
|
2009-06-30 08:09:20 +00:00
|
|
|
echo " <a href=\"$up_href\" style=\"text-decoration:none\">" .
|
|
|
|
"<img src=\"images/up.png\"> ". $lang['back_up_p'] ."</a><br />\n";
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
if( count( $dn_list ) == 0 )
|
2009-06-30 08:09:20 +00:00
|
|
|
echo " (". $lang['no_entries'] .")<br />\n";
|
2009-06-30 08:05:37 +00:00
|
|
|
else
|
|
|
|
foreach( $dn_list as $dn ) {
|
|
|
|
$href = "javascript:returnDN( '$dn' )";
|
2009-06-30 08:07:14 +00:00
|
|
|
echo " <a href=\"entry_chooser.php?form_element=$return_form_element".
|
|
|
|
"&server_id=$server_id&container=" .
|
2009-06-30 08:05:37 +00:00
|
|
|
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
|
|
|
|
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
|
|
|
|
}
|
|
|
|
}
|
2009-06-30 08:07:14 +00:00
|
|
|
/* draw the root of the selection tree (ie, list all the servers) */
|
2009-06-30 08:05:37 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach( $servers as $id => $server ) {
|
|
|
|
if( $server['host'] ) {
|
2009-06-30 08:07:14 +00:00
|
|
|
echo "<b>" . htmlspecialchars( $server['name'] ) . "</b><br />\n";
|
2009-06-30 08:09:20 +00:00
|
|
|
if( ! have_auth_info( $id ) )
|
|
|
|
echo "<small> (" . $lang['not_logged_in'] . ")</small><br />";
|
2009-06-30 08:07:14 +00:00
|
|
|
else {
|
2009-06-30 08:09:20 +00:00
|
|
|
$dn = ( $server['base'] ? $server['base'] : try_to_get_root_dn( $id ) );
|
2009-06-30 08:07:14 +00:00
|
|
|
if( ! $dn ) {
|
2009-06-30 08:09:20 +00:00
|
|
|
echo "<small> (". $lang['could_not_det_base_dn'] .")</small><br />";
|
2009-06-30 08:07:14 +00:00
|
|
|
} else {
|
|
|
|
$href = "javascript:returnDN( '$dn' )";
|
2009-06-30 08:09:20 +00:00
|
|
|
echo " <a href=\"entry_chooser.php?form_element=" .
|
2009-06-30 08:07:14 +00:00
|
|
|
"$return_form_element&server_id=$id&container=" .
|
|
|
|
rawurlencode( $dn ) . "\"><img src=\"images/plus.png\" /></a> " .
|
|
|
|
"<a href=\"$href\">" . htmlspecialchars( $dn ) . "</a><br />\n";
|
|
|
|
}
|
|
|
|
}
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
// added by PD. 14082003,
|
|
|
|
// adding the element access allows it to work with javascript arrays
|
|
|
|
|
|
|
|
// the name of the form extracted from the first part of the URL variable.
|
|
|
|
$formpart=substr($return_form_element,0,strpos($return_form_element,"."));
|
|
|
|
|
|
|
|
// the name of the element extracted from the last part of the URL variable (after the dot)
|
|
|
|
$elmpart =substr($return_form_element,strpos($return_form_element,".")+1);
|
|
|
|
|
|
|
|
// rebuilt return value
|
|
|
|
$return_form_element = $formpart . ".elements[\"" . $elmpart . "\"]";
|
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
<script language="javascript">
|
|
|
|
function returnDN( dn )
|
|
|
|
{
|
|
|
|
opener.document.<?php echo $return_form_element; ?>.value = dn;
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
</script>
|