- Zmieniono stronnicowanie - Dodano buttony oraz przykładowe zdjęcia do testów skryptu - Prowadzono 2 nowe pliki: functions.php - z funkcjami oraz config.php - konfiguracją - Wprowadzono mniej ważne poprawki git-svn-id: https://svn.pioder.pl/sg-svn@7 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8master
@ -1,20 +1,52 @@ | |||
<?php | |||
$i=intval($_GET['name'])+1; | |||
require('init.php'); | |||
$result = mysql_query('SELECT * FROM photos WHERE id='.$i); | |||
$row = mysql_fetch_assoc($result); | |||
if(!row) die('Error'); | |||
header('Content-Type: text/xml'); | |||
echo '<?xml version="1.0" encoding="utf-8"?>'; | |||
?> | |||
<data> | |||
<name><?=$row['id']?>: <?=basename($row['photo_name'])?></name> | |||
<desc xmlns="http://www.w3.org/1999/xhtml"><p><?=$row['description']?></p></desc> | |||
<src><?=$row['photo_name']?></src> | |||
<author><?=$row['author']?></author> | |||
<?if($i==$count){?><last /><? } ?> | |||
<?if($i==0){?><first /><? } ?> | |||
</data> | |||
<?php | |||
/** | |||
* @package Galeria Suczawa 2009 | |||
* @file ask.php | |||
* @version $Id$ | |||
* @author chp1994 <chp1994@gmail.com> | |||
* @link http://suczawa.ath.cx/ | |||
**/ | |||
$i=intval($_GET['name']); | |||
require('./init.php'); | |||
if ($i == 0) | |||
{ | |||
blad('Zdjecie nie istnieje!'); | |||
} | |||
$sql = "SELECT * FROM `photos` WHERE `id`='$i'"; | |||
if (!$result = $DB->query($sql)) | |||
{ | |||
blad('Nie mozna pobrac informacji o zdjeciu!'); | |||
} | |||
#sprawdź, czy zdjęcie istnieje | |||
$cnt = $result->num_rows; | |||
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']; | |||
} | |||
header('Content-Type: text/xml'); | |||
echo '<?xml version="1.0" encoding="utf-8"?>'; | |||
?> | |||
<data> | |||
<name><?=$row['id']?>: <?=basename($row['photo_name'])?></name> | |||
<desc xmlns="http://www.w3.org/1999/xhtml"><p><?=$row['description']?></p></desc> | |||
<src><?=$row['photo_name']?></src> | |||
<author><?= $row['author']; ?></author> | |||
<?if($i==$lastid){?><last /><? } ?> | |||
<?if($i==$firstid){?><first /><? } ?> | |||
</data> |
@ -0,0 +1,17 @@ | |||
<? | |||
/** | |||
* @package Galeria Suczawa 2009 | |||
* @file config.php | |||
* @version $Id$ | |||
* @author PioDer <pioder@wp.pl> | |||
* @link http://suczawa.ath.cx/ | |||
**/ | |||
define('DB_HOST','localhost'); | |||
define('DB_USER','root'); | |||
define('DB_PASS',''); | |||
define('DB_NAME','galeria'); | |||
//liczba zdjęć na stronę | |||
$per_page=3; | |||
?> |
@ -0,0 +1,64 @@ | |||
-- phpMyAdmin SQL Dump | |||
-- version 3.1.3.1 | |||
-- http://www.phpmyadmin.net | |||
-- | |||
-- Host: localhost | |||
-- Czas wygenerowania: 16 Cze 2009, 12:36 | |||
-- Wersja serwera: 5.1.33 | |||
-- Wersja PHP: 5.2.9 | |||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; | |||
-- | |||
-- Baza danych: `galeria` | |||
-- | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Struktura tabeli dla `admins` | |||
-- | |||
CREATE TABLE IF NOT EXISTS `admins` ( | |||
`id` smallint(1) NOT NULL, | |||
`nick` varchar(20) NOT NULL, | |||
`password` varchar(200) NOT NULL, | |||
`email` varchar(20) NOT NULL, | |||
`IP` varchar(14) NOT NULL, | |||
PRIMARY KEY (`id`) | |||
) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |||
-- | |||
-- Zrzut danych tabeli `admins` | |||
-- | |||
-- -------------------------------------------------------- | |||
-- | |||
-- Struktura tabeli dla `photos` | |||
-- | |||
CREATE TABLE IF NOT EXISTS `photos` ( | |||
`id` smallint(4) NOT NULL, | |||
`thumb_name` varchar(20) NOT NULL, | |||
`photo_name` varchar(20) NOT NULL, | |||
`author` varchar(30) NOT NULL, | |||
`description` text NOT NULL, | |||
PRIMARY KEY (`id`) | |||
) ENGINE=MyISAM DEFAULT CHARSET=utf8; | |||
-- | |||
-- Zrzut danych tabeli `photos` | |||
-- | |||
INSERT INTO `photos` (`id`, `thumb_name`, `photo_name`, `author`, `description`) VALUES | |||
(1, 'DSC_0026_m.png', 'DSC_0026.png', '', 'Pod zamkiem - grupowo'), | |||
(2, 'DSC_0132_m.png', 'DSC_0132.png', '', 'Pod szko³¹'), | |||
(3, 'DSC_0169_m.png', 'DSC_0169.png', '', 'Widoki na Monastyr'), | |||
(4, 'DSC_0294_m.png', 'DSC_0294.png', '', 'Bukowina Po³udniowa'), | |||
(5, 'DSC_0378_m.png', 'DSC_0378.png', '', 'Pani Monika :)'), | |||
(6, 'DSC_0080_m.png', 'DSC_0080.png', '', 'Nasz Geniusz podczas rozdawania nagród ;)'), | |||
(7, 'DSC_0672_m.png', 'DSC_0672.png', '', 'W¹wóz...'), | |||
(8, 'DSCF0372_m.png', 'DSCF0372.png', '', 'Œwi¹tynia w Monastyrze'), | |||
(9, 'DSCF0452_m.png', 'DSCF0452.png', '', 'Kolejna fotka z w¹wozu.'); |
@ -0,0 +1,67 @@ | |||
<? | |||
/** | |||
* @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 GenerujListeStron() | |||
{ | |||
global $cnt; | |||
global $page; | |||
$content = ''; | |||
if ($page>1) | |||
{ | |||
$content .= '<a href="?page=1" title="Pierwsza strona"><<</a>'; | |||
$content .= ' <a href="?page='.($page-1).'" title="Poprzednia strona"><</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">></a>'; | |||
$content .= ' <a href="?page='.$cnt.'" title="Ostatnia strona">>></a>'; | |||
} | |||
#dodaj linka do ostatniej strony | |||
echo $content; | |||
} | |||
?> |
@ -1,75 +1,90 @@ | |||
<?php | |||
$page=(isset($_GET['page']))?intval($_GET['page']):0; | |||
$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"'); | |||
require('init.php'); | |||
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</title> | |||
<link type="text/css" href="style.css" rel="stylesheet" /> | |||
<script type="text/javascript" src="script.js"></script> | |||
</head> | |||
<body onload="javascipt:init()"> | |||
<div id="page"> | |||
<div id="images_outer"> | |||
<table id="images"><tr> | |||
<?php | |||
$result = mysql_query('SELECT * FROM photos LIMIT '.($page*$per_page).', '.$per_page); | |||
for($i=$page*$per_page; $row = mysql_fetch_assoc($result); $i++) { | |||
echo '<td class="image_outer" onclick="javascript:previewImage('.$i.')"><img alt="'.$row['photo_name'].'" src="'.$row['thumb_name'].'" class="image" /></td>'; | |||
if($i%3==2 && $i!=$count-1) echo '</tr><tr>'; | |||
} | |||
while($i%3) { | |||
$i++; | |||
echo '<td class="image_outer_black"> </td>'; | |||
} | |||
?> | |||
</tr> | |||
</table> | |||
</div> | |||
<div id="pages_outer"> | |||
<div id="pages">Strony: | |||
<?php | |||
$pcount = ceil($count/$per_page)-1; | |||
for($i=0; $i<$page; $i++) { | |||
echo '<a href="?page='.$i.'">'.($i+1).'</a> | '; | |||
} | |||
if($page!=$pcount) echo ($page+1).' | '; | |||
else echo ($page+1); | |||
for($i=$page+1; $i<$pcount; $i++) { | |||
echo '<a href="?page='.$i.'">'.($i+1).'</a> | '; | |||
} | |||
if($page!=$pcount) echo '<a href="?page='.($pcount).'">'.($pcount+1).'</a>'; | |||
?> | |||
</div> | |||
</div> | |||
<div id="disp"> | |||
<div id="disp_middle"> | |||
<div id="disp_inner"> | |||
<div><h3 id="disp_name"> </h3></div> | |||
<div id="disp_top"> | |||
<img id="disp_prev" src="img/prev.png" onclick="javascript:prev()" alt="Poprzedni"></img> | |||
<a id="disp_a" href=""><img id="disp_img" src="" alt="Zdjęcie" /></a> | |||
<img id="disp_next" src="img/next.png" onclick="javascript:next()" alt="Następny"></img> | |||
</div> | |||
<div id="disp_info"></div> | |||
<div><b>Autor:</b> <a id="disp_author"> </a></div> | |||
<a id="disp_close" onclick="javascript:closeDisp()">Zamknij</a> | |||
</div> | |||
</div> | |||
</div> | |||
<div id="icons"> | |||
<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a> | |||
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img width="88px" height="31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Poprawny CSS!" /></a> | |||
</div> | |||
</div> | |||
</body> | |||
</html> | |||
<?php | |||
/** | |||
* @package Galeria Suczawa 2009 | |||
* @file gallery.php | |||
* @version $Id$ | |||
* @author chp1994 <chp1994@gmail.com> | |||
* @link http://suczawa.ath.cx/ | |||
**/ | |||
$page= (isset($_GET['page'])) ? intval($_GET['page']) : 0; | |||
$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"'); | |||
require('./init.php'); | |||
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 Suczawa 2009</title> | |||
<link type="text/css" href="style.css" rel="stylesheet" /> | |||
<script type="text/javascript"> | |||
<!-- | |||
sciezka = 'http://' + '<?= $_SERVER['HTTP_HOST']; ?>' + '/sg/robocze/'; | |||
//--> | |||
</script> | |||
<script type="text/javascript" src="script.js"><!-- AJAX Library by chp1994(c) //--></script> | |||
</head> | |||
<body onload="javascipt:init()"> | |||
<div id="page"> | |||
<div id="images_outer"> | |||
<table id="images"><tr> | |||
<?php | |||
//$sql = "SELECT * FROM `photos` LIMIT ".($page*$per_page).", $per_page"; | |||
$sql = "SELECT * FROM `photos` $limit"; | |||
if (!$result = $DB->query($sql)) | |||
{ | |||
blad('Nie mozna pobrac zdjec uzytkownikow!'); | |||
} | |||
for($i=$page*$per_page; $row = $result->fetch_assoc(); $i++) | |||
{ | |||
echo '<td class="image_outer" onclick="javascript:previewImage('.($row['id']).')"><img alt="'.$row['photo_name'].'" src="images/upload/'.$row['thumb_name'].'" class="image" /></td>'; | |||
if($i%3==2 && $i!=$count-1) echo '</tr><tr>'; | |||
} | |||
while($i%3) { | |||
$i++; | |||
echo '<td class="image_outer_black"> </td>'; | |||
} | |||
?> | |||
</tr> | |||
</table> | |||
</div> | |||
<div id="pages_outer"> | |||
<div id="pages">Strony: | |||
<?php | |||
GenerujListeStron(); | |||
?> | |||
</div> | |||
</div> | |||
<div id="disp"> | |||
<div id="disp_middle"> | |||
<div id="disp_inner"> | |||
<div><h3 id="disp_name"> </h3></div> | |||
<div id="disp_top"> | |||
<img id="disp_prev" src="images/prev.png" onclick="javascript:prev()" alt="Poprzedni"></img> | |||
<a id="disp_a" href=""><img id="disp_img" src="" alt="Zdjecie" /></a> | |||
<img id="disp_next" src="images/next.png" onclick="javascript:next()" alt="Nastepny"></img> | |||
</div> | |||
<div id="disp_info"></div> | |||
<div><b>Autor:</b> <a id="disp_author"> </a></div> | |||
<a id="disp_close" onclick="javascript:closeDisp()">Zamknij</a> | |||
</div> | |||
</div> | |||
</div> | |||
<div id="icons"> | |||
<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a> | |||
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img width="88px" height="31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Poprawny CSS!" /></a> | |||
</div> | |||
</div> | |||
</body> | |||
</html> |
@ -1,10 +1,105 @@ | |||
<? | |||
mysql_pconnect('HOST', 'USER', 'PASS'); | |||
mysql_select_db('DB'); | |||
mysql_query("SET NAMES 'utf8'"); | |||
$per_page=6; | |||
$result = mysql_query('SELECT COUNT(id) FROM photos'); | |||
$count= mysql_result($result, 0); | |||
?> | |||
<? | |||
/** | |||
* @package Galeria Suczawa 2009 | |||
* @file init.php | |||
* @version $Id$ | |||
* @author chp1994 <chp1994@gmail.com> | |||
* @link http://suczawa.ath.cx/ | |||
**/ | |||
#dołącz plik konfiguracyjny oraz funkcje | |||
require('./config.php'); | |||
require('./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!'); | |||
} | |||
#połącz z bazą danych | |||
$DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |||
#sprawdź pomyślność połączenia | |||
if ($DB->connect_error) | |||
{ | |||
blad('Could not connect do database server ('.$DB->connect_errno.')'.$DB->connect_error); | |||
} | |||
if (!$DB->query("SET NAMES 'utf8'")) | |||
{ | |||
blad('Could not set character to UTF-8'); | |||
} | |||
#pobierz id pierwszego zdjęcia | |||
$sql = "SELECT `id` FROM `photos` ORDER BY `id` LIMIT 1"; | |||
if (!$result = $DB->query($sql)) | |||
{ | |||
blad('Nie mozna odczytac id pierwszego zdjecia!'); | |||
} | |||
$row = $result->fetch_assoc(); | |||
$firstid = $row['id']; | |||
$result->free; //zwolnij pamięć | |||
unset($row); | |||
#pobierz id ostatniego zdjęcia | |||
$sql = "SELECT `id` FROM `photos` ORDER BY `id` DESC LIMIT 1"; | |||
if (!$result = $DB->query($sql)) | |||
{ | |||
blad('Nie mozna odczytac id ostatniego zdjecia!'); | |||
} | |||
$row = $result->fetch_assoc(); | |||
$lastid = $row['id']; | |||
$result->free; //zwolnij pamięć | |||
unset($row); | |||
#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)*$per_page; | |||
$limit = 'LIMIT '.$value . ', '.$per_page; | |||
$page = $_GET['page']; | |||
} | |||
else | |||
{ | |||
$limit = 'LIMIT 0, '.$per_page; | |||
$page=1; | |||
} | |||
$cnt = ceil($count / $per_page); | |||
if(isset($_GET['page']) && ($_GET['page']>$cnt)) | |||
{ | |||
blad('Podana strona nie istnieje!'); | |||
} | |||
// | |||
//koniec generowania stron | |||
// | |||
?> |
@ -1,119 +1,118 @@ | |||
var ajax; | |||
var disp; | |||
var disp_img; | |||
var disp_info; | |||
var disp_name; | |||
var disp_author, disp_a; | |||
var curr, last, first; | |||
function init() { | |||
initAjax(); | |||
disp=document.getElementById("disp"); | |||
disp_a=document.getElementById("disp_a"); | |||
disp_name=document.getElementById("disp_name"); | |||
disp_author=document.getElementById("disp_author"); | |||
disp_img=document.getElementById("disp_img"); | |||
disp_info=document.getElementById("disp_info"); | |||
if (!document.importNode) { | |||
document.importNode = function(node, allChildren) { | |||
switch (node.nodeType) { | |||
case 1: | |||
var newNode = document.createElement(node.nodeName); | |||
/*if (node.attributes && node.attributes.length > 0) | |||
for (var i = 0; il = node.attributes.length; i < il) | |||
newNode.setAttribute(node.attributes[i].nodeName, node.getAttribute(node.attributes[i++].nodeName));*/ | |||
//alert("Attr done"); | |||
if (allChildren && node.childNodes && node.childNodes.length > 0) { | |||
il=node.childNodes.length; | |||
for (var i = 0; i < il; i++) | |||
newNode.appendChild(document.importNode(node.childNodes[i], allChildren)); | |||
} | |||
return newNode; | |||
break; | |||
default: | |||
return document.createTextNode(node.nodeValue); | |||
break; | |||
} | |||
}; | |||
} | |||
if(!disp_name.firstChild) | |||
disp_name.appendChild(document.createTextNode(' ')); | |||
if(!disp_author.firstChild) | |||
disp_author.appendChild(document.createTextNode(' ')); | |||
} | |||
function initAjax() { | |||
try { | |||
if (window.XMLHttpRequest) { | |||
ajax = new XMLHttpRequest(); | |||
ajax.overrideMimeType('text/xml'); | |||
} | |||
else if (window.ActiveXObject) | |||
ajax = new ActiveXObject('Microsoft.XMLHTTP'); | |||
else throw 'AJAX Error'; | |||
} | |||
catch (e) { | |||
return false; | |||
} | |||
if (!ajax) { | |||
alert('AJAX Error'); | |||
return false; | |||
} | |||
return true; | |||
} | |||
function response() { | |||
if (ajax.readyState != 4 || ajax.status != 200) | |||
return; | |||
var xml = ajax.responseXML; | |||
while(disp_info.hasChildNodes()) disp_info.removeChild(disp_info.firstChild); | |||
elemXML=xml.getElementsByTagName("desc")[0]; | |||
if(document.importNode) children=document.importNode(elemXML, true).childNodes; | |||
else children=elemXML.childNodes; | |||
for(i=0; i<children.length; i++) { | |||
disp_info.appendChild(children[i]); | |||
} | |||
disp_img.src=xml.getElementsByTagName("src")[0].firstChild.nodeValue; | |||
disp_a.href=xml.getElementsByTagName("src")[0].firstChild.nodeValue; | |||
disp_name.firstChild.nodeValue=xml.getElementsByTagName("name")[0].firstChild.nodeValue; | |||
disp_author.firstChild.nodeValue=xml.getElementsByTagName("author")[0].firstChild.nodeValue; | |||
if(xml.getElementsByTagName("last").length) { | |||
document.getElementById("disp_next").src="img/next_i.png"; | |||
last=true; | |||
} | |||
if(xml.getElementsByTagName("first").length) { | |||
document.getElementById("disp_prev").src="img/prev_i.png"; | |||
first=true; | |||
} | |||
disp.style.display="block"; | |||
} | |||
function previewImage(el) { | |||
curr=el; | |||
last=false; | |||
first=false | |||
document.getElementById("disp_next").src="img/next.png"; | |||
document.getElementById("disp_prev").src="img/prev.png"; | |||
ajax.onreadystatechange = response; | |||
ajax.open('GET', 'http://www.amharc.yoyo.pl/ask.php?name=' + el, true); | |||
ajax.send(null); | |||
} | |||
function prev() { | |||
if(!first) previewImage(curr-1); | |||
} | |||
function next() { | |||
if(!last) previewImage(curr+1); | |||
} | |||
function closeDisp() { | |||
disp.style.display="none"; | |||
} | |||
var ajax; | |||
var disp; | |||
var disp_img; | |||
var disp_info; | |||
var disp_name; | |||
var disp_author, disp_a; | |||
var curr, last, first; | |||
function init() { | |||
initAjax(); | |||
disp=document.getElementById("disp"); | |||
disp_a=document.getElementById("disp_a"); | |||
disp_name=document.getElementById("disp_name"); | |||
disp_author=document.getElementById("disp_author"); | |||
disp_img=document.getElementById("disp_img"); | |||
disp_info=document.getElementById("disp_info"); | |||
if (!document.importNode) { | |||
document.importNode = function(node, allChildren) { | |||
switch (node.nodeType) { | |||
case 1: | |||
var newNode = document.createElement(node.nodeName); | |||
/*if (node.attributes && node.attributes.length > 0) | |||
for (var i = 0; il = node.attributes.length; i < il) | |||
newNode.setAttribute(node.attributes[i].nodeName, node.getAttribute(node.attributes[i++].nodeName));*/ | |||
//alert("Attr done"); | |||
if (allChildren && node.childNodes && node.childNodes.length > 0) { | |||
il=node.childNodes.length; | |||
for (var i = 0; i < il; i++) | |||
newNode.appendChild(document.importNode(node.childNodes[i], allChildren)); | |||
} | |||
return newNode; | |||
break; | |||
default: | |||
return document.createTextNode(node.nodeValue); | |||
break; | |||
} | |||
}; | |||
} | |||
if(!disp_name.firstChild) | |||
disp_name.appendChild(document.createTextNode(' ')); | |||
if(!disp_author.firstChild) | |||
disp_author.appendChild(document.createTextNode(' ')); | |||
} | |||
function initAjax() { | |||
try { | |||
if (window.XMLHttpRequest) { | |||
ajax = new XMLHttpRequest(); | |||
ajax.overrideMimeType('text/xml'); | |||
} | |||
else if (window.ActiveXObject) | |||
ajax = new ActiveXObject('Microsoft.XMLHTTP'); | |||
else throw 'AJAX Error'; | |||
} | |||
catch (e) { | |||
return false; | |||
} | |||
if (!ajax) { | |||
alert('AJAX Error'); | |||
return false; | |||
} | |||
return true; | |||
} | |||
function response() { | |||
if (ajax.readyState != 4 || ajax.status != 200) | |||
return; | |||
var xml = ajax.responseXML; | |||
while(disp_info.hasChildNodes()) disp_info.removeChild(disp_info.firstChild); | |||
elemXML=xml.getElementsByTagName("desc")[0]; | |||
if(document.importNode) children=document.importNode(elemXML, true).childNodes; | |||
else children=elemXML.childNodes; | |||
for(i=0; i<children.length; i++) { | |||
disp_info.appendChild(children[i]); | |||
} | |||
disp_img.src= 'images/upload/' + xml.getElementsByTagName("src")[0].firstChild.nodeValue; | |||
disp_a.href= 'images/upload/' + xml.getElementsByTagName("src")[0].firstChild.nodeValue; | |||
disp_name.firstChild.nodeValue=xml.getElementsByTagName("name")[0].firstChild.nodeValue; | |||
disp_author.firstChild.nodeValue=xml.getElementsByTagName("author")[0].firstChild.nodeValue; | |||
if(xml.getElementsByTagName("last").length) { | |||
document.getElementById("disp_next").src="images/next_i.png"; | |||
last=true; | |||
} | |||
if(xml.getElementsByTagName("first").length) { | |||
document.getElementById("disp_prev").src="images/prev_i.png"; | |||
first=true; | |||
} | |||
disp.style.display="block"; | |||
} | |||
function previewImage(el) { | |||
curr=el; | |||
last=false; | |||
first=false | |||
document.getElementById("disp_next").src="images/next.png"; | |||
document.getElementById("disp_prev").src="images/prev.png"; | |||
ajax.onreadystatechange = response; | |||
ajax.open('GET', sciezka + 'ask.php?name=' + el, true); | |||
ajax.send(null); | |||
} | |||
function prev() { | |||
if(!first) previewImage(curr-1); | |||
} | |||
function next() { | |||
if(!last) previewImage(curr+1); | |||
} | |||
function closeDisp() { | |||
disp.style.display="none"; | |||
} |
@ -1,105 +1,110 @@ | |||
body { | |||
background-color: black; | |||
text-align: center; | |||
} | |||
#page { | |||
margin: auto; | |||
width: 700px; | |||
} | |||
.image_outer_black { | |||
width: 190px; | |||
height: 120px; | |||
padding: 7px; | |||
margin: 5px; | |||
display: inline-block; | |||
text-align: center; | |||
} | |||
.image_outer { | |||
width: 190px; | |||
height: 120px; | |||
padding: 7px; | |||
margin: 5px; | |||
background-color: gray; | |||
display: inline-block; | |||
text-align: center; | |||
cursor: pointer; | |||
} | |||
.image_outer:hover { | |||
background-color: #F0F0F0; | |||
} | |||
.image { | |||
max-width: 200px; | |||
max-height: 120px; | |||
} | |||
#images_outer { | |||
text-align: center; | |||
} | |||
#images { | |||
margin:auto; | |||
} | |||
#disp { | |||
width: 80%; | |||
background-color: gray; | |||
border: solid 1px black; | |||
margin-left: auto; | |||
margin-right: auto; | |||
position: fixed; | |||
top: 10%; | |||
left: 10%; | |||
display:none; | |||
text-align: center; | |||
padding: 2px; | |||
font-size: 8pt; | |||
} | |||
#disp_close { | |||
cursor: pointer; | |||
} | |||
#disp_close:hover { | |||
text-decoration: underline; | |||
} | |||
#disp_a, #disp_a img { | |||
border: none; | |||
} | |||
#disp_prev, #disp_next { | |||
margin-bottom: 15%; | |||
} | |||
#disp_img { | |||
text-align: center; | |||
margin:auto; | |||
max-height: 300px; | |||
max-width: 80%; | |||
height: 300px; | |||
} | |||
#disp_info { | |||
clear: both; | |||
} | |||
#icons { | |||
padding: 0px; | |||
margin: 0px; | |||
text-align: center; | |||
} | |||
#icons a, #icons img { | |||
padding: 0px; | |||
margin: 0px; | |||
text-decoration: none; | |||
border: none; | |||
} | |||
#pages { | |||
color: white; | |||
text-align: left; | |||
margin-left: 40px; | |||
} | |||
#pages a, #pages a:link, #pages a:hover, #pages a:visited { | |||
color: white; | |||
} | |||
body { | |||
background-color: black; | |||
text-align: center; | |||
} | |||
a { | |||
text-decoration: none; | |||
} | |||
a:hover { | |||
text-decoration: underline; | |||
} | |||
#page { | |||
margin: auto; | |||
width: 700px; | |||
} | |||
.image_outer_black { | |||
width: 190px; | |||
height: 120px; | |||
padding: 7px; | |||
margin: 5px; | |||
display: inline-block; | |||
text-align: center; | |||
} | |||
.image_outer { | |||
width: 190px; | |||
height: 120px; | |||
padding: 7px; | |||
margin: 5px; | |||
background-color: gray; | |||
display: inline-block; | |||
text-align: center; | |||
cursor: pointer; | |||
} | |||
.image_outer:hover { | |||
background-color: #F0F0F0; | |||
} | |||
.image { | |||
max-width: 200px; | |||
max-height: 120px; | |||
} | |||
#images_outer { | |||
text-align: center; | |||
} | |||
#images { | |||
margin:auto; | |||
} | |||
#disp { | |||
width: 80%; | |||
background-color: gray; | |||
border: solid 1px black; | |||
margin-left: auto; | |||
margin-right: auto; | |||
position: fixed; | |||
top: 10%; | |||
left: 10%; | |||
display:none; | |||
text-align: center; | |||
padding: 2px; | |||
font-size: 8pt; | |||
} | |||
#disp_close { | |||
cursor: pointer; | |||
} | |||
#disp_close:hover { | |||
text-decoration: underline; | |||
} | |||
#disp_a, #disp_a img { | |||
border: none; | |||
} | |||
#disp_prev, #disp_next { | |||
margin-bottom: 15%; | |||
} | |||
#disp_img { | |||
text-align: center; | |||
margin:auto; | |||
max-height: 300px; | |||
max-width: 80%; | |||
height: 300px; | |||
} | |||
#disp_info { | |||
clear: both; | |||
} | |||
#icons { | |||
padding: 0px; | |||
margin: 0px; | |||
text-align: center; | |||
} | |||
#icons a, #icons img { | |||
padding: 0px; | |||
margin: 0px; | |||
text-decoration: none; | |||
border: none; | |||
} | |||
#pages { | |||
color: white; | |||
text-align: left; | |||
margin-left: 40px; | |||
} | |||
#pages a, #pages a:link, #pages a:hover, #pages a:visited { | |||
color: white; | |||
} |