Skip to content

Commit

Permalink
Lookup the existance of the env file / Better formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tracend committed Apr 2, 2012
1 parent 37f9756 commit 9478fbe
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
//===============================================
// ENVIRONMENT SETUP
//===============================================
$env = json_decode( file_get_contents("../env.json") );

$ENV = (file_exists("../env.json")) ? json_decode( file_get_contents("../env.json") ): array();

// Process enviromental variables (from env.json)
foreach( $ENV as $domain => $properties ){
// check the domain against each set
if( strpos($_SERVER['SERVER_NAME'], $domain) !== false ){
// available options: base, plugins, cdn, debug (sdk)
foreach( $properties as $key=>$value ){
if( !empty($value) ) eval("define('".strtoupper($key)."', '$value');");
}
// exit if we found a match
break;
}
}


//===============================================
Expand All @@ -30,29 +44,21 @@
// full path of where the templates reside
define('TEMPLATES', $_SERVER['DOCUMENT_ROOT'] . WEB_FOLDER . 'templates/');

// Process enviromental variables (from env.json)
foreach( $env as $domain => $properties ){
// check the domain against each set
if( strpos($_SERVER['SERVER_NAME'], $domain) !== false ){
// available options: base, plugins, cdn, debug (sdk)
foreach( $properties as $key=>$value ){
if( !empty($value) ) eval("define('".strtoupper($key)."', '$value');");
}
// exit if we found a match
break;
}
}

// Other Constants
// - find if this is running from localhost
//===============================================
// OTHER CONSTANTS
//===============================================

// find if this is running from localhost
define("IS_LOCALHOST", (strpos($_SERVER['SERVER_NAME'], "localhost") !== false) );
// - set to true to enable debug mode (where supported)
// set to true to enable debug mode (where supported)
if(!defined("DEBUG")) define('DEBUG', false);


//===============================================
// Start the controller
// INITIALIZATION
//===============================================

if (defined("APP") && is_file(APP.'bin/init.php')){
// find the clone file first
require_once(APP.'bin/init.php');
Expand Down

0 comments on commit 9478fbe

Please sign in to comment.