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.

53 lines
1.8 KiB

  1. <?php
  2. require_once('./init.php'); #init stuff
  3. $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; #check which photo's info should be send
  4. header('Content-Type: text/xml; charset="utf-8"');
  5. echo '<?xml version="1.0" encoding="utf-8"?>';
  6. ?>
  7. <display id="<?=$id?>">
  8. <?
  9. $sql = "SELECT * FROM `photos` WHERE `id`='$id'";
  10. if (!$result = $DB->query($sql))
  11. {
  12. showError('MySQL error');
  13. }
  14. if ($result->num_rows == 0)
  15. {
  16. $row = array(
  17. 'author' => '--',
  18. 'description' => 'Zdjęcie usunięte',
  19. 'photo_name' => 'no_image.png',
  20. 'id' => $i
  21. );
  22. }
  23. else
  24. {
  25. $row = $result->fetch_assoc();
  26. $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
  27. $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
  28. }
  29. ?>
  30. <current id="<?=htmlspecialchars($row['id'])?>" src="<?=htmlspecialchars($row['photo_name'])?>">
  31. <desc><?=nl2br(htmlspecialchars($row['description']))?></desc>
  32. <author><?=htmlspecialchars($row['author'])?></author>
  33. </current>
  34. <?
  35. $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
  36. $prev=$prev[0];
  37. if($prev>0) {
  38. $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
  39. echo '<prev thumb="'.$prev['thumb_name'].'" id="'.$prev['id'].'" />'; #and send it
  40. }
  41. $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
  42. $next=$next[0];
  43. if($next>0) {
  44. $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
  45. echo '<next thumb="'.$next['thumb_name'].'" id="'.$next['id'].'" />'; #and send it
  46. }
  47. ?>
  48. </display>