<?
/*----------------------------------------------------------------------------*/
/*-- Program   :     Schulkiosk                                               */
/*-- Author    :     Markus@Kaatze.de                                         */
/*-- Created on:     25 Januar 02                                             */ /*----------------------------------------------------------------------------*/
/*-- Benötigte Ubergabeparameter                                              */
/*-- $menue          --> Aktueller Menuepunkt                                 */
/*-- $session_id     --> Session-id des Benutzers                             */
/*-- -->*/
/*-- -->*/
/*----------------------------------------------------------------------------*/
?>
<html>
  <head>
      <title>Schulkiosk</title>
      <meta name="author" content="Markus Kaatze">
      <link rel="stylesheet" href="css/styles.css" type="text/css">
  </head>
  <body>
<?

/*-----Variablendeklaration---------------------------------------------------*/
$user_id=0;
$menue=$_GET['menue'];
if (!$menue)$menue=$_POST['menue'];
$todo=$_GET['todo'];
$session_id=$_GET['session_id'];
if (!$session_id)$session_id=$_POST['session_id'];

/*-----Einbindung der Include-Dateien-----------------------------------------*/
  include("html/tools/security_functions.php");
  include("html/tools/my_data.php");
  include("html/tools/sql_func.php");
  include("html/tools/debug.php");
  //show_vars();

/*-----Erzeugung der Session_id nach login------------------------------------*/
if ($_POST['todo']=='login')
{
  $kasse=$_POST['kasse'];
  $kasse_bestand_eingang=$_POST['kasse_bestand_eingang'];
  $user_id=check_login ($_POST['user_name'],$_POST['user_passwort']);
  if ($user_id !=0)
    {
      if ($kasse)
      {
        $kasse_id=check_kasse($kasse,$user_id,$kasse_bestand_eingang);
        if ($kasse_id)
          $session_id=create_Session_ID($user_id,$kasse_id);
        else
          $message="<div align='center'>Kasse schon vorhanden.<br><br></div>";
      }
      else
        $message="<div align='center'>Keine Kasse angegeben.<br><br></div>";
    }
  else
    $message="<div align='center'>Falscher Benutzername oder Passwort.<br><br></div>";
}

/*-----Überprüfung der Session_id---------------------------------------------*/
$res=check_Session_ID($session_id);
if ($res)
{
  $user_id      = $res["user_id"];
  $name         = $res["name"];
  $vorname      = $res["vorname"];
  $status       = $res["status"];
  $kasse_id     = $res['kasse_id'];
  $kasse        = $res['kasse'];
}

/*-----Erzeugung des Formurals-----------------------------------------------*/
echo "<form action=\"$PHP_SELF\" method=\"post\" enctype=\"multipart/form-data\" name=\"form\">";

/*-----Erzeugung der Titelleiste---------------------------------------------*/
include("html/navigation/titel.php");

/*-----Inhalt des Content-Bereichs------------------------------------------*/
if (!$res)
{
  include("html/navigation/menuekante.php");
  echo $message;
  include("html/navigation/login.php");
}
else
{
  if (($menue=='logout') && ($todo=$_POST['todo']=='logout'))
  {
    include("html/navigation/menuekante.php");
    include("html/inhalt/$menue/index1.php");
  }
  else
  {
    echo "<input type=\"hidden\" name=\"menue\" value=\"$menue\">";
    echo "<input type=\"hidden\" name=\"session_id\"  value=\"$session_id\">";
    include("html/navigation/hauptmenue.php");
    include("html/navigation/untermenue.php");
    include("html/navigation/menuekante.php");
    if ($menue)
      include("html/inhalt/$menue/index1.php");
    else
      include("html/inhalt/willkommen/index1.php");
  }
}
?>
   </form>
 </body>
</html>