|
|
- <?php
- require_once('init.php'); #init stuff
- $id=(isset($_GET['id']))?intval($_GET['id']):1; #check which photo should be loaded
-
- $xhtml = preg_match('/application\/xhtml\+xml(?![+a-z])(;q=(0\.\d{1,3}|[01]))?/i',
- $_SERVER['HTTP_ACCEPT'], $xhtml) && (isset($xhtml[2])?$xhtml[2]:1) > 0 ||
- strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false ||
- strpos($_SERVER["HTTP_USER_AGENT"], "WebKit")!==false;
- header('Content-Type: '.($xhtml?'application/xhtml+x':'text/ht').'ml; charset="utf-8"'); #IE doesn't support application/xhtml+xml - workaround
- echo '<?xml version="1.0" encoding="utf-8"?>';
- ?>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
- <head>
- <title>Podgląd zdjęcia nr <?=$id?></title>
- <link type="text/css" href="style.css" rel="stylesheet" />
- <script type="text/javascript">
- <!-- <[CDATA[ -->
- path='http://<?=$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])?>';
- <!-- ]]> -->
- </script>
- <script type="text/javascript" src="script.js"></script>
- </head>
- <body onload="init()">
- <div id="display">
- <?
- 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'];
- }?>
- <div id="current">
- <a href="<?=htmlspecialchars($row['photo_name'])?>"><img id="curr_image" height="300px" alt="Zdjęcie" src="<?=htmlspecialchars($row['photo_name'])?>" /></a>
- <br/>
- <b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br />
- <b>Opis: </b><a id="description"><?=nl2br(htmlspecialchars($row['description']))?></a>
- </div>
- <?
- $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
- ?>
- <div id="prev">
- <a onclick="javascript:prev()">
- <img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="<?=$prev['thumb_name']?>" /><br/>
- </a>
- <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
- </div>
- <?
- }
- else {
- ?>
- <div id="prev" style="display: none">
- <a onclick="javascript:prev()">
- <img id="prev_image" height="100px" alt="" src="" /><br/>
- </a>
- <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
- </div>
- <?
- }
- $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
- ?>
- <div id="next">
- <a onclick="javascript:next()">
- <img id="next_image" height="100px" alt="<?=$next['id']?>" src="<?=$next['thumb_name']?>" /><br/>
- </a>
- <a onclick="javascript:next()">Następne zdjęcie</a>
- </div>
- <?
- }
- else {
- ?>
- <div id="next" style="display: none">
- <a onclick="javascript:next()">
- <img id="next_image" height="100px" alt="" src="" /><br/>
- </a>
- <a onclick="javascript:next()">Następne zdjęcie</a>
- </div>
- <?
- }
- ?>
- </div>
- </body>
- </html>
|