<?php
/*
 * @version			$Id: index.php 10381 2008-06-01 03:35:53Z $
 * @package			Carteasy
 * @copyright		Copyright (C) 2005 - 2011 Wlanium
 * @license			proprietary
 * @author			Thomas Bartelt
 * Carteasy is a web shop system
 */

//echo "<h3>Wartungsarbeiten bis ca. 13 Uhr!</h3>";exit();
if (isset($_GET['debug']) && $_GET['debug'] == true) {
	ini_set('display_errors', 1);
	error_reporting(E_ALL);
} else {
	ini_set('display_errors', 1);
	error_reporting(E_ALL);
}


ini_set("memory_limit","1024M");
set_time_limit(60000);

// including libs
include_once './core/base.class.php';
include_once './core/registry.class.php';
include_once './core/uri.class.php';

//echo microtime_float() - $start_time;

// base object
$base_object = new base();

Registry::set('base', $base_object);

if (isset($_GET['admin_modul'])) {
	// go to admin website
	include './modules/admin_init.php';
} else if (isset($_GET['soap_modul'])) {
	// soap
	include './modules/soap_init.php';
} else if (isset($_GET['website_modul'])) {
	include './modules/website_init.php';
} else if (isset($_GET['lightningrod'])) {
	include './service/lightningrod_init.php';
} else if (isset($_GET['exportpdf'])) {
	include './scripts/exportpdf.php';
} else {
	// go to shop website
	// get structure
	if (isset($_GET['structure_suri'])) {
		$structure = URI::fetch_structure($_GET['structure_suri']);
		/*if (!$structure) {
			header('Location: /error_404/');
		} else {
			$_GET['menu_id'] = $structure;
		}*/
		$_GET['menu_id'] = $structure;
	}

	// get parent structures 2-8
	$_GET['parent_ids'] = isset($_GET['menu_id']) ? array($_GET['menu_id']) : array();
	for ($i=1;$i<9;$i++) {
		if (isset($_GET['structure_suri'.$i])) {
			$_GET['parent_ids'][] = URI::fetch_structure($_GET['structure_suri'.$i]);
		}
	}

	// get item
	if (isset($_GET['item_suri'])) {
		$item = URI::fetch_item($_GET['item_suri']);
		if (!$item) {
			header('Location: /error_404/');
		} else {
			$_GET['item_id'] = $item;
		}
	}

	include './modules/website_init.php';
}

?>