Jag har två php sidor som jag använder för att visa bilder.
thumbs.php och show.php
i thumbs.php så visas alla thumbs från en mapp - trycker man på en bild så kommer man till show.php
Jag skulle vilja att show.php kom upp i ett popupfönster istället.
Alla funktioner hämtas från en functions.inc
thumbs.php
function show_thumbs($cols, $th_width, $th_height, $cellpadding,
$cellspacing, $perpage)
{
$dir = $_GET["dir"];
$tot = count_files($dir);
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
if (isset($_GET["img"])) {
$img = $_GET["img"];
}
global $showfilename;
global $hidefilenameext;
if ($page == NULL) {
$page = ceil($img / $perpage);
}
echo "<div style='text-align: center'>";
echo "<table border='0' cellpadding='$cellpadding'
cellspacing='$cellspacing' align='center'>\n";
echo "<tr>\n";
$filelist = list_files("./$dir/thumbs");
$n = 1;
$end = min(($page * $perpage), sizeof($filelist));
for ($i = (($page - 1) * $perpage); $i < $end; $i++)
{
echo "<td align='center'>\n";
echo "<table border='0' cellspacing='1' cellpadding='0'
bgcolor='#F8F8F8'>\n";
echo "<tr><td>\n";
echo "<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
"&page=$page'>\n";
echo "<img src='$dir/thumbs/$filelist[$i]' width='$th_width'
height='$th_height' border='0'><br>\n";
echo "</a>\n";
echo "</td></tr>\n";
echo "</table>\n";
if ($showfilename)
{
if ($hidefilenameext) {
echo "<small>".substr($filelist[$i], 0, strrpos($filelist[$i], '.'))."</small>";
}
else
{
echo "<small>$filelist[$i]</small>";
}
}
echo "</td>\n";
if (($n % $cols) == 0 && ($n != $perpage))
{
echo "</tr>";
echo "<tr align='center'>";
}
$n++;
}
echo "</tr>\n";
echo "</table>";
// We need to show thumbs in more than one page
if (sizeof($filelist) > $perpage) {
echo ("Page: ");
for ($j = 1; $j <= ceil(sizeof($filelist) / $perpage); $j++) {
echo ("<a href='thumbs.php?dir=$dir&page=".$j."'>");
// Current page
if ($page == $j) {
echo "<b>".$j."</b>";
}
else
{
echo $j;
}
echo "</a>";
echo (" ");
}
echo "<br><br>";
}
echo "<a href='index.php'>Album</a> ";
echo "</div>";
}
show.php
function show_picture()
{
$dir = $_GET["dir"];
$tot = $_GET["tot"];
$img = $_GET["img"];
echo "<div style='text-align: center'>";
echo "<big>\n";
if ($img > 1)
{
echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'><<</a>";
}
echo "  \n";
echo "</big>\n";
echo "<b>".$img."</b> of ".$tot;
echo "  \n";
echo "<big>\n";
if ($img < $tot)
{
echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>>></a>";
}
echo "</big>\n";
echo "<br><br>\n";
echo "<table border='0' cellspacing='1' cellpadding='0'
bgcolor='#F8F8F8' align='center'>\n";
echo "<tr><td>\n";
echo "<a href='thumbs.php?dir=$dir&img=$img'>";
echo "<img src='$dir/".search_file("./$dir", $img)."' border=0
onLoad='resize(this);' name=foto
alt='Click to go to thumbnails page.'>";
echo "</a>";
echo "</td></tr>\n";
echo "</table>\n";
echo "<br><br>\n";
echo "<big>\n";
if ($img > 1)
{
echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'><<</a>";
}
echo "  \n";
if ($img < $tot)
{
echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>>></a>";
}
echo "</big>\n";
echo "<br><br>\n";
echo "<a href='index.php'>Album</a> - ";
echo "<a href='thumbs.php?dir=$dir&img=$img'>Bilder</a>";
echo "<br><br>\n";
echo "</div>";
}
?>