album.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. session_start();
  3. $http_host = $_SERVER['HTTP_HOST'];
  4. include("../functions.php");
  5. $con = startdb();
  6. //Language
  7. $lang = selectLanguage();
  8. include("../lang/lang_" . $lang . ".php");
  9. $cur_section = $lng['section_gallery'];
  10. //Get album
  11. $perm = mysqli_real_escape_string($con, $_GET['perm']);
  12. $q = mysqli_query($con, "SELECT id, permalink, title_$lang AS title, description_$lang AS description, user, open, dtime FROM album WHERE permalink = '$perm';");
  13. if (mysqli_num_rows($q) == 0){
  14. header("Location: /galeria/");
  15. exit (-1);
  16. }
  17. else{
  18. $r = mysqli_fetch_array($q);
  19. $id = $r['id'];
  20. ?>
  21. <!DOCTYPE html>
  22. <html>
  23. <head>
  24. <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  25. <meta charset="utf-8"/>
  26. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
  27. <title><?php echo $r['title'];?></title>
  28. <link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
  29. <!-- CSS files -->
  30. <style>
  31. <?php
  32. include("../css/ui.css");
  33. include("../css/galeria.css");
  34. ?>
  35. </style>
  36. <!-- CSS for mobile version -->
  37. <style media="(max-width : 990px)">
  38. <?php
  39. include("../css/m/ui.css");
  40. include("../css/m/galeria.css");
  41. ?>
  42. </style>
  43. <!-- Script files -->
  44. <script type="text/javascript">
  45. <?php
  46. include("../script/ui.js");
  47. include("../script/galeria.js");
  48. ?>
  49. </script>
  50. <!-- Meta tags -->
  51. <link rel="canonical" href="<?php echo "http://$http_host/galeria/$perm"; ?>"/>
  52. <link rel="author" href="<?php echo "http://$http_host"; ?>"/>
  53. <link rel="publisher" href="<?php echo "http://$http_host"; ?>"/>
  54. <meta name="description" content="<?php echo strip_tags($r['description']);?>"/>
  55. <meta property="og:title" content="<?php echo $l['title'];?>"/>
  56. <meta property="og:url" content="<?php echo "http://$http_host/galeria/$perm"; ?>"/>
  57. <meta property="og:description" content="<?php echo strip_tags($r['description']); ?>"/>
  58. <meta property="og:image" content="<?php echo "http://$http_host/img/logo/logo.png";?>"/>
  59. <meta property="og:site_name" content="Gasteizko Margolariak"/>
  60. <meta property="og:type" content="website"/>
  61. <meta property="og:locale" content="<?php echo $lang; ?>"/>
  62. <meta name="twitter:card" content="summary"/>
  63. <meta name="twitter:title" content="<?php echo $l['title'];?>"/>
  64. <meta name="twitter:description" content="<?php echo strip_tags($r['description']); ?>"/>
  65. <meta name="twitter:image" content="<?php echo "http://$http_host/img/logo/logo.png";?>"/>
  66. <meta name="twitter:url" content="<?php echo "http://$http_host/galeria/$perm"; ?>"/>
  67. <meta name="robots" content="index follow"/>
  68. </head>
  69. <body onLoad="populatePhotos();" onkeypress="keyDown(event);">
  70. <?php include("../header.php"); ?>
  71. <div id="content">
  72. <div class="section" id="album">
  73. <?php
  74. //Header
  75. echo "<h3 class='section_title' id='album_title'>$r[title]</h3>\n";
  76. if ($r['description'] != ''){
  77. echo "<div class='entry' id='album_header'>\n";
  78. echo $r['description'];
  79. echo "</div>\n";
  80. }
  81. //Photos of the album
  82. $q_photo = mysqli_query($con, "SELECT id, file, permalink, title_$lang AS title, description_$lang AS description, photo.dtime AS dtime, uploaded, width, height, size, user, username FROM photo, photo_album WHERE photo_album.photo = id AND album = $r[id] ORDER BY photo.dtime DESC;");
  83. /* TODO AND approved = 1*/
  84. while ($r_photo = mysqli_fetch_array($q_photo)){
  85. echo "<div class='entry photo'>\n<div class='photo_container'>\n";
  86. echo "<img class='pointer photo_img' path='$r_photo[file]' onClick=\"showPhotoByPath('$r_photo[file]');\" src='/img/galeria/miniature/$r_photo[file]' /></div>\n";
  87. if (strlen($r_photo['title']) > 0 ){
  88. echo "<h4><a href='javascript:;' onClick=\"showPhotoByPath('$r_photo[file]');\">$r_photo[title]</a></h4>\n";
  89. }
  90. if (strlen($r_photo['description']) > 0 ){
  91. echo "<span class='photo_description'>" . cutText($r_photo['description'], 50) . "</span>\n";
  92. }
  93. //Count comments
  94. $q_comments = mysqli_query($con, "SELECT id FROM photo_comment WHERE photo = $r_photo[id];");
  95. echo "<span class='comment_counter'>" . mysqli_num_rows($q_comments) . "<img src='http://$http_host/img/misc/comment.png' alt=' '/></span>\n"; //TODO: icon
  96. echo "\n</div>\n";
  97. }
  98. ?>
  99. </div>
  100. </div>
  101. <div id="screen_cover" onClick="closeViewer();">
  102. </div>
  103. <div id="photo_viewer" class="section">
  104. </div>
  105. <?php
  106. include("../footer.php");
  107. $ad = ad($con, $lang, $lng);
  108. stats($ad, $ad_static, "galeria", "$id");
  109. ?>
  110. </body>
  111. </html>
  112. <?php } ?>