Files
sg/robocze/ask.php
chp1994 6de08b68b4 Nowa wersja webmasterska
git-svn-id: https://svn.pioder.pl/sg-svn@12 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
2009-06-23 12:57:21 +00:00

52 lines
1.7 KiB
PHP

<?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?>">
<?
if (!$result = $DB->query('SELECT * FROM photos WHERE id=\'$i\''))
{
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>