Files
Nutrio/backend/config/Configuration.php
igor e59bfc26a0 generovane subory apilite,
fix globalnych $_SERVER v konfiguracii
2026-02-09 07:48:07 +01:00

32 lines
893 B
PHP

<?php
$others_config = scandir(__DIR__);
$loaded = false;
foreach ($others_config as $file) {
if ($file == basename(__FILE__)) continue;
if (substr($file, -4) == '.php') {
require_once __DIR__ . '/' . $file;
$loaded = true;
}
}
if (!$loaded) {
class Configuration
{
public const DB_TYPE = 'sqlite';
// MySQL
public const DB_HOST = 'localhost';
public const DB_USER = 'username';
public const DB_PASS = '****************';
public const DB_NAME = 'databasename';
// SQLite
public const DB_FILEPATH = __DIR__ . '/../../data/database.db';
}
}
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
$uri = $_SERVER['REQUEST_URI'] ?? ''; // obsahuje aj query string
define('URL_PREFIX', $protocol.$host.str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']));