update_020700.php 1.4 KB

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