phpldapadmin/htdocs/index.php

167 lines
6.5 KiB
PHP
Raw Normal View History

2009-06-30 08:07:14 +00:00
<?php
2009-06-30 09:29:51 +00:00
/**
* phpLDAPadmin Start Page
*
2009-06-30 09:29:51 +00:00
* @package phpLDAPadmin
* @subpackage Page
*/
/**
2009-06-30 09:29:51 +00:00
*/
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 11:46:44 +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
2009-06-30 11:46:44 +00:00
* first access the application.
2009-06-30 09:29:51 +00:00
*/
2009-06-30 11:50:46 +00:00
# The index we will store our config in $_SESSION
define('APPCONFIG','plaConfig');
2009-06-30 10:46:00 +00:00
define('LIBDIR',sprintf('%s/',realpath('../lib/')));
2009-06-30 09:29:51 +00:00
ini_set('display_errors',1);
error_reporting(E_ALL);
2009-06-30 10:26:08 +00:00
# General functions needed to proceed.
2009-06-30 09:29:51 +00:00
ob_start();
if (! file_exists(LIBDIR.'functions.php')) {
2009-06-30 10:46:00 +00: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 09:29:51 +00:00
}
if (! is_readable(LIBDIR.'functions.php')) {
2009-06-30 10:46:00 +00: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 09:29:51 +00:00
}
2009-06-30 11:46:44 +00:00
if (ob_get_level())
ob_end_clean();
2009-06-30 10:40:33 +00:00
2009-06-30 11:52:55 +00:00
# Make sure this PHP install has pcre
if (! extension_loaded('pcre'))
die('<p>Your install of PHP appears to be missing PCRE support.</p><p>Please install PCRE support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>');
2009-06-30 09:29:51 +00:00
require LIBDIR.'functions.php';
2009-06-30 11:46:44 +00: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 09:29:51 +00:00
2009-06-30 11:52:55 +00:00
# Make sure this PHP install has session support
if (! extension_loaded('session'))
error('<p>Your install of PHP appears to be missing php-session support.</p><p>Please install php-session support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small></p>','error',null,true);
2009-06-30 10:40:33 +00:00
# Make sure this PHP install has gettext, we use it for language translation
if (! extension_loaded('gettext'))
2009-06-30 11:52:55 +00:00
system_message(array(
'title'=>_('Missing required extension'),
'body'=>'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>',
'type'=>'error'));
# Make sure this PHP install has all our required extensions
if (! extension_loaded('ldap'))
system_message(array(
'title'=>_('Missing required extension'),
'body'=>'Your install of PHP appears to be missing LDAP support.<br /><br />Please install LDAP support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type'=>'error'));
# Make sure that we have php-xml loaded.
if (! function_exists('xml_parser_create'))
system_message(array(
'title'=>_('Missing required extension'),
'body'=>'Your install of PHP appears to be missing XML support.<br /><br />Please install XML support before using phpLDAPadmin.<br /><small>(Dont forget to restart your web server afterwards)</small>',
'type'=>'error'));
2009-06-30 10:40:33 +00:00
2009-06-30 11:46:44 +00:00
/**
2009-06-30 10:46:00 +00:00
* Helper functions.
2009-06-30 09:29:51 +00:00
* Our required helper functions are defined in functions.php
*/
2009-06-30 11:46:44 +00: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 11:52:55 +00:00
error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name),'error',null,true);
2009-06-30 09:29:51 +00:00
2009-06-30 11:46:44 +00:00
if (! is_readable($file_name))
2009-06-30 11:52:55 +00:00
error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name),'error',null,true);
2009-06-30 08:05:37 +00:00
2009-06-30 11:46:44 +00:00
ob_start();
require $file_name;
if (ob_get_level()) ob_end_clean();
}
2009-06-30 08:07:14 +00:00
2009-06-30 09:29:51 +00:00
# Configuration File check
2009-06-30 11:46:44 +00:00
if (! file_exists($app['config_file'])) {
error(sprintf(_('You need to configure %s. Edit the file "%s" to do so. An example config file is provided in "%s.example".'),app_name(),$app['config_file'],$app['config_file']),'error',null,true);
2009-06-30 08:09:20 +00:00
2009-06-30 11:46:44 +00:00
} elseif (! is_readable($app['config_file'])) {
2009-06-30 11:52:55 +00:00
error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file']),'error',null,true);
2009-06-30 09:29:51 +00:00
}
2009-06-30 08:05:37 +00:00
2009-06-30 10:46:00 +00:00
# If our config file fails the sanity check, then stop now.
if (! $config = check_config($app['config_file'])) {
2009-06-30 11:46:44 +00:00
$www['page'] = new page();
$www['body'] = new block();
$www['page']->block_add('body',$www['body']);
$www['page']->display();
2009-06-30 10:26:08 +00:00
exit;
} else {
app_session_start();
$_SESSION[APPCONFIG] = $config;
2009-06-30 10:26:08 +00:00
}
2009-06-30 08:05:37 +00:00
2009-06-30 11:52:55 +00:00
if ($uri = get_request('URI','GET'))
header(sprintf('Location: cmd.php?%s',base64_decode($uri)));
if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
system_message(array(
'title'=>_('This is a development version of phpLDAPadmin'),
'body'=>'This is a development version of phpLDAPadmin! You should <b>NOT</b> use it in a production environment (although we dont think it should do any damage).',
'type'=>'info','special'=>true));
if (count($_SESSION[APPCONFIG]->untested()))
system_message(array(
2009-07-08 13:24:43 +00:00
'title'=>'Untested configuration parameters',
'body'=>sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>',implode(', ',$_SESSION[APPCONFIG]->untested())),
'type'=>'info','special'=>true));
$server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
if (count($server->untested()))
system_message(array(
2009-07-08 13:24:43 +00:00
'title'=>'Untested server configuration parameters',
'body'=>sprintf('The following parameters have not been tested. If you have configured these parameters, and they are working as expected, please let the developers know, so that they can be removed from this message.<br/><small>%s</small>',implode(', ',$server->untested())),
'type'=>'info','special'=>true));
2009-07-08 13:24:43 +00:00
if (count($server->undocumented()) || count($_SESSION[APPCONFIG]->undocumented())) {
$body = '';
$site = 'http://phpldapadmin.sourceforge.net/wiki/index.php';
foreach ($server->undocumented() as $param)
$body .= sprintf('<a href="%s/Ldapserver:%s">%s</a>, ',$site,preg_replace('/\./',':',$param),$param);
$body = preg_replace('/, $/','',$body);
$body .= '<br/><br/>';
foreach ($_SESSION[APPCONFIG]->undocumented() as $param)
$body .= sprintf('<a href="%s/config:%s">%s</a>, ',$site,preg_replace('/\./',':',$param),$param);
$body = preg_replace('/, $/','',$body);
system_message(array(
'title'=>'Undocumented PLA configuration parameters',
'body'=>sprintf('The following parameters need to be documented:<br/><small>%s</small>',$body),
'type'=>'info','special'=>true));
}
}
2009-06-30 10:46:00 +00:00
include './cmd.php';
2009-06-30 08:05:37 +00:00
?>