function search($isbnList) { $bl = new BulkLookupQuery(); if (!is_array($isbnList)) { return false; } foreach ($isbnList as $one) { // Check existing ISBN. $existBibid = $bl->getExistBiblio($one['isbn']); if ($existBibid > 0) { for ($i = 0; $i < $one['amount']; $i++) { $bl->addCopy($existBibid); } $bl->setLookupStatus('copy', $one['isbn']); continue; } $list = $this->_getLookupServers(); $retry = false; if (!is_array($list) || count($list) < 1) { $bl->setLookupStatus('manual', $one['isbn'], $one['amount']); } foreach ($list as $server) { $result = $this->_getLookupResult($server, $one['isbn']); if (!$result || isset($result['error'])) { if (preg_match('/not connect/', $result['error']) || preg_match('/response error/', $result['error'])) { $retry = true; } continue; } $book = array('isbn' => $one['isbn'], 'data' => $result, 'amount' => $one['amount']); $this->_addResult($book); break; } if (isset($result['error'])) { $book = array('isbn' => $one['isbn'], 'data' => NULL); $this->_addResult($book); if ($retry) { $bl->setLookupStatus('retry', $one['isbn']); } else { $bl->setLookupStatus('manual', $one['isbn'], $one['amount']); } } } $bl->saveResults($this->_results); }
<?php $tab = "admin"; $nav = "BulkLookup"; $helpPage = "BulkLookup"; $cancelLocation = "../admin/index.php"; require_once "../shared/common.php"; require_once "../shared/logincheck.php"; require_once "../classes/Localize.php"; $loc = new Localize(OBIB_LOCALE, $tab); require_once '../classes/BulkLookup.php'; $q = new BulkLookupQuery(); $queued = $q->countQueue(); $trying = $q->countQueue('queue_try'); $done = $q->countQueue('publish'); $covered = $q->countQueue('cover'); $copied = $q->countQueue('copy'); $failed = $q->countQueue('manual'); $estimate_time = date('H:i:s', $q->getStartTime()); //1 $est_time = $q->getStartTime(); $est_hour = str_pad(floor($est_time / 3600), 2, '0', STR_PAD_LEFT); $est_min = str_pad(floor($est_time % 3600 / 60), 2, '0', STR_PAD_LEFT); $est_sec = str_pad(floor($est_time % 60), 2, '0', STR_PAD_LEFT); $estimate_time = $est_hour . ':' . $est_min . ':' . $est_sec; if ($queued < 1) { echo "DONE"; } $cron_status = file_get_contents('../cron/cronrun.txt'); echo $loc->getText('lookup_bulkStatus', array('updated' => date('Y-m-d H:i:s'), 'estimate' => $estimate_time, 'cron_status' => $cron_status, 'remain' => $queued, 'trying' => $trying, 'done' => $done + $covered, 'covered' => $covered, 'copied' => $copied, 'failed' => $failed)); if ($queued < 1) {
function import($row) { require_once "../classes/BulkLookup.php"; $bl = new BulkLookupQuery(); if (!isset($row['020a'], $row['100a'], $row['245a'])) { return false; } $isbn = $this->verifyISBN($row['020a']); $existBibid = $this->getExistBiblio($isbn); if ($existBibid > 0) { $bl->addCopy($existBibid); return 'copy'; } $this->_formatResults($row); $bib = $this->_getBiblio($row); $insert_bib[$isbn]['bibid'] = 0 + $this->_insertBiblio($bib); if ($insert_bib[$isbn]['bibid'] > 0) { $this->addCopy($insert_bib[$isbn]['bibid']); return 'done'; } else { return false; } }
#************************************************************************** if (0 + $_GET['hits'] > 1) { $i = 0; do { insertCopy(); $copy->setBarcodeNmbr(generateBarcode()); $i++; } while ($i < 0 + $_GET['hits']); require_once "../classes/BulkLookup.php"; $bl = new BulkLookupQuery(); $bl->clearManualItem($_GET['isbn'], $_GET['hits']); } else { insertCopy(); if (isset($_GET['isbn'], $_GET['hits'])) { require_once "../classes/BulkLookup.php"; $bl = new BulkLookupQuery(); $bl->clearManualItem($_GET['isbn'], $_GET['hits']); } } $copyQ->close(); #************************************************************************** #* Destroy form values and errors #************************************************************************** unset($_SESSION["postVars"]); unset($_SESSION["pageErrors"]); $msg = $loc->getText("biblioCopyNewSuccess"); header("Location: ../shared/biblio_view.php?bibid=" . U($bibid) . "&msg=" . U($msg)); exit; function generateBarcode() { global $copyQ;
<?php if ($_SERVER['REMOTE_ADDR'] !== $_SERVER['SERVER_ADDR']) { die('Access denied.'); } require_once dirname(__FILE__) . "/../shared/common.php"; require_once dirname(__FILE__) . '/../classes/BulkLookup.php'; // Process ISBN lookup $limit = 10; $q = new BulkLookupQuery(); $remain = $q->countQueue(); file_put_contents(dirname(__FILE__) . '/../cron/cronrun.txt', 'LOCK'); if ($remain < 1) { // Disable cron. file_put_contents(dirname(__FILE__) . '/../cron/cronrun.txt', 'OFF'); die; } else { $q->getQueue('queue', $limit); while ($row = $q->fetch()) { $rows[] = $row; } foreach ($rows as $row) { if ($row['tries'] < 3) { //$isbnList[] = $row['isbn']; $isbnList[] = array('isbn' => $row['isbn'], 'amount' => $row['amount']); } else { $q->setLookupStatus('manual', $row['isbn'], $row['amount']); } } $lookup = new BulkLookup(); $lookup->search($isbnList);
<table class="primary" border="1" cellpadding="3"> <th>ISBN</th><th><?php echo $loc->getText('Hits'); ?> </th><th><?php echo $loc->getText('Created'); ?> </th><th colspan="3"><?php echo $loc->getText('function'); ?> </th><th><?php echo $loc->getText('OPAC'); ?> </th></tr> <?php $bl = new BulkLookupQuery(); // Paging $limit = 50; $total = $bl->countQueue('manual_list'); if (0 + $_GET['page'] < 1 || ($p - 1) * $limit >= $total) { $p = 1; } else { $p = 0 + $_GET['page']; } $bl->getManualList($limit, ($p - 1) * $limit); $rows = array(); while ($row = $bl->fetch()) { $rows[] = $row; } if (count($rows) < 1) { echo "<tr><td colspan=\"7\" class=\"primary\">" . $loc->getText('bulkReportNoItem') . "</td></tr>";