"; echo "Error - There are no text, picture, or sound files in "; echo "the " . urlInThisFolder('') . " folder. "; } else { @$slideNumber = $_GET['slide']; if (empty($slideNumber)) { echo WebPage(0, $slides); } else { echo WebPage($slideNumber, $slides); } } Function CreateFileNameArray(){ // Create 2-D array of base names and picture/sound/text extensions (if they exist). // Arrays of file extensions are shown with most desired extension on the right. $slides = fileArray(array(), array('txt'), 'text'); $slides = fileArray($slides, array('bmp', 'png', 'jpg', 'jpeg', 'gif', 'htm'), 'picture'); $slides = fileArray($slides, array('mid', 'wma', 'mp3', 'au', 'wav'), 'sound'); // Return the array of slides if (!empty($slides)) { return $slides; } } Function fileArray($slides, $extensionsArray, $indexName) { // Add data about file types (in the $extensionArray) to the $slides array foreach ($extensionsArray as $extension) { if ($handle = opendir('./')) { while (false !== ($filepath = readdir($handle))) { if (strtolower(substr($filepath, strpos($filepath, ".") + 1)) == $extension) { $filebase = basename($filepath, '.' . $extension); $fileExt = substr($filepath, strrpos($filepath, ".") + 1); if (empty($slides)) { $slides[$filebase] = array('name'=>$filebase, 'sound'=>'', 'picture'=>'', 'text'=>''); } if (!(array_key_exists($filebase, $slides))) { $slides[$filebase] = array('name'=>$filebase, 'sound'=>'', 'picture'=>'', 'text'=>''); } $slides[$filebase][$indexName] = $extension; } } closedir($handle); } } return $slides; } Function WebPage($index, $slidesArray){ // Returns HTML to display the slide in the array element pointed to by the index // Get slide data for the slide that matches the desired index $slide = slideArray($index, $slidesArray); // HTML page header $html = "\n"; $html .= $GLOBALS["PRESENTATION_TITLE"]; $html .= " - Page " . ($index + 1) . " of " . count($slidesArray); $html .= "\n\n"; $html .= "\n\n"; // Left-side content $html .= "
"; $html .= "\n\n"; return $html; } Function leftSideHtml($index, $slidesArray) { $html = ''; $html .= "\n"; $html .= "\n"; // Links code $html .= "\n"; // Media Player code $html .= "
\n"; // Navigation button code $html .= navigationButtons($index, $slidesArray); $html .= "
\n"; $html .= linksList($slidesArray); $html .= "
\n"; $slide = slideArray($index, $slidesArray); If ($slide['sound'] != '') { $sound = urlInThisFolder($slide['name'] . '.' . $slide['sound']); if (isIE()) { // The SoundIE function needs to know the URL of the next page if ($index == (count($slidesArray) - 1)) { $html .= SoundIE($sound, $GLOBALS["END_PAGE"]); } else { $html .= SoundIE($sound, argumentsForThisUrl('?slide=' . ($index + 1))); } } elseif (IsWin()) { $html .= SoundWindows($sound); } else { $html .= SoundGeneric($sound); } } $html .= "
\n"; return $html; } Function rightSideHtml($index, $slidesArray) { // Returns HTML to display the slide $slide = slideArray($index, $slidesArray); $html = ''; // Picture $html .= pictureHtml($slide); // Text $html .= textHtml($slide); return $html; } Function slideArray($desiredIndex, $slidesArray) { // Returns a one-dimensional array containing data about the slide // Sort the slides in "natural" order ("1a" comes before "10a") $keys = array_keys($slidesArray); natcasesort($keys); // Check all slides until the index matches $pointer = -1; // Incremented to get the index for each slide in the array foreach ($keys as $key) { // Increment the pointer $pointer = $pointer + 1; if ($pointer == $desiredIndex) { return $slidesArray[$key]; } } } Function linksList($slidesArray) { // Sort the slides in "natural" order ("1a" comes before "10a") $keys = array_keys($slidesArray); natcasesort($keys); $pointer = -1; // Incremented to get the index for each slide in the array $html = ""; foreach ($keys as $key) { $pointer += 1; $html .= "\n
"; } $html .= "\n

"; return $html; } Function urlInThisFolder($document) { // Check popular server variables for a URI $uri = ''; foreach (array('PHP_SELF', 'REQUEST_URI', 'SCRIPT_NAME', 'REDIRECT_URL') as $varName) { if (empty($uri)) { $uri = $_SERVER[$varName]; if (!empty($uri)) { if (substr($uri, 0, 1) != '/') { $uri = ''; } } } } // Strip off the script name $path = substr($uri, 0, strrpos($uri, "/")); // Assemble the new URL return "http://" . $_SERVER["SERVER_NAME"] . $path . "/" . str_replace(" ", "%20", $document); } Function argumentsForThisUrl($args) { // Adds HTTP GET arguments to the existing script. Typical $args = '?foo=bar&afu=yes' $uri = ''; // Check popular server variables for a URI foreach (array('PHP_SELF', 'REQUEST_URI', 'SCRIPT_NAME', 'REDIRECT_URL') as $varName) { if (empty($uri)) { $uri = $_SERVER[$varName]; if (!empty($uri)) { if (substr($uri, 0, 1) != '/') { $uri = ''; } } } } $urlArray = explode('?', $uri); return "http://" . $_SERVER["SERVER_NAME"] . $urlArray[0] . $args; } Function isIE(){ return strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false; } Function isWin(){ return strpos($_SERVER["HTTP_USER_AGENT"], "Windows") !== false; } Function pictureHtml($slide){ // Returns the HTML needed to display the picture (if one exists) $html = ''; If ($slide['picture'] != '') { if (strtolower($slide['picture']) == 'htm') { // Picture is an htm file! Read it so we can use it's text. $handle = fopen($slide['name'] . '.' . $slide['picture'], "r"); $body = fread($handle, filesize($slide['name'] . '.' . $slide['picture'])); fclose($handle); // Use only the text inside the tags $pointer = stripos($body, ''); // location of end of body tag $body = substr($body, $pointer + 1); // remove through end of body tag $pointer = stripos($body, '\r\n", $html); // DOS line terminators } while (strpos($html, "\n\n")!== false ) { $html = str_replace("\n\n", "

\n", $html); // Unix line terminators } while (strpos($html, "\r\r")!== false ) { $html = str_replace("\r\r", "

\r", $html); // Apple line terminators } } return $html; } Function navigationButtons($index, $slidesArray) { // Supplies the HTML code for back, home, and next navigation buttons // See http://www.ericphelps.com/unicode/ for other unicode values $html = ''; // Back button URL $html .= "\t'audio/basic', 'mid'=>'audio/midi', 'mp3'=>'audio/mpeg', 'wav'=>'audio/wav', 'wma'=>'audio/x-wma'); $html = ""; $html .= "