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.

105 lines
3.4 KiB

  1. <?php
  2. require_once('init.php'); #init stuff
  3. $id=(isset($_GET['id']))?intval($_GET['id']):1; #check which photo should be loaded
  4. $xhtml = preg_match('/application\/xhtml\+xml(?![+a-z])(;q=(0\.\d{1,3}|[01]))?/i',
  5. $_SERVER['HTTP_ACCEPT'], $xhtml) && (isset($xhtml[2])?$xhtml[2]:1) > 0 ||
  6. strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false ||
  7. strpos($_SERVER["HTTP_USER_AGENT"], "WebKit")!==false;
  8. header('Content-Type: '.($xhtml?'application/xhtml+x':'text/ht').'ml; charset="utf-8"'); #IE doesn't support application/xhtml+xml - workaround
  9. echo '<?xml version="1.0" encoding="utf-8"?>';
  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. if (!$result = $DB->query('SELECT * FROM photos WHERE id=\'$i\''))
  27. {
  28. showError('MySQL error');
  29. }
  30. if ($result->num_rows == 0)
  31. {
  32. $row = array(
  33. 'author' => '--',
  34. 'description' => 'Zdjęcie usunięte',
  35. 'photo_name' => 'no_image.png',
  36. 'id' => $i
  37. );
  38. }
  39. else
  40. {
  41. $row = $result->fetch_assoc();
  42. $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
  43. $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
  44. }?>
  45. <div id="current">
  46. <a href="<?=htmlspecialchars($row['photo_name'])?>"><img id="curr_image" height="300px" alt="Zdjęcie" src="<?=htmlspecialchars($row['photo_name'])?>" /></a>
  47. <br/>
  48. <b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br />
  49. <b>Opis: </b><a id="description"><?=nl2br(htmlspecialchars($row['description']))?></a>
  50. </div>
  51. <?
  52. $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
  53. $prev=$prev[0];
  54. if($prev>0) {
  55. $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
  56. ?>
  57. <div id="prev">
  58. <a onclick="javascript:prev()">
  59. <img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="<?=$prev['thumb_name']?>" /><br/>
  60. </a>
  61. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  62. </div>
  63. <?
  64. }
  65. else {
  66. ?>
  67. <div id="prev" style="display: none">
  68. <a onclick="javascript:prev()">
  69. <img id="prev_image" height="100px" alt="" src="" /><br/>
  70. </a>
  71. <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
  72. </div>
  73. <?
  74. }
  75. $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
  76. $next=$next[0];
  77. if($next>0) {
  78. $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
  79. ?>
  80. <div id="next">
  81. <a onclick="javascript:next()">
  82. <img id="next_image" height="100px" alt="<?=$next['id']?>" src="<?=$next['thumb_name']?>" /><br/>
  83. </a>
  84. <a onclick="javascript:next()">Następne zdjęcie</a>
  85. </div>
  86. <?
  87. }
  88. else {
  89. ?>
  90. <div id="next" style="display: none">
  91. <a onclick="javascript:next()">
  92. <img id="next_image" height="100px" alt="" src="" /><br/>
  93. </a>
  94. <a onclick="javascript:next()">Następne zdjęcie</a>
  95. </div>
  96. <?
  97. }
  98. ?>
  99. </div>
  100. </body>
  101. </html>