2014-08-25 22:04:03 -04:00
|
|
|
<?php require 'config.php'; ?>
|
2014-08-25 14:44:37 -04:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
2014-08-25 14:46:48 -04:00
|
|
|
<title><?php echo $page_title; ?></title>
|
2014-08-25 14:44:37 -04:00
|
|
|
<link rel="stylesheet" href="pure/pure-min.css">
|
|
|
|
<link rel="stylesheet" href="pure/grids-responsive.css">
|
|
|
|
<link rel="stylesheet" href="pure/base-min.css">
|
2014-08-25 22:13:10 -04:00
|
|
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
|
|
|
|
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
2014-08-25 14:44:37 -04:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
</head>
|
|
|
|
<body>
|
2014-08-25 14:55:07 -04:00
|
|
|
<div class="pure-g">
|
|
|
|
<div class="pure-u-1">
|
|
|
|
<h1><?php echo $page_title; ?></h1>
|
|
|
|
<p><?php echo $user_message; ?></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
<div class="pure-control-group">
|
|
|
|
<legend><h3>Device Setup</h3></legend>
|
|
|
|
<label for="device">Device</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<select name="device" id="device" class="pure-input-1-2">
|
2014-08-25 14:55:07 -04:00
|
|
|
<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>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="pure-control-group">
|
2014-08-28 21:40:30 -04:00
|
|
|
<label for="source">Source</label>
|
|
|
|
<select name="source" id="source" class="pure-input-1-2">
|
|
|
|
<option value="Automatic Document Feeder" selected="selected">Document Feeder</option>
|
2014-08-25 14:55:07 -04:00
|
|
|
<option value="Flatbed">Flatbed</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="pure-control-group">
|
|
|
|
<label for="mode">Colors</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<select name="mode" id="mode" class="pure-input-1-2">
|
2014-08-25 14:55:07 -04:00
|
|
|
<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">
|
2014-08-25 21:44:59 -04:00
|
|
|
<label for="sResolution">Resolution</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<select name="sResolution" id="sResolution" class="pure-input-1-2">
|
2014-08-25 21:44:59 -04:00
|
|
|
<option value="75" selected="selected">75dpi (FASTEST!)</option>
|
|
|
|
<option value="300">300dpi</option>
|
2014-08-25 14:55:07 -04:00
|
|
|
<option value="600">600dpi (SLOW!)</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2014-08-28 21:40:30 -04:00
|
|
|
</fieldset>
|
|
|
|
<fieldset>
|
2014-08-25 14:55:07 -04:00
|
|
|
<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" />
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
|
|
<div class="pure-control-group">
|
|
|
|
<legend><h3>File Options</h3></legend>
|
|
|
|
<label for="filetype">File Type</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<select name="filetype" id="filetype" class="pure-input-1-2">
|
2014-08-25 14:55:07 -04:00
|
|
|
<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>
|
2014-08-28 21:40:30 -04:00
|
|
|
<input name="filenaming" type="text" id="filenaming" class="pure-input-1-2" placeholder="Append to filename">
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-3">
|
|
|
|
<div class="pure-control-group">
|
2014-08-25 21:44:59 -04:00
|
|
|
<legend><h3>Page Size (in mm)</h3></legend>
|
|
|
|
<label for="l">X-Start (top-left)</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<input name="l" type="number" id="l" class="pure-input-1-2" value="0">
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
|
|
|
<div class="pure-control-group">
|
2014-08-25 21:44:59 -04:00
|
|
|
<label for="t">Y-Start (top-left)</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<input name="t" type="number" id="t" class="pure-input-1-2" value="0">
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
|
|
|
<div class="pure-control-group">
|
2014-08-25 21:44:59 -04:00
|
|
|
<label for="sX">Width (215.9=8.5in)</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<input name="sX" type="number" id="sX" class="pure-input-1-2" value="215.9">
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
|
|
|
<div class="pure-control-group">
|
2014-08-25 21:44:59 -04:00
|
|
|
<label for="y">Height (279=11in)</label>
|
2014-08-28 21:40:30 -04:00
|
|
|
<input name="y" type="number" id="y" class="pure-input-1-2" value="279">
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2014-08-25 21:59:43 -04:00
|
|
|
<?php
|
|
|
|
// initialize scanned files directory path
|
|
|
|
$scans_dir = $app_dir . $scan_dir;
|
|
|
|
// set post variables
|
2014-08-28 21:40:30 -04:00
|
|
|
if(isset($_POST['sResolution'])){$pResolution = $_POST['sResolution'];};
|
|
|
|
if(isset($_POST['sX'])){$pX = $_POST['sX'];};
|
2014-08-25 21:59:43 -04:00
|
|
|
// decide to use scanimage if Flatbed or scanadf if ADF
|
|
|
|
if (isset($_POST['source'])) {
|
|
|
|
if ($_POST['source']=="Flatbed") {
|
2014-08-28 21:40:30 -04:00
|
|
|
// $scanprog = $scanimage;
|
|
|
|
$scanprog = $scanadf; //TEMP SET ALL TO ADF
|
2014-08-25 21:59:43 -04:00
|
|
|
} else {
|
|
|
|
$scanprog = $scanadf;
|
|
|
|
}
|
|
|
|
} else {
|
2014-08-28 21:40:30 -04:00
|
|
|
// $scanprog = $scanimage;
|
|
|
|
$scanprog = $scanadf; //TEMP SET ALL TO ADF
|
2014-08-25 14:38:53 -04:00
|
|
|
}
|
2014-08-25 21:59:43 -04:00
|
|
|
// are we being called as a result of a scan or just initial page view?
|
|
|
|
if (isset($_POST['scan'])) {
|
|
|
|
$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();
|
|
|
|
// append to filename if set, otherwise date only
|
|
|
|
if (isset($_POST['filenaming'])) {
|
|
|
|
if (empty($_POST['filenaming'])) {
|
|
|
|
$filename = date($date_format);
|
|
|
|
} else {
|
|
|
|
$filename = date($date_format)."_".$_POST['filenaming'];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$filename = date($date_format);
|
|
|
|
}
|
|
|
|
// do it!
|
2014-08-28 21:40:30 -04:00
|
|
|
$process = proc_open($scanprog . " -d " . $_POST['device'] . " --output-file " . $scans_dir . $filename . "-%04d --source " . $_POST['source'] . " --mode " . $_POST['mode'] . " --resolution " . $pResolution . " -l " . $_POST['l'] . " -t " . $_POST['t'] . " -x " . $pX . " -y " . $_POST['y'], $descriptorspec, $pipes, $cwd, $env);
|
2014-08-25 21:59:43 -04:00
|
|
|
if (is_resource($process)) {
|
|
|
|
$errors = stream_get_contents($pipes[2]);
|
|
|
|
$output = stream_get_contents($pipes[1]);
|
|
|
|
}
|
|
|
|
$dirList = scandir($scans_dir);
|
|
|
|
$inputFiles = array();
|
|
|
|
$firstFile = "";
|
|
|
|
foreach ($dirList as $file) {
|
|
|
|
if (stristr($file, $filename)) {
|
|
|
|
if ($firstFile=="") $firstFile = $file;
|
|
|
|
array_push($inputFiles, $file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (count($inputFiles)) {
|
|
|
|
$path="";
|
|
|
|
foreach ($inputFiles as $file) {
|
|
|
|
$path .= "pnm:" . $scans_dir . $file;
|
|
|
|
}
|
|
|
|
//exec($convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg");
|
|
|
|
// make a (multi-page) pdf file from the scanned pnm files
|
|
|
|
// we have to set density to match the scan resolution and then calculate the width to pixels in order to make the pdf correct
|
2014-08-28 21:40:30 -04:00
|
|
|
exec($convert . ' -density ' . $pResolution . ' ' . $path . ' ' . $scans_dir . $filename . '.pdf');
|
2014-08-25 21:59:43 -04:00
|
|
|
// $output = $convert . " pnm:" . $scans_dir . $firstFile . " -strip " . $scans_dir . $firstFile . ".jpg";
|
|
|
|
// $output .= ($convert . " " . $path . " " . $scans_dir . $filename . ".pdf");
|
|
|
|
echo "Scan Successful!";
|
|
|
|
} else {
|
|
|
|
echo "Scan Failed!";
|
2014-08-25 14:38:53 -04:00
|
|
|
}
|
2014-08-25 21:59:43 -04:00
|
|
|
ob_flush();
|
|
|
|
echo "";
|
|
|
|
}
|
|
|
|
?>
|
2014-08-25 14:57:20 -04:00
|
|
|
<div class="pure-g">
|
|
|
|
<div class="pure-u-1 pure-u-md-1-2">
|
|
|
|
<h2>Previous Document Scans (PDF)</h2>
|
|
|
|
<?php
|
|
|
|
$phpfiles = array_reverse(glob($scan_dir . "*.pdf"));
|
|
|
|
foreach($phpfiles as $phpfile) {
|
|
|
|
echo "<a target=\"_blank\" href=$phpfile>".basename($phpfile)."</a><br />";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<div class="pure-u-1 pure-u-md-1-2">
|
|
|
|
<h2>Previous Image Scans (JPG)</h2>
|
|
|
|
<?php
|
|
|
|
$phpfiles = array_reverse(glob($scan_dir . "*.jpg"));
|
|
|
|
foreach($phpfiles as $phpfile) {
|
|
|
|
echo "<a target=\"_blank\" href=$phpfile>".basename($phpfile)."</a><br />";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
2014-08-25 14:55:07 -04:00
|
|
|
</div>
|
2014-08-28 21:40:30 -04:00
|
|
|
<!-- include jQuery library -->
|
|
|
|
<script src="//code.jquery.com/jquery-latest.js"></script>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
/*
|
|
|
|
* check browser supports local storage
|
|
|
|
*/
|
|
|
|
if (localStorage) {
|
|
|
|
/*
|
|
|
|
* if form field values exist in local storage use
|
|
|
|
* them to populate the form when the page loads
|
|
|
|
*/
|
|
|
|
if (localStorage.type) {
|
|
|
|
$("#type").find("option[value=" + localStorage.type + "]").attr("selected", true);
|
|
|
|
}
|
|
|
|
if (localStorage.name) {
|
|
|
|
$("#name").val(localStorage.name);
|
|
|
|
}
|
|
|
|
if (localStorage.email) {
|
|
|
|
$("#email").val(localStorage.email);
|
|
|
|
}
|
|
|
|
if (localStorage.message) {
|
|
|
|
$("#message").val(localStorage.message);
|
|
|
|
}
|
|
|
|
if (localStorage.subscribe === "checked") {
|
|
|
|
$("#subscribe").attr("checked", "checked");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* when a form field changes store it's value in local storage
|
|
|
|
*/
|
|
|
|
$("input[type=text],select,textarea").change(function(){
|
|
|
|
$this = $(this);
|
|
|
|
localStorage[$this.attr("name")] = $this.val();
|
|
|
|
});
|
|
|
|
$("input[type=checkbox]").change(function(){
|
|
|
|
$this = $(this);
|
|
|
|
localStorage[$this.attr("name")] = $this.attr("checked");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("form")
|
|
|
|
/*
|
|
|
|
* clear local storage when the form is submitted
|
|
|
|
*/
|
|
|
|
.submit(function(){
|
|
|
|
localStorage.clear();
|
|
|
|
})
|
|
|
|
/*
|
|
|
|
* output local storage to the console each time the form changes
|
|
|
|
* (you may want to remove this code on the production server)
|
|
|
|
*/
|
|
|
|
.change(function(){
|
|
|
|
console.log(localStorage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2014-08-25 14:55:07 -04:00
|
|
|
</body>
|
2014-08-23 22:13:24 -04:00
|
|
|
</html>
|