Improved if conditions
This commit is contained in:
parent
34839d3805
commit
64e0d66d83
@ -37,7 +37,7 @@ final class Album {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -191,9 +191,10 @@ final class Album {
|
||||
|
||||
// Execute query
|
||||
$albums = Database::get()->query($query);
|
||||
if (!$albums) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not get all albums (' . Database::get()->error . ')');
|
||||
exit('Error: ' . Database::get()->error);
|
||||
|
||||
if ($albums===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not get albums from database (' . Database::get()->error . ')');
|
||||
exit('Error: Could not get albums from database!');
|
||||
}
|
||||
|
||||
// For each album
|
||||
@ -210,6 +211,11 @@ final class Album {
|
||||
$query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
|
||||
$thumbs = Database::get()->query($query);
|
||||
|
||||
if ($thumbs===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not get thumbs of album from database (' . Database::get()->error . ')');
|
||||
exit('Error: Could not get thumbs of album from database!');
|
||||
}
|
||||
|
||||
// For each thumb
|
||||
$k = 0;
|
||||
while ($thumb = $thumbs->fetch_object()) {
|
||||
@ -368,8 +374,7 @@ final class Album {
|
||||
$query = Database::prepare(Database::get(), "SELECT title FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
|
||||
$album = Database::get()->query($query);
|
||||
|
||||
// Error in database query
|
||||
if (!$album) {
|
||||
if ($album===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -484,7 +489,7 @@ final class Album {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -507,7 +512,7 @@ final class Album {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -577,7 +582,7 @@ final class Album {
|
||||
// Set public
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET public = '?', visible = '?', downloadable = '?', password = NULL WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $public, $visible, $downloadable, $this->albumIDs));
|
||||
$result = Database::get()->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -586,7 +591,7 @@ final class Album {
|
||||
if ($public===1) {
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET public = 0 WHERE album IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
|
||||
$result = Database::get()->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -633,7 +638,7 @@ final class Album {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -681,7 +686,7 @@ final class Album {
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET album = ? WHERE album IN (?)", array(LYCHEE_TABLE_PHOTOS, $albumID, $this->albumIDs));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -696,7 +701,7 @@ final class Album {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -735,7 +740,7 @@ final class Album {
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if ($error) return false;
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
|
@ -99,13 +99,13 @@ final class Database {
|
||||
Validator::required(isset($connection), __METHOD__);
|
||||
|
||||
// Check if database exists
|
||||
if ($connection->select_db($name)) return true;
|
||||
if ($connection->select_db($name)===true) return true;
|
||||
|
||||
// Create database
|
||||
$query = self::prepare($connection, 'CREATE DATABASE IF NOT EXISTS ?', array($name));
|
||||
$result = $connection->query($query);
|
||||
|
||||
if (!$connection->select_db($name)) return false;
|
||||
if ($connection->select_db($name)===false) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -120,37 +120,41 @@ final class Database {
|
||||
if ($connection->query($query)) return true;
|
||||
|
||||
// Create log
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_LOG));
|
||||
if (!$connection->query($exist)) {
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_LOG));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
|
||||
// Read file
|
||||
$file = __DIR__ . '/../database/log_table.sql';
|
||||
$query = @file_get_contents($file);
|
||||
|
||||
if (!isset($query)||$query===false) return false;
|
||||
if ($query===false) return false;
|
||||
|
||||
// Create table
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_LOG));
|
||||
if (!$connection->query($query)) return false;
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_LOG));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) return false;
|
||||
|
||||
}
|
||||
|
||||
// Create settings
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_SETTINGS));
|
||||
if (!$connection->query($exist)) {
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
|
||||
// Read file
|
||||
$file = __DIR__ . '/../database/settings_table.sql';
|
||||
$query = @file_get_contents($file);
|
||||
|
||||
if (!isset($query)||$query===false) {
|
||||
if ($query===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not load query for lychee_settings');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create table
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_SETTINGS));
|
||||
if (!$connection->query($query)) {
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, $connection->error);
|
||||
return false;
|
||||
}
|
||||
@ -159,14 +163,15 @@ final class Database {
|
||||
$file = __DIR__ . '/../database/settings_content.sql';
|
||||
$query = @file_get_contents($file);
|
||||
|
||||
if (!isset($query)||$query===false) {
|
||||
if ($query===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not load content-query for lychee_settings');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add content
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_SETTINGS));
|
||||
if (!$connection->query($query)) {
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, $connection->error);
|
||||
return false;
|
||||
}
|
||||
@ -174,7 +179,8 @@ final class Database {
|
||||
// Generate identifier
|
||||
$identifier = md5(microtime(true));
|
||||
$query = self::prepare($connection, "UPDATE `?` SET `value` = '?' WHERE `key` = 'identifier' LIMIT 1", array(LYCHEE_TABLE_SETTINGS, $identifier));
|
||||
if (!$connection->query($query)) {
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, $connection->error);
|
||||
return false;
|
||||
}
|
||||
@ -182,21 +188,23 @@ final class Database {
|
||||
}
|
||||
|
||||
// Create albums
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_ALBUMS));
|
||||
if (!$connection->query($exist)) {
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_ALBUMS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
|
||||
// Read file
|
||||
$file = __DIR__ . '/../database/albums_table.sql';
|
||||
$query = @file_get_contents($file);
|
||||
|
||||
if (!isset($query)||$query===false) {
|
||||
if ($query===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not load query for lychee_albums');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create table
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_ALBUMS));
|
||||
if (!$connection->query($query)) {
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_ALBUMS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, $connection->error);
|
||||
return false;
|
||||
}
|
||||
@ -204,21 +212,23 @@ final class Database {
|
||||
}
|
||||
|
||||
// Create photos
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_PHOTOS));
|
||||
if (!$connection->query($exist)) {
|
||||
$exist = self::prepare($connection, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_PHOTOS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
|
||||
// Read file
|
||||
$file = __DIR__ . '/../database/photos_table.sql';
|
||||
$query = @file_get_contents($file);
|
||||
|
||||
if (!isset($query)||$query===false) {
|
||||
if ($query===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not load query for lychee_photos');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create table
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_PHOTOS));
|
||||
if (!$connection->query($query)) {
|
||||
$query = self::prepare($connection, $query, array(LYCHEE_TABLE_PHOTOS));
|
||||
$result = $connection->query($exist);
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, $connection->error);
|
||||
return false;
|
||||
}
|
||||
@ -261,7 +271,7 @@ final class Database {
|
||||
|
||||
$query = self::prepare($connection, "UPDATE ? SET value = '?' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS, $version));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ final class Log {
|
||||
$query = Database::prepare(Database::get(), "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if (!$result) return false;
|
||||
if ($result===false) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ final class Photo {
|
||||
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum, medium) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
if ($returnOnError===true) return false;
|
||||
exit('Error: Could not save photo in database!');
|
||||
@ -260,8 +260,8 @@ final class Photo {
|
||||
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if (!$result) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not check for existing photos with the same checksum');
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, 'Could not check for existing photos with the same checksum (' . Database::get()->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -800,14 +800,15 @@ final class Photo {
|
||||
// Get photo
|
||||
$query = Database::prepare(Database::get(), "SELECT title, url FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
$photos = Database::get()->query($query);
|
||||
$photo = $photos->fetch_object();
|
||||
|
||||
// Error in database query
|
||||
if (!$photos) {
|
||||
if ($photos===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get photo object
|
||||
$photo = $photos->fetch_object();
|
||||
|
||||
// Photo not found
|
||||
if ($photo===null) {
|
||||
Log::error(__METHOD__, __LINE__, 'Album not found. Cannot start download.');
|
||||
@ -870,7 +871,7 @@ final class Photo {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -900,7 +901,7 @@ final class Photo {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -935,9 +936,10 @@ final class Photo {
|
||||
$star = ($photo->star==0 ? 1 : 0);
|
||||
|
||||
// Set star
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET star = '?' WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $star, $photo->id));
|
||||
$star = Database::get()->query($query);
|
||||
if (!$star) $error = true;
|
||||
$query = Database::prepare(Database::get(), "UPDATE ? SET star = '?' WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $star, $photo->id));
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if ($result===false) $error = true;
|
||||
|
||||
}
|
||||
|
||||
@ -1028,7 +1030,7 @@ final class Photo {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1056,7 +1058,7 @@ final class Photo {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1090,7 +1092,7 @@ final class Photo {
|
||||
// Call plugins
|
||||
Plugins::get()->activate(__METHOD__, 1, func_get_args());
|
||||
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1114,7 +1116,8 @@ final class Photo {
|
||||
// Get photos
|
||||
$query = Database::prepare(Database::get(), "SELECT id, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
$photos = Database::get()->query($query);
|
||||
if (!$photos) {
|
||||
|
||||
if ($photos===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1127,10 +1130,11 @@ final class Photo {
|
||||
while(strlen($id)<14) $id .= 0;
|
||||
|
||||
// Duplicate entry
|
||||
$values = array(LYCHEE_TABLE_PHOTOS, $id, LYCHEE_TABLE_PHOTOS, $photo->id);
|
||||
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum) SELECT '?' AS id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum FROM ? WHERE id = '?'", $values);
|
||||
$duplicate = Database::get()->query($query);
|
||||
if (!$duplicate) {
|
||||
$values = array(LYCHEE_TABLE_PHOTOS, $id, LYCHEE_TABLE_PHOTOS, $photo->id);
|
||||
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum) SELECT '?' AS id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum FROM ? WHERE id = '?'", $values);
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1157,7 +1161,8 @@ final class Photo {
|
||||
// Get photos
|
||||
$query = Database::prepare(Database::get(), "SELECT id, url, thumbUrl, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
|
||||
$photos = Database::get()->query($query);
|
||||
if (!$photos) {
|
||||
|
||||
if ($photos===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
@ -1201,8 +1206,9 @@ final class Photo {
|
||||
|
||||
// Delete db entry
|
||||
$query = Database::prepare(Database::get(), "DELETE FROM ? WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $photo->id));
|
||||
$delete = Database::get()->query($query);
|
||||
if (!$delete) {
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if ($result===false) {
|
||||
Log::error(__METHOD__, __LINE__, Database::get()->error);
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ final class Settings {
|
||||
|
||||
$result = Database::get()->query($query);
|
||||
|
||||
if (!$result) return false;
|
||||
if ($result===false) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -9,11 +9,12 @@ use Lychee\Modules\Database;
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
|
||||
// Add medium to photos
|
||||
$query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
|
||||
if (!$connection->query($query)) {
|
||||
$query = Database::prepare($connection, "SELECT `medium` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
|
||||
$result = $connection->query($query);
|
||||
if ($result===false) {
|
||||
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `medium` TINYINT(1) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_PHOTOS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_020700', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
@ -33,7 +34,7 @@ $result = $connection->query($query);
|
||||
if ($result->num_rows===0) {
|
||||
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('medium', '1')", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_020700', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
@ -10,24 +10,24 @@ if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
|
||||
// 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));
|
||||
$resetUsername = $connection->query($query);
|
||||
if (!$resetUsername) {
|
||||
$query = Database::prepare($connection, "UPDATE `?` SET `value` = '' WHERE `key` = 'username' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if ($result===false) {
|
||||
Log::error('update_030000', __LINE__, 'Could not reset username (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
$query = Database::prepare($connection, "UPDATE `?` SET `value` = '' WHERE `key` = 'password' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
||||
$resetPassword = $connection->query($query);
|
||||
if (!$resetPassword) {
|
||||
$query = Database::prepare($connection, "UPDATE `?` SET `value` = '' WHERE `key` = 'password' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if ($result===false) {
|
||||
Log::error('update_030000', __LINE__, 'Could not reset password (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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));
|
||||
$resetPublic = $connection->query($query);
|
||||
if (!$resetPublic) {
|
||||
$query = Database::prepare($connection, "UPDATE `?` SET `public` = 0, `password` = NULL", array(LYCHEE_TABLE_ALBUMS));
|
||||
$result = $connection->query($query);
|
||||
if ($result===false) {
|
||||
Log::error('update_030000', __LINE__, 'Could not reset public albums (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
// Change length of photo title
|
||||
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
@ -19,7 +19,7 @@ if (!$result) {
|
||||
// Change length of album title
|
||||
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `title` `title` VARCHAR( 100 ) NOT NULL DEFAULT ''", array(LYCHEE_TABLE_ALBUMS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
@ -30,7 +30,7 @@ $result = $connection->query($query);
|
||||
if ($result->num_rows===0) {
|
||||
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('sortingAlbums', 'ORDER BY id DESC')", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
@ -39,7 +39,7 @@ if ($result->num_rows===0) {
|
||||
// Rename sorting to sortingPhotos
|
||||
$query = Database::prepare($connection, "UPDATE ? SET `key` = 'sortingPhotos' WHERE `key` = 'sorting' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
@ -51,7 +51,7 @@ if ($result->num_rows===0) {
|
||||
$identifier = md5(microtime(true));
|
||||
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('identifier', '?')", array(LYCHEE_TABLE_SETTINGS, $identifier));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030001', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ $result = $connection->query($query);
|
||||
if ($result->num_rows===0) {
|
||||
$query = Database::prepare($connection, "INSERT INTO `?` (`key`, `value`) VALUES ('skipDuplicates', '0')", array(LYCHEE_TABLE_SETTINGS));
|
||||
$result = $connection->query($query);
|
||||
if (!$result) {
|
||||
if ($result===false) {
|
||||
Log::error('update_030003', __LINE__, 'Could not update database (' . $connection->error . ')');
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user