PHP gallery
Jeg har denne fine lille fil her, som kigger den mappe igennem den er i, for at finde billeder, og putter dem sammen til en billedoversigt.mega simpelt og enorm brugbart.
Nu er det således jeg sidst har brugt det i 2006 og er en del forældet.
Den kommer med fejl på linje 37, og 80.
Nogen der kan spotte hvad der skal rettes for det igen virker super.
HER ER HELE KODEN:
<?
include('db.php');
// PLEASE READ THE ACCOMPANYING README.TXT
// DEFINE VARIABLES:
// NUMBER OF <TD> PER <TR> ( IN ENGLISH: COLUMNS IN THE PAGE :-) )
$td='5';
// BACKGROUND COLOR OF THE PAGE
$bg='#CCCCCC';
// SHOW THE NAME OF THE FILE?
$name='1'; // 1 = yes, 0 = no
// TITLE OF YOUR PAGE
$pagetitle='';
### --- CHANGE NOTHING BELOW THIS LINE UNLESS YOU ARE OK WITH PHP --- ###
// DIRECTORY NAME
$handle=opendir('.');
// GO
$piccy=array();
$count=0;
// SCAN THE DIR
while (($filename = readdir($handle))!==false) {
// ADD IN EXTRA FILE TYPES HERE
if (substr($filename,-4) == ".jpg" || substr($filename,-4) == ".gif" || substr($filename,-4) == ".png" || substr($filename,-4) == ".JPG" || substr($filename,-4) == ".GIF" || substr($filename,-4) == ".PNG" || substr($filename,-4) == ".BMP" || substr($filename,-4) == ".bmp"){
$piccy[$count] = $filename;
$count++;
}}
// CLOSE DIR
closedir($handle);
// SORT THE FILES
sort($piccy);
reset($piccy);
// DISPLAY LARGE IMAGE
$large = $_GET["large"];
if (!$large == ""){
echo '<div align="center">';
// IS NAME SELECTED TO SHOW?
if ($name=="1") {
if (!(file_exists($large))){
echo "Billedet eksister ikke / kan ikke findes";
exit;
}
echo '<br><font face=Arial color="#000000"><span style="font-size:12pt;">' . $large . '</font>';}
// SHOW THE PICTURE
echo '<table width="100%" border=0 cellpadding=0 cellspacing=0>';
echo '<FONT><SPAN style="FONT-SIZE: 12pt"><FONT face=Arial color="blue"><B>Klik på billedet igen, for at vende tilbage til billed oversigten.</B>';
echo '<tr>';
echo "<body bgcolor=" . $bg='#CCCCCC' . ">";
echo '<td valign="middle" align="center"><a href=java script:history.back(-1)><img src="'.$large.'" alt="'.$large.'" border=0></a></td>';
echo '<br>';
echo '</tr></table>';
echo '<br><br>';
echo '<p> </p><p align="center"><SPAN style="FONT-SIZE: 12pt"><FONT face=Arial color="gray"><b>Copyright© World of Hi-Fi All rights reserved.</b></font></p></B>';
echo '<a href=java script:history.back(-1)>';
echo '</table>';}
// NO LARGE PICCY, CREATE TABLE FOR THUMBNAILS:
else{
// start table, if you want cellpadding, cellspacing, colors, set them here
echo "<body bgcolor=" . $bg='#CCCCCC' . ">";
echo '<div align="center"><font color="#000000"><span style="font-size:12pt;">' . $pagetitle . '</font>';
echo '<br><table width="100%" border=0 cellpadding=0 cellspacing=0>';
echo '<SPAN style="FONT-SIZE: 12pt"><FONT face=Arial
color=blue><B>Klik på et billed, for at få det vist i stort.</B><p> </p>';
// BECAUSE THE <TD> IS SET BY USER, WORK OUT THE PERCENTAGES:
$divider=ceil(100/$td);
if (($divider*$td)>100) $divider--;
// GRAB THE IMAGES
for ($l=0;$l<=sizeof($piccy)-1;$l++){
$isend = strpos((($l)/$td),".");
if (!$isend && ($l!=0)){echo "</tr>\n<tr><td colspan=$td><br></td></tr>\n<tr>\n";}
if ($l==0){echo "\n";}
// START THE <TD>
echo '<td width="'.$divider.'%" valign="middle" align="center">';
// GET THE LARGER PICTURE (IF SELECTED)
echo "<a href=".$_SERVER[$PHP_SELF]."?large=".$piccy[$l].">";
// DISPLAY THE THUMBNAILS
echo '<img src="thumbs/'.$piccy[$l].'" alt="'.$piccy[$l].'" border=0></a><br><br>';
// IS NAME SELECTED TO SHOW?
if ($name=="1") {
echo '<SPAN style="FONT-SIZE: 12pt"><FONT face=Arial color="#000000">' . ($piccy[$l]) . '</font>';}
echo '</td>';
echo"\n";}
echo ' </tr></table><p> </p>
<p align="center"><SPAN style="FONT-SIZE: 12pt"><FONT face=Arial color="gray"><b>Copyright© World of Hi-Fi All rights reserved.</b></font></p></B></SPAN></div>';}
?>