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.

109 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. <meta http-equiv="Content-Type" content="<?=$xhtml?'application/xhtml+x':'text/ht'?>ml; charset=utf-8" />
  17. <script type="text/javascript">
  18. <!-- <[CDATA[ -->
  19. path='http://<?=$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])?>';
  20. <!-- ]]> -->
  21. </script>
  22. <script type="text/javascript" src="script.js"></script>
  23. </head>
  24. <body onload="init()">
  25. <div id="display">
  26. <?
  27. $sql = "SELECT * FROM `photos` WHERE id='$id'";
  28. if (!$result = $DB->query($sql))
  29. {
  30. showError('Nie mozna pobrac informacji o zdjeciu!');
  31. }
  32. if ($result->num_rows == 0)
  33. {
  34. $row = array(
  35. 'author' => '--',
  36. 'description' => 'Zdjęcie usunięte',
  37. 'photo_name' => 'no_image.png',
  38. 'id' => $i
  39. );
  40. }
  41. else
  42. {
  43. $row = $result->fetch_assoc();
  44. $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
  45. $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
  46. }
  47. ?>
  48. <div id="current">
  49. <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>
  50. <br/>
  51. <b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br />
  52. <b>Opis: </b><a id="description"><?=nl2br(htmlspecialchars($row['description']))?></a>
  53. </div>
  54. <?
  55. $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
  56. $prev=$prev[0];
  57. if($prev>0) {
  58. $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
  59. ?>
  60. <div id="prev">
  61. <a onclick="javascript:prev()">
  62. <img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="images/upload/<?=$prev['thumb_name']?>" /><br/>
  63. </a>
  64. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  65. </div>
  66. <?
  67. }
  68. else {
  69. ?>
  70. <div id="prev" style="display: none">
  71. <a onclick="javascript:prev()">
  72. <img id="prev_image" height="100px" alt="" src="" /><br/>
  73. </a>
  74. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  75. </div>
  76. <?
  77. }
  78. $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
  79. $next=$next[0];
  80. if($next>0) {
  81. $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
  82. ?>
  83. <div id="next">
  84. <a onclick="javascript:next()">
  85. <img id="next_image" height="100px" alt="<?=$next['id']?>" src="images/upload/<?=$next['thumb_name']?>" /><br/>
  86. </a>
  87. <a onclick="javascript:next()">Następne zdjęcie</a>
  88. </div>
  89. <?
  90. }
  91. else {
  92. ?>
  93. <div id="next" style="display: none">
  94. <a onclick="javascript:next()">
  95. <img id="next_image" height="100px" alt="" src="" /><br/>
  96. </a>
  97. <a onclick="javascript:next()">Następne zdjęcie</a>
  98. </div>
  99. <?
  100. }
  101. ?>
  102. </div>
  103. </body>
  104. </html>