diff --git a/robocze/ask.php b/robocze/ask.php index 38ff4e4..b2d97ca 100644 --- a/robocze/ask.php +++ b/robocze/ask.php @@ -1,20 +1,52 @@ -'; -?> - - - : -

- - - - -
+ +* @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 ''; +?> + + + : +

+ + + + +
diff --git a/robocze/config.php b/robocze/config.php new file mode 100644 index 0000000..8599acb --- /dev/null +++ b/robocze/config.php @@ -0,0 +1,17 @@ + +* @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; +?> diff --git a/robocze/dump.txt b/robocze/dump.txt new file mode 100644 index 0000000..b2c6b67 --- /dev/null +++ b/robocze/dump.txt @@ -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.'); diff --git a/robocze/functions.php b/robocze/functions.php new file mode 100644 index 0000000..5b4952e --- /dev/null +++ b/robocze/functions.php @@ -0,0 +1,67 @@ + +* @link http://suczawa.ath.cx/ +**/ + +#wyÅ›wietl bÅ‚Ä…d +function blad($msg) +{ + die(' +

Blad Galerii Zdjec Suczawa 2009!

+ '.$msg.''); +} + +function GenerujListeStron() +{ + global $cnt; + global $page; + $content = ''; + + if ($page>1) + { + $content .= '<<'; + $content .= '  < '; + } + + #wygeneruj strony + for ($i=1;$i<=$cnt;$i++) + { + if ($i==$page) + { + if ($i == $cnt) + { + $content .= ''.$i.''; + } + else + { + $content .= ''.$i.''.' | '; + } + } + else + { + if ($i == $cnt) + { + $content .= ''.$i.' '; + } + else + { + $content .= ''.$i.' | '; + } + } + } + #dodaj linka "+1 strona" oraz do ostatniej + if ($page<$cnt) + { + $content .= '>'; + $content .= '  >>'; + } + + #dodaj linka do ostatniej strony + echo $content; +} + +?> diff --git a/robocze/index.php b/robocze/gallery.php similarity index 53% rename from robocze/index.php rename to robocze/gallery.php index ca4bc8c..b96d1bf 100644 --- a/robocze/index.php +++ b/robocze/gallery.php @@ -1,75 +1,90 @@ - 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 '' -?> - - - - - Galeria - - - - -
-
- - '.$row['photo_name'].''; - if($i%3==2 && $i!=$count-1) echo ''; - - } - while($i%3) { - $i++; - echo ''; - } - ?> - -
 
-
-
-
Strony: - '.($i+1).' | '; - } - if($page!=$pcount) echo ($page+1).' | '; - else echo ($page+1); - for($i=$page+1; $i<$pcount; $i++) { - echo ''.($i+1).' | '; - } - if($page!=$pcount) echo ''.($pcount+1).''; - ?> -
-
-
-
-
-

-
- Poprzedni - Zdjęcie - Następny -
-
-
Autor:
- Zamknij -
-
-
-
- Valid XHTML 1.1 - Poprawny CSS! -
-
- - + +* @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 ''; + +?> + + + + + Galeria Suczawa 2009 + + + + + +
+
+ + query($sql)) + { + blad('Nie mozna pobrac zdjec uzytkownikow!'); + } + + for($i=$page*$per_page; $row = $result->fetch_assoc(); $i++) + { + echo ''; + if($i%3==2 && $i!=$count-1) echo ''; + + } + while($i%3) { + $i++; + echo ''; + } + ?> + +
'.$row['photo_name'].'
 
+
+
+
Strony: + +
+
+
+
+
+

