load_photo.php 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. $http_host = $_SERVER['HTTP_HOST'];
  3. include("../functions.php");
  4. $con = startdb();
  5. $proto = getProtocol();
  6. //Language
  7. $lang = selectLanguage();
  8. include("../lang/lang_" . $lang . ".php");
  9. //Get photo data
  10. $path = mysqli_real_escape_string($con, $_GET['path']);
  11. $q = mysqli_query($con, "SELECT id, file, permalink, title_$lang AS title, description_$lang AS description, uploaded, size, user, username FROM photo WHERE file = '$path' AND approved = 1");
  12. if (mysqli_num_rows($q) == 0){
  13. exit(0);
  14. }
  15. else{
  16. $r = mysqli_fetch_array($q);
  17. echo "<div id='viewer_table'><div class='viewer_row'><div class='viewer_cell' id='cell_image'>\n";
  18. echo "<img id='photo_viewer_image' src='/img/galeria/preview/$r[file]'/>\n";
  19. echo "</br>\n";
  20. //Arrows
  21. echo "<div id='viewer_controls'>\n";
  22. echo "<img id='viewer_arrow_left' class='pointer' alt=' ' src='$proto$http_host/img/misc/slid-left.png' onClick='scrollPhoto(-1);'/>\n";
  23. echo "<img id='viewer_arrow_right' class='pointer' alt=' ' src='$proto$http_host/img/misc/slid-right.png' onClick='scrollPhoto(1);'/>\n";
  24. echo "<img id='viewer_close' class='pointer mobile' alt=' ' src='$proto$http_host/img/misc/close.png' onClick='closeViewer();'/>\n";
  25. echo "</div>\n"; //viewer_controls
  26. echo "</div>\n"; //cell
  27. echo "<div class='viewer_cell' id='cell_details'>\n";
  28. echo "<div id='photo_viewer_details'>\n";
  29. echo "<div class='entry' id='photo_data'>\n";
  30. if (strlen($r['title']) > 0){
  31. echo "<h3 class='entry_title'>$r[title]</h3>\n";
  32. }
  33. if (strlen($r['description']) > 0){
  34. echo "<span id='photo_description'>$r[description]</span>\n";
  35. }
  36. echo "<span id='photo_date'>" . formatDate($r['uploaded'], $lang) . "</span>\n";
  37. if (strlen($r['username']) > 0){
  38. echo "<span id='photo_user'>$lng[gallery_user]$r[username]</span>\n";
  39. }
  40. echo "</div>\n";
  41. $q_comment = mysqli_query($con, "SELECT * FROM photo_comment WHERE photo = $r[id];");
  42. $comment_count = mysqli_num_rows($q_comment);
  43. echo "<div class='entry' id='comments_section'/>\n";
  44. echo "<div id='photo_viewer_comment_counter'>\n";
  45. switch ($comment_count){
  46. case 0:
  47. echo "<h3 class='entry_title'><meta itemprop='interactionCount' content='0'/>$lng[gallery_comment_count_0]</h3>\n";
  48. break;
  49. case 1:
  50. echo "<h3 class='entry_title'><span itemprop='interactionCount'>1</span> $lng[gallery_comment_count_1]</h3>\n";
  51. break;
  52. default:
  53. echo "<h3 class='entry_title'><span itemprop='interactionCount'>$comment_count</span> $lng[gallery_comment_count_several]</h3>\n";
  54. }
  55. echo "</div>\n";
  56. echo "<div id='comment_list'>\n";
  57. //WARNING: If changes are done here, do the same in comment.php
  58. while ($r_comment = mysqli_fetch_array($q_comment)){
  59. echo "<div itemprop='comment' itemscope itemtype='http://schema.org/UserComments' id='comment_$r_comment[id]' class='comment'>\n";
  60. //When official users are implementes, see if there is user or username
  61. echo "<span itemprop='creator' class='comment_user'>$r_comment[username]</span>\n";
  62. echo "<span class='comment_date date'><meta itemprop='commentTime' content='$r_comment[isodate]'/>" . formatDate($r_comment['dtime'], $lang) . "</span>\n";
  63. echo "<p itemprop='commentText' class='comment_text'>$r_comment[text]</p>";
  64. echo "<hr class='comment_line'/>\n";
  65. echo "</div>\n";
  66. }
  67. echo "</div>\n";
  68. #Comment form
  69. echo "<div class='comment' id='comment_new'>\n";
  70. echo "<form id='comment_form' method='post' action='/' onsubmit='event.preventDefault();postComment($r[id], \"$lang\");'>\n";
  71. echo "<textarea id='new_comment_text' name='text' maxlength='1800' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);' placeholder='$lng[blog_placeholder_text]'></textarea>\n";
  72. //echo "<input type='hidden' name='id' value='$id'>\n";
  73. echo "<div id='identification_form'>\n";
  74. echo "<br><input id='new_comment_user' name='user' maxlength='50' type='text' placeholder='$lng[blog_placeholder_name]' onChange='defaultInputBorder(this);' onKeyDown='defaultInputBorder(this);'/>\n";
  75. echo "<input type='submit' value='$lng[blog_send]'/>\n";
  76. echo "</div>\n";
  77. echo "</form>\n";
  78. echo "</div>\n"; //New comment
  79. echo "</div>\n"; //Comments
  80. echo "</div>\n"; //Cell
  81. echo "</div>\n"; //Row
  82. echo "</div>\n"; //Table
  83. stats(-1, 0, "photo", "$r[id]");
  84. }
  85. ?>