2009-06-30 08:07:14 +00:00
|
|
|
<?php
|
2009-06-30 09:29:51 +00:00
|
|
|
// $Header: /cvsroot/phpldapadmin/phpldapadmin/index.php,v 1.39 2005/09/25 16:11:44 wurley Exp $
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
|
|
|
* @package phpLDAPadmin
|
|
|
|
* @todo: Move config.php syntax error processing to earlier.
|
|
|
|
*/
|
2009-06-30 08:07:14 +00:00
|
|
|
|
|
|
|
/*******************************************
|
|
|
|
<pre>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
If you are seeing this in your browser,
|
|
|
|
PHP is not installed on your web server!!!
|
|
|
|
|
2009-06-30 08:07:14 +00:00
|
|
|
</pre>
|
|
|
|
*******************************************/
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
|
|
|
* We will perform some sanity checking here, since this file is normally loaded first when users
|
|
|
|
* first setup PLA.
|
|
|
|
*/
|
|
|
|
@DEFINE(LIBDIR,'./');
|
|
|
|
ini_set('display_errors',1);
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
|
|
# General functions needed to proceed (pla_ldap_search(), pla_error(), get_object_attrs(), etc.)
|
|
|
|
ob_start();
|
|
|
|
if (! file_exists(LIBDIR.'functions.php')) {
|
|
|
|
ob_end_clean();
|
|
|
|
die("Fatal error: Required file 'functions.php' does not exist.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! is_readable(LIBDIR.'functions.php')) {
|
|
|
|
ob_end_clean();
|
|
|
|
die("Cannot read the file 'functions.php' its permissions are too strict.");
|
|
|
|
}
|
|
|
|
require LIBDIR.'functions.php';
|
|
|
|
$config_file = CONFDIR.'config.php';
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
/* Helper functions.
|
|
|
|
* Our required helper functions are defined in functions.php
|
|
|
|
*/
|
|
|
|
foreach ($pla_function_files as $file_name ) {
|
|
|
|
if (! file_exists($file_name))
|
|
|
|
pla_error("Fatal error: Required file '$file_name' does not exist.");
|
|
|
|
|
|
|
|
if (! is_readable($file_name))
|
|
|
|
pla_error( "Fatal error: Cannot read the file '$file_name', its permissions are too strict." );
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
ob_start();
|
|
|
|
require $file_name;
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
# Configuration File check
|
|
|
|
if (! file_exists($config_file)) {
|
2009-06-30 08:09:20 +00:00
|
|
|
?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
2009-06-30 08:07:14 +00:00
|
|
|
<title>phpLDAPadmin - <?php echo pla_version(); ?></title>
|
2009-06-30 09:29:51 +00:00
|
|
|
<link rel="stylesheet" href="style.css" />
|
2009-06-30 08:05:37 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2009-06-30 08:07:14 +00:00
|
|
|
<h3 class="title">Configure phpLDAPadmin</h1>
|
2009-06-30 08:05:37 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<center><?php echo $lang['need_to_configure']; ?></center>
|
2009-06-30 08:05:37 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php
|
|
|
|
die();
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
} elseif (! is_readable($config_file)) {
|
|
|
|
pla_error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions are too strict.',$config_file));
|
|
|
|
}
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
# Now read in config_default.php, which also reads in config.php
|
|
|
|
require LIBDIR.'config_default.php';
|
|
|
|
|
|
|
|
if (check_config()) {
|
|
|
|
print '<?xml version="1.0" encoding="utf-8"?>';
|
2009-06-30 08:05:37 +00:00
|
|
|
?>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
|
2009-06-30 08:05:37 +00:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="no-NO">
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<?php if ($pagetitle = $config->GetValue('appearance','page_title')) { ?>
|
|
|
|
<head><title>phpLDAPadmin (<?php echo pla_version(); ?>) - <?php echo $pagetitle; ?></title></head>
|
|
|
|
<?php } else { ?>
|
2009-06-30 08:07:14 +00:00
|
|
|
<head><title>phpLDAPadmin - <?php echo pla_version(); ?></title></head>
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php } ?>
|
2009-06-30 08:05:37 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<frameset cols="<?php echo $config->GetValue('appearance','tree_width'); ?>,*">
|
2009-06-30 08:05:37 +00:00
|
|
|
<frame src="tree.php" name="left_frame" id="left_frame" />
|
2009-06-30 08:07:14 +00:00
|
|
|
<frame src="welcome.php" name="right_frame" id="right_frame" />
|
2009-06-30 08:05:37 +00:00
|
|
|
</frameset>
|
|
|
|
|
|
|
|
</html>
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
<?php }
|
2009-06-30 08:05:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Makes sure that the config file is properly setup and
|
|
|
|
* that your install of PHP can handle LDAP stuff.
|
|
|
|
*/
|
2009-06-30 09:29:51 +00:00
|
|
|
function check_config() {
|
|
|
|
global $lang, $config_file;
|
|
|
|
|
|
|
|
# Make sure their PHP version is current enough
|
|
|
|
if (strcmp(phpversion(),REQUIRED_PHP_VERSION) < 0) {
|
|
|
|
pla_error(sprintf('phpLDAPadmin requires PHP version %s or greater. You are using %s',
|
|
|
|
REQUIRED_PHP_VERSION,phpversion()));
|
2009-06-30 08:09:20 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
# Make sure this PHP install has all our required extensions
|
|
|
|
if (! extension_loaded('ldap')) {
|
2009-06-30 08:05:37 +00:00
|
|
|
pla_error( "Your install of PHP appears to be missing LDAP support. Please install " .
|
2009-06-30 09:29:51 +00:00
|
|
|
"LDAP support before using phpLDAPadmin. (Don't forget to restart your web server afterwards)");
|
2009-06-30 08:05:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
# Make sure that we have php-xml loaded.
|
|
|
|
if (! function_exists('xml_parser_create')) {
|
|
|
|
pla_error( "Your install of PHP appears to be missing XML support. Please install " .
|
|
|
|
"XML support before using phpLDAPadmin. (Don't forget to restart your web server afterwards)");
|
2009-06-30 08:05:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
# Make sure their session save path is writable, if they are using a file system session module, that is.
|
|
|
|
if ( ! strcasecmp("Files",session_module_name() && ! is_writable(realpath(session_save_path())))) {
|
|
|
|
pla_error( "Your PHP session configuration is incorrect. Please check the value of session.save_path
|
|
|
|
in your php.ini to ensure that the directory specified there exists and is writable.
|
|
|
|
The current setting of \"". session_save_path() . "\" is un-writable by the web server.");
|
|
|
|
return false;
|
2009-06-30 09:22:30 +00:00
|
|
|
}
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
/* check for syntax errors in config.php */
|
2009-06-30 09:29:51 +00:00
|
|
|
# capture the result of including the file with output buffering
|
2009-06-30 08:05:37 +00:00
|
|
|
ob_start();
|
2009-06-30 09:29:51 +00:00
|
|
|
include $config_file;
|
2009-06-30 08:05:37 +00:00
|
|
|
$str = ob_get_contents();
|
|
|
|
ob_end_clean();
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
if( $str && false !== strpos( $str, 'error' ) ) {
|
2009-06-30 08:05:37 +00:00
|
|
|
$str = strip_tags( $str );
|
2009-06-30 08:09:20 +00:00
|
|
|
$matches = array();
|
|
|
|
preg_match( "/on line (\d+)/", $str, $matches );
|
2009-06-30 08:05:37 +00:00
|
|
|
$line_num = $matches[1];
|
2009-06-30 09:29:51 +00:00
|
|
|
$file = file($config_file);
|
2009-06-30 08:05:37 +00:00
|
|
|
?>
|
2009-06-30 09:29:51 +00:00
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>phpLDAPadmin Config File Error</title>
|
|
|
|
<link rel="stylesheet" href="style.css" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h3 class="title">Config file error</h3>
|
|
|
|
<h3 class="subtitle">Syntax error on line <?php echo $line_num; ?></h3>
|
|
|
|
|
|
|
|
<center>
|
|
|
|
Looks like your config file has a syntax error on line <?php echo $line_num; ?>.
|
|
|
|
Here is a snippet around that line
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<div style="text-align: left; margin-left: 80px; margin-right: 80px; border: 1px solid black; padding: 10px;">
|
|
|
|
<tt>
|
|
|
|
|
|
|
|
<?php for( $i=$line_num-9; $i<$line_num+5; $i++ ) {
|
|
|
|
if( $i+1 == $line_num )
|
|
|
|
echo "<div style=\"color:red;background:#fdd\">";
|
|
|
|
|
|
|
|
if( $i < 0 )
|
|
|
|
continue;
|
|
|
|
echo "<b>" . ($i+1) . "</b>: " . htmlspecialchars($file[ $i ]) . "<br />";
|
|
|
|
|
|
|
|
if( $i+1 == $line_num )
|
|
|
|
echo "</div>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</tt>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<br />
|
|
|
|
Hint: Sometimes these errors are caused by lines <b>preceding</b> the line reported.
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<?php return false;
|
2009-06-30 08:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check the existence of the servers array */
|
2009-06-30 09:29:51 +00:00
|
|
|
require $config_file;
|
|
|
|
|
|
|
|
if( ! isset($ldapservers) || count($ldapservers->GetServerList()) == 0) {
|
|
|
|
pla_error( "Your config.php is missing Server Definitions
|
|
|
|
Please see the sample file config.php.example ", false );
|
2009-06-30 08:05:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
# @todo: Implement this and fix all the tests.
|
|
|
|
/*
|
|
|
|
if ( ! count($ldapservers->GetServerList())) {
|
2009-06-30 09:22:30 +00:00
|
|
|
pla_error( "None of the " . count($servers) . " servers in your \$servers configuration is
|
|
|
|
active in config.php. At least one of your servers must set the 'host' directive.
|
|
|
|
Example: <br><pre>\$servers['host'] = \"ldap.example.com\";<br></pre>
|
|
|
|
phpLDAPadmin cannot proceed util you correct this.", false );
|
2009-06-30 08:05:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
// Check that 'base' is present on all serve entries
|
|
|
|
foreach( $servers as $id => $server ) {
|
|
|
|
if( isset( $server['host'] ) && isset( $server['name'] ) )
|
|
|
|
isset( $server['base'] )
|
|
|
|
or pla_error ( "Your configuration has an error. You omitted the 'base' directive
|
|
|
|
on server number $id. Your server entry must have a 'base' directive
|
|
|
|
even if it's empty ('')." );
|
|
|
|
}
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-06-30 08:09:20 +00:00
|
|
|
// Check each of the servers in the servers array
|
|
|
|
foreach( $servers as $id => $server ) {
|
|
|
|
if( isset( $server['host'] ) ) {
|
|
|
|
|
|
|
|
// Make sure they specified an auth_type
|
|
|
|
if( ! isset( $server['auth_type'] ) ) {
|
2009-06-30 09:29:51 +00:00
|
|
|
pla_error( "Your configuration has an error. You omitted the 'auth_type' directive on server number $id
|
2009-06-30 09:22:30 +00:00
|
|
|
'auth_type' must be set, and it must be one of 'config', 'cookie', or 'session'.", false );
|
2009-06-30 08:09:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure they specified a correct auth_type
|
2009-06-30 09:22:30 +00:00
|
|
|
if( ! in_array( $server['auth_type'], array( 'config', 'cookie', 'session' ) ) ) {
|
|
|
|
global $lang;
|
|
|
|
pla_error( sprintf( $lang['error_auth_type_config'], htmlspecialchars( $server['auth_type'] ) ) );
|
2009-06-30 08:09:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-30 09:29:51 +00:00
|
|
|
*/
|
2009-06-30 08:09:20 +00:00
|
|
|
|
2009-06-30 08:05:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
?>
|