image.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. require_once('include/config.php');
  3. require_once('include/db.php');
  4. require_once('include/comment.php');
  5. $dir = @$_GET['dir'];
  6. $file = @$_GET['file'];
  7. if (empty($dir) || empty($file)) {
  8. die('Niepoprawne żądanie');
  9. }
  10. $dirinfo = get_dir_info($dir);
  11. if (!$dirinfo) {
  12. die('Nie ma katalogu');
  13. }
  14. $images = get_dir_images($dir);
  15. $found = false;
  16. $prev = null;
  17. $next = null;
  18. $fileinfo = null;
  19. foreach ($images as $image) { // finding prev and next
  20. if (!$found) { // find current and previous one
  21. if ($image['path'] == $file) { // the current one
  22. $fileinfo = $image;
  23. $found = true;
  24. continue;
  25. }
  26. $prev = $image;
  27. } else {
  28. $next = $image;
  29. break;
  30. }
  31. }
  32. if (!$fileinfo) {
  33. die('File not found');
  34. }
  35. $dirhtml = urlencode($dirinfo['path']);
  36. $filehtml = urlencode($fileinfo['path']);
  37. $content = '<div class="full-image-div"><a class="gora" href="dir.php?dir='.$dirhtml.'"></a><a id="poprz" ';
  38. if ($prev) {
  39. $prevhtml = urlencode($prev['path']);
  40. $content .= 'href="image.php?file='.$prevhtml.'&amp;dir='.$dirhtml.'"';
  41. } else {
  42. $content .= 'style="display:none;"';
  43. }
  44. $content .= '></a><div><a id="imagelink"';
  45. if ($next) {
  46. $nexthtml = urlencode($next['path']);
  47. $content .= ' href="image.php?file='.$nexthtml.'&amp;dir='.$dirhtml.'"';
  48. }
  49. $content .= '><img id="image" src="'.$config['imagepath'] . $dirhtml.'/'.$filehtml.'" class="pelny"/></a><a id="nast" ';
  50. if ($next) {
  51. $content .= 'href="image.php?file='.$nexthtml.'&amp;dir='.$dirhtml.'"';
  52. } else {
  53. $content .= 'style="display:none;"';
  54. }
  55. $content .= '></a>';
  56. $dirname = htmlspecialchars($dirinfo['name']);
  57. $comments_data = get_comments($fileinfo['id'], 'image');
  58. $comments = generate_comment_field($comments_data, 'image', $fileinfo['id']);
  59. ?><!DOCTYPE html>
  60. <html>
  61. <head>
  62. <title>Obrazki: <?=$dirname?></title>
  63. <link rel="stylesheet" href="style.css?<?=$time?>" type="text/css">
  64. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  65. <script type="text/javascript">
  66. const imageUrlPrefix = <?=$config['imagepath']?>;
  67. const scriptUrlPrefix = <?=$config['basepath']?>;
  68. </script>
  69. <script type="text/javascript" src="https://k4be.pl/jquery/jquery-3.6.3.min.js"></script>
  70. <script type="text/javascript" src="image.js?<?=$time?>"></script>
  71. <script type="text/javascript" src="comment.js?<?=$time?>"></script>
  72. </head>
  73. <body>
  74. <h1>Obrazki: <?=$dirname?></h1>
  75. <div id="image-frame">
  76. <?=$content?>
  77. </div>
  78. <div id="comments">
  79. <?=$comments?>
  80. </div>
  81. <a class="k4" href="http://k4be.pl/"></a>
  82. </body>
  83. </html>