2013-09-25 04:03:52 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Epub loader action: load ebooks into calibre databases
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author Didier Corbière <didier.corbiere@opale-concept.com>
|
|
|
|
*/
|
|
|
|
|
2013-09-25 09:28:20 +03:00
|
|
|
// Init database file
|
|
|
|
$fileName = $dbConfig['db_path'] . DIRECTORY_SEPARATOR . 'metadata.db';
|
|
|
|
try {
|
|
|
|
// Open or create the database
|
|
|
|
$db = new CalibreDbLoader($fileName, $gConfig['create_db']);
|
|
|
|
echo sprintf('Load database %s', $fileName) . '<br />';
|
|
|
|
// Add the epub files into the database
|
|
|
|
if (!empty($dbConfig['epub_path'])) {
|
|
|
|
$fileList = glob($dbConfig['epub_path'] . DIRECTORY_SEPARATOR . '*.epub');
|
|
|
|
foreach ($fileList as $fileName) {
|
|
|
|
$db->AddEpub($fileName);
|
2013-09-25 04:03:52 +03:00
|
|
|
}
|
|
|
|
}
|
2013-09-25 09:28:20 +03:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
$gErrorArray[$fileName] = $e->getMessage();
|
2013-09-25 04:03:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|