konyvleltar/web/index.php
2021-12-20 12:50:53 +01:00

47 lines
1.4 KiB
PHP

<?php
include ('template.inc');
$rets = ['OK'=>'OK', 'ERROR'=>'ERROR'];
ob_start();
print "<h2>Book ID input</h2>";
print "<div class='isbn-input'>";
print '<form action="/scan.php" method="POST">';
print '<dl>';
print '<h3>ID type</h3>';
print '<input type="radio" id="isbn" name="idtype" value="isbn" checked="checked">';
print '<label for="isbn">ISBN</label><br>';
print '<input type="radio" id="moly" name="idtype" value="moly">';
print '<label for="moly">Moly.hu</label><br>';
print '</dl>';
print '<label for="content">ID:</label>';
print '<input type="text" id="isbn-content" name="content" inputmode="tel" autofocus>';
print '<input type="hidden" id="manual" name="manual" value="1">';
print '<input class="hidden" type="submit" value="Submit">';
print '</form>';
if (isset ($_GET['ret'])){
if (array_key_exists($_GET['ret'],$rets)){
$r = $rets[$_GET['ret']];
print "<p class='retek $r'>$r</p>";
}
}
print "</div>";
print "<h2>Errors</h2>";
print "<div class='errors'>".errors()."</div>";
$output = ob_get_clean();
Template::render($output);
function errors(){
ob_start();
$a = file("../data/isbn-error.txt");
$r = array_reverse($a);
print "<pre>";
foreach ($r as $l){
print($l);
}
print "</pre>";
return ob_get_clean();
}