<?php

/**
 * 
 * Copyright (C) Die Randgruppe GmbH
 * 
 * http://www.randshop.com
 * http://www.dierandgruppe.com
 * 
 * Unter der Lizenz von Die Randgruppe GmbH:
 * http://www.randshop.com/Lizenz
 *  
 * $Author$
 * $Date$
 * $Revision$
 * 
 */

session_start();

if (!isset($SEOCall) || !$SEOCall) {
    include_once("conf/config.inc.php");
}

if (INSTALL === true) {
    header("location: install/index.php");
} 

// SourceID = 1	

// Hauptkonfigurationsdatei

include_once(DATEIPFAD . "conf/db.inc.php");
include_once(DATEIPFAD . "includes/shopinitialize.inc.php");
include_once(DATEIPFAD . "includes/functions.global.inc.php");
include_once(DATEIPFAD . "includes/functions.artikel.inc.php");
include_once(DATEIPFAD . "includes/functions.slider.inc.php");

// ********************************************************************************
// ** Slider
// ********************************************************************************

$KategorieDataArray = GetSliderDataArray();


if (KUNDENGRUPPEN) {
    include_once(DATEIPFAD . "includes/functions.mod.kundengruppen.inc.php");
} else {
    include_once(DATEIPFAD . "includes/functions.kundengruppen.inc.php");
}
include_once(DATEIPFAD . "includes/functions.kategorie.inc.php");
include_once(DATEIPFAD . "includes/session_register.inc.php");
include_once(DATEIPFAD . "includes/functions.newsletter.inc.php");

if (file_exists(DATEIPFAD . 'includes/functions.mod.cms.inc.php')){
    include_once(DATEIPFAD . "includes/functions.mod.cms.inc.php");
}

include_once(DATEIPFAD . "includes/functions.statistik.inc.php");

// Spracheninclude
if (@fopen(DATEIPFAD . "includes/language/langu_" . $_SESSION["languageisocode"] . ".inc.php",r)) {
    include_once(DATEIPFAD . "includes/language/langu_" . $_SESSION["languageisocode"] . ".inc.php");
} else {
    include_once(DATEIPFAD . "includes/language/langu_de.inc.php");
}

    unset($_SESSION['artikelliste_shop']["kategorieid"]);
    unset($KategorieID);

// Header
include_once(DATEIPFAD . "includes/header.inc.php");
	
	

	
	// Statistik
	$tpl_refertype_neuheiten = VERWEIS_QUELLE_STARTSEITE_NEUHEITEN;
	$tpl_refertype_angebote = VERWEIS_QUELLE_STARTSEITE_ANGEBOTE;
	
	/********************************************************************************
	 * CMS
	 ********************************************************************************/	
	if(file_exists(DATEIPFAD . 'includes/functions.mod.cms.inc.php')){
		$tpl_artikelarray = GetCMSArtikelDataArray(0, 0, 0, 0, 0, 30, "", "", "", "", "", "", 0, 1, "", "", 0, "", "", $_SESSION["languageid"],1);
	}	
		
		
	if($tpl_artikelarray){
		$tpl_startText = true;
	}	
	
	// ********************************************************************************
	// ** Startseitenangebot
	// ********************************************************************************

    $StartseitenangebotSearchField = "startseitenangebot";
	$StartseitenangebotSearchString = "1";
	$StartseitenangebotSortField = "artikel_nr";
	$StartseitenangebotSortOrder = "ASC";

	$StartseitenangebotDataArray = GetArtikelDataArray($StartseitenangebotSearchField, $StartseitenangebotSearchString, $StartseitenangebotSortField, $StartseitenangebotSortOrder, "", "", $_SESSION["mail"], "", "", "", "", "", 1, 1, "", "", "", "", "", $_SESSION["languageid"]);
	
	$StartseitenangebotIDArray = array();
	
	foreach ($StartseitenangebotDataArray as $Artikel) {
	    $StartseitenangebotIDArray[] = $Artikel['id'];
	}
	
	// ********************************************************************************
	// ** aktuelle Artikel
	// ********************************************************************************

	$AktuelleArtikelSearchField = "aktuellartikel";
	$AktuelleArtikelSearchString = "1";
	$AktuelleArtikelSortField = "timestamp";
	$AktuelleArtikelSortOrder = "DESC";
	$AktuelleArtikelDataOffset = 0;
	$AktuelleArtikelDataCount = $startAktuell;

	$AktuelleArtikelDataArray = GetArtikelDataArray($AktuelleArtikelSearchField, $AktuelleArtikelSearchString, $AktuelleArtikelSortField, $AktuelleArtikelSortOrder, $AktuelleArtikelDataOffset, $AktuelleArtikelDataCount, $_SESSION["mail"], "", "", "", "", "", 1, 1, "", "", "", "", "", $_SESSION["languageid"]);
	
	$AktuelleArtikelIDArray = array();
	
        foreach ($AktuelleArtikelDataArray as $Artikel) {
            $AktuelleArtikelIDArray[] = $Artikel['id'];
        }
        
        $SEOURLArray = GetSEOURLArray(array_merge($StartseitenangebotIDArray, $AktuelleArtikelIDArray), SEOURL_TYPE_ARTIKEL, $_SESSION["languageid"], $SEOURLArray);
	
	// Templateaufruf fuer die Startseite
    if($mobilestyle) {
        $contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/mobile/startseite.phtml";
    } else {
        $contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/website/startseite/index.tpl";
    }
	
// Letzte globale Zusammenfassung z.B. fuer Warenkorbanzeige, bevor das Template geladen wird.
include_once(DATEIPFAD . "includes/footer.inc.php");


// Template	
if($mobilestyle) {
    include_once(DATEIPFAD . "templates/" . $rowTemp->name . "/mobile/layout.phtml");
} else {
    include_once(DATEIPFAD . "templates/" . $rowTemp->name . "/website/index.tpl");
}

	
@mysql_close($db);
