Fix the redirect in case of multiple databases and if the failing database is not the first. re #116

This commit is contained in:
Sébastien Lucas 2013-11-25 21:35:02 +01:00
parent 1051af4a61
commit 990976986e

View file

@ -23,16 +23,27 @@
exit (); exit ();
} }
// Access the database ASAP to be sure it's readable, redirect if that's not the case.
// It has to be done before any header is sent.
$test = Base::getDb ();
header ("Content-Type:text/html;charset=utf-8");
$page = getURLParam ("page", Base::PAGE_INDEX); $page = getURLParam ("page", Base::PAGE_INDEX);
$query = getURLParam ("query"); $query = getURLParam ("query");
$qid = getURLParam ("id"); $qid = getURLParam ("id");
$n = getURLParam ("n", "1"); $n = getURLParam ("n", "1");
$database = GetUrlParam (DB); $database = GetUrlParam (DB);
// Access the database ASAP to be sure it's readable, redirect if that's not the case.
// It has to be done before any header is sent.
if (is_array ($config['calibre_directory']) && is_null ($database)) {
$i = 0;
foreach (array_keys ($config['calibre_directory']) as $key) {
$test = Base::getDb ($i);
Base::clearDb ();
$i++;
}
} else {
$test = Base::getDb ();
}
header ("Content-Type:text/html;charset=utf-8");
?><!DOCTYPE html> ?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>