-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
51 lines (41 loc) · 1.12 KB
/
init.php
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
<?php
session_start();
// подключаем файлы классов
foreach (glob(__DIR__ . "/classes/*.php") as $file) {
require_once $file;
}
$GLOBALS['config'] = [
'debug' => true,
'site' => [
//'host' => $_SERVER['HTTP_HOST'],
'baseurl' => 'http://' . $_SERVER['HTTP_HOST'] . '',
'name' => 'User Management',
],
'dbdriver' => 'sqlite', // <------------ указать драйвер БД!
'mysql' => [
'host' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'test',
],
'sqlite' => [
'database' => __DIR__ . '/users.sqlite3',
],
'session' => [
'token_name' => 'token',
'user_session' => 'user'
],
'cookie' => [
'cookie_name' => 'hash',
'cookie_expiry' => 604800
]
];
if (Cookie::exists(Config::get('cookie.cookie_name')) && !Session::exists(Config::get('session.user_session'))) {
$hash = Cookie::get(Config::get('cookie.cookie_name'));
$hashCheck = Database::getInstance()->get('user_sessions', ['hash', '=', $hash]);
if ($hashCheck->count()) {
$user = new User($hashCheck->first()->user_id);
$user->login();
Redirect::to();
}
}