Skip to content

Commit

Permalink
implemented disabling of buttons, redirects, webserver switch
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMundhenk committed Oct 28, 2023
1 parent 352156a commit ca2dbac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
9 changes: 2 additions & 7 deletions files/api/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@
die("Error: No scanning function selected (try append: ?target=<file|email|image|ocr>)");
}
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
{
header($_SERVER["SERVER_PROTOCOL"] . " 400 OK");
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('<html><head><meta http-equiv="Refresh" content="0; url=/" /></head></html>');

?>
18 changes: 14 additions & 4 deletions files/gui/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,20 @@
<div class="title">Brother Scanner</div>
<div class="cut cut-long"></div>
<form action="/scan.php" method="get">
<button type="submit" name="target" value="file" class="submit"><?php $button_file ?></button>
<button type="submit" name="target" value="email" class="submit"><?php $button_email ?></button>
<button type="submit" name="target" value="image" class="submit"><?php $button_image ?></button>
<button type="submit" name="target" value="ocr" class="submit"><?php $button_ocr ?></button>
<?php
if (array_key_exists('DISABLE_GUI_SCANTOIMAGE', $_ENV) && $_ENV["DISABLE_GUI_SCANTOOCR"]) {
echo('<button type="submit" name="target" value="file" class="submit">'.$button_file.'</button>');
}
if (array_key_exists('DISABLE_GUI_SCANTOEMAIL', $_ENV) && $_ENV["DISABLE_GUI_SCANTOEMAIL"]) {
echo('<button type="submit" name="target" value="email" class="submit">'.$button_email.'</button>');
}
if (array_key_exists('DISABLE_GUI_SCANTOIMAGE', $_ENV) && $_ENV["DISABLE_GUI_SCANTOIMAGE"]) {
echo('<button type="submit" name="target" value="image" class="submit">'.$button_image.'</button>');
}
if (array_key_exists('DISABLE_GUI_SCANTOOCR', $_ENV) && $_ENV["DISABLE_GUI_SCANTOOCR"]) {
echo('<button type="submit" name="target" value="ocr" class="submit">'.$button_ocr.'</button>');
}
?>
</form>
</div>
</body>
Expand Down
18 changes: 10 additions & 8 deletions files/runScanner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca2dbac

Please sign in to comment.