165 lines
6.2 KiB
PHP
165 lines
6.2 KiB
PHP
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>Scanimage Web GUI</title>
|
|
<link rel="stylesheet" href="pure/pure-min.css">
|
|
<link rel="stylesheet" href="pure/grids-responsive.css">
|
|
<link rel="stylesheet" href="pure/base-min.css">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
</head>
|
|
<body>
|
|
<?php
|
|
if (isset($_POST["scan"])) {
|
|
$findScanner = array(
|
|
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
|
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
|
2 => array("pipe", "w") // stderr is a file to write to
|
|
);
|
|
$env=array();
|
|
$process = proc_open("/usr/bin/sane-find-scanner", $findScanner, $pipes, '/tmp', $env);
|
|
if (is_resource($process)) {
|
|
$data = stream_get_contents($pipes[2]);
|
|
$data .= stream_get_contents($pipes[1]);
|
|
}
|
|
proc_close($process);
|
|
$match = preg_match('/libusb:\d+:\d+/', $data, $matches);
|
|
if ($match&&count($matches)) {
|
|
$address=$matches[0];
|
|
}
|
|
$fileName = "Scan_".date("Y-m-d_H.i.s");
|
|
$descriptorspec = array(
|
|
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
|
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
|
2 => array("pipe", "w") // stderr is a file to write to
|
|
);
|
|
$cwd = '/tmp';
|
|
$env = array();
|
|
|
|
$process = proc_open("/usr/bin/scanadf -d epkowa:net:pr01.lzu01.point808.com --output-file ".
|
|
"/var/www/scanout/$fileName-%04d --quick-format Letter".
|
|
" --mode $_POST[mode] --resolution $_POST[quality] --source Automatic Document Feeder", $descriptorspec, $pipes, $cwd, $env);
|
|
|
|
if (is_resource($process)) {
|
|
$errors = stream_get_contents($pipes[2]);
|
|
$output = stream_get_contents($pipes[1]);
|
|
}
|
|
|
|
$dirList = scandir("/var/www/scanout");
|
|
$inputFiles = array();
|
|
$firstFile = "";
|
|
foreach ($dirList as $file) {
|
|
if (stristr($file, $fileName)) {
|
|
//this is one of our input files
|
|
if ($firstFile=="") $firstFile = $file;
|
|
array_push($inputFiles, $file);
|
|
}
|
|
}
|
|
|
|
if (count($inputFiles))
|
|
{
|
|
$path="";
|
|
foreach ($inputFiles as $file) {
|
|
$path .= "pnm:/var/www/scanout/$file ";
|
|
}
|
|
$output = `/usr/bin/convert pnm:/var/www/scanout/$firstFile -resize '>300x' -strip /var/www/scanout/$firstFile.jpg`;
|
|
$output .= `/usr/bin/convert -page a4 $path /var/www/scanout/$fileName.pdf`;
|
|
echo "Scan Successful!";
|
|
} else {
|
|
echo "Scan Failed! No pages were scanned. Is there a document in the scanner?";
|
|
}
|
|
ob_flush();
|
|
echo "";
|
|
}
|
|
?>
|
|
|
|
<div class="pure-g">
|
|
<div class="pure-u-1">
|
|
<h1>Scanner Web GUI</h1>
|
|
Use the drop-downs below to set preferences. Load documents in the feeder and press "Scan". When the job completes, you will be able to pick your file from the selection at the bottom of the page.
|
|
</div>
|
|
</div>
|
|
<form class="pure-form pure-form-stacked">
|
|
<fieldset>
|
|
<legend>Basic Settings</legend>
|
|
|
|
<div class="pure-g">
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
<label for="first-name">First Name</label>
|
|
<input id="first-name" type="text">
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
<label for="last-name">Last Name</label>
|
|
<input id="last-name" type="text">
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
<label for="email">E-Mail</label>
|
|
<input id="email" type="email" required>
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
<label for="city">City</label>
|
|
<input id="city" type="text">
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
<label for="state">State</label>
|
|
<select id="state" class="pure-input-1-2">
|
|
<option>AL</option>
|
|
<option>CA</option>
|
|
<option>IL</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<label for="terms" class="pure-checkbox">
|
|
<input id="terms" type="checkbox"> I've read the terms and conditions
|
|
</label>
|
|
|
|
<button type="submit" class="pure-button pure-button-primary">Submit</button>
|
|
</fieldset>
|
|
<fieldset class="pure-group">
|
|
<input type="text" class="pure-input-1-2" placeholder="Username">
|
|
<input type="text" class="pure-input-1-2" placeholder="Password">
|
|
<input type="email" class="pure-input-1-2" placeholder="Email">
|
|
</fieldset>
|
|
|
|
<fieldset class="pure-group">
|
|
<input type="text" class="pure-input-1-2" placeholder="Another Group">
|
|
<input type="text" class="pure-input-1-2" placeholder="More Stuff">
|
|
</fieldset>
|
|
|
|
<button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Sign in</button>
|
|
</form>
|
|
|
|
|
|
<form class="pure-form" action="index.php" method="post">
|
|
Color or Black & White?
|
|
<select name="mode">
|
|
<option value="Binary" selected="selected">Black & White</option>
|
|
<option value="Gray">Grayscale</option>
|
|
<option value="Color">Color</option>
|
|
</select><br />
|
|
Regular, high, low quality?
|
|
<select name="quality">
|
|
<option value="72dpi">Low (FAST!)</option>
|
|
<option value="150dpi" selected="selected">Standard</option>
|
|
<option value="300dpi">High (EXTREMELY SLOW!!!)</option>
|
|
</select><br />
|
|
|
|
<input type="hidden" name="scan" value="yes" />
|
|
<input type="submit" onclick="this.disabled=true;this.value='Scanning - PLEASE be patient!';this.form.submit();" value="Scan!" />
|
|
</form>
|
|
|
|
<h2>Previous Scans</h2>
|
|
<h4>(Newest scan is on top!)</h4>
|
|
<?php
|
|
$phpfiles = array_reverse(glob("scanout/*.pdf"));
|
|
foreach($phpfiles as $phpfile) {
|
|
echo "<a target=\"_blank\" href=$phpfile>".basename($phpfile)."</a><br>";
|
|
}
|
|
?>
|
|
|
|
</body>
|
|
</html>
|