misc.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @name Misc Module
  4. * @author Philipp Maurer
  5. * @author Tobias Reich
  6. * @copyright 2014 by Philipp Maurer, Tobias Reich
  7. */
  8. if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
  9. function getGraphHeader($database, $photoID) {
  10. if (!isset($database, $photoID)) return false;
  11. $photoID = mysqli_real_escape_string($database, $photoID);
  12. $result = $database->query("SELECT title, description, url FROM lychee_photos WHERE id = '$photoID';");
  13. $row = $result->fetch_object();
  14. $parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  15. $picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
  16. $return = '<!-- General Meta Data -->';
  17. $return .= '<meta name="title" content="'.$row->title.'" />';
  18. $return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
  19. $return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
  20. $return .= '<!-- Twitter Meta Data -->';
  21. $return .= '<meta name="twitter:card" content="photo">';
  22. $return .= '<meta name="twitter:title" content="'.$row->title.'">';
  23. $return .= '<meta name="twitter:image:src" content="'.$picture.'">';
  24. $return .= '<!-- Facebook Meta Data -->';
  25. $return .= '<meta property="og:title" content="'.$row->title.'">';
  26. $return .= '<meta property="og:image" content="'.$picture.'">';
  27. return $return;
  28. }
  29. function search($term) {
  30. global $database, $settings;
  31. $return['albums'] = '';
  32. // Photos
  33. $result = $database->query("SELECT id, title, tags, sysdate, public, star, album, thumbUrl FROM lychee_photos WHERE title like '%$term%' OR description like '%$term%' OR tags like '%$term%';");
  34. while($row = $result->fetch_assoc()) {
  35. $return['photos'][$row['id']] = $row;
  36. $return['photos'][$row['id']]['sysdate'] = date('d F Y', strtotime($row['sysdate']));
  37. }
  38. // Albums
  39. $result = $database->query("SELECT id, title, public, sysdate, password FROM lychee_albums WHERE title like '%$term%' OR description like '%$term%';");
  40. $i = 0;
  41. while($row = $result->fetch_object()) {
  42. // Info
  43. $return['albums'][$row->id]['id'] = $row->id;
  44. $return['albums'][$row->id]['title'] = $row->title;
  45. $return['albums'][$row->id]['public'] = $row->public;
  46. $return['albums'][$row->id]['sysdate'] = date('F Y', strtotime($row->sysdate));
  47. $return['albums'][$row->id]['password'] = ($row->password=='' ? false : true);
  48. // Thumbs
  49. $result2 = $database->query("SELECT thumbUrl FROM lychee_photos WHERE album = '" . $row->id . "' " . $settings['sorting'] . " LIMIT 0, 3;");
  50. $k = 0;
  51. while($row2 = $result2->fetch_object()){
  52. $return['albums'][$row->id]["thumb$k"] = $row2->thumbUrl;
  53. $k++;
  54. }
  55. $i++;
  56. }
  57. return $return;
  58. }
  59. ?>