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.

51 lines
1.7 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. if (!$result = $DB->query('SELECT * FROM photos WHERE id=\'$i\''))
  10. {
  11. showError('MySQL error');
  12. }
  13. if ($result->num_rows == 0)
  14. {
  15. $row = array(
  16. 'author' => '--',
  17. 'description' => 'Zdjęcie usunięte',
  18. 'photo_name' => 'no_image.png',
  19. 'id' => $i
  20. );
  21. }
  22. else
  23. {
  24. $row = $result->fetch_assoc();
  25. $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
  26. $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
  27. }
  28. ?>
  29. <current id="<?=htmlspecialchars($row['id'])?>" src="<?=htmlspecialchars($row['photo_name'])?>">
  30. <desc><?=nl2br(htmlspecialchars($row['description']))?></desc>
  31. <author><?=htmlspecialchars($row['author'])?></author>
  32. </current>
  33. <?
  34. $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
  35. $prev=$prev[0];
  36. if($prev>0) {
  37. $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
  38. echo '<prev thumb="'.$prev['thumb_name'].'" id="'.$prev['id'].'" />'; #and send it
  39. }
  40. $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
  41. $next=$next[0];
  42. if($next>0) {
  43. $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
  44. echo '<next thumb="'.$next['thumb_name'].'" id="'.$next['id'].'" />'; #and send it
  45. }
  46. ?>
  47. </display>