2014-01-22 10:12:51 +00:00
< ? php
/**
2014-02-17 16:01:46 +00:00
* @ name Misc Module
* @ author Philipp Maurer
* @ author Tobias Reich
* @ copyright 2014 by Philipp Maurer , Tobias Reich
2014-01-22 10:12:51 +00:00
*/
if ( ! defined ( 'LYCHEE' )) exit ( 'Error: Direct access is not allowed!' );
2014-04-04 21:17:54 +00:00
function getGraphHeader ( $database , $photoID ) {
2014-01-22 10:12:51 +00:00
2014-04-04 21:17:54 +00:00
if ( ! isset ( $database , $photoID )) return false ;
2014-02-17 16:01:46 +00:00
2014-02-09 21:30:16 +00:00
$photoID = mysqli_real_escape_string ( $database , $photoID );
2014-02-17 16:01:46 +00:00
2014-02-10 17:04:34 +00:00
$result = $database -> query ( " SELECT title, description, url FROM lychee_photos WHERE id = ' $photoID '; " );
2014-02-09 21:30:16 +00:00
$row = $result -> fetch_object ();
2014-02-17 16:01:46 +00:00
2014-02-27 20:51:12 +00:00
$parseUrl = parse_url ( " http:// " . $_SERVER [ 'HTTP_HOST' ] . $_SERVER [ 'REQUEST_URI' ]);
$picture = $parseUrl [ 'scheme' ] . " :// " . $parseUrl [ 'host' ] . $parseUrl [ 'path' ] . " /../uploads/big/ " . $row -> url ;
2014-02-17 16:01:46 +00:00
$return = '<!-- General Meta Data -->' ;
2014-01-22 10:12:51 +00:00
$return .= '<meta name="title" content="' . $row -> title . '" />' ;
$return .= '<meta name="description" content="' . $row -> description . ' - via Lychee" />' ;
2014-02-17 16:01:46 +00:00
$return .= '<link rel="image_src" type="image/jpeg" href="' . $picture . '" />' ;
2014-01-22 10:12:51 +00:00
$return .= '<!-- Twitter Meta Data -->' ;
$return .= '<meta name="twitter:card" content="photo">' ;
$return .= '<meta name="twitter:title" content="' . $row -> title . '">' ;
$return .= '<meta name="twitter:image:src" content="' . $picture . '">' ;
2014-02-17 16:01:46 +00:00
2014-01-22 10:12:51 +00:00
$return .= '<!-- Facebook Meta Data -->' ;
$return .= '<meta property="og:title" content="' . $row -> title . '">' ;
$return .= '<meta property="og:image" content="' . $picture . '">' ;
2014-02-17 16:01:46 +00:00
2014-02-09 21:30:16 +00:00
return $return ;
2014-01-22 10:12:51 +00:00
}
2014-04-19 18:27:53 +00:00
function search ( $database , $settings , $term ) {
2014-01-22 10:12:51 +00:00
2014-04-19 18:27:53 +00:00
if ( ! isset ( $database , $settings , $term )) return false ;
2014-01-22 10:12:51 +00:00
2014-02-09 21:30:16 +00:00
$return [ 'albums' ] = '' ;
2014-01-22 10:12:51 +00:00
2014-02-09 21:30:16 +00:00
// Photos
2014-04-11 08:38:28 +00:00
$result = $database -> query ( " SELECT id, title, tags, public, star, album, thumbUrl FROM lychee_photos WHERE title like '% $term %' OR description like '% $term %' OR tags like '% $term %'; " );
2014-03-20 13:52:54 +00:00
while ( $row = $result -> fetch_assoc ()) {
2014-02-17 16:01:46 +00:00
$return [ 'photos' ][ $row [ 'id' ]] = $row ;
2014-04-11 08:38:28 +00:00
$return [ 'photos' ][ $row [ 'id' ]][ 'sysdate' ] = date ( 'd M. Y' , substr ( $row [ 'id' ], 0 , - 4 ));
2014-02-17 16:01:46 +00:00
}
2014-01-22 10:12:51 +00:00
2014-02-09 21:30:16 +00:00
// Albums
2014-04-11 08:38:28 +00:00
$result = $database -> query ( " SELECT id, title, public, sysstamp, password FROM lychee_albums WHERE title like '% $term %' OR description like '% $term %'; " );
2014-02-17 16:01:46 +00:00
$i = 0 ;
while ( $row = $result -> fetch_object ()) {
2014-01-22 10:12:51 +00:00
2014-02-09 21:30:16 +00:00
// Info
2014-02-17 16:01:46 +00:00
$return [ 'albums' ][ $row -> id ][ 'id' ] = $row -> id ;
$return [ 'albums' ][ $row -> id ][ 'title' ] = $row -> title ;
$return [ 'albums' ][ $row -> id ][ 'public' ] = $row -> public ;
2014-04-11 08:38:28 +00:00
$return [ 'albums' ][ $row -> id ][ 'sysdate' ] = date ( 'F Y' , $row -> sysstamp );
2014-02-17 16:01:46 +00:00
$return [ 'albums' ][ $row -> id ][ 'password' ] = ( $row -> password == '' ? false : true );
2014-01-22 10:12:51 +00:00
2014-02-09 21:30:16 +00:00
// Thumbs
2014-02-17 16:01:46 +00:00
$result2 = $database -> query ( " SELECT thumbUrl FROM lychee_photos WHERE album = ' " . $row -> id . " ' " . $settings [ 'sorting' ] . " LIMIT 0, 3; " );
$k = 0 ;
while ( $row2 = $result2 -> fetch_object ()){
$return [ 'albums' ][ $row -> id ][ " thumb $k " ] = $row2 -> thumbUrl ;
$k ++ ;
}
2014-01-22 10:12:51 +00:00
2014-02-17 16:01:46 +00:00
$i ++ ;
2014-01-22 10:12:51 +00:00
2014-02-17 16:01:46 +00:00
}
return $return ;
2014-01-22 10:12:51 +00:00
}
?>