From 18e7dd5e4609b4496189102eef94f7af8de26ecb Mon Sep 17 00:00:00 2001
From: Conrad Zelck <git@simpel.cc>
Date: Thu, 5 Oct 2023 16:42:02 +0200
Subject: [PATCH] feat: make pandoc.php's debug mode switchable

Switch debug mode on with a file called "DEBUG".

Signed-off-by: Conrad Zelck <git@simpel.cc>
---
 pandoc.php | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/pandoc.php b/pandoc.php
index ed5b3cf..644be77 100644
--- a/pandoc.php
+++ b/pandoc.php
@@ -2,10 +2,18 @@
   if ('post' === strtolower($_SERVER['REQUEST_METHOD'])) {
     include 'localConfig.php';
 
+    // prepare for debug
+    $debug = false;
+    if (file_exists('DEBUG')) {
+      $debug = true;
+    }
+
     // DEBUG: output all set variables from $_POST
-    // var_dump($_POST);
-    // echo '==================================================
-    // ';
+    if ($debug) {
+      var_dump($_POST);
+      echo '==================================================
+      ';
+    }
 
     // give input file a name that shouldn't collide with other users
     $file = 'input/input' . microtime(true) . '.txt';
@@ -73,14 +81,18 @@
     $command .= ' ' . $file;
 
     // DEBUG: output error messages from cmd line
-    // $command .= '  2>&1';
+    if ($debug) {
+      $command .= '  2>&1';
+    }
 
     // DEBUG: output the whole command line
-    // echo $command;
-    // echo '
-    // ';
-    // echo '==================================================
-    // ';
+    if ($debug) {
+      echo $command;
+      echo '
+      ';
+      echo '==================================================
+      ';
+    }
 
     // put the path to pandoc temporarily to the servers path
     // configure the path in localConfig.php
-- 
GitLab