Poprawki w PHP i ścieżki do katalogu

git-svn-id: https://svn.pioder.pl/sg-svn@13 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
This commit is contained in:
pioder
2009-06-23 14:35:24 +00:00
parent 6de08b68b4
commit 2d445251b6
8 changed files with 474 additions and 349 deletions

View File

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

View File

@@ -1,7 +1,7 @@
<?php <?php
define('PERPAGE', 12); define('PERPAGE', 12);
define('DB_HOST', ''); define('DB_HOST', 'localhost');
define('DB_NAME', ''); define('DB_NAME', 'galeria');
define('DB_USER', ''); define('DB_USER', 'root');
define('DB_PASS', ''); define('DB_PASS', '');
?> ?>

View File

@@ -1,33 +1,35 @@
<?php <?php
require_once('init.php'); #init stuff /**
$id=(isset($_GET['id']))?intval($_GET['id']):1; #check which photo should be loaded * @package Galeria Suczawa 2009
* @file display.php
$xhtml = preg_match('/application\/xhtml\+xml(?![+a-z])(;q=(0\.\d{1,3}|[01]))?/i', * @version $Id$
$_SERVER['HTTP_ACCEPT'], $xhtml) && (isset($xhtml[2])?$xhtml[2]:1) > 0 || **/
strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false || require_once('./init.php'); #init stuff
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 $id=(isset($_GET['id'])) ? intval($_GET['id']) : 1; #check which photo should be loaded
echo '<?xml version="1.0" encoding="utf-8"?>';
?> NaglowekXHTML();
?>
<!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"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<title>Podgląd zdjęcia nr <?=$id?></title> <head>
<link type="text/css" href="style.css" rel="stylesheet" /> <title>Podgląd zdjęcia nr <?=$id?></title>
<script type="text/javascript"> <link type="text/css" href="style.css" rel="stylesheet" />
<!-- <[CDATA[ --> <script type="text/javascript">
path='http://<?=$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])?>'; <!-- <[CDATA[ -->
<!-- ]]> --> path='http://<?=$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI'])?>';
</script> <!-- ]]> -->
<script type="text/javascript" src="script.js"></script> </script>
</head> <script type="text/javascript" src="script.js"></script>
<body onload="init()"> </head>
<div id="display"> <body onload="init()">
<div id="display">
<? <?
if (!$result = $DB->query('SELECT * FROM photos WHERE id=\'$i\'')) $sql = "SELECT * FROM `photos` WHERE id='$id'";
if (!$result = $DB->query($sql))
{ {
showError('MySQL error'); showError('Nie mozna pobrac informacji o zdjeciu!');
} }
if ($result->num_rows == 0) if ($result->num_rows == 0)
@@ -45,61 +47,62 @@ else
$row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author']; $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author'];
$row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description']; $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> <div id="current">
<br/> <a href="images/upload/<?=htmlspecialchars($row['photo_name'])?>"><img id="curr_image" height="300px" alt="ZdjÄ_cie" src="images/upload/<?=htmlspecialchars($row['photo_name'])?>" /></a>
<b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br /> <br/>
<b>Opis: </b><a id="description"><?=nl2br(htmlspecialchars($row['description']))?></a> <b>Autor: </b><a id="author"><?=htmlspecialchars($row['author'])?></a><br />
</div> <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]; $prev = $DB->query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos
if($prev>0) { $prev=$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 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()"> <div id="prev">
<img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="<?=$prev['thumb_name']?>" /><br/> <a onclick="javascript:prev()">
</a> <img id="prev_image" height="100px" alt="<?=$prev['id']?>" src="images/upload/<?=$prev['thumb_name']?>" /><br/>
<a onclick="javascript:prev()">Poprzednie zdjęcie</a> </a>
</div> <a onclick="javascript:prev()">Poprzednie zdjęcie</a>
<? </div>
} <?
else { }
?> else {
<div id="prev" style="display: none"> ?>
<a onclick="javascript:prev()"> <div id="prev" style="display: none">
<img id="prev_image" height="100px" alt="" src="" /><br/> <a onclick="javascript:prev()">
</a> <img id="prev_image" height="100px" alt="" src="" /><br/>
<a onclick="javascript:prev()">Poprzednie zdjęcie</a> </a>
</div> <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]; $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos
if($next>0) { $next=$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 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()"> <div id="next">
<img id="next_image" height="100px" alt="<?=$next['id']?>" src="<?=$next['thumb_name']?>" /><br/> <a onclick="javascript:next()">
</a> <img id="next_image" height="100px" alt="<?=$next['id']?>" src="images/upload/<?=$next['thumb_name']?>" /><br/>
<a onclick="javascript:next()">Następne zdjęcie</a> </a>
</div> <a onclick="javascript:next()">Następne zdjęcie</a>
<? </div>
} <?
else { }
?> else {
<div id="next" style="display: none"> ?>
<a onclick="javascript:next()"> <div id="next" style="display: none">
<img id="next_image" height="100px" alt="" src="" /><br/> <a onclick="javascript:next()">
</a> <img id="next_image" height="100px" alt="" src="" /><br/>
<a onclick="javascript:next()">Następne zdjęcie</a> </a>
</div> <a onclick="javascript:next()">Następne zdjęcie</a>
<? </div>
} <?
?> }
</div> ?>
</body> </div>
</html> </body>
</html>

