dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
index.php
Go to the documentation of this file.
1<?php
4 *
5 * @package dbXapp
6 * @author Armin Leonard Braun
7 * @copyright 2021-2026 dbXapp
8 * @version 5.0
9 * @par License
10 * GPL-2.0-or-later
11 * @par Systemvoraussetzung
12 * PHP 8.x
13 * @see https://dbxapp.de Offizielle dbXapp Website
14 */
15
16$__dbx_request_started_at = microtime(true);
17
18ob_start('ob_gzhandler');
19
20$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
21 || (int)($_SERVER['SERVER_PORT'] ?? 0) === 443;
22
23if (session_status() !== PHP_SESSION_ACTIVE) {
24 ini_set('session.use_strict_mode', '1');
25 ini_set('session.use_only_cookies', '1');
26 ini_set('session.use_trans_sid', '0');
27 $sessionScript = str_replace('\\', '/', (string)($_SERVER['SCRIPT_NAME'] ?? '/index.php'));
28 $sessionPath = rtrim(str_replace('\\', '/', dirname($sessionScript)), '/');
29 $sessionPath = ($sessionPath === '' || $sessionPath === '.') ? '/' : $sessionPath . '/';
30 if (preg_match('#^/[A-Za-z0-9._~!$&\'()*+,;=:@%/-]*/$#', $sessionPath) !== 1) {
31 $sessionPath = '/';
32 }
33 $sessionHost = strtolower((string)($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? 'localhost'));
34 $sessionHost = preg_replace('/:\d+$/', '', $sessionHost) ?: 'localhost';
35 session_name(
36 'DBXSESSID'
37 . strtoupper(substr(hash('sha256', $sessionHost . '|' . $sessionPath), 0, 12))
38 );
39 session_set_cookie_params(array(
40 'lifetime' => 0,
41 'path' => $sessionPath,
42 'domain' => '',
43 'secure' => $https,
44 'httponly' => true,
45 'samesite' => 'Lax',
46 ));
47 session_start();
48}
49
50if (!defined('dbxSystem')) {
51 define('dbxSystem', 'dbxWebApp');
52}
53if (!defined('dbxRunAsAdmin')) {
54 define('dbxRunAsAdmin', 0);
55}
56
61function dbx_get_base_dir($cutData = 0): string {
62 $path = str_replace('\\', '/', __DIR__) . '/';
63 if ($cutData && str_ends_with($path, '/Data/')) {
64 $path = substr($path, 0, -5);
65 }
66 return rtrim($path, '/') . '/';
67}
68
72function dbx_get_file_dir(): string {
73 return dbx_get_base_dir() . 'files/';
74}
75
76error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_NOTICE);
77date_default_timezone_set('Europe/Berlin');
78set_time_limit(600);
79ini_set('max_execution_time', '600');
80ini_set('display_errors', '0');
81ini_set('log_errors', '1');
82
84if (!is_dir($errorLogDir)) {
85 @mkdir($errorLogDir, 0775, true);
86}
87ini_set('error_log', $errorLogDir . DIRECTORY_SEPARATOR . 'dbxError.log');
88
89require dbx_get_base_dir() . 'dbx/vendor/autoload.php';
90require_once dbx_get_base_dir() . 'dbx/include/dbxKernel.php';
91
92ini_set('error_log', dbx()->error_log_file());
93
94set_error_handler(function ($errno, $errstr, $errfile, $errline) {
95 if (!(error_reporting() & $errno)) {
96 return false;
97 }
98
99 dbx()->write_php_error_log(
100 dbx()->error_type((int)$errno),
101 (string)$errstr,
102 (string)$errfile,
103 (int)$errline
104 );
105 return true;
106});
107
108set_exception_handler(function ($exception) {
109 dbx()->write_php_error_log(
110 get_class($exception),
111 $exception->getMessage(),
112 $exception->getFile(),
113 $exception->getLine()
114 );
115 if (!headers_sent()) {
116 http_response_code(500);
117 }
118});
119
120register_shutdown_function(function () {
121 $error = error_get_last();
122 if (!$error) {
123 return;
124 }
125
126 $fatalTypes = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_RECOVERABLE_ERROR);
127 if (!in_array($error['type'], $fatalTypes, true)) {
128 return;
129 }
130
131 dbx()->write_php_error_log(
132 dbx()->error_type((int)$error['type']),
133 (string)($error['message'] ?? ''),
134 (string)($error['file'] ?? ''),
135 (int)($error['line'] ?? 0)
136 );
137});
138
139if ((string)($_GET['dbx_modul'] ?? '') === 'dbxContent'
140 && (string)($_GET['dbx_run1'] ?? '') === 'media'
141 && (int)($_GET['dbx_mid'] ?? 0) > 0) {
142 dbx()->get_include_obj('dbxContentMediaResponse', 'dbxContent')->serve_request();
143}
144
145dbx()->run_web_app_request();
error_log_file()
Liefert die zentrale PHP-Fehlerprotokolldatei.
Definition dbxApi.php:1592
error_type(int $errno)
Uebersetzt eine PHP-Fehlernummer in ihre symbolische Bezeichnung.
Definition dbxApi.php:1599
$_SERVER['REQUEST_METHOD']
$__dbx_request_started_at
Definition index.php:16
if(session_status() !==PHP_SESSION_ACTIVE) if(!defined('dbxSystem')) if(!defined( 'dbxRunAsAdmin')) dbx_get_base_dir($cutData=0)
Bootstrap-Ausnahme: liefert den portablen Installationspfad, bevor dbxApi geladen werden kann.
Definition index.php:61
$https
Definition index.php:20
exit
Definition index.php:146
$errorLogDir
Definition index.php:83
dbx_get_file_dir()
Bootstrap-Ausnahme: liefert den portablen Dateipfad vor dem API-Start.
Definition index.php:72
DBX schema administration.