-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathConfig.php
More file actions
39 lines (32 loc) · 881 Bytes
/
Config.php
File metadata and controls
39 lines (32 loc) · 881 Bytes
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
<?php
declare(strict_types=1);
class Config
{
protected const string DB_NAME_DEFAULT = 'faved';
protected const string STORAGE_PATH = ROOT_DIR . '/storage';
protected const string IMAGE_STORAGE_DIR_NAME = 'img';
public static function getDBPath(): string
{
$db_name = $_SERVER['DB_NAME'] ?? self::DB_NAME_DEFAULT;
return sprintf('%s/%s.db', self::STORAGE_PATH, $db_name);
}
public static function getImageStoragePath(): string
{
return sprintf('%s/%s', self::STORAGE_PATH, self::IMAGE_STORAGE_DIR_NAME);
}
public static function getPasswordAlgo(): string
{
if (in_array(PASSWORD_ARGON2ID, password_algos())) {
return PASSWORD_ARGON2ID;
}
return PASSWORD_DEFAULT;
}
public static function getSessionLifetime(): int
{
return 60 * 60 * 24 * 7; // 7 days
}
public static function getSessionCookieName(): string
{
return 'faved-session';
}
}