image.php 1.9 KB

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