True $filename = "./images/thumb/".$imgfile; if (file_exists($filename)) { $tn_img[$imgfile] = "true"; } // Look for a filename.txt file in the image dir. If it exists load it into an array // with the Key Value pair [IMAGE NAME] => Desc $filename = "./images/".substr($imgfile, 0, -3)."txt"; if (file_exists($filename)) { $desc_img[$imgfile] = str_replace("\"","'",file_get_contents($filename)); } } } // Ok we have everything loaded into our arrays.. Now lets start building the page! $tot_img = count($a_img); $i = 0; $count = 0; $page = 0; while($i < $tot_img) { if($count==0) { // if the count is 0, we have a new page. $page++; $output .= "
"; if($tn_img[$a_img[$i]] == TRUE) { $output .= "\"$a_img[$i]\""; } else { $output .= "$a_img[$i]"; } $output .= ""; // And if we are at the max image #, close the page div and reset the counter if($count==$MAX_IMAGES) { $output .= "
\n\n"; $count=0;} $i++; } if($count != 0) { $output .= "\n\n"; } // Write out the menu div for ($b=1; $b<$page+1; $b++) { $menu .= "page $b   "; } // Write out the JS hiding function for all of the pages for ($b=1; $b<$page+1; $b++) { $js .= "DOMCall('page$b').className = \"hidden\";\n"; } if ($USE_LARGE_IMAGES) { $placeholder = "\" title=\"Click for larger version\" style=\"cursor:pointer;\" onClick=\"return clickedImage(this);\" alt=\"\" />"; } else { $placeholder = "\" alt=\"\" />"; } // Ok we're done, lets build the page and send it to the browser. $rand_class=""; $rand_caption=""; // zero some stuff out $rand_img = $a_img[mt_rand(0, $tot_img-1)]; // grab a random starting image... $rand_caption = $desc_img[$rand_img]; // ...and it's caption if it exists $rand_class= ($rand_caption!="")?"asdasd":"hidden"; // if it exists, we'll want to show it. $placeholder = str_replace("", $rand_img, $placeholder); $page_output = file_get_contents("template.inc.html"); //grab the template, then replace the placeholders $page_output = str_replace("", $output, $page_output); $page_output = str_replace("", $menu, $page_output); $page_output = str_replace("", $js, $page_output); $page_output = str_replace("", $placeholder, $page_output); $page_output = str_replace("", $rand_class, $page_output); $page_output = str_replace("", $rand_caption, $page_output); echo $page_output; ?>