index.php 5.73 KB
Newer Older
cookie's avatar
cookie committed
1
<?php
Philip Häusler's avatar
Philip Häusler committed
2
require_once realpath(__DIR__ . '/../includes/engelsystem_provider.php');
Philip Häusler's avatar
Philip Häusler committed
3

Philip Häusler's avatar
Philip Häusler committed
4
$free_pages = array(
Philip Häusler's avatar
Philip Häusler committed
5
    'stats',
Philip Häusler's avatar
Philip Häusler committed
6
    'shifts_json_export_all',
Philip Häusler's avatar
Philip Häusler committed
7
    'user_password_recovery',
8
    'api',
Philip Häusler's avatar
Philip Häusler committed
9
    'credits',
Philip Häusler's avatar
Philip Häusler committed
10
    'angeltypes',
11 12
    'users',
    'ical',
13
    'shifts_json_export',
Philip Häusler's avatar
Philip Häusler committed
14
    'shifts',
jere123's avatar
jere123 committed
15 16
    'atom',
    'login'
Philip Häusler's avatar
Philip Häusler committed
17 18 19
);

// Gewünschte Seite/Funktion
20
$p = "";
21
if (! isset($_REQUEST['p']))
22
  $_REQUEST['p'] = isset($user) ? "news" : "login";