+
+ Poprzedni + Zdjecie + Nastepny +
+
+
Autor:
+ Zamknij +
+
+
+
+ Valid XHTML 1.1 + Poprawny CSS! +
+
+ + diff --git a/robocze/images/next.png b/robocze/images/next.png new file mode 100644 index 0000000..9f0a94b Binary files /dev/null and b/robocze/images/next.png differ diff --git a/robocze/images/next_i.png b/robocze/images/next_i.png new file mode 100644 index 0000000..b254983 Binary files /dev/null and b/robocze/images/next_i.png differ diff --git a/robocze/images/prev.png b/robocze/images/prev.png new file mode 100644 index 0000000..fd2bae7 Binary files /dev/null and b/robocze/images/prev.png differ diff --git a/robocze/images/prev_i.png b/robocze/images/prev_i.png new file mode 100644 index 0000000..f4b8acd Binary files /dev/null and b/robocze/images/prev_i.png differ diff --git a/robocze/images/upload/DSCF0372.png b/robocze/images/upload/DSCF0372.png new file mode 100644 index 0000000..50b5ad7 Binary files /dev/null and b/robocze/images/upload/DSCF0372.png differ diff --git a/robocze/images/upload/DSCF0372_m.png b/robocze/images/upload/DSCF0372_m.png new file mode 100644 index 0000000..a658cda Binary files /dev/null and b/robocze/images/upload/DSCF0372_m.png differ diff --git a/robocze/images/upload/DSCF0452.png b/robocze/images/upload/DSCF0452.png new file mode 100644 index 0000000..add2413 Binary files /dev/null and b/robocze/images/upload/DSCF0452.png differ diff --git a/robocze/images/upload/DSCF0452_m.png b/robocze/images/upload/DSCF0452_m.png new file mode 100644 index 0000000..f574fe1 Binary files /dev/null and b/robocze/images/upload/DSCF0452_m.png differ diff --git a/robocze/images/upload/DSC_0026.png b/robocze/images/upload/DSC_0026.png new file mode 100644 index 0000000..e7da855 Binary files /dev/null and b/robocze/images/upload/DSC_0026.png differ diff --git a/robocze/images/upload/DSC_0026_m.png b/robocze/images/upload/DSC_0026_m.png new file mode 100644 index 0000000..466a18d Binary files /dev/null and b/robocze/images/upload/DSC_0026_m.png differ diff --git a/robocze/images/upload/DSC_0080.png b/robocze/images/upload/DSC_0080.png new file mode 100644 index 0000000..aa8f3fc Binary files /dev/null and b/robocze/images/upload/DSC_0080.png differ diff --git a/robocze/images/upload/DSC_0080_m.png b/robocze/images/upload/DSC_0080_m.png new file mode 100644 index 0000000..1aeab02 Binary files /dev/null and b/robocze/images/upload/DSC_0080_m.png differ diff --git a/robocze/images/upload/DSC_0132.png b/robocze/images/upload/DSC_0132.png new file mode 100644 index 0000000..2ad6de1 Binary files /dev/null and b/robocze/images/upload/DSC_0132.png differ diff --git a/robocze/images/upload/DSC_0132_m.png b/robocze/images/upload/DSC_0132_m.png new file mode 100644 index 0000000..9849953 Binary files /dev/null and b/robocze/images/upload/DSC_0132_m.png differ diff --git a/robocze/images/upload/DSC_0169.png b/robocze/images/upload/DSC_0169.png new file mode 100644 index 0000000..69fe4a9 Binary files /dev/null and b/robocze/images/upload/DSC_0169.png differ diff --git a/robocze/images/upload/DSC_0169_m.png b/robocze/images/upload/DSC_0169_m.png new file mode 100644 index 0000000..81dd30f Binary files /dev/null and b/robocze/images/upload/DSC_0169_m.png differ diff --git a/robocze/images/upload/DSC_0294.png b/robocze/images/upload/DSC_0294.png new file mode 100644 index 0000000..351c249 Binary files /dev/null and b/robocze/images/upload/DSC_0294.png differ diff --git a/robocze/images/upload/DSC_0294_m.png b/robocze/images/upload/DSC_0294_m.png new file mode 100644 index 0000000..f35f33b Binary files /dev/null and b/robocze/images/upload/DSC_0294_m.png differ diff --git a/robocze/images/upload/DSC_0378.png b/robocze/images/upload/DSC_0378.png new file mode 100644 index 0000000..877748b Binary files /dev/null and b/robocze/images/upload/DSC_0378.png differ diff --git a/robocze/images/upload/DSC_0378_m.png b/robocze/images/upload/DSC_0378_m.png new file mode 100644 index 0000000..aec4418 Binary files /dev/null and b/robocze/images/upload/DSC_0378_m.png differ diff --git a/robocze/images/upload/DSC_0672.png b/robocze/images/upload/DSC_0672.png new file mode 100644 index 0000000..f59a058 Binary files /dev/null and b/robocze/images/upload/DSC_0672.png differ diff --git a/robocze/images/upload/DSC_0672_m.png b/robocze/images/upload/DSC_0672_m.png new file mode 100644 index 0000000..e2acaa2 Binary files /dev/null and b/robocze/images/upload/DSC_0672_m.png differ diff --git a/robocze/images/upload/no_image.png b/robocze/images/upload/no_image.png new file mode 100644 index 0000000..0579f45 Binary files /dev/null and b/robocze/images/upload/no_image.png differ diff --git a/robocze/init.php b/robocze/init.php index 65e0d8b..0de3fba 100644 --- a/robocze/init.php +++ b/robocze/init.php @@ -1,10 +1,105 @@ - + +* @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 +// +?> diff --git a/robocze/script.js b/robocze/script.js index 76ed265..a5eb48a 100644 --- a/robocze/script.js +++ b/robocze/script.js @@ -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