diff --git a/php/database/update_020700.php b/php/database/update_020700.php index eed5fd7..5575d46 100644 --- a/php/database/update_020700.php +++ b/php/database/update_020700.php @@ -5,8 +5,7 @@ */ use Lychee\Modules\Database; - -if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); +use Lychee\Modules\Response; // Add medium to photos $query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS)); @@ -17,7 +16,7 @@ if ($result===false) { $query = Database::prepare($connection, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS)); $result = Database::execute($connection, $query, 'update_020700', __LINE__); - if ($result===false) return false; + if ($result===false) Response::error('Could not add medium-field to database!'); } @@ -27,11 +26,12 @@ if (is_dir(LYCHEE_UPLOADS_MEDIUM)===false) { // Only create the folder when it is missing if (@mkdir(LYCHEE_UPLOADS_MEDIUM)===false) { Log::error($connection, 'update_020700', __LINE__, 'Could not create medium-folder'); + Response::error('Could not create medium-folder!'); } } // Set version -if (Database::setVersion($connection, '020700')===false) return false; +if (Database::setVersion($connection, '020700')===false) Response::error('Could not update version of database!'); ?> \ No newline at end of file diff --git a/php/database/update_030000.php b/php/database/update_030000.php index 3557be3..1832627 100644 --- a/php/database/update_030000.php +++ b/php/database/update_030000.php @@ -5,29 +5,28 @@ */ use Lychee\Modules\Database; - -if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); +use Lychee\Modules\Response; // Remove login // Login now saved as crypt without md5. Legacy code has been removed. $query = Database::prepare($connection, "UPDATE `?` SET `value` = '' WHERE `key` = 'username' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030000', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not reset username in database!'); $query = Database::prepare($connection, "UPDATE `?` SET `value` = '' WHERE `key` = 'password' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030000', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not reset password in database!'); // Make public albums private and reset password // Password now saved as crypt without md5. Legacy code has been removed. $query = Database::prepare($connection, "UPDATE `?` SET `public` = 0, `password` = NULL", array(LYCHEE_TABLE_ALBUMS)); $result = Database::execute($connection, $query, 'update_030000', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not reset publicity of photos in database!'); // Set version -if (Database::setVersion($connection, '030000')===false) return false; +if (Database::setVersion($connection, '030000')===false) Response::error('Could not update version of database!'); ?> \ No newline at end of file diff --git a/php/database/update_030001.php b/php/database/update_030001.php index 9193fef..b3a0e25 100644 --- a/php/database/update_030001.php +++ b/php/database/update_030001.php @@ -5,33 +5,32 @@ */ use Lychee\Modules\Database; - -if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); +use Lychee\Modules\Response; // Change length of photo title $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not change length of photo title in database!'); // Change length of album title $query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_ALBUMS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not change length of album title in database!'); // Add album sorting to settings $query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'sortingAlbums' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not get current album sorting from database!'); if ($result->num_rows===0) { $query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('sortingAlbums', 'ORDER BY id DESC')", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); - if ($result===false) return false; + if ($result===false) Response::error('Could not add album sorting to database!'); } @@ -39,13 +38,13 @@ if ($result->num_rows===0) { $query = Database::prepare($connection, "UPDATE ? SET `key` = 'sortingPhotos' WHERE `key` = 'sorting' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not rename photo sorting row in database!'); // Add identifier to settings $query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'identifier' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not get current identifier from database!'); if ($result->num_rows===0) { @@ -53,11 +52,11 @@ if ($result->num_rows===0) { $query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('identifier', '?')", array(LYCHEE_TABLE_SETTINGS, $identifier)); $result = Database::execute($connection, $query, 'update_030001', __LINE__); - if ($result===false) return false; + if ($result===false) Response::error('Could not add identifier to database!'); } // Set version -if (Database::setVersion($connection, '030001')===false) return false; +if (Database::setVersion($connection, '030001')===false) Response::error('Could not update version of database!'); ?> \ No newline at end of file diff --git a/php/database/update_030003.php b/php/database/update_030003.php index 95876d1..4e73862 100644 --- a/php/database/update_030003.php +++ b/php/database/update_030003.php @@ -5,25 +5,24 @@ */ use Lychee\Modules\Database; - -if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!'); +use Lychee\Modules\Response; // Add skipDuplicates to settings $query = Database::prepare($connection, "SELECT `key` FROM `?` WHERE `key` = 'skipDuplicates' LIMIT 1", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030003', __LINE__); -if ($result===false) return false; +if ($result===false) Response::error('Could not get current skipDuplicates from database!'); if ($result->num_rows===0) { $query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('skipDuplicates', '0')", array(LYCHEE_TABLE_SETTINGS)); $result = Database::execute($connection, $query, 'update_030003', __LINE__); - if ($result===false) return false; + if ($result===false) Response::error('Could not add skipDuplicates to database!'); } // Set version -if (Database::setVersion($connection, '030003')===false) return false; +if (Database::setVersion($connection, '030003')===false) Response::error('Could not update version of database!'); ?> \ No newline at end of file