Philip Häusler's avatar
Philip Häusler committed
23
if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (in_array($_REQUEST['p'], $free_pages) || in_array($_REQUEST['p'], $privileges))) {
24
  $p = $_REQUEST['p'];
25
  
26 27
  $title = $p;
  $content = "";
28
  
Philip Häusler's avatar
Philip Häusler committed
29
  if ($p == "api") {
30
    require_once realpath(__DIR__ . '/../includes/controller/api.php');
Philip Häusler's avatar
Philip Häusler committed
31 32
    error("Api disabled temporily.");
    redirect(page_link_to('login'));
Philip Häusler's avatar
Philip Häusler committed
33
    api_controller();
Philip Häusler's avatar
Philip Häusler committed
34
  } elseif ($p == "ical") {
35
    require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
Philip Häusler's avatar
Philip Häusler committed
36 37
    user_ical();
  } elseif ($p == "atom") {
38
    require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
Philip Häusler's avatar
Philip Häusler committed
39 40
    user_atom();
  } elseif ($p == "shifts_json_export") {
41
    require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
Philip Häusler's avatar
Philip Häusler committed
42 43
    shifts_json_export_controller();
  } elseif ($p == "shifts_json_export_all") {
44
    require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
Philip Häusler's avatar
Philip Häusler committed
45 46
    shifts_json_export_all_controller();
  } elseif ($p == "stats") {
47
    require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
Philip Häusler's avatar
Philip Häusler committed
48 49
    guest_stats();
  } elseif ($p == "user_password_recovery") {
50
    require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
Philip Häusler's avatar
Philip Häusler committed
51 52
    $title = user_password_recovery_title();
    $content = user_password_recovery_controller();
53 54
  } elseif ($p == "angeltypes") {
    list($title, $content) = angeltypes_controller();
Philip Häusler's avatar
Philip Häusler committed
55 56
  } elseif ($p == "shifts") {
    list($title, $content) = shifts_controller();
Philip Häusler's avatar
Philip Häusler committed
57 58
  } elseif ($p == "users") {
    list($title, $content) = users_controller();
59 60
  } elseif ($p == "user_angeltypes") {
    list($title, $content) = user_angeltypes_controller();
Philip Häusler's avatar
Philip Häusler committed
61 62
  } elseif ($p == "shifttypes") {
    list($title, $content) = shifttypes_controller();
Philip Häusler's avatar
Philip Häusler committed
63
  } elseif ($p == "news") {
Philip Häusler's avatar
Philip Häusler committed
64
    $title = news_title();
65
    $content = user_news();
Philip Häusler's avatar
Philip Häusler committed
66
  } elseif ($p == "news_comments") {
67
    require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
68
    $title = user_news_comments_title();
69
    $content = user_news_comments();
Philip Häusler's avatar
Philip Häusler committed
70
  } elseif ($p == "user_meetings") {
Philip Häusler's avatar
Philip Häusler committed
71
    $title = meetings_title();
72
    $content = user_meetings();
Philip Häusler's avatar
Philip Häusler committed
73
  } elseif ($p == "user_myshifts") {
Philip Häusler's avatar
Philip Häusler committed
74
    $title = myshifts_title();
75
    $content = user_myshifts();
Philip Häusler's avatar
Philip Häusler committed
76
  } elseif ($p == "user_shifts") {
Philip Häusler's avatar
Philip Häusler committed
77
    $title = shifts_title();
78
    $content = user_shifts();
Philip Häusler's avatar
Philip Häusler committed
79
  } elseif ($p == "user_messages") {
Philip Häusler's avatar
Philip Häusler committed
80
    $title = messages_title();
81
    $content = user_messages();
Philip Häusler's avatar
Philip Häusler committed
82
  } elseif ($p == "user_questions") {
Philip Häusler's avatar
Philip Häusler committed
83
    $title = questions_title();
84
    $content = user_questions();
Philip Häusler's avatar
Philip Häusler committed
85
  } elseif ($p == "user_settings") {
86
    $title = settings_title();
87
    $content = user_settings();
Philip Häusler's avatar
Philip Häusler committed
88
  } elseif ($p == "login") {
89
    $title = login_title();
90
    $content = guest_login();
Philip Häusler's avatar
Philip Häusler committed
91
  } elseif ($p == "register") {
92
    $title = register_title();
93
    $content = guest_register();
Philip Häusler's avatar
Philip Häusler committed
94
  } elseif ($p == "logout") {
95
    $title = logout_title();
96
    $content = guest_logout();
Philip Häusler's avatar
Philip Häusler committed
97
  } elseif ($p == "admin_questions") {
Philip Häusler's avatar
Philip Häusler committed
98
    $title = admin_questions_title();
99
    $content = admin_questions();
Philip Häusler's avatar
Philip Häusler committed
100
  } elseif ($p == "admin_user") {
Philip Häusler's avatar
Philip Häusler committed
101
    $title = admin_user_title();
102
    $content = admin_user();
Philip Häusler's avatar
Philip Häusler committed
103
  } elseif ($p == "admin_arrive") {
Philip Häusler's avatar
Philip Häusler committed
104
    $title = admin_arrive_title();
105
    $content = admin_arrive();
Philip Häusler's avatar
Philip Häusler committed
106
  } elseif ($p == "admin_active") {
Philip Häusler's avatar
Philip Häusler committed
107
    $title = admin_active_title();
108
    $content = admin_active();
Philip Häusler's avatar
Philip Häusler committed
109
  } elseif ($p == "admin_free") {
Philip Häusler's avatar
Philip Häusler committed
110
    $title = admin_free_title();
111
    $content = admin_free();
Philip Häusler's avatar
Philip Häusler committed
112
  } elseif ($p == "admin_news") {
113
    require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
114
    $content = admin_news();
Philip Häusler's avatar
Philip Häusler committed
115
  } elseif ($p == "admin_rooms") {
Philip Häusler's avatar
Philip Häusler committed
116
    $title = admin_rooms_title();
117
    $content = admin_rooms();
Philip Häusler's avatar
Philip Häusler committed
118
  } elseif ($p == "admin_groups") {
Philip Häusler's avatar
Philip Häusler committed
119
    $title = admin_groups_title();
120
    $content = admin_groups();
Philip Häusler's avatar
Philip Häusler committed
121
  } elseif ($p == "admin_language") {
122
    require_once realpath(__DIR__ . '/../includes/pages/admin_language.php');
123
    $content = admin_language();
Philip Häusler's avatar
Philip Häusler committed
124
  } elseif ($p == "admin_import") {
Philip Häusler's avatar
Philip Häusler committed
125
    $title = admin_import_title();
126
    $content = admin_import();
Philip Häusler's avatar
Philip Häusler committed
127
  } elseif ($p == "admin_shifts") {
Philip Häusler's avatar
Philip Häusler committed
128
    $title = admin_shifts_title();
129
    $content = admin_shifts();
Philip Häusler's avatar
Philip Häusler committed
130
  } elseif ($p == "admin_log") {
Philip Häusler's avatar
Philip Häusler committed
131
    $title = admin_log_title();
132
    $content = admin_log();
Philip Häusler's avatar
Philip Häusler committed
133
  } elseif ($p == "credits") {
134
    require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
Philip Häusler's avatar
Philip Häusler committed
135 136
    $title = credits_title();
    $content = guest_credits();
137
  } else {
138
    require_once realpath(__DIR__ . '/../includes/pages/guest_start.php');
139 140
    $content = guest_start();
  }
Philip Häusler's avatar
Philip Häusler committed
141
} else {
142
  // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
Philip Häusler's avatar
Philip Häusler committed
143
  if (isset($user)) {
Philip Häusler's avatar
Philip Häusler committed
144 145
    $title = _("No Access");
    $content = _("You don't have permission to view this page. You probably have to sign in or register in order to gain access!");
146 147 148 149
  } else {
    // Sonst zur Loginseite leiten
    redirect(page_link_to("login"));
  }
Philip Häusler's avatar
Philip Häusler committed
150 151
}

152
echo template_render('../templates/layout.html', array(
Philip Häusler's avatar
Philip Häusler committed
153 154 155 156
    'theme' => isset($user) ? $user['color'] : $default_theme,
    'title' => $title,
    'atom_link' => ($p == 'news' || $p == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($p == 'user_meetings') ? '&amp;meetings=1' : '') . '&amp;key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
    'menu' => make_menu(),
157
    'content' => msg() . $content,
Philip Häusler's avatar
Philip Häusler committed
158
    'header_toolbar' => header_toolbar(),
Philip Häusler's avatar
Philip Häusler committed
159
    'faq_url' => $faq_url,
root's avatar
root committed
160
    'sitetitle' => $sitetitle,
Philip Häusler's avatar
Philip Häusler committed
161
    'locale' => locale() 
Philip Häusler's avatar
Philip Häusler committed
162
));
Philip Häusler's avatar
Philip Häusler committed
163

cookie's avatar
cookie committed
164
?>