update_020700.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. ###
  3. # @name Update to version 2.7.0
  4. # @copyright 2015 by Tobias Reich
  5. ###
  6. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  7. # Add medium to photos
  8. $query = Database::prepare($database, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
  9. if (!$database->query($query)) {
  10. $query = Database::prepare($database, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
  11. $result = $database->query($query);
  12. if (!$result) {
  13. Log::error($database, 'update_020700', __LINE__, 'Could not update database (' . $database->error . ')');
  14. return false;
  15. }
  16. }
  17. # Create medium folder
  18. if (is_dir(LYCHEE_UPLOADS_MEDIUM)===false) {
  19. # Only create the folder when it is missing
  20. if (@mkdir(LYCHEE_UPLOADS_MEDIUM)===false)
  21. Log::error($database, 'update_020700', __LINE__, 'Could not create medium-folder');
  22. }
  23. # Add medium to settings
  24. $query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'medium' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
  25. $result = $database->query($query);
  26. if ($result->num_rows===0) {
  27. $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('medium', '1')", array(LYCHEE_TABLE_SETTINGS));
  28. $result = $database->query($query);
  29. if (!$result) {
  30. Log::error($database, 'update_020700', __LINE__, 'Could not update database (' . $database->error . ')');
  31. return false;
  32. }
  33. }
  34. # Set version
  35. if (Database::setVersion($database, '020700')===false) return false;
  36. ?>