function importISBN($file, &$isbnList) { // Get uploaded file. $path = $file['tmp_name']; // Validations. if (!is_uploaded_file($path)) { return array('error' => 'invalid upload files'); } if ($file['size'] <= 0 || $file['size'] > 10000) { return array('error' => 'oversized files'); } // Read ISBN. $fp = fopen($file['tmp_name'], 'r'); if (!$fp) { return array('error' => 'unable to open uploaded files'); } $bl = new BulkLookupQuery(); $isbnList = array(); while (!feof($fp)) { $line = trim(fgets($fp)); $isbn = $this->verifyISBN($line); if (strlen($isbn) == 10) { $isbnList[$isbn]++; } } // $bl->queue($isbnList); // Enable cron. if (preg_match('/OFF/', file_get_contents("../cron/cronrun.txt"))) { file_put_contents("../cron/cronrun.txt", 'ON'); } $bl->clearDoneQueue(); }
// Paging link if ($p > 1) { $prev = "<a href=\"?type=cover&page=" . ($p - 1) . "\">Previous</a>"; } if ($p * $limit < $total) { $next = "<a href=\"?type=cover&page=" . ($p + 1) . "\">Next</a>"; } echo $prev . ($prev && $next ? ' | ' : '') . $next; ?> <?php break; case 'manual': if ($_GET['act'] == 'cleartemp') { $bl = new BulkLookupQuery(); $bl->clearDoneQueue('manual_list'); $msg = '<h5 id="updateMsg">' . $loc->getText('bulkReportZeroHitsClear') . '</h5>'; } else { if ($_GET['act'] == 'export') { $bl = new BulkLookupQuery(); $total = $bl->countQueue('manual_list'); $bl->getManualList($total); while ($row = $bl->fetch()) { for ($i = 0; $i < $row['hits']; $i++) { $f .= $row['isbn'] . "\n"; } } header("Content-Type: plain/text"); header("Content-Disposition: attachment; filename=isbn_export_" . date('Ymd_his') . ".txt"); header("Content-Length: " . strlen($f)); die($f);