<?php
error_reporting(E_ALL);
ini_set("display_errors", "1");
#################################################
# One-page Gallery v.9.0 #
#################################################
#
#Copyright (C) 2005 Karma Wangchuk Sonam
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#Check http://www.phoenixphp.net for newer version
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
############################################################################
$open = @$_GET['content'];
$num = @$_GET['num'];
$slik = @$_GET['slika'];
$path = $_SERVER['DOCUMENT_ROOT'] . "/onepage/";
$path2 = "http://" . $_SERVER['SERVER_NAME'] . "/onepage";
$thumbs_break = '<div id="thumbs_break"> </div>';
include_once($path . "scripts/onepage_custom.php");
$main_dir = opendir($path . "gallery");
while (false !== ($folders = readdir($main_dir))) {
if($folders == "." || $folders == ".." ) {
continue;
} else {
$dirs[] = $folders;
}
}
sort($dirs);
if(count($dirs) != count($all_dirs) || $all_dirs[0] == "") {
$chosen = $dirs;
} else {
$chosen = $all_dirs;
}
if(empty($open) || array_search($open, $chosen) === FALSE) {
$dir = $path . "gallery/" . $chosen[0];
$open = $chosen[0];
} else {
$dir = $path . "gallery/" . $open;
}
foreach($chosen as $val) {
if(strpos($dir, $val) === FALSE) {
$dir_nasl = file($path . "gallery/" . $val . "/title.txt");
$dirs_nasl = @$dirs_nasl . "<a href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$val'); return true \" >$dir_nasl[0]</a>";
}
}
$count_dirs = count($chosen);
if($count_dirs > 1){
$other_dirs = '<div id="gall_other">' . $other_gall . $dirs_nasl . '</div>';
} else {
$other_dirs = '<div id="gall_other"> </div>';
}
$openDir = opendir($dir);
while (false !== ($fileNames = readdir($openDir))) {
if(strpos($fileNames, "txt") !== FALSE && strpos($fileNames, "title") !== FALSE ) {
$gall_nasl = file($dir . "/" . $fileNames);
$gall_naslov = '<div id="gall_title">' . $gall_nasl[0] . '</div>';
}
if($fileNames == "." || $fileNames == ".." || strpos($fileNames, "txt") !== FALSE) {
continue;
} else {
$ff[] = $fileNames;
}
}
$count_ff = count($ff);
if($num == "") {
$num = 0;
}
$n=$num+$max_thumbs;
$p=$num-$max_thumbs;
if($p < 0 ) {
$prev = '<div id="gall_prev" style="height:' . $thumbs_WH . 'px; background:transparent;"> </div>';
} else {
$prev = '<div id="gall_prev" style="height:' . $thumbs_WH . 'px;">' . '<a style="height:' . $thumbs_WH . 'px;"' . "href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$open&num=$p'); return true \" > </a>" . '</div>';
}
if($n > ($count_ff-1)) {
$next = '<div id="gall_next" style="height:' . $thumbs_WH . 'px; background:transparent;"> </div>';
} else {
$next = '<div id="gall_next" style="height:' . $thumbs_WH . 'px;">' . '<a style="height:' . $thumbs_WH . 'px;"' . " href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$open&num=$n'); return true \" > </a>" . '</div>';
}
foreach($ff as $key => $value) {
$display = $path2 . "/gallery/" . $open . "/" . $ff[$key]; $vals = $ff[$key];
$sizes = @getimagesize($display);
if($key == $n) { break; }
if($key < $num) { continue; }
// resize images
if ($sizes[0] >= $sizes[1] && $sizes[0] > $thumbs_WH) {
$resize = $sizes[0]/$thumbs_WH;
$width = round($sizes[0]/$resize);
$height = round($sizes[1]/$resize);
$margin = round(($thumbs_WH - $height)/2);
$img = '<div class="gall_thumb" style="height:' . $thumbs_WH . 'px; width:' . $thumbs_WH . 'px;">' . '<a style="width:' . $thumbs_WH . 'px; height:' . $thumbs_WH . "px; display:block;\" href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$open&num=$num&slika=$key'); return true \" >" . '<img style="margin-top:' . $margin . 'px;" src="' . $display . '" width="' . $width . '" height="' . $height . '" border="0" alt="" title="" /></a></div>' ;
$resize2 = $sizes[0]/$image_WH;
$width2 = round($sizes[0]/$resize2);
$height2 = round($sizes[1]/$resize2);
$img2 = '<img src="' . $display . '" width="' . $width2 . '" height="' . $height2 . '" border="0" alt="" title="" />';
$slike[$key] = $img2;
} elseif($sizes[0] < $sizes[1] && $sizes[1] > $thumbs_WH) {
$resize = $sizes[1]/$thumbs_WH;
$height = round($sizes[1]/$resize);
$width = round($sizes[0]/$resize);
$margin = round(($thumbs_WH - $height)/2);
$img = '<div class="gall_thumb" style="height:' . $thumbs_WH . 'px; width:' . $thumbs_WH . 'px;">' . '<a style="width:' . $thumbs_WH . 'px; height:' . $thumbs_WH . "px; display:block;\" href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$open&num=$num&slika=$key'); return true \" >" . '<img style="margin-top:' . $margin . 'px;" src="' . $display . '" width="' . $width . '" height="' . $height . '" border="0" alt="" title="" /></a></div>';
$resize2 = $sizes[1]/$image_WH;
$width2 = round($sizes[0]/$resize2);
$height2 = round($sizes[1]/$resize2);
$img2 = '<img src="' . $display . '" width="' . $width2 . '" height="' . $height2 . '" border="0" alt="" title="" />';
$slike[$key] = $img2;
} else {
$width = $sizes[0];
$height = $sizes[1];
$margin = round(($thumbs_WH - $height)/2);
$img = '<div class="gall_thumb" style="height:' . $thumbs_WH . 'px; width:' . $thumbs_WH . 'px;">' . '<a style="width:' . $thumbs_WH . 'px; height:' . $thumbs_WH . "px; display:block;\" href=\"javascript:void(0)\" onClick=\"loadurl('$path2/scripts/onepage.php?content=$open&num=$num&slika=$key'); return true \" >" . '<img style="margin-top:' . $margin . 'px;" src="' . $display . '" width="' . $width . '" height="' . $height . '" border="0" alt="" title="" /></a></div>';
$width2 = $sizes[0];
$height2 = $sizes[1];
$img2 = '<img src="' . $display . '" width="' . $width2 . '" height="' . $height2 . '" border="0" alt="" title="" />';
$slike[$key] = $img2;
}
$thumbs = @$thumbs . $img;
}
if($slik == ""){
$slika = $slike[$num];
} else {
$slika = $slike[$slik];
}
echo '<div id="onepage">' . $gall_naslov . $other_dirs . '<div id="gall_thumbs">' . $prev . $thumbs . $next . $thumbs_break . '</div>' . '<div id="gall_image" style="height:' . ($image_WH+20) . 'px">' . $slika . '<br /><a style="font-size:10px;" href="http://phoenixphp.net/onepage/" target="_blank">~ Powered by Phoenix PHP ~</a></div></div>';
?>