install/includes/common.php
changeset 1227 bdac73ed481e
parent 1195 449fdd113eb0
child 1259 49db7495f6b8
--- a/install/includes/common.php	Sun Mar 28 21:49:26 2010 -0400
+++ b/install/includes/common.php	Sun Mar 28 23:10:46 2010 -0400
@@ -15,40 +15,40 @@
 
 // Our version number. This needs to be changed for any custom releases.
 $installer_version = array(
-  'version' => '1.1.8',
-  'type' => 'beta'
-  // 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
+	'version' => '1.1.8',
+	'type' => 'beta'
+	// 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
 );
 
 function installer_enano_version($long = false)
 {
-  global $installer_version;
-  static $keywords = array(
-    'alpha' => 'a',
-    'beta' => 'b',
-    'RC' => 'rc'
-    );
-  $v = $installer_version['version'];
-  if ( isset($installer_version['sub']) )
-  {
-    $v .= ( !$long ) ? $keywords[$installer_version['type']] : " {$installer_version['type']} ";
-    $v .= $installer_version['sub'];
-  }
-  return $v;
+	global $installer_version;
+	static $keywords = array(
+		'alpha' => 'a',
+		'beta' => 'b',
+		'RC' => 'rc'
+		);
+	$v = $installer_version['version'];
+	if ( isset($installer_version['sub']) )
+	{
+		$v .= ( !$long ) ? $keywords[$installer_version['type']] : " {$installer_version['type']} ";
+		$v .= $installer_version['sub'];
+	}
+	return $v;
 }
  
 // Determine Enano root directory
 
 if ( !defined('ENANO_ROOT') )
 {
-  $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);
+	$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);
@@ -56,45 +56,45 @@
 // Determine our scriptPath
 if ( isset($_SERVER['REQUEST_URI']) && !defined('scriptPath') )
 {
-  // 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);
+	// 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') && !isset($_GET['debug_warn_php4']) )
 {
-  $title = 'Installation locked';
-  require('includes/common.php');
-  $template->header();
-  echo '<p>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.</p>';
-  $template->footer();
-  exit();
+	$title = 'Installation locked';
+	require('includes/common.php');
+	$template->header();
+	echo '<p>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.</p>';
+	$template->footer();
+	exit();
 }
 
 if ( !function_exists('microtime_float') )
 {
-  function microtime_float()
-  {
-    list($usec, $sec) = explode(" ", microtime());
-    return ((float)$usec + (float)$sec);
-  }
+	function microtime_float()
+	{
+		list($usec, $sec) = explode(" ", microtime());
+		return ((float)$usec + (float)$sec);
+	}
 }
 
 define('IN_ENANO_INSTALL', 1);
@@ -109,7 +109,7 @@
 // If we have at least PHP 5, load json2
 if ( version_compare(PHP_VERSION, '5.0.0', '>=') )
 {
-  require_once(ENANO_ROOT . '/includes/json2.php');
+	require_once(ENANO_ROOT . '/includes/json2.php');
 }
 
 strip_magic_quotes_gpc();
@@ -117,7 +117,7 @@
 // Build a list of available languages
 $dir = @opendir( ENANO_ROOT . '/language' );
 if ( !$dir )
-  die('CRITICAL: could not open language directory');
+	die('CRITICAL: could not open language directory');
 
 $languages = array();
 // Use the old PHP4-compatible JSON decoder
@@ -125,30 +125,30 @@
 
 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'],
-          'name_eng' => $meta['lang_name_english'],
-          'dir' => $dh
-        );
-    }
-  }
+	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'],
+					'name_eng' => $meta['lang_name_english'],
+					'dir' => $dh
+				);
+		}
+	}
 }
 
 if ( count($languages) < 1 )
 {
-  die('The Enano installer couldn\'t find any languages in the language/ folder. Enano needs at least one language in this folder to load and install properly.');
+	die('The Enano installer couldn\'t find any languages in the language/ folder. Enano needs at least one language in this folder to load and install properly.');
 }
 
 // List of available DB drivers
@@ -157,10 +157,10 @@
 // Divert to CLI loader if running from CLI
 if ( isset($argc) && isset($argv) )
 {
-  if ( is_int($argc) && is_array($argv) && !isset($_SERVER['REQUEST_URI']) )
-  {
-    define('ENANO_CLI', '');
-  }
+	if ( is_int($argc) && is_array($argv) && !isset($_SERVER['REQUEST_URI']) )
+	{
+		define('ENANO_CLI', '');
+	}
 }
 
 ?>