db ();
$fts = join (" ", $filetypes);
if (strlen ($fts)) {
$fts = ", filetypes: $fts";
}
$ls = join (" ", $langs);
if (strlen ($ls)) {
$ls = ", languages: $ls";
}
$caption = "All Files (offset: $offset$fts$ls)";
echo <<< EOT
$caption - Project Gutenberg
$caption
EOT;
$where_filetypes = join ("','", $filetypes);
if (strlen ($where_filetypes)) {
$where_filetypes = " and fk_filetypes in ('$where_filetypes') ";
}
$where_languages = join ("','", $langs);
if (strlen ($where_languages)) {
$where_languages = " and fk_langs in ('$where_languages') ";
}
$db->exec ($sql = "select pk, files.fk_books, fk_langs, filename
from files left join mn_books_langs
on mn_books_langs.fk_books = files.fk_books
where (fk_compressions = 'zip' or fk_filetypes in
('epub.images', 'epub.noimages', 'kindle.images', 'kindle.noimages', 'mp3'))
$where_filetypes
$where_languages
and diskstatus != 5 and obsoleted = 0
and pk > $offset order by pk limit $limit;");
// p ($sql);
if ($db->FirstRow ()) {
do {
$filename = $db->get ("filename", SQLCHAR);
$offset = $db->get ("pk", SQLINT);
$fk_books = $db->get ("fk_books", SQLINT);
/*
$dir = etext2dir ($fk_books);
if (preg_match ("!^$dir!", $filename)) {
$symlink = preg_replace ("!^$dir!", "$config->files/$fk_books/", $filename);
} elseif (strncmp ($filename, "cache/", 6) == 0) {
$symlink = "/$filename";
} else {
$symlink = "$config->downloadbase/$filename";
} */
if (strpos ($filename, '/epub/') !== false) {
// gbn: For change to aleph.gutenberg.org:
// $filename = str_replace ('/epub/', '/generated/', $filename);
$symlink = $epub_mirror . $filename;
} else {
$symlink = $mirror . $filename;
}
p ("$symlink");
} while ($db->NextRow ());
$url = "harvest?offset=$offset";
foreach ($filetypes as $filetype) {
$url .= "&filetypes[]=$filetype";
}
foreach ($langs as $l) {
$url .= "&langs[]=$l";
}
p ("Next Page");
} else {
p ("No more files.");
}
echo (" \n\n");
?>