From 095136c5df5921cd64891a007cfdebf41f06d8a9 Mon Sep 17 00:00:00 2001 From: Nils Date: Sun, 10 Dec 2023 19:42:23 +0100 Subject: [PATCH] Repair protocol php script and guard against the next php update fail --- protokolle.php | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/protokolle.php b/protokolle.php index b0b11cf..319ffe2 100644 --- a/protokolle.php +++ b/protokolle.php @@ -6,22 +6,34 @@
 
 " . $path_parts['filename'] . "";
-  echo "\n";
-  echo $urlHighlight->highlightUrls(file_get_contents($file));
-  echo "\n";
+// Check if autoload.php file exists
+if (!file_exists($autoloadPath)) {
+    echo "

PHP Configuration changed. The autoload.php file is missing. Please run composer install or composer require vstelmakh/url-highlight. Please inform the osamc.de staff about this problem.

"; +} else { + require $autoloadPath; + // Check if UrlHighlight class exists + if (!class_exists(\VStelmakh\UrlHighlight\UrlHighlight::class)) { + echo "

PHP Configuration changed. Run composer require vstelmakh/url-highlight. Please inform the osamc.de staff about this problem.

"; + } else { + // Your existing code goes here + use VStelmakh\UrlHighlight\UrlHighlight; + $urlHighlight = new UrlHighlight(); + $files = glob("./protokolle/osamc_*.txt"); + foreach(array_reverse($files) as $file){ + $path_parts = pathinfo($file); + echo "

" . $path_parts['filename'] . "

"; + echo "\n"; + echo $urlHighlight->highlightUrls(file_get_contents($file)); + echo "\n"; + } + // Remove fclose($out); as $out is not defined + } } -fclose($out); + ?>