You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lychee/php/modules/tags.php

38 lines
869 B

<?php
/**
* @name Album Module
* @author Tobias Reich
* @copyright 2014 by Philipp Maurer, Tobias Reich
*/
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
function getTags($photoID) {
global $database;
$result = $database->query("SELECT tags FROM lychee_photos WHERE id = '$photoID';");
$return = $result->fetch_array();
if (!$result) return false;
return $return;
}
function setTags($photoIDs, $tags) {
global $database;
if (substr($tags, strlen($tags)-1)===',') $tags = substr($tags, 0, strlen($tags)-1);
$tags = str_replace(' , ', ',', $tags);
$tags = str_replace(', ', ',', $tags);
$tags = str_replace(' ,', ',', $tags);
$tags = str_replace(',,', ',', $tags);
$result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);");
if (!$result) return false;
return true;
}