@echo off z: cd z:\home\10.74.0.98\www\scans\%1 z:\jpeg2pdf\jpeg2pdf.exe -z none *.jpg -o %1.pdf move *.pdf ..
<?php $ip = '10.74.0.98'; $pagename = 'scan57578.php'; $folder = 'scans'; $jpeg2pdf = 'z:\\jpeg2pdf\\makepdf.bat'; ?> <html> <script> function $_GET(key) { var s = window.location.search; s = s.match(new RegExp(key + '=([^&=]+)')); return s ? s[1] : false; } function gettime() { var d = new Date(); var curr_date = d.getDate(); if (curr_date < 10) curr_date = '0'+curr_date; var curr_month = d.getMonth() + 1; if (curr_month < 10) curr_month = '0'+curr_month; var curr_year = d.getFullYear(); var curr_hour = d.getHours(); if (curr_hour < 10) curr_hour = '0'+curr_hour; var curr_min = d.getMinutes(); if (curr_min < 10) curr_min = '0'+curr_min; var curr_sec = d.getSeconds(); if (curr_sec < 10) curr_sec = '0'+curr_sec; return curr_year+'-'+curr_month+'-'+curr_date+'-'+curr_hour+'-'+curr_min+'-'+curr_sec; } function jpgclick() { document.getElementById('scanprogress').style.display = 'block'; document.getElementById('scanjpg').href='/<?=$pagename?>?scantype=jpg&time='+gettime(); } function pdfclick() { document.getElementById('scanprogress').style.display = 'block'; document.getElementById('scanpdf').href='/<?=$pagename?>?scantype=pdf&time='+gettime(); } function pdfnextclick() { document.getElementById('scanprogress').style.display = 'block'; document.getElementById('pdfnext').href='/<?=$pagename?>?scantype=pdf&time='+$_GET('time'); } </script> <body> <div style="font-size: 150%"> <a id="scanpdf" href="#" style="color: #00C" onclick="pdfclick()">New PDF scan</a> <a id="pdfnext" href="#" style="display: none; color: #00C" onclick="pdfnextclick()">Scan PDF next page</a> <a id="makepdf" href="/<?=$pagename?>?scantype=makepdf&time=<?=$_GET['time']?>" style="color: #000; display: none">Make PDF</a><br /><br /> <a id="scanjpg" href="#" style="color: #00C" onclick="jpgclick()">New JPG scan</a><br /><br /> <a href="/<?=$folder?>/" target="_blank" style="color: #090">Browse images</a> </div> <br /><br /> <div id="scanprogress" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: white; display: none"> <h1 style="position: absolute; left: 20%; top: 30%">Scanning in progress. Don't close browser tab.</h1> </div> <?php if($_GET['scantype']=='jpg') { $filename = 'Z:\\home\\'.$ip.'\\www\\'.$folder.'\\'.$_GET['time'].'.jpg'; if(!is_file($filename)){ $cmd = '"C:\Program Files\GssEziSoft\CmdTwain\CmdTwain.exe" "'.$filename.'"'; system($cmd); } echo ('<a href="/'.$folder.'/'.$_GET['time'].'.jpg"><img style="height: 80%" src="/'.$folder.'/'.$_GET['time'].'.jpg" alt="Picture" /></a>'); } if($_GET['scantype']=='pdf') { if($_GET['delete']!='') { $i = -2; $files = scandir($folder.'/'.$_GET['time']); foreach($files as $filename) { $i++; if ($filename[0] == '.') continue; if ($_GET['delete'] == $i) system('del '.'Z:\\home\\'.$ip.'\\www\\'.$folder.'\\'.$_GET['time'].'\\'.$filename); } } else { if (!is_dir($folder.'/'.$_GET['time'])) { system('md Z:\\home\\'.$ip.'\\www\\'.$folder.'\\'.$_GET['time']); $filename = 'Z:\\home\\'.$ip.'\\www\\'.$folder.'\\'.$_GET['time'].'\\0001.jpg'; $cmd = '"C:\Program Files\GssEziSoft\CmdTwain\CmdTwain.exe" "'.$filename.'"'; system($cmd); } else { $n = 1; $files = scandir($folder.'/'.$_GET['time']); foreach($files as $filename) { if ($filename[0] == '.') continue; $t = substr($filename, 0, -4)+0; if ($t > $n) $n = $t; } $n++; $fn = str_pad($n, 4, "0", STR_PAD_LEFT).'.jpg'; $filename = 'Z:\\home\\'.$ip.'\\www\\'.$folder.'\\'.$_GET['time'].'\\'.$fn; $cmd = '"C:\Program Files\GssEziSoft\CmdTwain\CmdTwain.exe" "'.$filename.'"'; system($cmd); } } $i = -2; $files = scandir($folder.'/'.$_GET['time']); foreach($files as $filename) { $i++; if ($filename[0] == '.') continue; echo "<table style='float: left' width='19%'><tr><td><a href='#' onclick='document.getElementById(\"preview\").style.display=\"block\"; document.getElementById(\"prepic\").src=\"/".$folder."/".$_GET['time']."/".$filename."\"'><img alt='Picture' style='width: 100%' src='/".$folder."/".$_GET['time']."/".$filename."' /></a></td></tr><tr><td align='center'><a href='/".$pagename."?scantype=pdf&time=".$_GET['time']."&delete=".$i."'>Delete page ".$i."</a><br /><br /></td></tr></table>"; } if ($i == 0) echo '<div style="position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: white"><br /><br /><br /><center><h1><a href="/'.$pagename.'"> </a></h1></center></div>'; } if($_GET['scantype']=='makepdf') { $cmd = $jpeg2pdf.' '.$_GET['time']; echo '<span style="display: none">'; system($cmd); echo "</span><h1><a href='scans/".$_GET['time'].".pdf'>Download PDF</a></h1>"; } ?> <div id="preview" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: black; color: white; display: none"><img id="prepic" style="position: relative; left: 23%; height: 100%" src="" alt="Picture" /><div style="position: absolute; top: 0; right: 0; color: #FFF"><a href="#" onclick="document.getElementById('preview').style.display='none'; return false" style="text-decoration: none; font-size: 250%; color: white; font-family: arial">X </a></div></div> </body> <script> if ($_GET('scantype') == 'pdf') document.getElementById('pdfnext').style.display = 'inline'; if ($_GET('scantype') == 'pdf') document.getElementById('makepdf').style.display = 'inline'; </script> </html>
Source: https://habr.com/ru/post/315160/
All Articles