Define prefix after config-file has been loaded (#38 #214 #196)

This commit is contained in:
Tobias Reich 2014-08-29 23:07:54 +02:00
parent bef84572fb
commit af37f5c138
2 changed files with 20 additions and 9 deletions

View File

@ -39,6 +39,9 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
} }
# Define the table prefix
defineTablePrefix($dbTablePrefix);
# Connect to database # Connect to database
$database = Database::connect($dbHost, $dbUser, $dbPassword, $dbName); $database = Database::connect($dbHost, $dbUser, $dbPassword, $dbName);

View File

@ -26,15 +26,23 @@ define('LYCHEE_CONFIG_FILE', LYCHEE_DATA . 'config.php');
define('LYCHEE_URL_UPLOADS_THUMB', 'uploads/thumb/'); define('LYCHEE_URL_UPLOADS_THUMB', 'uploads/thumb/');
define('LYCHEE_URL_UPLOADS_BIG', 'uploads/big/'); define('LYCHEE_URL_UPLOADS_BIG', 'uploads/big/');
# Parse table prefix function defineTablePrefix($dbTablePrefix) {
# Old users do not have the table prefix stored in their config-file
if (!isset($dbTablePrefix)) $dbTablePrefix = '';
else $dbTablePrefix .= '_';
# Define tables # This part is wrapped into a function, because it needs to be called
define('LYCHEE_TABLE_ALBUMS', $dbTablePrefix . 'lychee_albums'); # after the config-file has been loaded. Other defines are also available
define('LYCHEE_TABLE_LOG', $dbTablePrefix . 'lychee_log'); # before the config-file has been loaded.
define('LYCHEE_TABLE_PHOTOS', $dbTablePrefix . 'lychee_photos');
define('LYCHEE_TABLE_SETTINGS', $dbTablePrefix . 'lychee_settings'); # Parse table prefix
# Old users do not have the table prefix stored in their config-file
if (!isset($dbTablePrefix)) $dbTablePrefix = '';
else $dbTablePrefix .= '_';
# Define tables
define('LYCHEE_TABLE_ALBUMS', $dbTablePrefix . 'lychee_albums');
define('LYCHEE_TABLE_LOG', $dbTablePrefix . 'lychee_log');
define('LYCHEE_TABLE_PHOTOS', $dbTablePrefix . 'lychee_photos');
define('LYCHEE_TABLE_SETTINGS', $dbTablePrefix . 'lychee_settings');
}
?> ?>