diff -r 299a90e28abc -r 87e08a6e4fec install/includes/common.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/includes/common.php Wed Jan 16 13:55:49 2008 -0500 @@ -0,0 +1,130 @@ + '1.1.1', + 'type' => 'alpha' + // If type is set to "rc", "beta", or "alpha", optionally another version number can be issued with the key 'sub': + // 'sub' => '3' will produce Enano 1.1.1a3 / Enano 1.1.1 alpha 3 +); + +// Determine Enano root directory + +$enano_root = dirname(dirname(dirname(__FILE__))); +if ( preg_match('#/repo$#', $enano_root) && file_exists("$enano_root/../.enanodev") ) +{ + $enano_root = preg_replace('#/repo$#', '', $enano_root); +} + +define('ENANO_ROOT', $enano_root); + +chdir(ENANO_ROOT); + +// Determine our scriptPath +if ( isset($_SERVER['REQUEST_URI']) ) +{ + // Use reverse-matching to determine where the REQUEST_URI overlaps the Enano root. + $requri = $_SERVER['REQUEST_URI']; + if ( isset($_SERVER['PATH_INFO']) && !preg_match('/index\.php$/', $_SERVER['PATH_INFO']) ) + { + $requri = preg_replace(';' . preg_quote($_SERVER['PATH_INFO']) . '$;', '', $requri); + } + if ( !preg_match('/\.php$/', $requri) ) + { + // user requested http://foo/enano as opposed to http://foo/enano/index.php + $requri .= '/index.php'; + } + $sp = dirname($_SERVER['REQUEST_URI']); + if ( $sp == '/' || $sp == '\\' ) + { + $sp = ''; + } + $sp = preg_replace('#/install$#', '', $sp); + define('scriptPath', $sp); +} + +// is Enano already installed? +@include(ENANO_ROOT . '/config.php'); +if ( defined('ENANO_INSTALLED') && defined('ENANO_DANGEROUS') ) +{ + $title = 'Installation locked'; + require('includes/common.php'); + $template->header(); + echo '

The installer has detected that an installation of Enano already exists on your server. You MUST delete config.php if you wish to reinstall Enano.

'; + $template->footer(); + exit(); +} + +function microtime_float() +{ + list($usec, $sec) = explode(" ", microtime()); + return ((float)$usec + (float)$sec); +} + +define('IN_ENANO_INSTALL', 1); + +require(ENANO_ROOT . '/install/includes/ui.php'); +require(ENANO_ROOT . '/includes/functions.php'); +require(ENANO_ROOT . '/includes/json.php'); +require(ENANO_ROOT . '/includes/constants.php'); +require(ENANO_ROOT . '/includes/rijndael.php'); +// If we have at least PHP 5, load json2 +if ( version_compare(PHP_VERSION, '5.0.0', '>=') ) +{ + require(ENANO_ROOT . '/includes/json2.php'); +} + +// Build a list of available languages +$dir = @opendir( ENANO_ROOT . '/language' ); +if ( !$dir ) + die('CRITICAL: could not open language directory'); + +$languages = array(); +// Use the old PHP4-compatible JSON decoder +$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); + +while ( $dh = @readdir($dir) ) +{ + if ( $dh == '.' || $dh == '..' ) + continue; + if ( file_exists( ENANO_ROOT . "/language/$dh/meta.json" ) ) + { + // Found a language directory, determine metadata + $meta = @file_get_contents( ENANO_ROOT . "/language/$dh/meta.json" ); + if ( empty($meta) ) + // Could not read metadata file, continue silently + continue; + $meta = $json->decode($meta); + if ( isset($meta['lang_name_english']) && isset($meta['lang_name_native']) && isset($meta['lang_code']) ) + { + $languages[$meta['lang_code']] = array( + 'name' => $meta['lang_name_native'], + 'dir' => $dh + ); + } + } +} + +if ( count($languages) < 1 ) +{ + die('CRITICAL: No languages are available'); +} + +// List of available DB drivers +$supported_drivers = array('mysql', 'postgresql'); + +?>