-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.php
172 lines (165 loc) · 6.49 KB
/
index.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
declare(strict_types=1);
const DS = DIRECTORY_SEPARATOR;
const LIB = __DIR__ . DS . 'lib' . DS;
const INC = LIB . 'php' . DS;
const DBG = true;
spl_autoload_register(function (string $className): void {
$filePath = INC . str_replace(['\\', '_'], [DS, DS], strtolower($className)) . '.php';
if (DBG) { error_log("filePath=$filePath"); }
if (!is_file($filePath)) {
throw new \LogicException("Class $className not found");
}
require $filePath;
});
enum AclLevel: int
{
case SuperAdmin = 0;
case Admin = 1;
case User = 2;
case Suspended = 3;
case Anonymous = 9;
}
class Config
{
public function __construct(
public array $cfg = [],
public array $in = [],
public array $out = [],
public array $db = [],
public array $nav1 = [],
public array $nav2 = [],
public array $dns = [],
public array $acl = []
) {
$defaults = [
'cfg' => [
'email' => '',
'admpw' => '',
'file' => LIB . '.ht_conf.php',
'hash' => 'SHA512-CRYPT',
'host' => '',
'perp' => 25,
'self' => '/',
],
'in' => [
'a' => '',
'd' => '',
'g' => null,
'i' => null,
'l' => '',
'm' => 'list',
'o' => 'home',
'r' => 'local',
't' => 'bootstrap5',
'x' => '',
],
'out' => [
'doc' => 'NetServa',
'css' => '',
'log' => '',
'nav1' => '',
'nav2' => '',
'nav3' => '',
'head' => 'NetServa HCP',
'main' => 'Error: missing page!',
'foot' => 'Copyright (C) 2015-2024 Netserva HCP (AGPL-3.0)',
'js' => '',
'end' => '',
],
'db' => [
'host' => '127.0.0.1',
'name' => 'sysadm',
'pass' => LIB . DS . '.ht_pw',
'path' => '/var/lib/sqlite/sysadm/sysadm.db',
'port' => '3306',
'sock' => '',
'type' => 'mysql',
'user' => 'sysadm',
],
'nav1' => [
'non' => [
['Webmail', 'webmail/', 'bi bi-envelope-fill'],
['Phpmyadmin', 'phpmyadmin/', 'bi bi-globe'],
],
'usr' => [
['Webmail', 'webmail/', 'bi bi-envelope-fill'],
['Phpmyadmin', 'phpmyadmin/', 'bi bi-globe'],
],
'adm' => [
['Manage', [
['Accounts', '?o=accounts', 'bi bi-people-fill'],
['SSH Manager', '?o=sshm', 'bi bi-key'],
['Vhosts', '?o=vhosts', 'bi bi-globe2'],
['Mailboxes', '?o=vmails', 'bi bi-envelope-fill'],
['Aliases', '?o=valias', 'bi bi-envelope-paper-fill'],
['DKIM', '?o=dkim', 'bi bi-person-vcard-fill'],
['Domains', '?o=domains', 'bi bi-globe-americas'],
], 'bi bi-stack'],
['Stats', [
['Sys Info', '?o=infosys', 'bi bi-speedometer2'],
['Processes', '?o=processes', 'bi bi-bezier2'],
['Mail Info', '?o=infomail', 'bi bi-envelope-open'],
], 'bi bi-graph-up-arrow'],
['Links', [
['Webmail', 'webmail/', 'bi bi-envelope-fill'],
['Phpmyadmin', 'phpmyadmin/', 'bi bi-globe'],
], 'bi bi-list'],
['Sites', [
['local', '?r=local', 'bi bi-globe', 'r'],
['mgo', '?r=mgo', 'bi bi-globe', 'r'],
['vmd1', '?r=vmd1', 'bi bi-globe', 'r'],
], 'bi bi-globe'],
],
],
'nav2' => [
['local', '?r=local', 'bi bi-globe'],
['mgo', '?r=mgo', 'bi bi-globe'],
['vmd1', '?r=vmd1', 'bi bi-globe'],
],
'dns' => [
'a' => '127.0.0.1',
'mx' => '',
'ns1' => 'ns1.',
'ns2' => 'ns2.',
'prio' => 0,
'ttl' => 300,
'soa' => [
'primary' => 'ns1.',
'email' => 'admin.',
'refresh' => 7200,
'retry' => 540,
'expire' => 604800,
'ttl' => 3600,
],
'db' => [
'host' => '127.0.0.1',
'name' => 'pdns',
'pass' => 'lib' . DS . '.ht_dns_pw',
'path' => '/var/lib/sqlite/sysadm/pdns.db',
'port' => '3306',
'sock' => '',
'type' => 'sqlite',
'user' => 'sysadm',
],
],
'acl' => [
AclLevel::SuperAdmin->value => AclLevel::SuperAdmin->name,
AclLevel::Admin->value => AclLevel::Admin->name,
AclLevel::User->value => AclLevel::User->name,
AclLevel::Suspended->value => AclLevel::Suspended->name,
AclLevel::Anonymous->value => AclLevel::Anonymous->name,
],
];
$this->cfg = array_merge($defaults['cfg'], $cfg);
$this->in = array_merge($defaults['in'], $in);
$this->out = array_merge($defaults['out'], $out);
$this->db = array_merge($defaults['db'], $db);
$this->nav1 = array_merge($defaults['nav1'], $nav1);
$this->nav2 = array_merge($defaults['nav2'], $nav2);
$this->dns = array_merge($defaults['dns'], $dns);
$this->acl = array_merge($defaults['acl'], $acl);
}
}
$config = new Config();
echo new Init($config);