]> mop.ddnsfree.com - git repositories - brisk.git/commitdiff
error.php and doc_download.php: $DOCUMENT_ROOT was never set
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:33:39 +0000 (12:33 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:33:39 +0000 (12:33 +0200)
Both scripts include Obj/brisk.phh, which on line 94 does

    require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF);

but neither of them set $DOCUMENT_ROOT. The path collapsed to
"/Etc/brisk_spu.conf.pho", the require failed and the page answered 500.

This is not a consequence of the port: the git history shows that
doc_download.php never had that line in two commits, and error.php does not
mention it at all. INSTALL.sh substitutes $DOCUMENT_ROOT only in spush/*.ph*
and donometer.php (line 445), not in these two.

NOTE: in the working copy doc_download.php carried a local fix that was never
committed, with the path written by hand
($DOCUMENT_ROOT="/home/nastasi/web"). Since INSTALL.sh distributes from the
working copy and not from git, that is probably what runs in production: a
fix that existed on one disk only and would have disappeared at the first
clone onto a new machine. This commit replaces it with the portable form.

Used the scheme already present in usermgmt.php, mailmgr.php,
briskin5/statadm.php and the others, which derive the value from $_SERVER: it
works both with mod_php and with php-fpm and does not depend on a hardcoded
path. $G_base = "" was added to doc_download.php too, which brisk.phh:95 needs
and which was missing.

Found by handing the pages not given to the daemon over to php-fpm, which
under apache were served by mod_php: both answered 500. After the fix: 200.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014M1jiEq9cHdE5SE5j6vFuE

web/doc_download.php
web/error.php

index 9e86ef18479e76ad0e59a8c784b51034eeb72ad5..81fff9959e9a531dc68c465d16d53b13aa9632d8 100644 (file)
@@ -1,4 +1,16 @@
 <?php
+$G_base = "";
+
+/* Obj/brisk.phh needs $DOCUMENT_ROOT to find the configuration file under
+   Etc/. With mod_php it was not filled in by itself and this script failed;
+   it is taken from $_SERVER, as usermgmt.php, mailmgr.php and the others
+   already do. */
+foreach (array("HTTP_HOST", "DOCUMENT_ROOT") as $i) {
+    if (isset($_SERVER[$i])) {
+        $$i = $_SERVER[$i];
+        }
+    }
+
 require_once("Obj/brisk.phh");
 
 function main()
index b106d0a2be86a6789eb07af20f87b234a4491b7d..db2dff1ad5ee4b53f506045d2cd8a02a04f44db0 100644 (file)
 
 $G_base = "";
 
+/* Obj/brisk.phh needs $DOCUMENT_ROOT to find the configuration file under
+   Etc/. With mod_php it was not filled in by itself and this script failed;
+   it is taken from $_SERVER, as usermgmt.php, mailmgr.php and the others
+   already do. */
+foreach (array("HTTP_HOST", "DOCUMENT_ROOT") as $i) {
+    if (isset($_SERVER[$i])) {
+        $$i = $_SERVER[$i];
+        }
+    }
+
 require_once("Obj/brisk.phh");
 require_once("Obj/user.phh");
 require_once("Obj/auth.phh");