<?php

require_once(dirname(__FILE__) . '/protected/components/CArray.php');
require_once(dirname(__FILE__) . '/protected/utilities/WebLogger.php');
require_once(dirname(__FILE__) . '/protected/utilities/ZipFile.php');
require_once(dirname(__FILE__) . '/protected/utilities/KriaExceptionHandler.php');
//set_exception_handler('KriaExceptionHandler::getInstance()->handleException');
global $_TMP;
$_TMP = new CArray();

require_once(dirname(__FILE__) . '/protected/components/CryptoEngine.php');
require_once 'install.php';
require_once 'build_number.php';
require_once(dirname(__FILE__) . '/protected/extensions/yii-environment/Environment.php');
$env = new Environment();

defined('YII_DEBUG') or define('YII_DEBUG', $env->yiiDebug);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', $env->yiiTraceLevel);

require_once(dirname(__FILE__) . '/protected/globals.php');
require_once($env->yiiPath);
require_once(dirname(__FILE__) . '/protected/components/KriaWebApplication.php');

$env->runYiiStatics();
$app = Yii::createApplication('KriaWebApplication', $env->configWeb);

spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once('log4php/Logger.php'); // require registers Logger autoload
spl_autoload_register(array('YiiBase', 'autoload'));

$app->params['environment'] = $env->determineMode();

Logger::configure($app->params['log4php']);

//throw new Exception('Uncaught Exception');
$app->run();
