sbs20 / scanserv

scanserv is a simple web-based UI for SANE which allows you to share a scanner on a network.
GNU General Public License v2.0
41 stars 13 forks source link

PHP parse error #9

Closed DanielO closed 5 years ago

DanielO commented 6 years ago

Hi, I was trying this out and I see..

[Thu Apr 19 11:09:51.201699 2018] [fcgid:warn] [pid 51408] [client 1.2.3.4:58676] mod_fcgid: stderr: PHP Parse error: syntax error, unexpected ')', expecting '(' in /home/xxx/scanserv/classes_php/Scanimage.php on line 38, referer: https://1.2.3.4/scanserve/

I had a look but I'm not very knowledgable about PHP.

DanielO commented 6 years ago

After smashing my head against the POLA violations of PHP I find this code works..

diff --git a/classes_php/Scanimage.php b/classes_php/Scanimage.php
index dc8daf0..bf47e12 100644
--- a/classes_php/Scanimage.php
+++ b/classes_php/Scanimage.php
@@ -35,7 +35,7 @@ class Scanimage implements IScanner {
                }

                // No output filter or default output format which is handled by scanimage directly
-               if (empty(Config::OutputFilter) || $scanRequest->format == Config::OutputExtension) {
+               if (defined("Config::OutputFilter") || $scanRequest->format == Config::OutputExtension) {
                        $cmd = $cmd . ' > "' . $scanRequest->outputFilepath . '"';
                } else {
                        $cmd = $cmd . ' | ' . $cmd2 . ' "' . $scanRequest->outputFilepath . '"';

Also the default config example of.. const OutputFilter = self::Convert . " - ";

does not work, you can't reference self::Convert this way (nor does Config::Convert work)

I removed this since I wanted an empty output filter, but otherwise I would suggest just using 'cat'.

mrPsycho commented 6 years ago

@DanielO can you create pull request?

DanielO commented 6 years ago

Done

sbs20 commented 5 years ago

Merged. I'm so sorry this has taken forever to do.