From 533103d2093143c40c6f361297a67d717d651af7 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 3 Nov 2005 12:31:16 +0000 Subject: [PATCH] better environment check --- lam/templates/login.php | 68 ++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/lam/templates/login.php b/lam/templates/login.php index 8230b6e6..e95fc746 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -28,6 +28,50 @@ $Id$ * @package main */ +/** status messages */ +include_once("../lib/status.inc"); + +// check environment +$criticalErrors = array(); +// check if PHP has session support +if (! function_exists('session_start')) { + $criticalErrors[] = array("ERROR", "Your PHP has no session support!", "Please install the session extension for PHP."); +} +// check if PHP has LDAP support +if (! function_exists('ldap_search')) { + $criticalErrors[] = array("ERROR", "Your PHP has no LDAP support!", "Please install the LDAP extension for PHP."); +} +// check if PHP has gettext support +if (! function_exists('gettext') || !function_exists('_')) { + $criticalErrors[] = array("ERROR", "Your PHP has no gettext support!", "Please install gettext for PHP."); +} +// check file permissions +$writableDirs = array('config', 'config/profiles', 'config/pdf', 'sess', 'tmp', ); +for ($i = 0; $i < sizeof($writableDirs); $i++) { + $path = realpath('../') . "/" . $writableDirs[$i]; + if (!is_writable($path)) { + $criticalErrors[] = array("ERROR", _('The directory %s is not writable for the web server. Please change your file permissions.'), '', array($path)); + } +} +// stop login if critical errors occured +if (sizeof($criticalErrors) > 0) { + echo "\n"; + echo "\n\n"; + echo "\n\n"; + echo "\n"; + echo "\n \n"; + echo ""; + echo "LDAP Account Manager\n"; + echo "\n"; + for ($i = 0; $i < sizeof($criticalErrors); $i++) { + call_user_func_array("StatusMessage", $criticalErrors[$i]); + echo "

"; + } + echo ""; + exit(); +} + + /** access to configuration options */ include_once("../lib/config.inc"); // Include config.inc which provides Config class @@ -129,35 +173,11 @@ function display_LoginPage($config_object) {



"; - } // check if all password hashes are possible if ((! function_exists('mHash')) && (! function_exists('sha1'))) { StatusMessage("INFO", "Your PHP does not support MHash or sha1(), you will only be able to use CRYPT/PLAIN/MD5/SMD5 for user passwords!", "Please install MHash or update to PHP >4.3."); echo "

"; } - // check if PHP has LDAP support - if (! function_exists('ldap_search')) { - StatusMessage("ERROR", "Your PHP has no LDAP support!", "Please install the LDAP extension for PHP."); - echo "

"; - } - // check if PHP has gettext support - if (! function_exists('gettext')) { - StatusMessage("ERROR", "Your PHP has no gettext support!", "Please install gettext for PHP."); - echo "

"; - } - // check file permissions - $writableDirs = array('config', 'config/profiles', 'config/pdf', 'sess', 'tmp', ); - for ($i = 0; $i < sizeof($writableDirs); $i++) { - $path = realpath('../') . "/" . $writableDirs[$i]; - if (!is_writable($path)) { - StatusMessage("ERROR", _('The directory %s is not writable for the web server. Please change your file permissions.'), '', array($path)); - echo "
"; - } - } ?>