Fix #263 gallery system using imgur

setup tutorial: https://github.com/Znote/ZnoteAAC/wiki/IMGUR-powered-Gallery-page
This commit is contained in:
Znote
2020-12-13 22:20:54 +00:00
parent 8128804021
commit 48d1dd5712
5 changed files with 66 additions and 22 deletions

View File

@@ -40,7 +40,8 @@ CREATE TABLE IF NOT EXISTS `znote_images` (
`desc` text NOT NULL,
`date` int NOT NULL,
`status` int NOT NULL,
`image` varchar(30) NOT NULL,
`image` varchar(50) NOT NULL,
`delhash` varchar(30) NOT NULL,
`account_id` int NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;

View File

@@ -6,21 +6,22 @@
// Fetch Images
function fetchImages($status) {
$status = (int)$status;
return mysql_select_multi("SELECT `id`, `title`, `desc`, `date`, `status`, `image`, `account_id` FROM znote_images WHERE `status`='$status' ORDER BY `date` DESC;");
return mysql_select_multi("SELECT `id`, `title`, `desc`, `date`, `status`, `image`, `delhash`, `account_id` FROM znote_images WHERE `status`='$status' ORDER BY `date` DESC;");
}
// Insert image data
function insertImage($account_id, $title, $desc, $image) {
function insertImage($account_id, $title, $desc, $image, $image_delete) {
$title = sanitize($title);
$desc = sanitize($desc);
$image = sanitize($image);
$image_delete = sanitize($image_delete);
$account_id = (int)$account_id;
$time = time();
// Insert only if image dosn't already exist there
$exist = mysql_select_single("SELECT `id` FROM `znote_images` WHERE `image`='$image' LIMIT 1;");
if ($exist === false) {
mysql_insert("INSERT INTO `znote_images` (`title`, `desc`, `date`, `status`, `image`, `account_id`) VALUES ('$title', '$desc', '$time', '1', '$image', '$account_id');");
mysql_insert("INSERT INTO `znote_images` (`title`, `desc`, `date`, `status`, `image`, `delhash`, `account_id`) VALUES ('$title', '$desc', '$time', '1', '$image', '$image_delete', '$account_id');");
return true;
}
return false;