aboutsummaryrefslogtreecommitdiff
path: root/index.php
blob: 52bf1622d23002f72f2bd193be8df5ea5f3b4f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php

require_once( dirname(__FILE__) . '/bootstrap.php');
ob_start('minify');
session_name(SESSION);
session_start();

if ( ! isset($cache) )
	$cache = true;

$c = new cache(REDIS_CONNECT, REDIS_DB);

if ( isset($_SESSION["loggedin"]) && $_SESSION["loggedin"]){
	$a = "1_";
} else {
	$a = "0_";
}

if ( $cache && $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 ) {
	$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');
	echo "<style>" . file_get_contents('static/style.min.css');
	?>
	.dl-horizontal dt{white-space: normal;}.btn-info{background-color:#3083D6;border-color:#357ebd}.btn-primary{background-color:#3083D6;}.img-responsive{margin:0 auto;}@-moz-document url-prefix(){fieldset{display:table-cell;}}ul.nav li.dropdown:hover ul.dropdown-menu {display:block;}.video{max-width:720px;margin-right: auto;margin-left: auto;}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active{background-color:#3071a9}</style>
	<noscript><style>.navbar{margin-bottom:0;}</style></noscript>
	<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">
</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("download"):
				print_download();
				break;
			case("action"):
				require_once 'action.php';
				break;
			case("404"):
				print_404();
				break;
			case("recover"):
				print_recover();
				break;
			case("cache"):
				flush_cache();
				break;
			default:
				print_404();
				break;
		}
	}
?>
</div>
</div>
<?php
require_once 'static/footer.php';

$html = ob_get_contents();

if ( $cache && $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 ) {
	$c->setKey($token, $html, 3600);
}
ob_end_flush();