Переглянути джерело

autopublish config.ini on /config.ini

Miraty 1 рік тому
батько
коміт
2a3795bf93
2 змінених файлів з 7 додано та 0 видалено
  1. 1 0
      config.template.ini
  2. 6 0
      router.php

+ 1 - 0
config.template.ini

@@ -1,4 +1,5 @@
 ; Directives here are described in https://servnest.niv.re/back/configuration
 ; Directives here are described in https://servnest.niv.re/back/configuration
+; When named config.ini, this file is served over HTTP as /config.php
 
 
 [common]
 [common]
 public_domains[] = "servnest.test"
 public_domains[] = "servnest.test"

+ 6 - 0
router.php

@@ -11,6 +11,12 @@ define('PAGE_ADDRESS', $pageAddress . ((substr($pageAddress, -1) === '/' OR $pag
 define('PAGE_LINEAGE', explode('/', PAGE_ADDRESS));
 define('PAGE_LINEAGE', explode('/', PAGE_ADDRESS));
 define('SERVICE', dirname(PAGE_ADDRESS));
 define('SERVICE', dirname(PAGE_ADDRESS));
 
 
+if (PAGE_ADDRESS === 'config.ini') {
+	header('Content-Type: text/plain');
+	echo file_get_contents(ROOT_PATH . '/config.ini');
+	exit();
+}
+
 function pageNotFound(): never {
 function pageNotFound(): never {
 	http_response_code(404);
 	http_response_code(404);
 	exit(_('Page not found.'));
 	exit(_('Page not found.'));