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

<?php
require_once('./init.php'); #init stuff
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; #check which photo's info should be send
header('Content-Type: text/xml; charset="utf-8"');
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<display id="<?=$id?>">
<?
$sql = "SELECT * FROM `photos` WHERE `id`='$id'";
if (!$result = $DB->query($sql))
{
showError('MySQL error');
}
if ($result->num_rows == 0)
{
$row = array(
'author' => '--',
'description' => 'Zdjęcie usunięte',
'photo_name' => 'no_image.png',
'id' => $i
);
}
else
{
$row = $result->fetch_assoc();
$row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
$row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description'];
}
?>
<current id="<?=htmlspecialchars($row['id'])?>" src="<?=htmlspecialchars($row['photo_name'])?>">
<desc><?=nl2br(htmlspecialchars($row['description']))?></desc>
<author><?=htmlspecialchars($row['author'])?></author>
</current>
<?
$prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
$prev=$prev[0];
if($prev>0) {
$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
echo '<prev thumb="'.$prev['thumb_name'].'" id="'.$prev['id'].'" />'; #and send it
}
$next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
$next=$next[0];
if($next>0) {
$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
echo '<next thumb="'.$next['thumb_name'].'" id="'.$next['id'].'" />'; #and send it
}
?>
</display>