Add a configuration check page (checkconfig.php)

If opening the database is impossible redirect to the configuration check.

fix #7
This commit is contained in:
Sébastien Lucas 2013-01-05 07:35:19 +01:00
parent 0ba361e434
commit 5105fa0a69
2 changed files with 97 additions and 3 deletions

View file

@ -439,14 +439,19 @@ abstract class Base
private static $db = NULL;
public static function getDbFileName () {
global $config;
return $config['calibre_directory'] .'metadata.db';
}
public static function getDb () {
global $config;
if (is_null (self::$db)) {
try {
self::$db = new PDO('sqlite:'. $config['calibre_directory'] .'metadata.db');
self::$db = new PDO('sqlite:'. self::getDbFileName ());
} catch (Exception $e) {
echo $e;
die($e);
header("location: checkconfig.php");
exit();
}
}
return self::$db;