<?php
ini_set("display_errors",true);
error_reporting(E_ALL);
session_start();
if(isset($_GET['logoff']) and $_GET['logoff'] == 1 ) { session_destroy(); session_start();}
$_SESSION['debug'] = false;
  include("init.php");
  // require_once("eaclass.php");
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>SNKO-Logbuch</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link  href="LB_style.css" type="text/css" rel="stylesheet">
  </head>
  <body>
    <h2>SNKO-Logbuch</h2>
    <?php
    if(isset($_GET['LID'])) {
      $LID = $_GET['LID'];
      $_SESSION['prefix'] = $USER->test_id($LID);
    }

    if(isset($_POST['passw']) && isset($_POST['usern'])) {
      $_SESSION['prefix'] = $USER->check_login($_POST['usern'],$_POST['passw']);
    }

    if (isset($prefix)) {
      $prefix = $USER->test_id();

    }

    if (!isset($_SESSION['user_logged_in']) || $_SESSION['user_logged_in'] == false) {
      $USER->user_login();
    }
    if (isset($_SESSION['user_logged_in']) && $_SESSION['user_logged_in'] == "config") {
      $USER->user_config();
    }
    if (isset($_SESSION['prefix']) ) {
      $LB = new LB("Database",".php",$_SESSION['prefix']);

   ?>
    <div id="menu">
      <?php
            echo $_SESSION['user']; ?>
          | <a href="index.php?cont=eingabe">Neu</a> |
          <a href="index.php?cont=liste">Liste</a> |
          <!-- <a href="index.php?cont=summen">Summen</a> | -->
          <a href="index.php?logoff=1">Exit</a>
          <!-- <a href="index.php?cont=config">Konfig</a> | -->
          <!-- <a href="index.php?cont=admin_update">Update</a> | <br/> -->
    </div>
    <!-- <a href="index.php?cont="></a> | <br/> -->
    <br />
    <br />
    <div id="inhalt">
    <?php
    if(isset($_GET['cont'])) {
      switch ($_GET['cont']) {
        case 'eingabe':
          $LB->eingabe();
          break;
        case 'liste':
          $LB->liste($_GET,$_POST);
          break;
        case 'aendern':
          $LB->aendern($_GET);
          break;
        case 'schreiben':
          $LB->schreiben($_POST);
          break;
        case 'updaten':
          $LB->updaten($_POST);
          break;
        // case "admin_update":
    		// 	if (isset($_GET['version'])) {$v = $_GET['version']; } else { $v = "";}
    		// 	$ADMIN->update($v);
  			//   break;
        // case "bereich":
    		// 	$ADMIN->admin_bereich_form($konfig['tbl_config'],$spalten['config']);
    		// 	break;
        //
        // case "kor_eintrag":
    		// 	$ADMIN->kor_eintrag();
    		// 	break;

        default:
          # code...
          break;
      }

    }
    // echo "<hr />\n";
    ?>
  </div>
  <?php
  }
  ?>
  </body>
</html>
<?php
// $EA->liste();
 ?>
