2014-08-27 19:17:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
###
|
|
|
|
# @name Update to version 2.6.2
|
2015-02-01 21:08:37 +00:00
|
|
|
# @copyright 2015 by Tobias Reich
|
2014-08-27 19:17:05 +00:00
|
|
|
###
|
|
|
|
|
2015-02-08 14:29:06 +00:00
|
|
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
|
|
|
|
2014-08-27 19:17:05 +00:00
|
|
|
# Add a checksum
|
2014-08-30 05:05:26 +00:00
|
|
|
$query = Database::prepare($database, "SELECT `id`, `url` FROM `?` WHERE `checksum` IS NULL", array(LYCHEE_TABLE_PHOTOS));
|
2014-08-29 21:49:52 +00:00
|
|
|
$result = $database->query($query);
|
2014-08-27 19:17:05 +00:00
|
|
|
if (!$result) {
|
|
|
|
Log::error($database, 'update_020602', __LINE__, 'Could not find photos without checksum (' . $database->error . ')');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while ($photo = $result->fetch_object()) {
|
|
|
|
$checksum = sha1_file(LYCHEE_UPLOADS_BIG . $photo->url);
|
|
|
|
if ($checksum!==false) {
|
2014-08-30 05:05:26 +00:00
|
|
|
$query = Database::prepare($database, "UPDATE `?` SET `checksum` = '?' WHERE `id` = '?'", array(LYCHEE_TABLE_PHOTOS, $checksum, $photo->id));
|
2014-08-29 21:49:52 +00:00
|
|
|
$setChecksum = $database->query($query);
|
2014-08-27 19:17:05 +00:00
|
|
|
if (!$setChecksum) {
|
|
|
|
Log::error($database, 'update_020602', __LINE__, 'Could not update checksum (' . $database->error . ')');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Log::error($database, 'update_020602', __LINE__, 'Could not calculate checksum for photo with id ' . $photo->id);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-29 22:11:26 +00:00
|
|
|
# Add Imagick
|
2014-08-30 05:05:26 +00:00
|
|
|
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'imagick' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
2014-08-29 22:11:26 +00:00
|
|
|
$result = $database->query($query);
|
|
|
|
if ($result->num_rows===0) {
|
2014-08-30 05:05:26 +00:00
|
|
|
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('imagick', '1')", array(LYCHEE_TABLE_SETTINGS));
|
2014-08-29 22:11:26 +00:00
|
|
|
$result = $database->query($query);
|
|
|
|
if (!$result) {
|
2014-10-11 14:04:43 +00:00
|
|
|
Log::error($database, 'update_020602', __LINE__, 'Could not update database (' . $database->error . ')');
|
2014-08-29 22:11:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-27 19:17:05 +00:00
|
|
|
# Set version
|
2014-08-30 17:25:01 +00:00
|
|
|
if (Database::setVersion($database, '020602')===false) return false;
|
2014-08-27 19:17:05 +00:00
|
|
|
|
|
|
|
?>
|