-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.php
More file actions
40 lines (30 loc) · 1.11 KB
/
init.php
File metadata and controls
40 lines (30 loc) · 1.11 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
<?php
declare(strict_types=1);
require_once 'helpers.php';
require_once 'constants.php';
require_once 'vendor/autoload.php';
$is_session_started = session_start();
if (!$is_session_started) {
exit_with_message(
'Возникла техническая ошибка. Пожалуйста, попробуйте обновить страницу или зайти позже.',
500
);
}
if (!setlocale(LC_ALL, 'ru_RU.UTF-8')) {
exit_with_message('Не удалось установить локаль', 500);
}
if (!date_default_timezone_set('UTC')) {
exit_with_message('Не удалось установить часовой пояс', 500);
}
$config = require_once './config/autoload.php';
$conn = mysqli_connect(
$config['db']['host'] ?? 'localhost',
$config['db']['user'] ?? 'root',
$config['db']['password'] ?? 'pw',
$config['db']['name'] ?? 'database',
$config['db']['port'] ?? 3306,
);
if ($conn === false) {
exit_with_message('Ошибка подключения к базе данных. Пожалуйста, попробуйте позже.');
}
return $conn;