Autoconfigure root_path using __DIR__
This commit is contained in:
parent
887ddd2474
commit
d41ac85b55
|
@ -4,10 +4,6 @@ This document describes the `config.ini` directives. It's an INI file, parsed by
|
||||||
|
|
||||||
## `[common]`
|
## `[common]`
|
||||||
|
|
||||||
### `root-path`
|
|
||||||
|
|
||||||
Filesystem path to the directory where the root of the program is installed.
|
|
||||||
|
|
||||||
### `public_domains[]`
|
### `public_domains[]`
|
||||||
|
|
||||||
Allowed server names. Used to make the authentication tokens specific to the service.
|
Allowed server names. Used to make the authentication tokens specific to the service.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
; Directives here are described in DOCS/configuration.md
|
; Directives here are described in DOCS/configuration.md
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
root_path = "/srv/servnest/core"
|
|
||||||
public_domains[] = "servnest.test"
|
public_domains[] = "servnest.test"
|
||||||
prefix = ""
|
prefix = ""
|
||||||
service_name = "ServNest"
|
service_name = "ServNest"
|
||||||
|
|
|
@ -20,7 +20,7 @@ $domain = formatAbsoluteDomain($_POST['subdomain'] . '.' . $_POST['suffix']);
|
||||||
if (query('select', 'registry', ['domain' => $domain], 'domain') !== [])
|
if (query('select', 'registry', ['domain' => $domain], 'domain') !== [])
|
||||||
output(403, _('This domain is already registered.'));
|
output(403, _('This domain is already registered.'));
|
||||||
|
|
||||||
if (in_array($_POST['subdomain'], explode(LF, file_get_contents(CONF['common']['root_path'] . '/pg-act/reg/reserved.txt'))))
|
if (in_array($_POST['subdomain'], explode(LF, file_get_contents(ROOT_PATH . '/pg-act/reg/reserved.txt'))))
|
||||||
output(403, _('This domain is reserved.'));
|
output(403, _('This domain is reserved.'));
|
||||||
|
|
||||||
rateLimit();
|
rateLimit();
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
define('CONF', parse_ini_file(__DIR__ . '/config.ini', true, INI_SCANNER_TYPED));
|
const ROOT_PATH = __DIR__;
|
||||||
|
define('CONF', parse_ini_file(ROOT_PATH . '/config.ini', true, INI_SCANNER_TYPED));
|
||||||
|
|
||||||
define('DB', new PDO('sqlite:' . CONF['common']['root_path'] . '/db/servnest.db'));
|
define('DB', new PDO('sqlite:' . ROOT_PATH . '/db/servnest.db'));
|
||||||
|
|
||||||
$locale = 'en';
|
$locale = 'en';
|
||||||
foreach (explode(',', preg_replace('/[A-Z0-9]|q=|;|-|\./', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '')) as $client_locale) {
|
foreach (explode(',', preg_replace('/[A-Z0-9]|q=|;|-|\./', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '')) as $client_locale) {
|
||||||
|
@ -23,8 +24,8 @@ const PLACEHOLDER_DOMAIN = 'example'; // From RFC2606: Reserved Top Level DNS Na
|
||||||
const PLACEHOLDER_IPV6 = '2001:db8::3'; // From RFC3849: IPv6 Address Prefix Reserved for Documentation
|
const PLACEHOLDER_IPV6 = '2001:db8::3'; // From RFC3849: IPv6 Address Prefix Reserved for Documentation
|
||||||
const PLACEHOLDER_IPV4 = '203.0.113.42'; // From RFC5737: IPv4 Address Blocks Reserved for Documentation
|
const PLACEHOLDER_IPV4 = '203.0.113.42'; // From RFC5737: IPv4 Address Blocks Reserved for Documentation
|
||||||
|
|
||||||
foreach (array_diff(scandir(CONF['common']['root_path'] . '/fn'), ['..', '.']) as $file)
|
foreach (array_diff(scandir(ROOT_PATH . '/fn'), ['..', '.']) as $file)
|
||||||
require CONF['common']['root_path'] . '/fn/' . $file;
|
require ROOT_PATH . '/fn/' . $file;
|
||||||
|
|
||||||
require 'pages.php';
|
require 'pages.php';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue