]> mop.ddnsfree.com - git repositories - brisk.git/commitdiff
custom.js is optional, and the page no longer demands it
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:37:13 +0000 (12:37 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:37:13 +0000 (12:37 +0200)
index.php always loaded it, but custom.js holds the customisations of the
single site and may not be distributed: whoever installs from scratch got a
404 on every page load, on both branches of the layout.

The tag is now emitted only if the file is really there. The hook it uses
(custom_bedge) was already guarded on the javascript side, so without the
file the room behaves exactly as it always has.

Same approach as cookie_law.* and brisk_donate.txt: what belongs to a single
installation must not break the others.

Checked in the container: with the file the page references it and downloads
it (200), without the file the page is served complete, does not name it and
nginx logs no 404. Both occurrences were tried, the one on the entry page and
the one in the room.

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

web/index.php

index b87af3794b157720c630fdffd865c86f46efef87..40a72040e4c598c0beb647e9e9d4e6f15d3daa0a 100644 (file)
@@ -359,6 +359,15 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f
     GLOBAL $G_with_poll;
     GLOBAL $G_lang, $G_lng, $mlang_room;
     GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER, $_COOKIE;
+    GLOBAL $G_base;
+
+    /* custom.js is optional: it holds the customisations of the single site
+       and may not be distributed. The hook it uses (custom_bedge) is already
+       guarded in room.js, but without this check the browser would ask for a
+       file that does not exist on every page. */
+    $custom_js = (file_exists($G_base."custom.js") ?
+                  sprintf('<script type="text/javascript" src="custom.js?v=%s"></script>',
+                          BSK_BUSTING) : "");
 
     $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) &&
                      $header["X-Forwarded-Proto"] == "https") ? 443 : 80);
@@ -1044,7 +1053,7 @@ supported by:<br>
 <script type="text/javascript" src="heartbit.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="xynt-streaming.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js?v=<?php echo BSK_BUSTING; ?>"></script>
-<script type="text/javascript" src="custom.js?v=<?php echo BSK_BUSTING; ?>"></script>
+<?php echo $custom_js; ?>
 <script type="text/javascript" src="room.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="md5.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="probrowser.js?v=<?php echo BSK_BUSTING; ?>"></script>
@@ -1218,7 +1227,7 @@ cookie_law(null);
 <script type="text/javascript" src="ticker.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="heartbit.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="xynt-streaming.js?v=<?php echo BSK_BUSTING; ?>"></script>
-<script type="text/javascript" src="custom.js?v=<?php echo BSK_BUSTING; ?>"></script>
+<?php echo $custom_js; ?>
 <script type="text/javascript" src="room.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js?v=<?php echo BSK_BUSTING; ?>"></script>
 <script type="text/javascript" src="probrowser.js?v=<?php echo BSK_BUSTING; ?>"></script>