forked from wolfgang-wiedermann/php_mobile_accounting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
55 lines (53 loc) · 1.92 KB
/
index.php
File metadata and controls
55 lines (53 loc) · 1.92 KB
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
<?php
/*
* Copyright (c) 2013 by Wolfgang Wiedermann
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 3 of the
* License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
if(!isset($_REQUEST['controller'])) {
# Nicht-Ajax-Zugriffe nach ./html/index.php weiterleiten
$hostname = $_SERVER['HTTP_HOST'];
$path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$url = "http://".$hostname.$path."/html/index.php";
header("Location: $url");
exit;
} else {
# Datenbank-Helper laden
require_once("./lib/Util.php");
require_once("./lib/Database.php");
require_once("./lib/QueryHandler.php");
# So umstellen das Errors als Exceptions geliefert werden
include_once("./lib/ErrorsToExceptions.php");
# Einstiegspunkt in das Framework
require_once("./lib/Dispatcher.php");
// für MOD-PHP unter Apache2
if(isset($_SERVER['REMOTE_USER'])) {
$disp = new Dispatcher();
$user = $_SERVER['REMOTE_USER'];
$disp->setRemoteUser($user);
echo $disp->invoke($_REQUEST);
}
// für PHP5-FPM mit nginx
else if(isset($_SERVER["PHP_AUTH_USER"])) {
$disp = new Dispatcher();
$user = $_SERVER["PHP_AUTH_USER"];
$disp->setRemoteUser($user);
echo $disp->invoke($_REQUEST);
} else {
throw new Exception("Fehler: Benutzer nicht über \$_SERVER['REMOTE_USER'] oder \$_SERVER['PHP_AUTH_USER'] ermittelbar");
}
}
?>