-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.inc.php
executable file
·87 lines (73 loc) · 2.36 KB
/
env.inc.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
// Prevent direct access to this file
defined('SECURE_ACCESS') or die('Direct access to this file is not allowed');
class EnvironmentChecker {
private $messages = [];
private $errors = [];
private $configWritable = false;
public function checkPHPVersion() {
if (version_compare(PHP_VERSION, '7.4.0', '>=')) {
$this->messages[] = "✓ " . __('php_version_ok', PHP_VERSION);
} else {
$this->errors[] = "✗ " . __('php_version_error', PHP_VERSION);
}
return $this;
}
public function checkPDOExtension() {
if (extension_loaded('pdo_mysql')) {
$this->messages[] = "✓ " . __('pdo_ok');
} else {
$this->errors[] = "✗ " . __('pdo_error');
}
return $this;
}
public function checkOpenSSLExtension() {
if (extension_loaded('openssl')) {
$this->messages[] = "✓ " . __('openssl_ok');
} else {
$this->errors[] = "✗ " . __('openssl_error');
}
return $this;
}
public function checkKeysDirectory() {
$keysDir = __DIR__ . '/keys';
if (!file_exists($keysDir)) {
if (mkdir($keysDir, 0755, true)) {
$this->messages[] = "✓ " . __('keys_dir_created');
} else {
$this->errors[] = "✗ " . __('keys_dir_error');
return $this;
}
}
if (is_writable($keysDir)) {
$this->messages[] = "✓ " . __('keys_dir_writable');
} else {
$this->errors[] = "✗ " . __('keys_dir_not_writable');
}
return $this;
}
public function checkConfigWritable() {
$configFile = 'config.inc.php';
if (file_exists($configFile)) {
$this->configWritable = is_writable($configFile);
} else {
$this->configWritable = is_writable(dirname($configFile));
}
if (!$this->configWritable) {
$this->errors[] = "✗ " . __('config_not_writable');
}
return $this;
}
public function isConfigWritable() {
return $this->configWritable;
}
public function getMessages() {
return $this->messages;
}
public function getErrors() {
return $this->errors;
}
public function hasErrors() {
return !empty($this->errors);
}
}