image.php 2.7 KB

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