<?PHP
/*
  Guestbox 0.94 - (16. September 07)
  Michael Salzer
  http://www.flinkthink.ch
  It's free to use, but don't delete these lines.
*/

session_name("guestbox");
session_start();
header('P3P: CP="CAO PSA OUR"');

if (isset($_GET['admin_logout'])) {
  session_destroy();
  header("Location: ".$_SERVER['PHP_SELF']."?".str_replace("&admin_logout", "", $_SERVER['QUERY_STRING']));
}

if (isset($_POST['auth_password']) && isset($_POST['auth_username'])) {
  include_once "gb_config.php";
  include_once "gb_functions.php";
  if ((md5($_POST['auth_password']) == $admin_password) && ($_POST['auth_username'] == $adminname)) {
    $_SESSION['admin'] = $_POST['auth_username'];
    //Header("Location: ./?".str_replace("admin_login", "", $_SERVER['QUERY_STRING'])."");
  } else {
    //Header("Location: ".baseurl()."/guestbox.php");
    echo "<div class=\"hinweis\">
      <b>Sorry, falsches Passwort</b><br />Mögliche Fehler: <br />
      - Falsche Eingabe<br />-Passwort nicht verschlüsselt in der gb_config.php
      </div><br />";
  }
}

if (file_exists("gb_config.php")) {
  include_once "gb_config.php";
  include_once "gb_functions.php";
  if (!isset($_GET['command'])) {
    if (!isset($_GET['Anfangsposition'])) Header("Location: ".$_SERVER['PHP_SELF']."?Anfangsposition=0");
  }
  /* error level auf krass */
  //error_reporting (E_ALL);
  ?>
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html>
    <head>
      <title>Guestbox <?=$version;?></title>
      <link rel="stylesheet" href="<?=$style;?>" type="text/css" />
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta name=keywords content="Guestbox, Gästebuch, Guestbook, PHP, Script, Skript, Scripts, Michael, Salzer, www.flinkthink.ch, Salzer Design, Webdesign, Gratis, <?=$version;?>" />
      <meta name="generator" content="Michael Salzer www.flinkthink.ch" />
      <meta name="language" content="German, de, deutsch" />
      <script type="text/javascript" src="javascript.js"></script>
    </head>
    <body>
      <div id="all">
        <?PHP

        include_once "gbeingabe.php";
        if (isset($_GET['admin_login']) && !isset($_SESSION['admin'])) {
          include_once "admin_login.php";
        }
        include_once "seitenwechsel.php";
        include_once "gbshow.php";
        include_once "seitenwechsel.php";
?>
      </div>
    </body>
  </html>
  <?PHP
  } else {
    echo "Konfigurations-Datei fehlt.<br />
    Bitte zuerst <a href=\"setup.php\">Setup</a> ausführen. Viel Spass ;-)";
  }
?>