Merge pull request #221 from cternes/array-old-syntax

Arrays old php syntax
This commit is contained in:
Tobias Reich 2014-08-30 10:34:30 +02:00
commit d0ba19e622
15 changed files with 125 additions and 123 deletions

View File

@ -6,9 +6,9 @@
# @copyright 2014 by Tobias Reich
###
$query = Database::prepare($database, "SELECT `tags` FROM `?` LIMIT 1", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `tags` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if(!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `tags` VARCHAR( 1000 ) NULL DEFAULT ''", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
@ -16,10 +16,10 @@ if(!$database->query($query)) {
}
}
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'dropboxKey' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'dropboxKey' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('dropboxKey', '')", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('dropboxKey', '')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
@ -27,17 +27,17 @@ if ($result->num_rows===0) {
}
}
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'version' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'version' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('version', '020100')", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('version', '020100')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
} else {
$query = Database::prepare($database, "UPDATE ? SET value = '020100' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020100' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -6,14 +6,14 @@
# @copyright 2014 by Tobias Reich
###
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `value` `value` VARCHAR( 200 ) NULL DEFAULT ''", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `value` `value` VARCHAR( 200 ) NULL DEFAULT ''", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020101', __LINE__, 'Could not update database (' . $database->error . ')');
return false;
}
$query = Database::prepare($database, "UPDATE ? SET value = '020101' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020101' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020101', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -6,9 +6,9 @@
# @copyright 2014 by Tobias Reich
###
$query = Database::prepare($database, "SELECT `visible` FROM `?` LIMIT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "SELECT `visible` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `visible` TINYINT(1) NOT NULL DEFAULT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `visible` TINYINT(1) NOT NULL DEFAULT 1", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020200', __LINE__, 'Could not update database (' . $database->error . ')');
@ -16,7 +16,7 @@ if (!$database->query($query)) {
}
}
$query = Database::prepare($database, "UPDATE ? SET value = '020200' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020200' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020200', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -7,10 +7,10 @@
###
# Add `plugins`
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'plugins' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'plugins' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('plugins', '')", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('plugins', '')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -19,9 +19,9 @@ if ($result->num_rows===0) {
}
# Add `takestamp`
$query = Database::prepare($database, "SELECT `takestamp` FROM `?` LIMIT 1;", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `takestamp` FROM `?` LIMIT 1;", array(LYCHEE_TABLE_PHOTOS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `takestamp` INT(11) DEFAULT NULL", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `takestamp` INT(11) DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -30,9 +30,9 @@ if (!$database->query($query)) {
}
# Convert to `takestamp`
$query = Database::prepare($database, "SELECT `takedate`, `taketime` FROM `?` LIMIT 1;", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `takedate`, `taketime` FROM `?` LIMIT 1;", array(LYCHEE_TABLE_PHOTOS));
if ($database->query($query)) {
$query = Database::prepare($database, "SELECT `id`, `takedate`, `taketime` FROM `?` WHERE `takedate` <> '' AND `taketime` <> ''", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `id`, `takedate`, `taketime` FROM `?` WHERE `takedate` <> '' AND `taketime` <> ''", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -40,35 +40,35 @@ if ($database->query($query)) {
}
while ($photo = $result->fetch_object()) {
$takestamp = strtotime($photo->takedate . $photo->taketime);
$query = Database::prepare($database, "UPDATE `?` SET `takestamp` = '?' WHERE `id` = '?'", [LYCHEE_TABLE_PHOTOS, $takestamp, $photo->id]);
$query = Database::prepare($database, "UPDATE `?` SET `takestamp` = '?' WHERE `id` = '?'", array(LYCHEE_TABLE_PHOTOS, $takestamp, $photo->id));
$database->query($query);
}
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `takedate`;", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `takedate`;", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `taketime`", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `taketime`", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
}
# Remove `import_name`
$query = Database::prepare($database, "SELECT `import_name` FROM `?` LIMIT 1", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `import_name` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if ($database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `import_name`", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `import_name`", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
}
# Remove `sysdate` and `systime`
$query = Database::prepare($database, "SELECT `sysdate`, `systime` FROM `?` LIMIT 1", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `sysdate`, `systime` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if ($database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `sysdate`", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `sysdate`", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `systime`", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `systime`", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
}
# Add `sysstamp`
$query = Database::prepare($database, "SELECT `sysstamp` FROM `?` LIMIT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "SELECT `sysstamp` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `sysstamp` INT(11) DEFAULT NULL", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `sysstamp` INT(11) DEFAULT NULL", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -77,9 +77,9 @@ if (!$database->query($query)) {
}
# Convert to `sysstamp`
$query = Database::prepare($database, "SELECT `sysdate` FROM `?` LIMIT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "SELECT `sysdate` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if ($database->query($query)) {
$query = Database::prepare($database, "SELECT `id`, `sysdate` FROM `?`", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "SELECT `id`, `sysdate` FROM `?`", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -87,10 +87,10 @@ if ($database->query($query)) {
}
while ($album = $result->fetch_object()) {
$sysstamp = strtotime($album->sysdate);
$query = Database::prepare($database, "UPDATE `?` SET `sysstamp` = '?' WHERE `id` = '?'", [LYCHEE_TABLE_ALBUMS, $sysstamp, $album->id]);
$query = Database::prepare($database, "UPDATE `?` SET `sysstamp` = '?' WHERE `id` = '?'", array(LYCHEE_TABLE_ALBUMS, $sysstamp, $album->id));
$database->query($query);
}
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `sysdate`", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` DROP COLUMN `sysdate`", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
}
@ -102,7 +102,7 @@ if (!$result) {
}
# Set character
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -110,7 +110,7 @@ if (!$result) {
}
# Set character
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -118,7 +118,7 @@ if (!$result) {
}
# Set character
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "ALTER TABLE `?` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -126,7 +126,7 @@ if (!$result) {
}
# Set album password length to 100 (for longer hashes)
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `password` `password` VARCHAR(100)", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `password` `password` VARCHAR(100)", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -134,7 +134,7 @@ if (!$result) {
}
# Set make length to 50
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `make` `make` VARCHAR(50)", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` CHANGE `make` `make` VARCHAR(50)", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -142,7 +142,7 @@ if (!$result) {
}
# Reset sorting
$query = Database::prepare($database, "UPDATE ? SET value = 'ORDER BY takestamp DESC' WHERE `key` = 'sorting' AND `value` LIKE '%UNIX_TIMESTAMP%'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = 'ORDER BY takestamp DESC' WHERE `key` = 'sorting' AND `value` LIKE '%UNIX_TIMESTAMP%'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');
@ -150,7 +150,7 @@ if (!$result) {
}
# Set version
$query = Database::prepare($database, "UPDATE ? SET value = '020500' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020500' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020500', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -7,9 +7,9 @@
###
# Add `checksum`
$query = Database::prepare($database, "SELECT `checksum` FROM `?` LIMIT 1", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `checksum` FROM `?` LIMIT 1", array(LYCHEE_TABLE_PHOTOS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `checksum` VARCHAR(100) DEFAULT NULL", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `checksum` VARCHAR(100) DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020505', __LINE__, 'Could not update database (' . $database->error . ')');
@ -18,7 +18,7 @@ if (!$database->query($query)) {
}
# Set version
$query = Database::prepare($database, "UPDATE ? SET value = '020505' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020505' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020505', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -7,9 +7,9 @@
###
# Add `downloadable`
$query = Database::prepare($database, "SELECT `downloadable` FROM `?` LIMIT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "SELECT `downloadable` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if (!$database->query($query)) {
$query = Database::prepare($database, "ALTER TABLE `?` ADD `downloadable` TINYINT(1) NOT NULL DEFAULT 1", [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, "ALTER TABLE `?` ADD `downloadable` TINYINT(1) NOT NULL DEFAULT 1", array(LYCHEE_TABLE_ALBUMS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020601', __LINE__, 'Could not update database (' . $database->error . ')');
@ -18,7 +18,7 @@ if (!$database->query($query)) {
}
# Set version
$query = Database::prepare($database, "UPDATE ? SET value = '020601' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020601' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020601', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -7,7 +7,7 @@
###
# Add a checksum
$query = Database::prepare($database, "SELECT `id`, `url` FROM `?` WHERE `checksum` IS NULL", [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, "SELECT `id`, `url` FROM `?` WHERE `checksum` IS NULL", array(LYCHEE_TABLE_PHOTOS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020602', __LINE__, 'Could not find photos without checksum (' . $database->error . ')');
@ -16,7 +16,7 @@ if (!$result) {
while ($photo = $result->fetch_object()) {
$checksum = sha1_file(LYCHEE_UPLOADS_BIG . $photo->url);
if ($checksum!==false) {
$query = Database::prepare($database, "UPDATE `?` SET `checksum` = '?' WHERE `id` = '?'", [LYCHEE_TABLE_PHOTOS, $checksum, $photo->id]);
$query = Database::prepare($database, "UPDATE `?` SET `checksum` = '?' WHERE `id` = '?'", array(LYCHEE_TABLE_PHOTOS, $checksum, $photo->id));
$setChecksum = $database->query($query);
if (!$setChecksum) {
Log::error($database, 'update_020602', __LINE__, 'Could not update checksum (' . $database->error . ')');
@ -29,10 +29,10 @@ while ($photo = $result->fetch_object()) {
}
# Add Imagick
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'imagick' LIMIT 1", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "SELECT `key` FROM `?` WHERE `key` = 'imagick' LIMIT 1", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if ($result->num_rows===0) {
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('imagick', '1')", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('imagick', '1')", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020100', __LINE__, 'Could not update database (' . $database->error . ')');
@ -41,7 +41,7 @@ if ($result->num_rows===0) {
}
# Set version
$query = Database::prepare($database, "UPDATE ? SET value = '020602' WHERE `key` = 'version'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, "UPDATE ? SET value = '020602' WHERE `key` = 'version'", array(LYCHEE_TABLE_SETTINGS));
$result = $database->query($query);
if (!$result) {
Log::error($database, 'update_020602', __LINE__, 'Could not update database (' . $database->error . ')');

View File

@ -39,7 +39,7 @@ class Album extends Module {
# Database
$sysstamp = time();
$query = Database::prepare($this->database, "INSERT INTO ? (title, sysstamp, public, visible) VALUES ('?', '?', '?', '?')", [LYCHEE_TABLE_ALBUMS, $title, $sysstamp, $public, $visible]);
$query = Database::prepare($this->database, "INSERT INTO ? (title, sysstamp, public, visible) VALUES ('?', '?', '?', '?')", array(LYCHEE_TABLE_ALBUMS, $title, $sysstamp, $public, $visible));
$result = $this->database->query($query);
# Call plugins
@ -65,27 +65,27 @@ class Album extends Module {
switch ($this->albumIDs) {
case 'f': $return['public'] = false;
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE star = 1 " . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE star = 1 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
break;
case 's': $return['public'] = false;
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE public = 1 " . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE public = 1 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
break;
case 'r': $return['public'] = false;
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
break;
case '0': $return['public'] = false;
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE album = 0 " . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE album = 0 " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
break;
default: $query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
default: $query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query);
$return = $albums->fetch_assoc();
$return['sysdate'] = date('d M. Y', $return['sysstamp']);
$return['password'] = ($return['password']=='' ? false : true);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE album = '?' " . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM ? WHERE album = '?' " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
break;
}
@ -156,8 +156,8 @@ class Album extends Module {
if ($public===false) $return = $this->getSmartInfo();
# Albums query
$query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', [LYCHEE_TABLE_ALBUMS]);
if ($public===false) $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ?', [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS));
if ($public===false) $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ?', array(LYCHEE_TABLE_ALBUMS));
# Execute query
$albums = $this->database->query($query);
@ -177,7 +177,7 @@ class Album extends Module {
if (($public===true&&$album['password']===false)||($public===false)) {
# Execute query
$query = Database::prepare($this->database, "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr($this->settings['sorting'], 9) . " LIMIT 3", [LYCHEE_TABLE_PHOTOS, $album['id']]);
$query = Database::prepare($this->database, "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr($this->settings['sorting'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
$thumbs = $this->database->query($query);
# For each thumb
@ -210,7 +210,7 @@ class Album extends Module {
self::dependencies(isset($this->database, $this->settings));
# Unsorted
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
$unsorted = $this->database->query($query);
$i = 0;
while($row = $unsorted->fetch_object()) {
@ -222,7 +222,7 @@ class Album extends Module {
$return['unsortedNum'] = $unsorted->num_rows;
# Public
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
$public = $this->database->query($query);
$i = 0;
while($row2 = $public->fetch_object()) {
@ -234,7 +234,7 @@ class Album extends Module {
$return['publicNum'] = $public->num_rows;
# Starred
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
$starred = $this->database->query($query);
$i = 0;
while($row3 = $starred->fetch_object()) {
@ -246,7 +246,7 @@ class Album extends Module {
$return['starredNum'] = $starred->num_rows;
# Recent
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
$recent = $this->database->query($query);
$i = 0;
while($row3 = $recent->fetch_object()) {
@ -278,25 +278,25 @@ class Album extends Module {
# Photos query
switch($this->albumIDs) {
case 's':
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE public = 1', [LYCHEE_TABLE_PHOTOS]);
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE public = 1', array(LYCHEE_TABLE_PHOTOS));
$zipTitle = 'Public';
break;
case 'f':
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE star = 1', [LYCHEE_TABLE_PHOTOS]);
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE star = 1', array(LYCHEE_TABLE_PHOTOS));
$zipTitle = 'Starred';
break;
case 'r':
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) GROUP BY checksum', [LYCHEE_TABLE_PHOTOS]);
$photos = Database::prepare($this->database, 'SELECT title, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) GROUP BY checksum', array(LYCHEE_TABLE_PHOTOS));
$zipTitle = 'Recent';
break;
default:
$photos = Database::prepare($this->database, "SELECT title, url FROM ? WHERE album = '?'", [LYCHEE_TABLE_PHOTOS, $this->albumIDs]);
$photos = Database::prepare($this->database, "SELECT title, url FROM ? WHERE album = '?'", array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
$zipTitle = 'Unsorted';
}
# Set title
if ($this->albumIDs!=0&&is_numeric($this->albumIDs)) {
$query = Database::prepare($this->database, "SELECT title FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT title FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$album = $this->database->query($query);
$zipTitle = $album->fetch_object()->title;
}
@ -394,7 +394,7 @@ class Album extends Module {
if (strlen($title)>50) $title = substr($title, 0, 50);
# Execute query
$query = Database::prepare($this->database, "UPDATE ? SET title = '?' WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $title, $this->albumIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET title = '?' WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $title, $this->albumIDs));
$result = $this->database->query($query);
# Call plugins
@ -421,7 +421,7 @@ class Album extends Module {
if (strlen($description)>1000) $description = substr($description, 0, 1000);
# Execute query
$query = Database::prepare($this->database, "UPDATE ? SET description = '?' WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $description, $this->albumIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET description = '?' WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $description, $this->albumIDs));
$result = $this->database->query($query);
# Call plugins
@ -446,7 +446,7 @@ class Album extends Module {
if ($this->albumIDs==='0'||$this->albumIDs==='s'||$this->albumIDs==='f') return false;
# Execute query
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query);
$album = $albums->fetch_object();
@ -469,7 +469,7 @@ class Album extends Module {
if ($this->albumIDs==='0'||$this->albumIDs==='s'||$this->albumIDs==='f'||$this->albumIDs==='r') return false;
# Execute query
$query = Database::prepare($this->database, "SELECT downloadable FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT downloadable FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query);
$album = $albums->fetch_object();
@ -490,7 +490,7 @@ class Album extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get public
$query = Database::prepare($this->database, "SELECT id, public FROM ? WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT id, public FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query);
while ($album = $albums->fetch_object()) {
@ -505,7 +505,7 @@ class Album extends Module {
$downloadable = ($downloadable==='true' ? 1 : 0);
# Set public
$query = Database::prepare($this->database, "UPDATE ? SET public = '?', visible = '?', downloadable = '?', password = NULL WHERE id = '?'", [LYCHEE_TABLE_ALBUMS, $public, $visible, $downloadable, $album->id]);
$query = Database::prepare($this->database, "UPDATE ? SET public = '?', visible = '?', downloadable = '?', password = NULL WHERE id = '?'", array(LYCHEE_TABLE_ALBUMS, $public, $visible, $downloadable, $album->id));
$result = $this->database->query($query);
if (!$result) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
@ -514,7 +514,7 @@ class Album extends Module {
# Reset permissions for photos
if ($public===1) {
$query = Database::prepare($this->database, "UPDATE ? SET public = 0 WHERE album = '?'", [LYCHEE_TABLE_PHOTOS, $album->id]);
$query = Database::prepare($this->database, "UPDATE ? SET public = 0 WHERE album = '?'", array(LYCHEE_TABLE_PHOTOS, $album->id));
$result = $this->database->query($query);
if (!$result) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
@ -550,13 +550,13 @@ class Album extends Module {
# Set hashed password
# Do not prepare $password because it is hashed and save
# Preparing (escaping) the password would destroy the hash
$query = Database::prepare($this->database, "UPDATE ? SET password = '$password' WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET password = '$password' WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$result = $this->database->query($query);
} else {
# Unset password
$query = Database::prepare($this->database, "UPDATE ? SET password = NULL WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET password = NULL WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$result = $this->database->query($query);
}
@ -581,7 +581,7 @@ class Album extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Execute query
$query = Database::prepare($this->database, "SELECT password FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT password FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$albums = $this->database->query($query);
$album = $albums->fetch_object();
@ -606,7 +606,7 @@ class Album extends Module {
$error = false;
# Execute query
$query = Database::prepare($this->database, "SELECT id FROM ? WHERE album IN (?)", [LYCHEE_TABLE_PHOTOS, $this->albumIDs]);
$query = Database::prepare($this->database, "SELECT id FROM ? WHERE album IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
$photos = $this->database->query($query);
# For each album delete photo
@ -618,7 +618,7 @@ class Album extends Module {
}
# Delete albums
$query = Database::prepare($this->database, "DELETE FROM ? WHERE id IN (?)", [LYCHEE_TABLE_ALBUMS, $this->albumIDs]);
$query = Database::prepare($this->database, "DELETE FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_ALBUMS, $this->albumIDs));
$result = $this->database->query($query);
# Call plugins

View File

@ -29,7 +29,7 @@ class Database extends Module {
if (!Database::createDatabase($database, $name)) exit('Error: Could not create database!');
# Check tables
$query = Database::prepare($database, 'SELECT * FROM ?, ?, ?, ? LIMIT 0', [LYCHEE_TABLE_PHOTOS, LYCHEE_TABLE_ALBUMS, LYCHEE_TABLE_SETTINGS, LYCHEE_TABLE_LOG]);
$query = Database::prepare($database, 'SELECT * FROM ?, ?, ?, ? LIMIT 0', array(LYCHEE_TABLE_PHOTOS, LYCHEE_TABLE_ALBUMS, LYCHEE_TABLE_SETTINGS, LYCHEE_TABLE_LOG));
if (!$database->query($query))
if (!Database::createTables($database)) exit('Error: Could not create tables!');
@ -141,7 +141,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
Module::dependencies(isset($database));
# Create log
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_LOG]);
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_LOG));
if (!$database->query($exist)) {
# Read file
@ -151,13 +151,13 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
if (!isset($query)||$query===false) return false;
# Create table
$query = Database::prepare($database, $query, [LYCHEE_TABLE_LOG]);
$query = Database::prepare($database, $query, array(LYCHEE_TABLE_LOG));
if (!$database->query($query)) return false;
}
# Create settings
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_SETTINGS]);
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_SETTINGS));
if (!$database->query($exist)) {
# Read file
@ -170,7 +170,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Create table
$query = Database::prepare($database, $query, [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, $query, array(LYCHEE_TABLE_SETTINGS));
if (!$database->query($query)) {
Log::error($database, __METHOD__, __LINE__, $database->error);
return false;
@ -186,7 +186,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Add content
$query = Database::prepare($database, $query, [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($database, $query, array(LYCHEE_TABLE_SETTINGS));
if (!$database->query($query)) {
Log::error($database, __METHOD__, __LINE__, $database->error);
return false;
@ -195,7 +195,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Create albums
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_ALBUMS]);
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_ALBUMS));
if (!$database->query($exist)) {
# Read file
@ -208,7 +208,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Create table
$query = Database::prepare($database, $query, [LYCHEE_TABLE_ALBUMS]);
$query = Database::prepare($database, $query, array(LYCHEE_TABLE_ALBUMS));
if (!$database->query($query)) {
Log::error($database, __METHOD__, __LINE__, $database->error);
return false;
@ -217,7 +217,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Create photos
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', [LYCHEE_TABLE_PHOTOS]);
$exist = Database::prepare($database, 'SELECT * FROM ? LIMIT 0', array(LYCHEE_TABLE_PHOTOS));
if (!$database->query($exist)) {
# Read file
@ -230,7 +230,7 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
}
# Create table
$query = Database::prepare($database, $query, [LYCHEE_TABLE_PHOTOS]);
$query = Database::prepare($database, $query, array(LYCHEE_TABLE_PHOTOS));
if (!$database->query($query)) {
Log::error($database, __METHOD__, __LINE__, $database->error);
return false;

View File

@ -37,7 +37,7 @@ class Log extends Module {
$sysstamp = time();
# Save in database
$query = Database::prepare($database, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", [LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text]);
$query = Database::prepare($database, "INSERT INTO ? (time, type, function, line, text) VALUES ('?', '?', '?', '?', '?')", array(LYCHEE_TABLE_LOG, $sysstamp, $type, $function, $line, $text));
$result = $database->query($query);
if (!$result) return false;

View File

@ -175,7 +175,7 @@ class Photo extends Module {
}
# Save to DB
$values = [LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $description, $tags, $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum];
$values = array(LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $description, $tags, $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum);
$query = Database::prepare($this->database, "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
$result = $this->database->query($query);
@ -199,8 +199,8 @@ class Photo extends Module {
self::dependencies(isset($this->database, $checksum));
# Exclude $photoID from select when $photoID is set
if (isset($photoID)) $query = Database::prepare($this->database, "SELECT id, url, thumbUrl FROM ? WHERE checksum = '?' AND id <> '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $checksum, $photoID]);
else $query = Database::prepare($this->database, "SELECT id, url, thumbUrl FROM ? WHERE checksum = '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $checksum]);
if (isset($photoID)) $query = Database::prepare($this->database, "SELECT id, url, thumbUrl FROM ? WHERE checksum = '?' AND id <> '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $checksum, $photoID));
else $query = Database::prepare($this->database, "SELECT id, url, thumbUrl FROM ? WHERE checksum = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $checksum));
$result = $this->database->query($query);
@ -434,7 +434,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get photo
$query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT * FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
$photo = $photos->fetch_assoc();
@ -453,7 +453,7 @@ class Photo extends Module {
if ($photo['album']!=0) {
# Get album
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_ALBUMS, $photo['album']]);
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_ALBUMS, $photo['album']));
$albums = $this->database->query($query);
$album = $albums->fetch_assoc();
@ -577,7 +577,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get photo
$query = Database::prepare($this->database, "SELECT title, url FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT title, url FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
$photo = $photos->fetch_object();
@ -618,7 +618,7 @@ class Photo extends Module {
if (strlen($title)>50) $title = substr($title, 0, 50);
# Set title
$query = Database::prepare($this->database, "UPDATE ? SET title = '?' WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $title, $this->photoIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET title = '?' WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $title, $this->photoIDs));
$result = $this->database->query($query);
# Call plugins
@ -645,7 +645,7 @@ class Photo extends Module {
if (strlen($description)>1000) $description = substr($description, 0, 1000);
# Set description
$query = Database::prepare($this->database, "UPDATE ? SET description = '?' WHERE id IN ('?')", [LYCHEE_TABLE_PHOTOS, $description, $this->photoIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET description = '?' WHERE id IN ('?')", array(LYCHEE_TABLE_PHOTOS, $description, $this->photoIDs));
$result = $this->database->query($query);
# Call plugins
@ -671,7 +671,7 @@ class Photo extends Module {
$error = false;
# Get photos
$query = Database::prepare($this->database, "SELECT id, star FROM ? WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT id, star FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
# For each photo
@ -681,7 +681,7 @@ class Photo extends Module {
$star = ($photo->star==0 ? 1 : 0);
# Set star
$query = Database::prepare($this->database, "UPDATE ? SET star = '?' WHERE id = '?'", [LYCHEE_TABLE_PHOTOS, $star, $photo->id]);
$query = Database::prepare($this->database, "UPDATE ? SET star = '?' WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $star, $photo->id));
$star = $this->database->query($query);
if (!$star) $error = true;
@ -707,7 +707,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get photo
$query = Database::prepare($this->database, "SELECT public, album FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT public, album FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
$photo = $photos->fetch_object();
@ -736,7 +736,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get public
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT public FROM ? WHERE id = '?' LIMIT 1", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
$photo = $photos->fetch_object();
@ -744,7 +744,7 @@ class Photo extends Module {
$public = ($photo->public==0 ? 1 : 0);
# Set public
$query = Database::prepare($this->database, "UPDATE ? SET public = '?' WHERE id = '?'", [LYCHEE_TABLE_PHOTOS, $public, $this->photoIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET public = '?' WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $public, $this->photoIDs));
$result = $this->database->query($query);
# Call plugins
@ -767,7 +767,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Set album
$query = Database::prepare($this->database, "UPDATE ? SET album = '?' WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $albumID, $this->photoIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET album = '?' WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $albumID, $this->photoIDs));
$result = $this->database->query($query);
# Call plugins
@ -798,7 +798,7 @@ class Photo extends Module {
}
# Set tags
$query = Database::prepare($this->database, "UPDATE ? SET tags = '?' WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $tags, $this->photoIDs]);
$query = Database::prepare($this->database, "UPDATE ? SET tags = '?' WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $tags, $this->photoIDs));
$result = $this->database->query($query);
# Call plugins
@ -821,7 +821,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get photos
$query = Database::prepare($this->database, "SELECT id, checksum FROM ? WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT id, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
if (!$photos) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
@ -836,7 +836,7 @@ class Photo extends Module {
while(strlen($id)<14) $id .= 0;
# Duplicate entry
$values = [LYCHEE_TABLE_PHOTOS, $id, LYCHEE_TABLE_PHOTOS, $photo->id];
$values = array(LYCHEE_TABLE_PHOTOS, $id, LYCHEE_TABLE_PHOTOS, $photo->id);
$query = Database::prepare($this->database, "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 = $this->database->query($query);
if (!$duplicate) {
@ -859,7 +859,7 @@ class Photo extends Module {
$this->plugins(__METHOD__, 0, func_get_args());
# Get photos
$query = Database::prepare($this->database, "SELECT id, url, thumbUrl, checksum FROM ? WHERE id IN (?)", [LYCHEE_TABLE_PHOTOS, $this->photoIDs]);
$query = Database::prepare($this->database, "SELECT id, url, thumbUrl, checksum FROM ? WHERE id IN (?)", array(LYCHEE_TABLE_PHOTOS, $this->photoIDs));
$photos = $this->database->query($query);
if (!$photos) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);
@ -898,7 +898,7 @@ class Photo extends Module {
}
# Delete db entry
$query = Database::prepare($this->database, "DELETE FROM ? WHERE id = '?'", [LYCHEE_TABLE_PHOTOS, $photo->id]);
$query = Database::prepare($this->database, "DELETE FROM ? WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $photo->id));
$delete = $this->database->query($query);
if (!$delete) {
Log::error($this->database, __METHOD__, __LINE__, $this->database->error);

View File

@ -27,7 +27,7 @@ class Settings extends Module {
self::dependencies(isset($this->database));
# Execute query
$query = Database::prepare($this->database, "SELECT * FROM ?", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($this->database, "SELECT * FROM ?", array(LYCHEE_TABLE_SETTINGS));
$settings = $this->database->query($query);
# Add each to return
@ -77,7 +77,7 @@ class Settings extends Module {
}
# Execute query
$query = Database::prepare($this->database, "UPDATE ? SET value = '?' WHERE `key` = 'username'", [LYCHEE_TABLE_SETTINGS, $username]);
$query = Database::prepare($this->database, "UPDATE ? SET value = '?' WHERE `key` = 'username'", array(LYCHEE_TABLE_SETTINGS, $username));
$result = $this->database->query($query);
if (!$result) {
@ -98,7 +98,7 @@ class Settings extends Module {
# Execute query
# Do not prepare $password because it is hashed and save
# Preparing (escaping) the password would destroy the hash
$query = Database::prepare($this->database, "UPDATE ? SET value = '$password' WHERE `key` = 'password'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($this->database, "UPDATE ? SET value = '$password' WHERE `key` = 'password'", array(LYCHEE_TABLE_SETTINGS));
$result = $this->database->query($query);
if (!$result) {
@ -120,7 +120,7 @@ class Settings extends Module {
}
# Execute query
$query = Database::prepare($this->database, "UPDATE ? SET value = '?' WHERE `key` = 'dropboxKey'", [LYCHEE_TABLE_SETTINGS, $key]);
$query = Database::prepare($this->database, "UPDATE ? SET value = '?' WHERE `key` = 'dropboxKey'", array(LYCHEE_TABLE_SETTINGS, $key));
$result = $this->database->query($query);
if (!$result) {
@ -184,7 +184,7 @@ class Settings extends Module {
# Execute query
# Do not prepare $sorting because it is a true statement
# Preparing (escaping) the sorting would destroy it
$query = Database::prepare($this->database, "UPDATE ? SET value = '$sorting' WHERE `key` = 'sorting'", [LYCHEE_TABLE_SETTINGS]);
$query = Database::prepare($this->database, "UPDATE ? SET value = '$sorting' WHERE `key` = 'sorting'", array(LYCHEE_TABLE_SETTINGS));
$result = $this->database->query($query);
if (!$result) {

View File

@ -16,7 +16,7 @@ function search($database, $settings, $term) {
$return['albums'] = '';
// Photos
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%%' OR tags LIKE '%?%'", [LYCHEE_TABLE_PHOTOS, $term, $term, $term]);
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
$result = $database->query($query);
while($row = $result->fetch_assoc()) {
$return['photos'][$row['id']] = $row;
@ -25,7 +25,7 @@ function search($database, $settings, $term) {
}
// Albums
$query = Database::prepare($database, "SELECT id, title, public, sysstamp, password FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%'", [LYCHEE_TABLE_ALBUMS, $term, $term]);
$query = Database::prepare($database, "SELECT id, title, public, sysstamp, password FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%'", array(LYCHEE_TABLE_ALBUMS, $term, $term));
$result = $database->query($query);
$i = 0;
while($row = $result->fetch_object()) {
@ -38,7 +38,7 @@ function search($database, $settings, $term) {
$return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
// Thumbs
$query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sorting'] . " LIMIT 0, 3", [LYCHEE_TABLE_PHOTOS, $row->id]);
$query = Database::prepare($database, "SELECT thumbUrl FROM ? WHERE album = '?' " . $settings['sorting'] . " LIMIT 0, 3", array(LYCHEE_TABLE_PHOTOS, $row->id));
$result2 = $database->query($query);
$k = 0;
while($row2 = $result2->fetch_object()){
@ -58,7 +58,7 @@ function getGraphHeader($database, $photoID) {
if (!isset($database, $photoID)) return false;
$query = Database::prepare($database, "SELECT title, description, url FROM ? WHERE id = '?'", [LYCHEE_TABLE_PHOTOS, $photoID]);
$query = Database::prepare($database, "SELECT title, description, url FROM ? WHERE id = '?'", array(LYCHEE_TABLE_PHOTOS, $photoID));
$result = $database->query($query);
$row = $result->fetch_object();

View File

@ -102,7 +102,9 @@ echo('PHP Version: ' . floatval(phpversion()) . PHP_EOL);
echo('MySQL Version: ' . $database->server_version . PHP_EOL);
echo('Imagick: ' . extension_loaded('imagick') . PHP_EOL);
echo('Imagick Active: ' . $settings['imagick'] . PHP_EOL);
echo('Imagick Version: ' . @Imagick::getVersion()['versionNumber'] . PHP_EOL);
echo('GD Version: ' . gd_info()['GD Version'] . PHP_EOL);
$imagickVersion = @Imagick::getVersion();
echo('Imagick Version: ' . $imagickVersion['versionNumber'] . PHP_EOL);
$gdVersion = gd_info();
echo('GD Version: ' . $gdVersion['GD Version'] . PHP_EOL);
?>

View File

@ -37,7 +37,7 @@ if (mysqli_connect_errno()!=0) {
}
# Result
$query = Database::prepare($database, "SELECT FROM_UNIXTIME(time), type, function, line, text FROM ?", [LYCHEE_TABLE_LOG]);
$query = Database::prepare($database, "SELECT FROM_UNIXTIME(time), type, function, line, text FROM ?", array(LYCHEE_TABLE_LOG));
$result = $database->query($query);
# Output