<?
//  Copyright (c) 2004-2006 randshop
//  http://www.randshop.com
//
//  Unter Lizenz von randshop
//	
//	Letzte Bearbeitung: 08.04.2006

	session_start();

	// SourceID = 1
	
	// Hauptkonfigurationsdatei
	include_once("../../config.inc.php");
	include_once(DATEIPFAD . "db.inc.php");
	include_once(DATEIPFAD . "includes/functions.global.inc.php");
	include_once(DATEIPFAD . "includes/functions.artikel.inc.php");
	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");

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

	// Header
	include(DATEIPFAD . "includes/header.inc.php");
	
	
	
	unset($_SESSION["kategorieid"]);
	
if($_GET["id"]) {
	// Newsdetailabfrage
	$abfrage = "SELECT * FROM " . TABLE_NEWS . " where id = '" . $_GET["id"] . "'";
	$ergebnis = mysql_query($abfrage);
	$row = mysql_fetch_object($ergebnis);
	
	$datum = $row->datum;
	list ($jahr, $monat, $tag, $stunde, $min, $sec) = split ('[-: ]', $datum);
	if($row->bigImage != "") {
		if(file_exists("images/dbimages/" . $row->bigImage))
		{
			$imageSize = getimagesize("images/dbimages/" . $row->bigImage);
			$newsImage = "<img src=\"images/dbimages/" . $row->bigImage . "\" width=\"" . $imageSize[0] . "\" height=\"" . $imageSize[1] . "\" border=\"0\" align=\"left\">\n";
		}
	}
	
	$tpl_newsHeadline = $row->headline;
	$tpl_newsBeitrag = nl2br(stripslashes($row->textEintrag));

	// Template
	$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/news/news_detail.tpl";
}
else {
	if($rowFeat->news =="1") 	{
		// Newsabfrage
		$abfrage = "SELECT * FROM " . TABLE_NEWS . " where aktiv = '1' order by datum desc limit 0,10";
		$ergebnis = mysql_query($abfrage);
		while($row = mysql_fetch_object($ergebnis))
		{
			$datum = $row->datum;
			list ($jahr, $monat, $tag, $stunde, $min, $sec) = split ('[-: ]', $datum);
			$newsDatum = $tag . "." . $monat . "." . $jahr;
			$newsHeadline = "<a href=\"" . URLPFAD . "themes/news/index.php?id=" . $row->id ."\">" . $row->headline . "</a>";
			
			$news_uebersicht[] = array('id'=>$row->id,
												'newsDatum'=>$newsDatum,
												'newsHeadline'=>$newsHeadline);
		}
	}

	// Templateaufruf fuer die Startseite
	$contentFile = DATEIPFAD . "templates/" . $rowTemp->name . "/news/uebersicht.tpl";

}
	
	
	
// Letzte globale Zusammenfassung z.B. fuer Warenkorbanzeige, bevor das Template geladen wird.
include(DATEIPFAD . "includes/footer.inc.php");


// Template	
include(DATEIPFAD . "templates/" . $rowTemp->name . "/index.tpl");

	
@mysql_close($db);
?>
