<?php

// APPLICATION_PATH is a constant pointing to our application/ subdirectory.
// We use this to add our "library" directory to the include_path, so that
// PHP can find our Zend Framework classes.


$resultado = strpos($_SERVER['REQUEST_URI'], '/lcc/');

if($resultado === false){
	define('APPLICATION_ENVIRONMENT', 'desarrollo');
} else{
 	define('APPLICATION_ENVIRONMENT', 'produccion');
}
//echo APPLICATION_ENVIRONMENT;
// VCC_T es para pruebas
//define('APPLICATION_ENVIRONMENT', 'produccion');

define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/'));
set_include_path(APPLICATION_PATH . '/../library' . PATH_SEPARATOR . get_include_path());


error_reporting(E_ALL);

// AUTOLOADER - Set up autoloading.
// This is a nifty trick that allows ZF to load classes automatically so
// that you don't have to litter your code with 'include' or 'require'
// statements.

//para version 1.7 de zend
   
/*require_once "Zend/Loader.php";
Zend_Loader::registerAutoload();*/


   // version 1.10
      require_once 'Zend/Loader/Autoloader.php';
   
      Zend_Loader_Autoloader::getInstance();




// REQUIRE APPLICATION BOOTSTRAP: Perform application-specific setup
// This allows you to setup the MVC environment to utilize. Later you
// can re-use this file for testing your applications.
// The try-catch block below demonstrates how to handle bootstrap
// exceptions. In this application, if defined a different
// APPLICATION_ENVIRONMENT other than 'production', we will output the
// exception and stack trace to the screen to aid in fixing the issue
try {
    require '../application/app/bootstrap.php';
} catch (Exception $exception) {
    echo '<html><body><center>'
       . 'An exception occured while bootstrapping the application.';
    if (defined('APPLICATION_ENVIRONMENT') && APPLICATION_ENVIRONMENT != 'production') {
        echo '<br /><br />' . $exception->getMessage() . '<br />'
           . '<div align="left">Stack Trace:'
           . '<pre>' . $exception->getTraceAsString() . '</pre></div>';
    }
    echo '</center></body></html>';
    exit(1);
}


// DISPATCH:  Dispatch the request using the front controller.
// The front controller is a singleton, and should be setup by now. We
// will grab an instance and dispatch it, which dispatches your
// application.
$instancia = Zend_Controller_Front::getInstance();
try{
	/* url amigables 
	$request = UrlAmigable::getRequest();
	$instancia->dispatch();
	*/
	$instancia->dispatch();
} catch (Exception $exception) {
	echo $exception;    
  	//header('Location: '. $instancia->getBaseUrl() .'/errores/error');
}
