Merge branch 'master' of github.com:seblucas/cops
This commit is contained in:
commit
62a7034ab8
4 changed files with 41 additions and 25 deletions
14
base.php
14
base.php
|
@ -1201,6 +1201,9 @@ abstract class Base
|
|||
global $config;
|
||||
if (self::isMultipleDatabaseEnabled ()) {
|
||||
if (is_null ($database)) $database = GetUrlParam (DB, 0);
|
||||
if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
|
||||
return self::error ($database);
|
||||
}
|
||||
$array = array_keys ($config['calibre_directory']);
|
||||
return $array[$database];
|
||||
}
|
||||
|
@ -1211,6 +1214,9 @@ abstract class Base
|
|||
global $config;
|
||||
if (self::isMultipleDatabaseEnabled ()) {
|
||||
if (is_null ($database)) $database = GetUrlParam (DB, 0);
|
||||
if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
|
||||
return self::error ($database);
|
||||
}
|
||||
$array = array_values ($config['calibre_directory']);
|
||||
return $array[$database];
|
||||
}
|
||||
|
@ -1222,11 +1228,11 @@ abstract class Base
|
|||
return self::getDbDirectory ($database) .'metadata.db';
|
||||
}
|
||||
|
||||
private static function error () {
|
||||
private static function error ($database) {
|
||||
if (php_sapi_name() != "cli") {
|
||||
header("location: checkconfig.php?err=1");
|
||||
}
|
||||
throw new Exception('Database not found.');
|
||||
throw new Exception("Database <{$database}> not found.");
|
||||
}
|
||||
|
||||
public static function getDb ($database = NULL) {
|
||||
|
@ -1238,10 +1244,10 @@ abstract class Base
|
|||
self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1);
|
||||
}
|
||||
} else {
|
||||
self::error ();
|
||||
self::error ($database);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
self::error ();
|
||||
self::error ($database);
|
||||
}
|
||||
}
|
||||
return self::$db;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue