Silnik strony + galerii zdjęć Suczawa 2009
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.3 KiB

  1. <?php
  2. /**
  3. * @package Galeria Suczawa 2009
  4. * @file display.php
  5. * @version $Id$
  6. **/
  7. require_once('./init.php'); #init stuff
  8. $id=(isset($_GET['id'])) ? intval($_GET['id']) : 1; #check which photo should be loaded
  9. NaglowekXHTML();
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
  13. <head>
  14. <title>Podgląd zdjęcia nr <?=$id?></title>
  15. <link type="text/css" href="style.css" rel="stylesheet" />
  16. <script type="text/javascript">
  17. <!-- <[CDATA[ -->
  18. path='http://<?=$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])?>';
  19. <!-- ]]> -->
  20. </script>
  21. <script type="text/javascript" src="script.js"></script>
  22. </head>
  23. <body onload="init()">
  24. <div id="display">
  25. <?
  26. $sql = "SELECT * FROM `photos` WHERE id='$id'";
  27. if (!$result = $DB->query($sql))
  28. {
  29. showError('Nie mozna pobrac informacji o zdjeciu!');
  30. }
  31. if ($result->num_rows == 0)
  32. {
  33. $row = array(
  34. 'author' => '--',
  35. 'description' => 'Zdjęcie usunięte',
  36. 'photo_name' => 'no_image.png',
  37. 'id' => $i
  38. );
  39. }
  40. else
  41. {
  42. $row = $result->fetch_assoc();
  43. $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
  44. $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
  45. }
  46. ?>
  47. <div id="current">
  48. <a href="images/upload/<?=htmlspecialchars($row['photo_name'])?>"><img id="curr_image" height="300px" alt="ZdjÄ_cie" src="images/upload/<?=htmlspecialchars($row['photo_name'])?>" /></a>
  49. <br/>
  50. <b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br />
  51. <b>Opis: </b><a id="description"><?=nl2br(htmlspecialchars($row['description']))?></a>
  52. </div>
  53. <?
  54. $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
  55. $prev=$prev[0];
  56. if($prev>0) {
  57. $prev=$DB->query('SELECT * FROM photos WHERE id<'.$id.' ORDER BY id DESC LIMIT 1;')->fetch_assoc(); #if yes, get the previous photo's data
  58. ?>
  59. <div id="prev">
  60. <a onclick="javascript:prev()">
  61. <img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="images/upload/<?=$prev['thumb_name']?>" /><br/>
  62. </a>
  63. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  64. </div>
  65. <?
  66. }
  67. else {
  68. ?>
  69. <div id="prev" style="display: none">
  70. <a onclick="javascript:prev()">
  71. <img id="prev_image" height="100px" alt="" src="" /><br/>
  72. </a>
  73. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  74. </div>
  75. <?
  76. }
  77. $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
  78. $next=$next[0];
  79. if($next>0) {
  80. $next=$DB->query('SELECT * FROM photos WHERE id>'.$id.' ORDER BY id ASC LIMIT 1;')->fetch_assoc(); #if yes, get the next photo's data
  81. ?>
  82. <div id="next">
  83. <a onclick="javascript:next()">
  84. <img id="next_image" height="100px" alt="<?=$next['id']?>" src="images/upload/<?=$next['thumb_name']?>" /><br/>
  85. </a>
  86. <a onclick="javascript:next()">Następne zdjęcie</a>
  87. </div>
  88. <?
  89. }
  90. else {
  91. ?>
  92. <div id="next" style="display: none">
  93. <a onclick="javascript:next()">
  94. <img id="next_image" height="100px" alt="" src="" /><br/>
  95. </a>
  96. <a onclick="javascript:next()">Następne zdjęcie</a>
  97. </div>
  98. <?
  99. }
  100. ?>
  101. </div>
  102. </body>
  103. </html>