diff options
Diffstat (limited to 'index.php')
| -rw-r--r-- | index.php | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/index.php b/index.php new file mode 100644 index 0000000..21cbda7 --- /dev/null +++ b/index.php @@ -0,0 +1,122 @@ +<?php + + +# if we kann redirect user with the ?goto variable +$redirect = true; + +require_once( dirname(__FILE__) . '/bootstrap.php'); +ob_start('minify'); +session_name(SESSION); +session_start(); + +$c = new cache(REDIS_CONNECT, REDIS_DB); + +if ( isset($_SESSION["loggedin"]) && $_SESSION["loggedin"]){ + $a = "1_"; +} else { + $a = "0_"; +} + +if ( $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 && strpos($_SERVER["QUERY_STRING"], "account") === false ) { + $token = $c->getToken($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]. $_SERVER["QUERY_STRING"], $a); + if ( $c->exists($token)){ + header("X-Cache: Hit"); + echo $c->getValue($token); + ob_end_flush(); + exit; + } +} else { + header("X-Cache: Miss "); +} + +$db = new db(); +if ( ! isset($_SESSION["username"])) + $u = null; +else + $u = $_SESSION["username"]; + +$user = new jg($u); +?> +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> + <?php + //<link rel ="stylesheet" href="/static/style.css"> + + echo "<style>" . file_get_contents('static/style.min.css');?> + .dl-horizontal dt{white-space: normal;} .btn-info{background-color:#3083D6;} .img-responsive{margin: 0 auto;} @-moz-document url-prefix() { fieldset { display: table-cell; } }</style> + <title>Junge Gemeinde Adlershof</title> + <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <noscript><style>.navbar{margin-bottom:0;}</style></noscript> +</head> +<?php +require_once 'static/header.php'; +?> +<div class="container"> + <div class="text-center"> + <div class="row"> +<?php + if( ! isset($_GET["page"])) + $_GET["page"] = ""; + + if($_GET["page"] == "" || $_GET["page"] == "index") + print_index(); + else{ + switch($_GET["page"]){ + case("login"): + print_login(); + break; + case("logout"): + print_logout(); + break; + case("liste"): + print_list(); + break; + case("register"): + print_register(); + break; + case("update"): + print_update_list($_GET['id']); + break; + case("add"): + print_add_entry_to_list(); + break; + case("account"): + print_account(); + break; + case("404"): + print_404(); + break; + case("action"): + require_once 'action.php'; + break; + case("recover"). + print_recover(); + break; + default: + print_index(); + break; + } + } + +/* +if ( isset($_GET['goto']) && $_GET['goto'] != "" && $redirect ){ + header($_SERVER['SERVER_PROTOCOL'] . ' 302 Moved'); + header('Location: /?page='.$_GET['goto']); +} +*/ +?> +</div> +</div> +<?php +require_once 'static/footer.php'; + +$html = ob_get_contents(); + +if ( $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 && strpos($_SERVER["QUERY_STRING"], "account") === false ) { + $c->setKey($token, $html, 3600); +} +ob_end_flush(); |
