<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

session_start();

/*
 * Classes API
 */

include_once(dirname(__FILE__) . '/../classes/api/class.api.ovis.php');

/*
 * Classes: Miscellaneous
 */

include_once(dirname(__FILE__) . '/../classes/class.mijn.ovis.php');

/*
 * Pages
 * 
 * Used to include the necessary assets per page
 */

$aCatalogusPages	= ['','verhuur'];
$aAddEditPages		= ['edit','add'];
$aVerkoopPages		= [''];
$aVerhuurPages		= ['verhuur'];
$aConceptPages		= ['concepten'];
$aInkoopPages		= ['inkoop'];
$aSettingsPages		= ['instellingen'];
$aSaldoPages		= ['saldo'];
$aMarktplaatsPages	= ['marktplaats'];

$aContentPages		= ['saldo','marktplaats'];

$aDashboardPages	= [''];
$aSettingPages   	= ['instellingen'];

$aAddOrEditPages   	= ['optie-toevoegen', 'optie-wijzigen', 'artikel-toevoegen', 'artikel-wijzigen'];

/*
 * Customer ID
 */

$iCustomerId = !empty($_SESSION['customerid']) ? $_SESSION['customerid'] : 0;

/*
 * Host
 */

$sHost = !empty(filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING)) ? filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_STRING) : gethostname();

//define('ASSETS_VERSION', '1.0.0');
define('ASSETS_VERSION', date('U'));

switch($sHost) {
	
	case 'mijn.ovis.local':
	case 'ISN-010-HOME':
		
		define('ENVIRONMENT', 'local');
		define('REALM', 'mijnovis');
		define('ARTICLE_NOTATION', 'o');
		define('OVISURL', 'http://develop.ovis.local');
		define('BASEURL', 'http://mijn.ovis.local');
		define('BASEDOMAIN', 'mijn.ovis.local');
		define('ROBOTS', 'noindex, nofollow');
		define('NAME', 'Mijn OVIS');
		
		/*
		 * OVIS
		 */
		
		define('API_ENDPOINT_OVIS', 'https://api-develop.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS', '5f721d8bd7d77574c72ded7cf5d8371eb05f62194f3b5ce27b44cf72ea1c2c81');
		
		/*
		 * OVIS SEARCH
		 */
		
		define('API_ENDPOINT_OVIS_SEARCH', 'https://api-develop.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS_SEARCH', '486cd7bc0d2510d5b1ec1d52008b967967672b7a8488ed7ce1c6986df7040182');
		
		/*
		 * Images
		 */
		
		define('IMAGE_DIRECTORY', 'C:\wamp64\www\netbeans\configurator.ovis.nl\configuratorimages');
		define('IMAGE_TEMPORARY_DIRECTORY', 'C:\wamp64\www\netbeans\configurator.ovis.nl\configuratorimagestemp');
		
		/*
		 * Pages
		 */
		
		define('PAGE_DIRECTORY', 'C:\wamp64\www\netbeans\configurator.ovis.nl\configuratorpages');
		
		/*
		 * Error reporting
		 */
		
		ini_set('display_errors', '1');
		ini_set('display_startup_errors', '1');
		error_reporting(E_ALL);	
		
		/*
		 * Local testing
		 */
		
		// Caravan, camper
		$_SESSION['ssoRouteLoginUserId'] = 164;
		
		break;
	
	case 'dev-mijn.ovis.nl':
	case 'develop':

		define('ENVIRONMENT', 'development');
		define('REALM', 'mijnovis');
		define('ARTICLE_NOTATION', 'o');
		define('BASEURL', 'https://dev-mijn.ovis.nl');
		define('OVISURL', 'http://develop.ovis.nl');
		define('BASEDOMAIN', 'dev-mijn.ovis.nl');
		define('ROBOTS', 'noindex, nofollow');
		define('NAME', 'Mijn OVIS');
		
		/*
		 * OVIS
		 */
		
		define('API_ENDPOINT_OVIS', 'https://api-develop.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS', '5f721d8bd7d77574c72ded7cf5d8371eb05f62194f3b5ce27b44cf72ea1c2c81');
		
		/*
		 * OVIS SEARCH
		 */
		
		define('API_ENDPOINT_OVIS_SEARCH', 'https://api-develop.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS_SEARCH', '486cd7bc0d2510d5b1ec1d52008b967967672b7a8488ed7ce1c6986df7040182');
		
		/*
		 * Images
		 */
		
		define('IMAGE_DIRECTORY', '/var/www/configurator.ovis.nl/configuratorimages');
		define('IMAGE_TEMPORARY_DIRECTORY', '/var/www/configurator.ovis.nl/configuratorimagestemp');
		
		/*
		 * Pages
		 */
		
		define('PAGE_DIRECTORY', '/var/www/configurator.ovis.nl/configuratorpages');
		
		/*
		 * Error reporting
		 */
		
		ini_set('display_errors', '1');
		ini_set('display_startup_errors', '1');
		error_reporting(E_ALL);	
		
		break;
		
	default:

		define('ENVIRONMENT', 'production');
		define('REALM', 'mijnovis');
		define('ARTICLE_NOTATION', 'o');
		define('BASEURL', 'https://mijn.ovis.nl');
		define('OVISURL', 'http://www.ovis.nl');
		define('BASEDOMAIN', 'mijn.ovis.nl');
		define('ROBOTS', 'index, follow');
		define('NAME', 'Mijn OVIS');
		
		/*
		 * OVIS
		 */
		
		define('API_ENDPOINT_OVIS', 'https://api.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS', 'c41c554c26999421d0276e11fcd285e47a0969f9502c8e95a7717fb53b67dd4b');
		
		/*
		 * OVIS SEARCH
		 */
		
		define('API_ENDPOINT_OVIS_SEARCH', 'https://api.ovis.nl');
		define('AUTHENTICATION_KEY_OVIS_SEARCH', '918701ac47b99eb753d8072a528eea6bc0c0b88c3df8cf8a6ffd4d3820b858a1');
		
		/*
		 * Pages
		 */
		
		define('PAGE_DIRECTORY', '/var/www/configurator.ovis.nl/configuratorpages');
		
		/*
		 * Images
		 */		 
		
		define('IMAGE_DIRECTORY','/var/www/configurator.ovis.nl/configuratorimages');
		define('IMAGE_TEMPORARY_DIRECTORY', '/var/www/configurator.ovis.nl/configuratorimagestemp');
		
		break;		
		
}


function jsonPrepare($sString=false){
	
	if(!empty($sString)){
		$sString = json_encode($sString,  JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
	}

	return $sString;
 
}