phpldapadmin/htdocs/index.php

92 lines
2.9 KiB
PHP
Raw Normal View History

2009-06-30 18:07:14 +10:00
<?php
2009-06-30 21:51:50 +10:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/index.php,v 1.49.2.5 2008/01/12 10:01:28 wurley Exp $
2009-06-30 19:22:30 +10:00
2009-06-30 19:29:51 +10:00
/**
* @package phpLDAPadmin
*/
2009-06-30 18:07:14 +10:00
/*******************************************
<pre>
2009-06-30 18:05:37 +10:00
If you are seeing this in your browser,
PHP is not installed on your web server!!!
2009-06-30 18:07:14 +10:00
</pre>
*******************************************/
2009-06-30 18:05:37 +10:00
2009-06-30 21:46:44 +10:00
/**
2009-06-30 19:29:51 +10:00
* We will perform some sanity checking here, since this file is normally loaded first when users
2009-06-30 21:46:44 +10:00
* first access the application.
2009-06-30 19:29:51 +10:00
*/
2009-06-30 21:50:46 +10:00
# The index we will store our config in $_SESSION
define('APPCONFIG','plaConfig');
2009-06-30 20:46:00 +10:00
define('LIBDIR',sprintf('%s/',realpath('../lib/')));
2009-06-30 19:29:51 +10:00
ini_set('display_errors',1);
error_reporting(E_ALL);
2009-06-30 20:26:08 +10:00
# General functions needed to proceed.
2009-06-30 19:29:51 +10:00
ob_start();
if (! file_exists(LIBDIR.'functions.php')) {
2009-06-30 20:46:00 +10:00
if (ob_get_level()) ob_end_clean();
die(sprintf("Fatal error: Required file '<b>%sfunctions.php</b>' does not exist.",LIBDIR));
2009-06-30 19:29:51 +10:00
}
if (! is_readable(LIBDIR.'functions.php')) {
2009-06-30 20:46:00 +10:00
if (ob_get_level()) ob_end_clean();
die(sprintf("Cannot read the file '<b>%sfunctions.php</b>' its permissions may be too strict.",LIBDIR));
2009-06-30 19:29:51 +10:00
}
2009-06-30 21:46:44 +10:00
if (ob_get_level())
ob_end_clean();
2009-06-30 20:40:33 +10:00
2009-06-30 19:29:51 +10:00
require LIBDIR.'functions.php';
2009-06-30 21:46:44 +10:00
# Define the path to our configuration file.
if (defined('CONFDIR'))
$app['config_file'] = CONFDIR.'config.php';
else
$app['config_file'] = 'config.php';
2009-06-30 19:29:51 +10:00
2009-06-30 20:40:33 +10:00
# Make sure this PHP install has gettext, we use it for language translation
if (! extension_loaded('gettext'))
2009-06-30 21:51:50 +10:00
error('<p>Your install of PHP appears to be missing GETTEXT support.</p><p>GETTEXT is used for language translation.</p><p>Please install GETTEXT support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>','error',true);
2009-06-30 20:40:33 +10:00
2009-06-30 21:46:44 +10:00
/**
2009-06-30 20:46:00 +10:00
* Helper functions.
2009-06-30 19:29:51 +10:00
* Our required helper functions are defined in functions.php
*/
2009-06-30 21:46:44 +10:00
if (isset($app['function_files']) && is_array($app['function_files']))
foreach ($app['function_files'] as $file_name ) {
if (! file_exists($file_name))
2009-06-30 21:51:50 +10:00
error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name),'error',true);
2009-06-30 19:29:51 +10:00
2009-06-30 21:46:44 +10:00
if (! is_readable($file_name))
2009-06-30 21:51:50 +10:00
error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name),'error',true);
2009-06-30 18:05:37 +10:00
2009-06-30 21:46:44 +10:00
ob_start();
require $file_name;
if (ob_get_level()) ob_end_clean();
}
2009-06-30 18:07:14 +10:00
2009-06-30 19:29:51 +10:00
# Configuration File check
2009-06-30 21:46:44 +10:00
if (! file_exists($app['config_file'])) {
2009-06-30 21:51:50 +10:00
error(sprintf(_('You need to configure %s. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),'phpLDAPadmin',$app['config_file'],$app['config_file']),'error',true);
2009-06-30 18:09:20 +10:00
2009-06-30 21:46:44 +10:00
} elseif (! is_readable($app['config_file'])) {
2009-06-30 21:51:50 +10:00
error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file']),'error',true);
2009-06-30 19:29:51 +10:00
}
2009-06-30 18:05:37 +10:00
2009-06-30 20:46:00 +10:00
# If our config file fails the sanity check, then stop now.
2009-06-30 21:46:44 +10:00
if (! check_config($app['config_file'])) {
$www['page'] = new page();
$www['body'] = new block();
$www['page']->block_add('body',$www['body']);
$www['page']->display();
2009-06-30 20:46:00 +10:00
2009-06-30 20:26:08 +10:00
exit;
}
2009-06-30 18:05:37 +10:00
2009-06-30 20:46:00 +10:00
include './cmd.php';
2009-06-30 18:05:37 +10:00
?>