Location: PHPKode > projects > LDAP Navigator > ldapnavigator-0.9.6/submit.php
<?php

$ret = include_once ('./config.php');
$ret or die( "Missing configuration file - please refer to install instructions" );

// open a LDAP connexion - connexion id is stored in global var $ds
LDAP_Open();


// some shared shortcuts
$iconSchema = '<img src="img/tb_schema.gif" border=0 valign=bottom> ';

/*
	big problem with Konqueror
	http_post_vars[A] seems to be unset when user clicks "Modify", in some cases at least
	client problem or not ?
*/

//echo "<pre>"; print_r( $GLOBALS);

// switch action requested
switch( $A )
{

	case "search":
	case "search.advanced":
		require( "./modules/search/index.php" );
		break;


/********
 *	BATCH ACTIONS
 *******/

	case "batch.run":
		require( "./modules/batch/run.php");
		break;

	case "batch.form":
		require( "./modules/batch/form.php" );
		break;

/********
 *	ENTRY ACTIONS
 *******/

	// updating an entry, invoked from "edit" form
	case "entry.modify":
		// handle all the update process
		require( "./modules/entry/modify.php" );
		// to view the updated entry
		require( "./modules/entry/properties.php" );
		break;

	case "entry.edit":
		// a bugfix test for konqueror bug
		header( "Cache-Control: no-cache" );
		header( "Pragma: no-cache" );
		require( "./modules/entry/form.php" );
		break;

	// view entry properties
	case "entry.properties":
		require( "./modules/entry/properties.php" );
		break;

	// new entry form
	case "entry.new":
		require( "./modules/entry/newform.php" );
		break;

	// updating the RDN of an entry
	case "entry.rename":
		if( ! function_exists( "ldap_rename" ))
			ErrorPage( "Unsupported", "LDAP extension does not provides required function ldap_rename" );
		$dnparts = ldap_explode_dn( $newdn, 0 );
		unset( $dnparts['count'] );
		$rdn = array_shift( $dnparts );
		$parent_dn = implode( ", ", $dnparts );
		echo "ldap_rename( $ds, $dn, $rdn, $parent_dn )";
		$ret = ldap_rename( $ds, $dn, $rdn, $parent_dn );
		// to view the updated entry
		require( "./modules/entry/properties.php" );		
		break;
	
	// adding a new entry, invoked from "edit" form
	case "entry.add":
		// add the entry
		require( "./modules/entry/add.php" );
		// TreeView may need a refresh
		$treeReload = 1;
		// view the new entry
		require( "./modules/entry/properties.php" );
		break;
	
	case "entry.delete":
		require( "./modules/entry/delete.php" );
		break;


/********
 *	ATTRIBUTE ACTIONS
 *******/
 
	// @todo
	case "attribute.modify":
		ErrorPage(
			"Feature not implemented", 
			"The action you requested is not implemented yet\ncome back soon !",
			"window.back()"
		);
		break;

	// merged because most of the code is shared
	case "attribute.delete":
	case "attribute.download":
			
		if( ! isset($dn) )
				ErrorPage( 
					"Missing parameter", 
					"A parameter required by this this page is missing: dn"
				);

		if( ! isset($attribute) )
				ErrorPage( 
					"Missing parameter", 
					"A parameter required by this this page is missing: attribute"
				);

		if( ! isset($idx) )
				ErrorPage( 
					"Missing parameter", 
					"A parameter required by this this page is missing: idx"
				);
					
		$sr = ldap_read( $ds, $dn, "objectclass=*" );
		$er = @ldap_first_entry( $ds, $sr );

		if( ! $er )
			ErrorPage( "", "no such entry $dn in the directory" );

		$attrs = ldap_get_values_len( $ds, $er, $attribute );

		if( $idx >= $attrs['count'] ) {
			ErrorPage( 
				"Invalid parameter", 
				"Attribute Index out of bound ($idx) - $attribute only contains $attrs[count] values"
			);
		}
		
		if( $A == "attribute.download" ) {
			// send the attribute
			$size = strlen($attrs[$idx]);
			//  @todo : guess content-type guesser func
			
			$contentType = $config->attributeContentTypes[$attribute];

			if( ! $contentType )
				$contentType = "application/x-unknown";
//			echo "$attribute => $contentType $config->attributeContentTypes" ;
			
			// removed becos of a "feature" of IE5
//			header( "Content-Disposition: attachment" );
			header( "Content-Type: $contentType" );
			// to correct a bug in IE5, we override the use of no-cache,no-store
			header( "Cache-Control: must-revalidate" );
			print $attrs[$idx];
			exit; // to stop before redirection
			
		} elseif( $A == "attribute.delete" ) {
			
			unset( $attrs[$idx] );
			$ret = ldap_mod_replace( $ds, $dn, $attrs );
			if( ! $ret )
				ErrorPage( "Delete error", "LDAP server says: " . ldap_error($ds) );
				
			
		}		
		break;


/**************************************************************
 *	SCHEMA ACTIONS
 **************************************************************/
 
	case "objectclass.list":
		require( "./modules/schema/objectclass.list.php" );
		break;
	
	case "attribute.list":
		require( "./modules/schema/attribute.list.php" );
		break;
	
	case "objectclass.info":
		require( "./modules/schema/objectclass.properties.php" );
		break;
	
	case "attribute.info":
		require( "./modules/schema/attribute.properties.php" );
		break;
	

/******
 *	PERMISSIONS ACTIONS
 *****/
 
	// permissions actions (ACI)
	case "aci.edit":
		require( "./modules/aci/aci.form.php" );
		break;

	case "aci.delete":
		require( "./modules/aci/aci.delete.php" );
		require( "./modules/aci/aci.form.php" );
		break;
			
	case "aci.update":
	case "aci.add":
		require( "./modules/aci/aci.update.php" );
		require( "./modules/aci/aci.form.php" );
		break;

	case "about":
		require( "./modules/help/about.php" );
		break;

	case "session.info":
		require( "./modules/entry/session.php" );
		break;


	default:
		// false because his is not a ldap error
		ErrorPage( "Invalid parameter", "Action not handled: $A", "history.go(-1)" );
		break;

}

?>
Return current item: LDAP Navigator