times.
// Put the main script before the <head> tag.
<?php
// Declare variables.
// I don't know if these have to be global or not.
global $picList;
global $indx;
global $nindx;
global $pindx;
global $thumDir;
global $capsDir;
global $showDir;
global $indx;
$thumDir = "thumbs/t"; // I prefix thumbs with a 't' so i don't use identical file names.
$capsDir = "caps/";
$showDir = "show/";
$indx = 0;
// Open the directory, read all the file names and load them into an array...
$dir = opendir($showDir);
while ($f = readdir($dir)) // read and sort by date of creation
if(is_file($showDir.$f)) {
// ...but strip off the extension so we can use the same array for pics, thumbs and captions.
$picList[$indx] = substr($f, 0, strlen($f) - 4);
$indx++;
}
closedir($dir);
// Read the 'indx' variable from the page request to see which pic to display.
// Really should set a defaule here, but right now I am just making sure to always call the page with a paramater.
// Either way, we have to do this, because the page calls itself with the next and previous links.
$indx = $_GET['indx'];
// Set the next and previous indexes and be sure they fall within the size of the array.
// We will use these to display the thumbnails and as paramaters to pass when calling another page.
$lenList = (count($picList) - 1);
$nindx = $indx + 1;
if($nindx > $lenList) {
$nindx = 0;
}
$pindx = $indx - 1;
if($pindx < 0) {
$pindx = $lenList;
}
// Open the text file for the caption, read the entire file and pass it pack to the PHP section which will display it.
function getCap($d, $p) {
$fCap = fopen($d.$p.".txt", "r");
$cap = fread($fCap, filesize($d.$p.".txt"));
return $cap;
}
?>
// Display the main picture and the caption.
<?php
echo "<img src=\"".$showDir.$picList[$indx].".gif\">";
echo "<center>".getCap($capsDir,$picList[$indx]);
?>
// Display the 'next' thumbnail in a link which will reload the page for the 'next' index.
<?php
echo "<center><a href=\"show_no_js.php?indx=".$nindx."\">";
echo "<img src=\"".$thumDir.$picList[$nindx].".gif\">";
echo "<br>Next<br>Image</center></a>";
?>
// Display the 'previous' thumbnail in a link which will reload the page for the 'previous' index.
<?php
echo "<center><a href=\"show_no_js.php?indx=".$pindx."\">";
echo "<img src=\"".$thumDir.$picList[$pindx].".gif\">";
echo "<br>Previous<br>Image</a></center>";
Warning: Cannot modify header information - headers already sent by (output started at /home/dlilahl/public_html/PHP/phpPicShow.php:5) in /home/dlilahl/public_html/PHP/ICMmerge.txt on line 2
JFIF >CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality
C
$.' ",#(7),01444'9=82<.342 C
2!!22222222222222222222222222222222222222222222222222 ,,"
} !1AQa"q2#BR$3br
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz
w !1AQaq"2B #3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ? sNsN" )P8
" )@
H1NS- bH
v(HLsNS- SH
P)@Z$Z@!("Xi)*%SHYCDdSHYCDdSHHP
7Ԙ͢#"EHE4hB)SH!SHYCDdSqRMCD4;ӀiVS
piS
pEF)UZ@;Nhi8
Z$RAiQiUZ@8
Z$ZBN)UZAh"UBFE4i
)TP
M""Ef
M""ECD4FE7)sYCCRM"hM""ECD4FE4iD40n*LSqP
4(4+DH@)P8
H1N)Vb&)VS@*- Z$ZAiQpE (ZE S
piA9h]ȦRbECD4FE7!*%2)TSH!"ECD4Gn*LSHhȦRM"hM""ECD4FE4iD4FE&)RbZ(8
H @+DH
piF)VN SZ$Z@8
Z$ZBbVi (ZE RJ8
" )Av.DSHHP
"EHE4͢Z#"EHE4͢E0a
)74CDdSHYCDx"B+6hi!+6hn*B)h;bZE S
pib
Z$RApbhi P8
H1J S- pbZE S
pE SZE$ PE8h"b2)TSHhM""ECDFE4iD4FE4i
SqHE3D40i!+6hi!*!SHM"hMIn*%اF)ثH +DH @*- 4)1OH@)ح- SHiQpE R@*- S- )ؠhUȦRM"Z#"EHE4͢E4y+6ha*B)T4CDdSqIn9!SHM"ZE4~)!2)TSH!