PageRenderTime 21ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/index.php

https://bitbucket.org/dereckson/phpldapadmin
PHP | 147 lines | 86 code | 27 blank | 34 comment | 23 complexity | eb1fdf728c379f6e76adb5686770dccc MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * phpLDAPadmin Start Page
  4. *
  5. * @package phpLDAPadmin
  6. * @subpackage Page
  7. */
  8. /**
  9. */
  10. /*******************************************
  11. <pre>
  12. If you are seeing this in your browser,
  13. PHP is not installed on your web server!!!
  14. </pre>
  15. *******************************************/
  16. /**
  17. * We will perform some sanity checking here, since this file is normally loaded first when users
  18. * first access the application.
  19. */
  20. # The index we will store our config in $_SESSION
  21. define('APPCONFIG','plaConfig');
  22. define('LIBDIR',sprintf('%s/',realpath('../lib/')));
  23. ini_set('display_errors',1);
  24. error_reporting(E_ALL);
  25. # General functions needed to proceed.
  26. ob_start();
  27. if (! file_exists(LIBDIR.'functions.php')) {
  28. if (ob_get_level()) ob_end_clean();
  29. die(sprintf("Fatal error: Required file '<b>%sfunctions.php</b>' does not exist.",LIBDIR));
  30. }
  31. if (! is_readable(LIBDIR.'functions.php')) {
  32. if (ob_get_level()) ob_end_clean();
  33. die(sprintf("Cannot read the file '<b>%sfunctions.php</b>' its permissions may be too strict.",LIBDIR));
  34. }
  35. if (ob_get_level())
  36. ob_end_clean();
  37. # Make sure this PHP install has pcre
  38. if (! extension_loaded('pcre'))
  39. 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>');
  40. require LIBDIR.'functions.php';
  41. # Define the path to our configuration file.
  42. if (defined('CONFDIR'))
  43. $app['config_file'] = CONFDIR.'config.php';
  44. else
  45. $app['config_file'] = 'config.php';
  46. # Make sure this PHP install has session support
  47. if (! extension_loaded('session'))
  48. 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);
  49. # Make sure this PHP install has gettext, we use it for language translation
  50. if (! extension_loaded('gettext'))
  51. system_message(array(
  52. 'title'=>_('Missing required extension'),
  53. '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>',
  54. 'type'=>'error'));
  55. # Make sure this PHP install has all our required extensions
  56. if (! extension_loaded('ldap'))
  57. system_message(array(
  58. 'title'=>_('Missing required extension'),
  59. '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>',
  60. 'type'=>'error'));
  61. # Make sure that we have php-xml loaded.
  62. if (! function_exists('xml_parser_create'))
  63. system_message(array(
  64. 'title'=>_('Missing required extension'),
  65. '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>',
  66. 'type'=>'error'));
  67. /**
  68. * Helper functions.
  69. * Our required helper functions are defined in functions.php
  70. */
  71. if (isset($app['function_files']) && is_array($app['function_files']))
  72. foreach ($app['function_files'] as $file_name ) {
  73. if (! file_exists($file_name))
  74. error(sprintf('Fatal error: Required file "%s" does not exist.',$file_name),'error',null,true);
  75. if (! is_readable($file_name))
  76. error(sprintf('Fatal error: Cannot read the file "%s", its permissions may be too strict.',$file_name),'error',null,true);
  77. ob_start();
  78. require $file_name;
  79. if (ob_get_level()) ob_end_clean();
  80. }
  81. # Configuration File check
  82. if (! file_exists($app['config_file'])) {
  83. 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);
  84. } elseif (! is_readable($app['config_file'])) {
  85. error(sprintf('Fatal error: Cannot read your configuration file "%s", its permissions may be too strict.',$app['config_file']),'error',null,true);
  86. }
  87. # If our config file fails the sanity check, then stop now.
  88. if (! $config = check_config($app['config_file'])) {
  89. $www['page'] = new page();
  90. $www['body'] = new block();
  91. $www['page']->block_add('body',$www['body']);
  92. $www['page']->display();
  93. exit;
  94. } else {
  95. app_session_start();
  96. $_SESSION[APPCONFIG] = $config;
  97. }
  98. if ($uri = get_request('URI','GET'))
  99. header(sprintf('Location: cmd.php?%s',base64_decode($uri)));
  100. if (! preg_match('/^([0-9]+\.?)+/',app_version())) {
  101. system_message(array(
  102. 'title'=>_('This is a development version of phpLDAPadmin'),
  103. '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).',
  104. 'type'=>'info','special'=>true));
  105. if (count($_SESSION[APPCONFIG]->untested()))
  106. system_message(array(
  107. 'title'=>'Untested configuration paramaters',
  108. '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())),
  109. 'type'=>'info','special'=>true));
  110. $server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST'));
  111. if (count($server->untested()))
  112. system_message(array(
  113. 'title'=>'Untested server configuration paramaters',
  114. '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())),
  115. 'type'=>'info','special'=>true));
  116. }
  117. include './cmd.php';
  118. ?>