If you are seeing this in your browser,
PHP is not installed on your web server!!!
*******************************************/
/**
* We will perform some sanity checking here, since this file is normally loaded first when users
* first setup PLA.
*/
define('LIBDIR','../lib/');
ini_set('display_errors',1);
error_reporting(E_ALL);
# General functions needed to proceed.
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(sprintf('Fatal error: Required file "%s" does not exist.',$file_name));
if (! is_readable($file_name))
pla_error(sprintf('Fatal error: Cannot read the file "%s", its permissions are too strict.',$file_name));
ob_start();
require $file_name;
ob_end_clean();
}
# Configuration File check
if (! file_exists($config_file)) {
echo '';
echo '';
echo '
';
printf(_('You need to configure phpLDAPadmin. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),$config_file,$config_file);
echo '
';
echo '';
echo '';
die();
} elseif (! is_readable($config_file)) {
pla_error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions are too strict.',$config_file));
}
if (! check_config()) {
exit;
}
echo ''."\n";
echo ''."\n";
echo "\n";
echo '';
if ($pagetitle = $config->GetValue('appearance','page_title'))
printf('phpLDAPadmin (%s) - %s',pla_version(),$pagetitle);
else
printf('phpLDAPadmin - %s',pla_version());
printf('';
echo '';
/*
* Makes sure that the config file is properly setup and
* that your install of PHP can handle LDAP stuff.
*/
function check_config() {
global $config_file,$config;
/* Check for syntax errors in config.php
As of php 4.3.5, this NO longer catches fatal errors :( */
ob_start();
include $config_file;
$str = ob_get_contents();
ob_end_clean();
if ($str) {
$str = strip_tags($str);
$matches = array();
preg_match('/(.*):\s+(.*):.*\s+on line (\d+)/',$str,$matches);
$error_type = $matches[1];
$error = $matches[2];
$line_num = $matches[3];
$file = file($config_file);
echo ''."\n";
echo ''."\n";
echo "\n";
echo '';
echo '';
echo 'phpLDAPadmin Config File Error';
echo '';
echo '';
echo '';
echo '
Config File ERROR
';
printf('
%s (%s) on line %s
',$error_type,$error,$line_num);
echo '
';
printf('Looks like your config file has an ERROR on line %s. ',$line_num);
echo 'Here is a snippet around that line ';
echo ' '."\n";
echo '
';
for ($i = $line_num-9; $i<$line_num+5; $i++) {
if ($i+1 == $line_num)
echo '
';
if ($i < 0)
continue;
printf('%s: %s ',$i+1,htmlspecialchars($file[$i]));
if ($i+1 == $line_num)
echo '
';
}
echo '
';
echo ' ';
echo 'Hint: Sometimes these errors are caused by lines preceding the line reported.';
echo '
';
echo '';
echo '';
return false;
}
# Now read in config_default.php, which also reads in config.php
require LIBDIR.'config_default.php';
# 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()));
}
# Make sure this PHP install has all our required extensions
if (! extension_loaded('ldap')) {
pla_error('Your install of PHP appears to be missing LDAP support. Please install LDAP support before using phpLDAPadmin. (Dont forget to restart your web server afterwards)');
return false;
}
# 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. (Dont forget to restart your web server afterwards)');
return false;
}
# 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;
}
if (! isset($ldapservers) || count($ldapservers->GetServerList()) == 0) {
pla_error('Your config.php is missing Server Definitions.
Please see the sample file config/config.php.example.',false);
return false;
}
return true;
}
?>