diff --git a/index.php b/index.php index 8bc5e93..5fc64c7 100644 --- a/index.php +++ b/index.php @@ -23,16 +23,27 @@ 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); $query = getURLParam ("query"); $qid = getURLParam ("id"); $n = getURLParam ("n", "1"); $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"); ?>