<?php
/**
 * @version      $Id: index.php 10381 2008-06-01 03:35:53Z $
 * @package      Carteasy
 * @copyright    Copyright (C) 2005 - 2024 Wlanium
 * @license      proprietary
 * @author       Thomas Bartelt
 * Carteasy is a web shop system
 */
// WARTUNGSMODUS MIT ADMIN-BYPASS
session_start();
$MAINTENANCE_MODE = false;

// Admin-Session setzen wenn admin_modul aufgerufen wird
if (isset($_GET['admin_modul'])) {
    $_SESSION['admin_logged_in'] = true;
}

// Wartungsmodus nur für nicht-eingeloggte User
if ($MAINTENANCE_MODE && !isset($_SESSION['admin_logged_in']) && !isset($_GET['admin_modul']) && !isset($_GET['soap_modul'])) {
    echo '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Wartungsarbeiten</title></head><body style="font-family:Arial;text-align:center;padding:50px;background:url(/media/images/e1759de19cc7e0592d0aa161f86bfe8b.jpg) no-repeat center center fixed;background-size:cover;"><div style="background:white;padding:40px;border-radius:10px;display:inline-block;"><h1>🔧 Wartungsarbeiten</h1><p>Wir sind bald wieder da!</p><p>Bis ca. 21:00 Uhr</p><p>📧 intelectra-ersatzteile@t-online.de</p></div></body></html>';
    exit();
}
$debugOverride = false;

// redirect away from testing site
/*session_start();
if (isset($_GET["garda"]) || isset($_SESSION["garda"])) {
	$_SESSION["garda"] = "";
} else {
	header("location: https://www.intelectra-shop.de");
}*/

// DEV DEBUG TEMPORARY
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/error_log.txt'); 

//setlocale(LC_ALL, 'de_DE.UTF-8@euro', 'de_DE', 'deu_deu', 'ge');

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';
} elseif (isset($_GET['soap_modul'])) {
	// soap
	include './modules/soap_init.php';
} elseif (isset($_GET['website_modul'])) {
	include './modules/website_init.php';
} elseif (isset($_GET['lightningrod'])) {
	include './service/lightningrod_init.php';
} elseif (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) {
                $_GET['menu_id'] = $structure;
            }
            else {
                header('HTTP/1.1 301 Moved Permanently');
                header('Location: /');
                exit();
            }
        }
	
	// 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) {
                    $_GET['item_id'] = $item;
                }
                else {
                    header('HTTP/1.1 301 Moved Permanently');
                    header('Location: /');
                    exit();
                }
        }

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

/* EOF */