From ca2dbac2e1021ffa84fd80cfbf38fb0d355eb2d8 Mon Sep 17 00:00:00 2001 From: Philipp Mundhenk Date: Sat, 28 Oct 2023 21:43:05 +0200 Subject: [PATCH] implemented disabling of buttons, redirects, webserver switch --- files/api/scan.php | 9 ++------- files/gui/index.php | 18 ++++++++++++++---- files/runScanner.sh | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/files/api/scan.php b/files/api/scan.php index 7a14089..884cb1f 100644 --- a/files/api/scan.php +++ b/files/api/scan.php @@ -14,9 +14,7 @@ die("Error: No scanning function selected (try append: ?target=)"); } if (in_array($target, array('file','email','image','ocr'))) { - exec('sudo -u NAS /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.sh', $output, $retVal); - echo("retVal=".$retVal); - var_dump($output); + $output=shell_exec('sudo -u \#'.$_ENV[UID].' /opt/brother/scanner/brscan-skey/script/scanto'.$target.'.sh &'); } else { @@ -24,9 +22,6 @@ die("Error: Thou shalt not inject unknown script names!"); } -header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); -header("Cache-Control: public"); // needed for internet explorer -header("Content-Type: text/plain"); -die(); +echo(''); ?> \ No newline at end of file diff --git a/files/gui/index.php b/files/gui/index.php index 0e5f392..08e98d8 100644 --- a/files/gui/index.php +++ b/files/gui/index.php @@ -32,10 +32,20 @@
Brother Scanner
- - - - + '.$button_file.''); + } + if (array_key_exists('DISABLE_GUI_SCANTOEMAIL', $_ENV) && $_ENV["DISABLE_GUI_SCANTOEMAIL"]) { + echo(''); + } + if (array_key_exists('DISABLE_GUI_SCANTOIMAGE', $_ENV) && $_ENV["DISABLE_GUI_SCANTOIMAGE"]) { + echo(''); + } + if (array_key_exists('DISABLE_GUI_SCANTOOCR', $_ENV) && $_ENV["DISABLE_GUI_SCANTOOCR"]) { + echo(''); + } + ?>
diff --git a/files/runScanner.sh b/files/runScanner.sh index 0d377a0..7a01bdd 100755 --- a/files/runScanner.sh +++ b/files/runScanner.sh @@ -16,14 +16,16 @@ chmod -R 777 /opt/brother su - $USERNAME -c "/usr/bin/brsaneconfig4 -a name=$NAME model=$MODEL ip=$IPADDRESS" su - $USERNAME -c "/usr/bin/brscan-skey" -echo "starting webserver for API & GUI..." -if [[ -z ${PORT} ]]; then - PORT=80 -fi -echo "running on port $PORT" -sed -i "s/server.port\W*= 80/server.port = $PORT/" /etc/lighttpd/lighttpd.conf -/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -echo "webserver started" +if [ "$WEBSERVER" == "true" ] + echo "starting webserver for API & GUI..." + if [[ -z ${PORT} ]]; then + PORT=80 + fi + echo "running on port $PORT" + sed -i "s/server.port\W*= 80/server.port = $PORT/" /etc/lighttpd/lighttpd.conf + /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf + echo "webserver started" +} echo "capabilities:" scanimage -A