<?php
include("config/config.inc.php");
include("class/Template.class.php");
include("class/dB.class.php");
include("class/SysUtil.class.php");

session_start();

if ($_SESSION['auth'] != true)
{
	$_SESSION['authId'] = "false";
	header("Location: login.php");
	exit();
}
else
{
  if( isset($_GET["pageId"]) )
  {
    $pageId = $_GET["pageId"];
  }
  else
  {
    $pageId = 1; 
    
  }
}

//neue Instanz der Datenbank-Klasse
$mydbBaseSystem = new DB_MySQL($db_name,$db_user,$db_pass,$db_server);

//neue Instanz der Util-Klasse
$sysutil = new SYS_UTIL();

// Das Template laden
$tpl = new Template();
$tpl->load("main.tpl");

//Variablen ersetzten
$tpl->assign( "UserInformation",  $sysutil->GetUserInfobox($_SESSION['userId'],$mydbBaseSystem));
$tpl->assign( "MainMenue",  $sysutil->GetMainMenue($_SESSION['authId'], $pageId,$mydbBaseSystem));
if ($sysutil->AccessAllowed($_SESSION['authId'],$pageId,$mydbBaseSystem))
{
  $tpl->assign( "Content",  $sysutil->GetContent($pageId)); 
}
else
{
  $tpl->assign( "Content",  $sysutil->GetContent(0));
}

// Seite anzeigen
$tpl->display();

$mydbBaseSystem->disconnect();
?>
