Updated to include Purecss as well as other code cleanup
This commit is contained in:
parent
67ca9256ee
commit
062200f747
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*.jpg
|
||||||
|
*.JPG
|
||||||
|
*.Jpg
|
||||||
|
*.pdf
|
||||||
|
*.PDF
|
||||||
|
*.Pdf
|
195
index.php
195
index.php
@ -8,7 +8,18 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
$scanner_address = "epkowa:net:pr01.lzu01.point808.com";
|
// Configuration
|
||||||
|
$app_dir = "/var/www/scan/"; // Absolute path to where this app directory is - must end with a /
|
||||||
|
$scan_dir = "scans/"; // Relative path inside application directory that holds the scans - must end with a /
|
||||||
|
|
||||||
|
// Don't touch below!
|
||||||
|
$scans_dir = $app_dir . $scan_dir;
|
||||||
|
|
||||||
|
if (isset($_POST["filenaming"])) {
|
||||||
|
$filename = date("Y-m-d_H.i.s")."_".$filenaming;
|
||||||
|
} else {
|
||||||
|
$filename = date("Y-m-d_H.i.s");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST["scan"])) {
|
if (isset($_POST["scan"])) {
|
||||||
@ -28,7 +39,6 @@ if (isset($_POST["scan"])) {
|
|||||||
if ($match&&count($matches)) {
|
if ($match&&count($matches)) {
|
||||||
$address=$matches[0];
|
$address=$matches[0];
|
||||||
}
|
}
|
||||||
$fileName = "Scan_".date("Y-m-d_H.i.s");
|
|
||||||
$descriptorspec = array(
|
$descriptorspec = array(
|
||||||
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
|
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
|
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
|
||||||
@ -37,8 +47,8 @@ if (isset($_POST["scan"])) {
|
|||||||
$cwd = '/tmp';
|
$cwd = '/tmp';
|
||||||
$env = array();
|
$env = array();
|
||||||
|
|
||||||
$process = proc_open("/usr/bin/scanadf -d epkowa:net:pr01.lzu01.point808.com --output-file ".
|
$process = proc_open("/usr/bin/scanimage -d $device --output-file ".
|
||||||
"/var/www/scanout/$fileName-%04d --quick-format Letter".
|
"$scans_dir . $fileName-%04d --quick-format Letter".
|
||||||
" --mode $_POST[mode] --resolution $_POST[quality] --source Automatic Document Feeder", $descriptorspec, $pipes, $cwd, $env);
|
" --mode $_POST[mode] --resolution $_POST[quality] --source Automatic Document Feeder", $descriptorspec, $pipes, $cwd, $env);
|
||||||
|
|
||||||
if (is_resource($process)) {
|
if (is_resource($process)) {
|
||||||
@ -46,7 +56,7 @@ if (isset($_POST["scan"])) {
|
|||||||
$output = stream_get_contents($pipes[1]);
|
$output = stream_get_contents($pipes[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirList = scandir("/var/www/scanout");
|
$dirList = scandir($scans_dir);
|
||||||
$inputFiles = array();
|
$inputFiles = array();
|
||||||
$firstFile = "";
|
$firstFile = "";
|
||||||
foreach ($dirList as $file) {
|
foreach ($dirList as $file) {
|
||||||
@ -61,10 +71,10 @@ if (isset($_POST["scan"])) {
|
|||||||
{
|
{
|
||||||
$path="";
|
$path="";
|
||||||
foreach ($inputFiles as $file) {
|
foreach ($inputFiles as $file) {
|
||||||
$path .= "pnm:/var/www/scanout/$file ";
|
$path .= "pnm:" . $scans_dir . $file;
|
||||||
}
|
}
|
||||||
$output = `/usr/bin/convert pnm:/var/www/scanout/$firstFile -resize '>300x' -strip /var/www/scanout/$firstFile.jpg`;
|
$output = `/usr/bin/convert pnm:$scans_dir$firstFile -resize '>300x' -strip $scans_dir$firstFile.jpg`;
|
||||||
$output .= `/usr/bin/convert -page a4 $path /var/www/scanout/$fileName.pdf`;
|
$output .= `/usr/bin/convert -page a4 $path $scans_dir$fileName.pdf`;
|
||||||
echo "Scan Successful!";
|
echo "Scan Successful!";
|
||||||
} else {
|
} else {
|
||||||
echo "Scan Failed! No pages were scanned. Is there a document in the scanner?";
|
echo "Scan Failed! No pages were scanned. Is there a document in the scanner?";
|
||||||
@ -80,86 +90,105 @@ if (isset($_POST["scan"])) {
|
|||||||
<p>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.</p>
|
<p>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.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form class="pure-form pure-form-stacked">
|
<form class="pure-form pure-form-aligned" action="index.php" method="post">
|
||||||
|
<div class="pure-g">
|
||||||
|
<div class="pure-u-1 pure-u-md-1-3">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Basic Settings</legend>
|
<div class="pure-control-group">
|
||||||
<div class="pure-g">
|
<legend><h3>Device Setup</h3></legend>
|
||||||
<div class="pure-u-1 pure-u-md-1-3">
|
<label for="device">Device</label>
|
||||||
<label for="device">Device</label>
|
<select id="device" class="pure-input-rounded">
|
||||||
<select id="device" class="pure-input-1-2">
|
<option value="epkowa:net:pr01.lzu01.point808.com" selected="selected">pr01 (Epson WF-2540)</option>
|
||||||
<option value="epkowa:net:pr01.lzu01.point808.com" selected="selected">pr01 (Epson WF-2540)</option>
|
<option value="hpaio:/net/Deskjet_F4500_series?ip=192.168.101.222">pr02 (HP DeskJet F4580)</option>
|
||||||
<option value="hpaio:/net/Deskjet_F4500_series?ip=192.168.101.222">pr02 (HP DeskJet F4580)</option>
|
</select>
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="pure-u-1 pure-u-md-1-3">
|
|
||||||
<label for="source">Feed Source</label>
|
|
||||||
<select id="source" class="pure-input-1-2">
|
|
||||||
<option value="Automatic Document Feeder" selected="selected">Automatic Document Feeder</option>
|
|
||||||
<option value="Flatbed">Flatbed</option>
|
|
||||||
</select>
|
|
||||||
</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 value="150dpi" selected="selected">AL</option>
|
|
||||||
<option>CA</option>
|
|
||||||
<option>IL</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="pure-button pure-button-primary">Submit</button>
|
<div class="pure-control-group">
|
||||||
|
<label for="source">Feed Source</label>
|
||||||
|
<select id="source" class="pure-input-rounded">
|
||||||
|
<option value="Automatic Document Feeder" selected="selected">Automatic Document Feeder</option>
|
||||||
|
<option value="Flatbed">Flatbed</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="mode">Colors</label>
|
||||||
|
<select id="mode" class="pure-input-rounded">
|
||||||
|
<option value="Binary">Black & White</option>
|
||||||
|
<option value="Gray" selected="selected">Grayscale</option>
|
||||||
|
<option value="Color">Color</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="resolution">Resolution</label>
|
||||||
|
<select id="resolution" class="pure-input-rounded">
|
||||||
|
<option value="75">75dpi (FASTEST!)</option>
|
||||||
|
<option value="300" selected="selected">300dpi (FAST!)</option>
|
||||||
|
<option value="600">600dpi (SLOW!)</option>
|
||||||
|
<option value="1200">1200dpi (SLOWEST!)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<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!" class="pure-button pure-button-primary" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-1 pure-u-md-1-3">
|
||||||
|
<fieldset>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<legend><h3>File Options</h3></legend>
|
||||||
|
<label for="filetype">File Type</label>
|
||||||
|
<select id="filetype" class="pure-input-rounded">
|
||||||
|
<option value="pdf" selected="selected">PDF (multipage)</option>
|
||||||
|
<option value="jpg">JPG (image)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="filenaming">File Naming</label>
|
||||||
|
<input id="filenaming" class="pure-input-rounded" placeholder="Append to filename">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-1 pure-u-md-1-3">
|
||||||
|
<fieldset>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
<fieldset class="pure-group">
|
<legend><h3>Page Size</h3></legend>
|
||||||
<input type="text" class="pure-input-1-2" placeholder="Username">
|
<label for="l">X-Start (top-left, mm)</label>
|
||||||
<input type="text" class="pure-input-1-2" placeholder="Password">
|
<input type="number" id="l" class="pure-input-rounded" value="0">
|
||||||
<input type="email" class="pure-input-1-2" placeholder="Email">
|
</div>
|
||||||
</fieldset>
|
<div class="pure-control-group">
|
||||||
|
<label for="t">Y-Start (top-left, mm)</label>
|
||||||
<fieldset class="pure-group">
|
<input type="number" id="t" class="pure-input-rounded" value="0">
|
||||||
<input type="text" class="pure-input-1-2" placeholder="Another Group">
|
</div>
|
||||||
<input type="text" class="pure-input-1-2" placeholder="More Stuff">
|
<div class="pure-control-group">
|
||||||
</fieldset>
|
<label for="x">Width (mm)</label>
|
||||||
|
<input type="number" id="x" class="pure-input-rounded" value="215.9">
|
||||||
<button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Sign in</button>
|
</div>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="y">Height (mm)</label>
|
||||||
|
<input type="number" id="y" class="pure-input-rounded" value="279">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div class="pure-g">
|
||||||
<form class="pure-form" action="index.php" method="post">
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
Color or Black & White?
|
<h2>Previous Document Scans (PDF)</h2>
|
||||||
<select name="mode">
|
<?php
|
||||||
<option value="Binary" selected="selected">Black & White</option>
|
$phpfiles = array_reverse(glob($scan_dir . "*.pdf"));
|
||||||
<option value="Gray">Grayscale</option>
|
foreach($phpfiles as $phpfile) {
|
||||||
<option value="Color">Color</option>
|
echo "<a target=\"_blank\" href=$phpfile>".basename($phpfile)."</a><br />";
|
||||||
</select><br />
|
}
|
||||||
Regular, high, low quality?
|
?>
|
||||||
<select name="quality">
|
</div>
|
||||||
<option value="72dpi">Low (FAST!)</option>
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
<option value="150dpi" selected="selected">Standard</option>
|
<h2>Previous Image Scans (JPG)</h2>
|
||||||
<option value="300dpi">High (EXTREMELY SLOW!!!)</option>
|
<?php
|
||||||
</select><br />
|
$phpfiles = array_reverse(glob($scan_dir . "*.jpg"));
|
||||||
|
foreach($phpfiles as $phpfile) {
|
||||||
<input type="hidden" name="scan" value="yes" />
|
echo "<a target=\"_blank\" href=$phpfile>".basename($phpfile)."</a><br />";
|
||||||
<input type="submit" onclick="this.disabled=true;this.value='Scanning - PLEASE be patient!';this.form.submit();" value="Scan!" />
|
}
|
||||||
</form>
|
?>
|
||||||
|
</div>
|
||||||
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user