Lige et billed af hele koden:
<?php
if (!isset($_GET['page'])) { $page = ""; } else { $page = $_GET['page']; }
switch ($page) {
default:
// Drawing table
echo "<div align=\"center\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"8\" class=\"gallery\" border=\"0\">\n";
echo "<tr>\n";
// Getting files and putting into table
$dir = "simplegallery/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$i = 0;
while (($file = readdir($dh)) !== false) {
// HER ER DET ENE PROBLEM
list ($name, $type) = preg_split('[.]', $file);
if ($type == "JPG" || $type == "jpg" ) {
// Checking for thumbnails
if (!file_exists("thumbs/tb_".$file)) {
echo "<!-- to lighten page, run index.php?page=init (".$file." - thumbs/tb_".$file." not found) -->\n";
$thumbimg = "simplegallery/".$file;
} else {
echo "<!-- thumbs/tb_".$file." found -->";
$thumbimg = "thumbs/tb_".$file;
}
// Drawing pictures
echo " <td align=\"center\" valign=\"top\">\n";
echo "<a href=\"?page=picture&name=".$file."\" target=\"_top\"><img src=\"".$thumbimg."\" height=\"".$thumbsize."\" alt=\"\" border=\"0\" /></a><br />\n";
echo "<a href=\"?page=picture&name=".$file."\" target=\"_top\">".$name."</a>\n";
echo " </td>\n";
// Drawing linebreak for every n picturs
$i++;
if ($i >= $n) {
echo "</tr>\n";
echo "<tr>\n";
$i = 0;
}
}
}
closedir($dh);
}
}
echo "</tr>\n</table>\n</div>";
break;
case "picture":
if (isset($_GET['name'])) { $name = $_GET['name']; } else { header('Location:./'); exit; }
// Drawing table
echo "<div align=\"center\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"8\" class=\"gallery\" border=\"0\">\n";
echo "<tr>\n";
// Checking for standard pictures
if (!file_exists("standard/std_".$name)) {
echo "<!-- to lighten page, run index.php?page=init (".$name." - standard/std_".$name." not found) -->\n";
$standardimg = "simplegallery/".$name;
} else {
echo "<!-- standard/std_".$name." found -->";
$standardimg = "standard/std_".$name;
}
$dir = "simplegallery/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$i = 0;
while (($file = readdir($dh)) !== false) {
// HER ER DET ANDET PROBLEM
list($fname, $type) = preg_split('[.]', $file);
if ($type == "JPG" || $type == "jpg" ) {
$filename[$i] = $file;
$i++;
}
}
for ($t = 0; (count($filename)-1) >= $t; $t++) {
$looptest = $filename[$t];
if ($looptest == $name) {
if ($t == 0) {
echo " <td align=\"right\" width=\"40%\"><span class=\"grey\"><< previous</span></td>\n";
echo " <td align=\"center\" width=\"20%\"><a href=\"./\" target=\"_top\">up</a></td>\n";
echo " <td align=\"left\" width=\"40%\"><a href=\"?page=picture&name=".$filename[$t+1]."\" target=\"_top\">next >></a></td>\n";
} elseif ($t == (count($filename)-1)) {
echo " <td align=\"right\" width=\"40%\"><a href=\"?page=picture&name=".$filename[$t-1]."\" target=\"_top\"><< previous</a></td>\n";
echo " <td align=\"center\" width=\"20%\"><a href=\"./\" target=\"_top\">up</a></td>\n";
echo " <td align=\"left\" width=\"40%\"><span class=\"grey\">next >></span></td>\n";
} else {
echo " <td align=\"right\" width=\"40%\"><a href=\"?page=picture&name=".$filename[$t-1]."\" target=\"_top\"><< previous</a></td>\n";
echo " <td align=\"center\" width=\"20%\"><a href=\"./\" target=\"_top\">up</a></td>\n";
echo " <td align=\"left\" width=\"40%\"><a href=\"?page=picture&name=".$filename[$t+1]."\" target=\"_top\">next >></a></td>\n";
}
echo "</tr>\n<tr>\n";
echo " <td align=\"center\" colspan=\"3\">\n";
echo " <a href=\"simplegallery/".$name."\" target=\"_top\">\n";
echo " <img src=\"".$standardimg."\" height=\"".$standardsize."\" border=\"0\" alt=\"".$name."\" />\n";
echo " </a>\n";
echo " </td>\n";
}
}
}
}
echo "</tr>\n</table>\n</div>";
break;
case "init":
// Getting files and putting into table
$dir = "simplegallery/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$i = 0;
while (($file = readdir($dh)) !== false) {
list($name, $type) = split('[.]', $file);
if ($type == "JPG" || $type == "jpg" ) {
// Checking for thumbnails
if (!file_exists("thumbs/tb_".$file)) {
// Creating thumbnail
set_time_limit(30);
createImage($file, "simplegallery", $thumbsize, "thumbs", "tb_", 25);
echo "Thumbnail tb_".$file." created.<br />\n";
} else {
echo "File: tb_".$file." already excists<br />\n";
}
// Checking for standard pictures
if (!file_exists("standard/std_".$file)) {
// Creating standard picturs
set_time_limit(30);
createImage($file, "simplegallery", $standardsize, "standard", "std_", 100);
echo "Standard std_".$file." created.<br />\n";
} else {
echo "File: std_".$file." already excists<br />\n";
}
}
}
if ($autoexit_init == 1) {
header("Location:./");
exit;
}
}
}
break;
}
?>
Indlæg senest redigeret d. 02.10.2010 20:54 af Bruger #16176