View File

@@ -1,5 +1,78 @@
<?php <?php
function showError($message) { /**
die($message); * @package Galeria Suczawa 2009
} * @file functions.php
?> * @version $Id$
* @author PioDer <pioder@wp.pl>
* @link http://suczawa.ath.cx/
**/
#wyświetl błąd
function blad($msg)
{
die('
<h1>Blad Galerii Zdjec Suczawa 2009!</h1>
<span style="color: red; font-weight: bold; font-size: 12pt">'.$msg.'</span>');
}
function NaglowekXHTML()
{
$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"?>';
}
function GenerujListeStron()
{
global $cnt;
global $page;
$content = '';
if ($page>1)
{
$content .= '<a href="?page=1" title="Pierwsza strona">&laquo;</a>';
$content .= '&nbsp;&nbsp;<a href="?page='.($page-1).'" title="Poprzednia strona">&lt;</a> ';
}
#wygeneruj strony
for ($i=1;$i<=$cnt;$i++)
{
if ($i==$page)
{
if ($i == $cnt)
{
$content .= '<span style="text-decoration: underline">'.$i.'</span>';
}
else
{
$content .= '<span style="text-decoration: underline">'.$i.'</span>'.' | ';
}
}
else
{
if ($i == $cnt)
{
$content .= '<a href="?page='.$i.'">'.$i.'</a> ';
}
else
{
$content .= '<a href="?page='.$i.'">'.$i.'</a> | ';
}
}
}
#dodaj linka "+1 strona" oraz do ostatniej
if ($page<$cnt)
{
$content .= '<a href="?page='.($page+1).'" title="Następna strona">&gt;</a>';
$content .= '&nbsp;&nbsp;<a href="?page='.$cnt.'" title="Ostatnia strona">&raquo;</a>';
}
#dodaj linka do ostatniej strony
echo $content;
}
?>

View File

@@ -1,75 +1,58 @@
<?php
require_once('init.php'); #init stuff
$page=(isset($_GET['page']))?intval($_GET['page']):1; #check which page 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>Galeria zdjęć</title>
<link type="text/css" href="style.css" rel="stylesheet" />
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="page">
<img src="images/logo.png" width="800px" alt="Logo strony" />
<div id="content">
<div id="images">
<?php <?php
if (!$result = $DB->query('SELECT * FROM photos LIMIT '.(($page-1)*PERPAGE).' , '.PERPAGE)) { /**
showError('MySQL error'); * @package Galeria Suczawa 2009
} * @file gallery.php
while($row = $result->fetch_assoc() ){ * @version $Id$
?> **/
<div class="image_outer">
<a target="blank" href="display.php?id=<?=$row['id']?>"> $page = (isset($_GET['page'])) ? intval($_GET['page']) : 0;
<img class="image" height="100px" alt="Zdjęcie: <?=$row['photo_name']?>" src="<?=$row['thumb_name']?>" id="image_<?=$row['id']?>" />
</a> require_once('./init.php'); #init stuff
</div> NaglowekXHTML();
<? ?>
}
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
</div> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<? <head>
if (!$result = $DB->query('SELECT COUNT(id) AS count FROM photos')) { <title>Galeria Zdjęć</title>
showError('MySQL error'); <link type="text/css" href="style.css" rel="stylesheet" />
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="page">
<img src="images/logo.png" width="800px" alt="Logo strony" />
<div id="content">
<div id="images">
<?php
$sql = "SELECT * FROM `photos` $limit";
if (!$result = $DB->query($sql))
{
blad('Nie mozna pobrac zdjec uzytkownikow!');
} }
$row = $result->fetch_assoc(); while($row = $result->fetch_assoc() )
$count = $row['count']; {
$pcount=ceil($result[0]/PERPAGE); ?>
?> <div class="image_outer">
<div id="pages">Strony: <a target="blank" href="display.php?id=<?=$row['id']?>">
<?if($page==1) <img class="image" height="100px" alt="Zdj___cie: <?= $row['photo_name']; ?>" src="images/upload/<?= $row['thumb_name']; ?>" id="image_<?=$row['id']?>" />
echo'&lt;&lt;&#160;&lt;&#160;|&#160;'; </a>
else </div>
echo '<a href="gallery.php?page=1">&lt;&lt;</a>&#160;<a href="gallery.php?page='.($page-1).'">&lt;</a>&#160;|&#160;'; <?
for($i=1; $i<$page; $i++) { }
echo '<a href="gallery.php?page='.$i.'">'.$i.'</a>&#160;|&#160;'; ?>
} </div>
echo $page.'&#160;|&#160;'; <div id="pages">Strony:
for($i=$page+1; $i<=$pcount; $i++) { <?
echo '<a href="gallery.php?page='.$i.'">'.$i.'</a>&#160;|&#160;'; GenerujListeStron();
} ?>
if($page==$pcount) </div>
echo '&gt;&#160;&gt;&gt;'; </div>
else <div id="footer">
echo '<a href="gallery.php?page='.($page+1).'">&gt;</a>&#160;<a href="gallery.php?page='.$pcount.'">&gt;&gt;</a>'; <a id="copyright">Copyright © 2009 ...</a><br />
?> <div id="links">
</div> <a href="index.php">Strona Główna</a> | <a href="gallery.php">Fotogaleria</a> | <a href="download.php">Download</a> | <a href="http://suczawa.ath.cx">Forum</a>
</div> </div>
<div id="footer"> </div>
<a id="copyright">Copyright © 2009 ...</a><br /> </div>
<div id="links"> </body>
<a href="index.php">Strona główna</a> | <a href="gallery.php">Fotogaleria</a> | <a href="download.php">Download</a> | <a href="http://suczawa.ath.cx">Forum</a> </html>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,34 +1,31 @@
<?php <?php
$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 || require_once('./functions.php');
strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false || NaglowekXHTML();
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>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <title>Strona Główna</title>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl"> <link type="text/css" href="style.css" rel="stylesheet" />
<head> </head>
<title>Strona główna</title> <body>
<link type="text/css" href="style.css" rel="stylesheet" /> <div id="page">
</head> <img src="images/logo.png" width="800px" alt="Logo strony" />
<body> <div id="content">
<div id="page"> <div id="dlinks">
<img src="images/logo.png" width="800px" alt="Logo strony" /> <a href="gallery.php"><img src="images/galeria.png" alt="Galeria Zdjęć" /></a> <br/>
<div id="content"> <a href="download.php"><img src="images/download.png" alt="Download" /></a> <br/>
<div id="dlinks"> <a href="http://suczawa.ath.cx"><img src="images/forum.png" alt="Forum" /></a>
<a href="gallery.php"><img src="images/galeria.png" alt="Galeria zdjęć" /></a> <br/> </div>
<a href="download.php"><img src="images/download.png" alt="Download" /></a> <br/> </div>
<a href="http://suczawa.ath.cx"><img src="images/forum.png" alt="Forum" /></a> <div id="footer">
</div> <a id="copyright">Copyright © 2009 ...</a><br />
</div> <div id="links">
<div id="footer"> <a href="index.php">Strona główna</a> | <a href="gallery.php">Fotogaleria</a> | <a href="download.php">Download</a> | <a href="http://suczawa.ath.cx">Forum</a>
<a id="copyright">Copyright © 2009 ...</a><br /> </div>
<div id="links"> </div>
<a href="index.php">Strona główna</a> | <a href="gallery.php">Fotogaleria</a> | <a href="download.php">Download</a> | <a href="http://suczawa.ath.cx">Forum</a> </div>
</div> </body>
</div> </html>
</div>
</body>
</html>

View File

@@ -1,12 +1,78 @@
<? <?php
require_once('config.php'); /**
require_once('functions.php'); * @package Galeria Suczawa 2009
* @file init.php
* @version $Id$
**/
#dołącz plik konfiguracyjny oraz funkcje
require_once('./config.php');
require_once('./functions.php');
#sprawdź, czy jest wyłączone register globals oraz magic quotes?
if (ini_get('register_globals') == 1)
{
ini_set('register_globals', '0');
if (ini_get('register_globals') == 1)
{
blad('Could not disable register_globals.');
}
}
if (get_magic_quotes_gpc())
{
blad('Prosze wylaczyc magic_quotes_gpc w php.ini!');
}
$DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); #connect with the database $DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); #connect with the database
if ($DB->connect_error) { #check if there were any errors connecting if ($DB->connect_error)
showError('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error); { #check if there were any errors connecting
blad('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error);
} }
if (!$DB->query("SET NAMES 'utf8'")) { #use utf-8
showError('Could not set character to UTF-8'); if (!$DB->query("SET NAMES 'utf8'")) #użyj utf-8
} {
?> blad('Could not set character to UTF-8');
}
#pobierz liczbę zdjęć w galerii
$sql = "SELECT COUNT(`id`) AS `count` FROM `photos`";
if (!$result = $DB->query($sql))
{
blad('Nie mozna odczytac liczby zdjec!');
}
$row = $result->fetch_assoc();
$count = $row['count'];
$result->free; //zwolnij pamięć
//
//wygeneruj strone
//
if (isset($_GET['page'])&&($_GET['page']!=1))
{
if (!is_numeric($_GET['page']))
{
die('Hacking attempt');
}
$value = ($_GET['page']-1)*PERPAGE;
$limit = 'LIMIT '.$value . ', '.PERPAGE;
$page = $_GET['page'];
}
else
{
$limit = 'LIMIT 0, '.PERPAGE;
$page=1;
}
$cnt = ceil($count / PERPAGE);
if(isset($_GET['page']) && ($_GET['page']>$cnt))
{
blad('Podana strona nie istnieje!');
}
//
//koniec generowania stron
//
?>

View File

@@ -1,103 +1,104 @@
var ajax, previd, nextid; var ajax, previd, nextid;
function init() { function init() {
initAjax(); initAjax();
if (!document.importNode) { if (!document.importNode) {
document.importNode = function(node, allChildren) { document.importNode = function(node, allChildren) {
switch (node.nodeType) { switch (node.nodeType) {
case 1: case 1:
var newNode = document.createElement(node.nodeName); var newNode = document.createElement(node.nodeName);
if (allChildren && node.childNodes && node.childNodes.length > 0) { if (allChildren && node.childNodes && node.childNodes.length > 0) {
il=node.childNodes.length; il=node.childNodes.length;
for (var i = 0; i < il; i++) for (var i = 0; i < il; i++)
newNode.appendChild(document.importNode(node.childNodes[i], allChildren)); newNode.appendChild(document.importNode(node.childNodes[i], allChildren));
} }
return newNode; return newNode;
break; break;
default: default:
return document.createTextNode(node.nodeValue); return document.createTextNode(node.nodeValue);
break; break;
} }
}; };
} }
nextid=(document.getElementById("next_image")!=null)?document.getElementById("next_image").alt:-1; nextid=(document.getElementById("next_image")!=null)?document.getElementById("next_image").alt:-1;
previd=(document.getElementById("prev_image")!=null)?document.getElementById("prev_image").alt:-1; previd=(document.getElementById("prev_image")!=null)?document.getElementById("prev_image").alt:-1;
} }
function initAjax() { function initAjax() {
try { try {
if (window.XMLHttpRequest) { if (window.XMLHttpRequest) {
ajax = new XMLHttpRequest(); ajax = new XMLHttpRequest();
ajax.overrideMimeType('text/xml'); ajax.overrideMimeType('text/xml');
} }
else if (window.ActiveXObject) else if (window.ActiveXObject)
ajax = new ActiveXObject('Microsoft.XMLHTTP'); ajax = new ActiveXObject('Microsoft.XMLHTTP');
else throw 'AJAX Error'; else throw 'AJAX Error';
} }
catch (e) { catch (e) {
return false; return false;
} }
if (!ajax) { if (!ajax) {
alert('AJAX Error'); alert('AJAX Error');
return false; return false;
} }
return true; return true;
} }
function response() { function response() {
if (ajax.readyState != 4 || ajax.status != 200) if (ajax.readyState != 4 || ajax.status != 200)
return; return;
var xml = ajax.responseXML; var xml = ajax.responseXML;
document.getElementById("curr_image").parentNode.href=document.getElementById("curr_image").src=xml.getElementsByTagName("current")[0].getAttribute("src"); document.getElementById("curr_image").parentNode.href=document.getElementById("curr_image").src='images/upload/'+xml.getElementsByTagName("current")[0].getAttribute("src");
document.getElementById("author").firstChild.nodeValue=xml.getElementsByTagName("author")[0].firstChild.nodeValue; document.title = 'Podgląd zdjęcia nr ' + xml.getElementsByTagName("current")[0].getAttribute("id");
document.getElementById("author").firstChild.nodeValue=xml.getElementsByTagName("author")[0].firstChild.nodeValue;
desc=document.getElementById("description");
while(desc.hasChildNodes()) desc.removeChild(desc.firstChild); desc=document.getElementById("description");
while(desc.hasChildNodes()) desc.removeChild(desc.firstChild);
children=document.importNode(xml.getElementsByTagName("desc")[0], true).childNodes;
for(i=0; i<children.length; i++) { children=document.importNode(xml.getElementsByTagName("desc")[0], true).childNodes;
desc.appendChild(children[i]); for(i=0; i<children.length; i++) {
} desc.appendChild(children[i]);
}
document.getElementById("current").src=xml.getElementsByTagName("current")[0].getAttribute("src");
document.getElementById("current").src=xml.getElementsByTagName("current")[0].getAttribute("src");
if(xml.getElementsByTagName("next").length>0) {
document.getElementById("next_image").src=xml.getElementsByTagName("next")[0].getAttribute("thumb"); if(xml.getElementsByTagName("next").length>0) {
nextid=xml.getElementsByTagName("next")[0].getAttribute("id"); document.getElementById("next_image").src='images/upload/'+xml.getElementsByTagName("next")[0].getAttribute("thumb");
document.getElementById("next_image").alt=nextid; nextid=xml.getElementsByTagName("next")[0].getAttribute("id");
document.getElementById("next").style.display="block"; document.getElementById("next_image").alt=nextid;
} document.getElementById("next").style.display="block";
else { }
document.getElementById("next").style.display="none"; else {
nextid=-1; document.getElementById("next").style.display="none";
} nextid=-1;
}
if(xml.getElementsByTagName("prev").length>0) {
document.getElementById("prev_image").src=xml.getElementsByTagName("prev")[0].getAttribute("thumb"); if(xml.getElementsByTagName("prev").length>0) {
previd=xml.getElementsByTagName("prev")[0].getAttribute("id"); document.getElementById("prev_image").src='images/upload/'+xml.getElementsByTagName("prev")[0].getAttribute("thumb");
document.getElementById("prev_image").alt=previd; previd=xml.getElementsByTagName("prev")[0].getAttribute("id");
document.getElementById("prev").style.display="block"; document.getElementById("prev_image").alt=previd;
} document.getElementById("prev").style.display="block";
else { }
document.getElementById("prev").style.display="none"; else {
previd=-1; document.getElementById("prev").style.display="none";
} previd=-1;
} }
}
function previewImage(el) {
if(el==-1) return 0; function previewImage(el) {
ajax.onreadystatechange = response; if(el==-1) return 0;
ajax.open('GET', path+ '/ask.php?id=' + el, true); ajax.onreadystatechange = response;
ajax.send(null); ajax.open('GET', path+ '/ask.php?id=' + el, true);
} ajax.send(null);
}
function prev() {
previewImage(previd); function prev() {
} previewImage(previd);
}
function next() {
previewImage(nextid); function next() {
} previewImage(nextid);
}