<?php

/*
 *---------------------------------------------------------------
 * PHP ERROR REPORTING LEVEL
 *---------------------------------------------------------------
 *
 * By default CI runs with error reporting set to ALL.  For security
 * reasons you are encouraged to change this to 0 when your site goes live.
 * For more info visit:  http://www.php.net/error_reporting
 *
 */
	error_reporting(E_ALL | E_STRICT);
        date_default_timezone_set('Europe/Vienna');
        setlocale(LC_CTYPE, 'de_DE.UTF-8');
	
/*
|---------------------------------------------------------------
| BASIC REQUIREMENTS AND ERROR DISPLAY
|---------------------------------------------------------------
|
*/
	if (!@extension_loaded('ionCube Loader') && !isset($_SERVER['HTTP_MYSEC'])) {
		$msg = 'ionCube Loader missing';
		header('Location: install.php/install/'.rawurlencode($msg));
		die($msg);
	}
        
        ini_set('display_errors', 0);

/*
 *---------------------------------------------------------------
 * BASE SYSTEM INFOS
 *---------------------------------------------------------------
 */
	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

	define('EXT', '.php');

	define('FCPATH', str_replace(SELF, '', __FILE__));

/*
 *---------------------------------------------------------------
 * SYSTEM FOLDER NAME
 *---------------------------------------------------------------
 *
 * This variable must contain the name of your "system" folder.
 * Include the path if the folder is not in the same  directory
 * as this file.
 *
 */
	$system_path = FCPATH.'system';

/*
 *---------------------------------------------------------------
 * APPLICATION FOLDER NAME
 *---------------------------------------------------------------
 *
 * If you want this front controller to use a different "application"
 * folder then the default one you can set its name here. The folder
 * can also be renamed or relocated anywhere on your server.  If
 * you do, use a full server path. For more info please see the user guide:
 * https://codeigniter.com/user_guide/general/managing_apps.html
 *
 * NO TRAILING SLASH!
 *
 */
	$application_folder = FCPATH.'application';
        $install_folder = FCPATH.'installer';

/*
 * ---------------------------------------------------------------
 *  Resolve the system path for increased reliability
 * ---------------------------------------------------------------
 */
	if (realpath($system_path) !== FALSE)
	{
		$system_path = realpath($system_path).'/';
	}

	$system_path = rtrim($system_path, '/').'/';

	if ( ! is_dir($system_path))
	{
		exit('Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME));
	}

/*
 * -------------------------------------------------------------------
 *  Now that we know the path, set the main path constants
 * -------------------------------------------------------------------
 */
	define('BASEPATH', str_replace("\\", "/", $system_path));

	define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));

        if (($us_saaspath = getenv('US_SAASPATH'))) {
            putenv('US_SAASPATH');
            $mysec = filter_input(INPUT_SERVER, 'HTTP_MYSEC', FILTER_SANITIZE_EMAIL);
            $myhost = filter_input(INPUT_SERVER, 'HTTP_X_FORWARDED_HOST', FILTER_SANITIZE_URL);
            if (!isset($mysec) || empty($mysec)) {
                exit('Parameter missing. Invalid setup. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME));
            }
            if (!isset($myhost) || empty($myhost)) {
                exit('Proxy parameter missing. Invalid setup. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME));
            }
            define('US_TENANTPATH', $us_saaspath.$mysec.sha1($myhost).'/');
            define('WRITEABLEPATH', US_TENANTPATH.'writeable/');
        } else {
            define('WRITEABLEPATH', pathinfo(__FILE__, PATHINFO_DIRNAME).'/writeable/');
        }

	define('APPPATH', realpath($application_folder).'/');
	define('APPPATHLIVE', realpath($application_folder).'/' );
	define('INSTALLPATH', realpath($install_folder).'/' );
        
        define('PRESET_PATH', APPPATH.'presets/');
        define('PRESET_PATH_FORM_TYPES', PRESET_PATH.'form_types/');
        define('PRESET_PATH_OFFER_FORM_TYPES', PRESET_PATH.'offer_form_types/');
        define('PRESET_PATH_OFFER_COMPONENT_FORM_TYPES', PRESET_PATH.'offer_component_form_types/');
        define('PRESET_PATH_TRANSMITTAL_FORM_TYPES', PRESET_PATH.'transmittal_form_types/');
        define('PRESET_PATH_PAYMENT_FORM_TYPES', PRESET_PATH.'payment_form_types/');
        define('PRESET_PATH_PAYMENT_COMPONENT_FORM_TYPES', PRESET_PATH.'payment_component_form_types/');
        define('PRESET_PATH_COLLECTIVE_BILL_TYPES', PRESET_PATH.'collective_bill_types/');
        define('PRESET_PATH_COLLECTIVE_OFFER_TYPES', PRESET_PATH.'collective_offer_types/');
        define('PRESET_PATH_REPORTSX', PRESET_PATH.'reportsx/');
        define('PRESET_PATH_F2G_REPORT_FORM_TYPES', PRESET_PATH.'f2g_report_form_types/');
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 *
 */
require_once BASEPATH.'core/CodeIgniter.php';

/* End of file index_us.php */
/* Location: ./index_us.php */