File: edit.php

package info (click to toggle)
phpldapadmin 0.9.5-3sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,052 kB
  • ctags: 2,526
  • sloc: php: 21,258; sh: 262; makefile: 132; xml: 42
file content (61 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/edit.php,v 1.48 2004/10/14 03:33:36 uugdave Exp $
 

/*
 * edit.php
 * Displays the specified dn from the specified server for editing
 * in its template as determined by get_template(). This is a simple
 * shell for displaying entries. The real work is done by the templates
 * found in tempaltes/modification/
 *
 * Variables that come in as GET vars:
 *  - dn (rawurlencoded)
 *  - server_id
 *  - use_default_template (optional) If set, use the default template no matter what
 *  - Other vars may be set and used by the modification templates
 */

require_once realpath( 'common.php' );
require_once realpath( 'templates/template_config.php' );

$dn = isset( $_GET['dn'] ) ? $_GET['dn'] : false;
$dn !== false or pla_error( $lang['missing_dn_in_query_string'] );
$decoded_dn = rawurldecode( $dn );
$encoded_dn = rawurlencode( $decoded_dn );

$server_id = isset( $_GET['server_id'] ) ? $_GET['server_id'] : false;
$server_id !== false or pla_error( $lang['missing_server_id_in_query_string'] );

// Template authors may wish to present the user with a link back to the default, generic 
// template for editing. They may use this as the target of the href to do so.
$default_href = "edit.php?server_id=$server_id&amp;dn=$encoded_dn&amp;use_default_template=true";

$use_default_template = isset( $_GET['use_default_template'] ) ? true : false;

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'] );

$ds = pla_ldap_connect( $server_id );
pla_ldap_connection_is_error( $ds );

if( $use_default_template ) {
	require realpath( 'templates/modification/default.php' );
} else {

	$template = get_template( $server_id, $dn );
	$template_file = "templates/modification/$template.php";
	if( file_exists( realpath( $template_file ) ) )
		require realpath( $template_file );
	else {
		echo "\n\n";
		echo $lang['missing_template_file']; 
		echo " <b>$template_file</b>. ";
		echo $lang['using_default'];
		echo "<br />\n\n";
		require realpath( 'templates/modification/default.php' );
	}
}

?>