<?php
date_default_timezone_set('Europe/Istanbul');
require_once dirname(__FILE__) . '/utils.php';
$localConfigPath = __DIR__ . '/config.local.php';
if (file_exists($localConfigPath)) {
require_once $localConfigPath;
}
$host = env_or_config('HIZMEN_DB_HOST', $host ?? null);
$dbname = env_or_config('HIZMEN_DB_NAME', $dbname ?? null);
$user = env_or_config('HIZMEN_DB_USER', $user ?? null);
$pass = env_or_config('HIZMEN_DB_PASS', $pass ?? null);
$charset = env_or_config('HIZMEN_DB_CHARSET', $charset ?? 'utf8mb4');
if (!$host || !$dbname || !$user || $pass === null) {
http_response_code(500);
die('Database configuration is missing.');
}
$dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $user, $pass, $options);
$db = $pdo;
ensure_auth_tokens_table($db);
require_once dirname(__FILE__) . '/core/notification_service.php';
$notifications = new NotificationService($db);
} catch (PDOException $e) {
http_response_code(500);
die('Database connection failed.');
}
Name Last modified Size Description