< Back to ' . htmlspecialchars($album) . '

'; switch (substr($file, strrpos($file, '.') + 1)) { // jpeg files are included using the img element case 'jpg': case 'jpeg': echo '' . htmlspecialchars($file) . ''; break; // QuickTime files are included using the object/embed elements case 'mov': echo ''; echo ''; echo ''; echo ''; break; // redirect if file format is not valid default: header('Location: ' . htmlspecialchars($_SERVER['PHP_SELF'])); exit(); } $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } // generate album view else if ($album) { // redirect to album list if album does not exist or is outside the // allowed base directory if (strpos(realpath($album_p), BASEDIR) !== 0 || !file_exists($album_p)) { header('Location: ' . htmlspecialchars($_SERVER['PHP_SELF'])); exit(); } ob_start(); // provide link for album index echo '

' . '< Back to album index

'; // retrieve album description if available if (file_exists($album_p . '/desc.txt')) { echo '

' . nl2br(file_get_contents($album_p . '/desc.txt')) . '

'; } // read in list of image and QuickTime files $dir = opendir($album_p); $images = array(); while($f = basename(readdir($dir))) { if($f == '.' || $f == '..') continue; if (!is_dir($f)) { $ext = (substr($f, strpos($f, '.') + 1)); if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'mov') { $images[] = $f; } } } closedir($dir); // sort images natcasesort($images); //display thumbnails in a table $counter = 0; $columns = 7; echo ''; foreach ($images as $image) { if (0 == ($counter % $columns)) { echo ''; } echo ''; if (0 == (++$counter % $columns)) { echo ''; } } // finish table's row with blank cells if necessary while ($counter++ % $columns) { echo ''; } if (substr(ob_get_contents(), -5) == '') { echo ''; } echo '
'; printf ('%s ', htmlspecialchars($_SERVER['PHP_SELF']), urlencode($album), urlencode($image), urlencode($album . '/' . $image), htmlspecialchars($image)); echo '
 
'; $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } // generate default view showing list of available albums else { ob_start(); // retrieve list of albums $albums = array(); $dir = opendir(BASEDIR); while($f = basename(readdir($dir))) { if($f == '.' || $f == '..') continue; if (is_dir(BASEDIR . '/' . $f)) { $albums[] = $f; } } closedir($dir); // sort albums natcasesort($albums); // display album list echo '

Albums

'; echo ''; $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } /*// include shared code include '../lib/config.php'; // accept incoming parameters $album = (isset($_GET['album'])) ? $_GET['album'] : ''; $album_p = BASEDIR . '/' . $album; $file = (isset($_GET['file'])) ? $_GET['file'] : ''; $file_p = $album_p . '/' . $file; // generate image view if ($album && $file) { // redirect to album list if album or file is outside allowed base // directory or does not exist if (strpos(realpath($album_p), BASEDIR) !== 0 || strpos(realpath($file_p), BASEDIR) !== 0 || !file_exists($file_p)) { // header('Location: ' . htmlspecialchars($_SERVER['PHP_SELF'])); // exit(); echo $file_p; } ob_start(); // provide link for album view echo '

< Back to ' . htmlspecialchars($album) . '

'; switch (substr($file, strrpos($file, '.') + 1)) { // jpeg files are included using the img element case 'jpg': case 'jpeg': echo '' . htmlspecialchars($file) . ''; break; // quicktime files are included using the object/embed elements case 'mov': echo ''; echo ''; echo ''; echo ''; break; // redirect if file format is not valid default: header('Location: ' . htmlspecialchars($_SERVER['PHP_SELF'])); exit(); } $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } // generate album view else if ($album) { // redirect to album list if album does not exist or is outside the // allowed base directory if (strpos(realpath($album_p), BASEDIR) !== 0 || !file_exists($album_p)) { header('Location: ' . htmlspecialchars($_SERVER['PHP_SELF'])); exit(); } ob_start(); // provide link for album index echo '

' . '< Back to album index

'; // retrieve album description if available if (file_exists($album_p . '/desc.txt')) { echo '

' . nl2br(file_get_contents($album_p . '/desc.txt')) . '

'; } // read in list of images $dir = opendir($album_p); $images = array(); while($f = basename(readdir($dir))) { if($f == '.' || $f == '..') continue; if (!is_dir($f)) { $images[] = $f; } } closedir($dir); // sort images natcasesort($images); //gather thumbnails foreach ($images as $image) { switch (substr($image, strpos($image, '.') + 1)) { case 'jpg': case 'jpeg': case 'mov': printf ('%s ', htmlspecialchars($_SERVER['PHP_SELF']), urlencode($album), urlencode($image), urlencode($album . '/' . $image), htmlspecialchars($image)); break; } } $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } // generate default view showing list of available albums else { ob_start(); // retrieve list of albums $albums = array(); $dir = opendir(BASEDIR); while($f = basename(readdir($dir))) { if($f == '.' || $f == '..') continue; if (is_dir(BASEDIR . '/' . $f)) { $albums[] = $f; } } closedir($dir); // sort albums natcasesort($albums); // display album list echo '

Albums

'; echo ''; $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); } // display the page */// include '../templates/template-page.php'; echo $GLOBALS['TEMPLATE']['content']; ?>