Upload projektu webmasterskiego
git-svn-id: https://svn.pioder.pl/sg-svn@6 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
This commit is contained in:
20
robocze/ask.php
Normal file
20
robocze/ask.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?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>
|
||||||
75
robocze/index.php
Normal file
75
robocze/index.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?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>
|
||||||
10
robocze/init.php
Normal file
10
robocze/init.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?
|
||||||
|
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);
|
||||||
|
?>
|
||||||
119
robocze/script.js
Normal file
119
robocze/script.js
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
105
robocze/style.css
Normal file
105
robocze/style.css
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user