tags.php 807 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @name Album Module
  4. * @author Tobias Reich
  5. * @copyright 2014 by Philipp Maurer, Tobias Reich
  6. */
  7. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  8. function getTags($photoID) {
  9. global $database;
  10. $result = $database->query("SELECT tags FROM lychee_photos WHERE id = '$photoID';");
  11. $return = $result->fetch_array();
  12. if (!$result) return false;
  13. return $return;
  14. }
  15. function setTags($photoIDs, $tags) {
  16. global $database;
  17. // Parse tags
  18. $tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags);
  19. $tags = preg_replace('/,$|^,/', ',', $tags);
  20. if (strlen($tags)>1000) return false;
  21. $result = $database->query("UPDATE lychee_photos SET tags = '$tags' WHERE id IN ($photoIDs);");
  22. if (!$result) return false;
  23. return true;
  24. }