get_queried_object(); $post_ID = $post_obj->ID; $post_name = $post_obj->post_name; // Get the current gallery page's permalink $permalink = get_permalink(); // Base the UnGallery linking format on the site's permalink settings if (strstr($permalink, "?")) { $QorA = "&"; $gallery_ID = "?page_id=" . $post_ID; } else { $QorA = "?"; $gallery_ID = $post_name; } // Get the image directory path associated with the gallery if($gallery_ID == get_option( 'gallery' )) $pic_root = get_option( 'images_path' ); if($gallery_ID == get_option( 'gallery2' )) $pic_root = get_option( 'images2_path' ); if($gallery_ID == get_option( 'gallery3' )) $pic_root = get_option( 'images3_path' ); if($gallery_ID == get_option( 'gallery4' )) $pic_root = get_option( 'images4_path' ); if($gallery_ID == get_option( 'gallery5' )) $pic_root = get_option( 'images5_path' ); if($gallery_ID == get_option( 'gallery6' )) $pic_root = get_option( 'images6_path' ); // Load the configuration data from the database $version = get_option( 'version' ); $hidden = get_option( 'hidden' ); $marquee = get_option( 'marquee' ); $marquee_size = get_option( 'marquee_size' ); $thumbW = get_option( 'thumbnail' ); $srcW = get_option( 'browse_view' ); $movie_height = get_option( 'movie_height' ); $movie_width = get_option( 'movie_width' ); $columns = get_option( 'columns' ); if($columns == "") $columns = 4; // set a default so admin page does not need visit after update. Remove at some point. $max_thumbs = get_option( 'max_thumbs' ); if ($max_thumbs == 0) $max_thumbs = 25; // Provide the version of UnGallery print ""; $w = $thumbW; $blogURI = get_bloginfo('url') . "/"; $dir = "wp-content/plugins/ungallery/"; $gallerylink = $_GET['gallerylink']; $src = $_GET['src']; $movie_types = array(); $page = $_GET['page']; // If we are browsing a gallery, gallerylink is not set so derive it from src in URL if (isset($src)) { $lastslash = strrpos($src, "/"); $gallerylink = substr($src, strlen($pic_root)); // Trim the path off root and above $length = strrpos($gallerylink, "/"); // Find length of gallery in string $gallerylink = substr($gallerylink, 0, $length); // Trim the filename off the end } if ($gallerylink == "") { $gallerylink = ""; } else { // If ?gallerylink is set and not "" then.... // Build the full gallery path into an array $gallerylinkarray = explode("/", $gallerylink); // Render the Up/Current directory links print 'Top'; foreach ($gallerylinkarray as $key => $level) { $parentpath = $parentpath . $level ; print ' / '. $level .''; $parentpath = $parentpath . "/"; } } // Create the arrays with the dir's media files $dp = opendir( $pic_root.$gallerylink); while ($filename = readdir($dp)) { if (!is_dir($pic_root.$gallerylink. "/". $filename)) { // If it's a file, begin $pic_types = array("JPG", "jpg", "GIF", "gif", "PNG", "png", "BMP", "bmp"); if (in_array(substr($filename, -3), $pic_types)) $pic_array[] = $filename; // If it's a picture, add it to thumb array else { $movie_types = array("MP4", "mp4"); if (in_array(substr($filename, -3), $movie_types)) $movie_array[$filename] = size_readable(filesize($pic_root.$gallerylink. "/". $filename)); // If it's a movie, add name and size to the movie array } } } // If we are viewing a gallery, arrange the thumbs if($pic_array) sort($pic_array); // Unless we are at the top level or the marquee is set, display the zip link and search form if ($_SERVER["REQUEST_URI"] !== "/".$gallery) print ' / -zip- /
-search-
'; elseif ($marquee !== "yes") print ' / -zip- / '; // Display the movie links if($movie_array) { print '
Movies:  '; foreach ($movie_array as $filename => $filesize) { print ' ' .$filename.'  /  '; } } closedir($dp); $dp = opendir($pic_root.$gallerylink); // Read the directory for subdirectories while ($subdir = readdir($dp)) { // If it is a subdir and not set as hidden, enter it into the array if (is_dir($pic_root.$gallerylink. "/". $subdir) && $subdir != "." && $subdir != ".." && !strstr($subdir, $hidden)) { $subdirs[] = $subdir; } } if($subdirs) { // List each subdir and link print '   
    Sub Galleries :  '; sort($subdirs); foreach ($subdirs as $key => $subdir) { print '' .$subdir.' / '; } } closedir($dp); print ' '; // Begin the table if (!isset($src) && isset($pic_array)) { // If we are not in browse view, if ($marquee == "yes" && $gallerylink == "") $w = $marquee_size ; // Set size of marquee picture else $w = $thumbW; print '"; // Close cell. Add a bit of space print '

'; if (file_exists($pic_root.$gallerylink."/banner.txt")) { include ($pic_root.$gallerylink."/banner.txt"); // We also display the caption from banner.txt } else { $lastslash = strrpos($gallerylink, "/"); if (strpos($gallerylink, "/")) print "

" . substr($gallerylink, $lastslash + 1) ."

"; else print "

" . $gallerylink . "

"; } print "

'; $column = 0; // Handle maximum thumbs per page $sliced_array = $pic_array; if ($max_thumbs < count($pic_array)) { // If we are displaying thumbnails across multiple pages, update array with page data if($page) { $page = substr($page, 1) ; // Remove p from page string $offset = ($page -1) * $max_thumbs; } $sliced_array = array_slice($pic_array, $offset, $max_thumbs); } foreach ($sliced_array as $filename) { // Use the pic_array to display the thumbs and assign the links print ''; $column++; if ( $column == $columns ) { print '
'; $column = 0; } } // If we are displaying thumbnails across multiple pages, display Next/Previos page links if ($max_thumbs < count($pic_array)) { $pages = ceil(count($pic_array) / $max_thumbs) ; // Get the number of pages if (!$page) $page = 1; print "

"; if ($page > 1) { $previous = $page - 1; print 'Previous Page'; } print "     "; if ($pages > $page) { $next = $page + 1; print 'Next Page'; } print "      - This gallery has $pages pages -"; } // Complete the table formatting print "
"; } else { // Render the browsing version, link to original, last/next picture, and link to parent gallery if (isset($src) && !in_array(substr($src, -3), $movie_types)) { // If we are in broswing mode and the source is not a movie $filename = substr($src, $lastslash + 1); $before_filename = $pic_array[array_search($filename, $pic_array) - 1 ]; $after_filename = $pic_array[array_search($filename, $pic_array) + 1 ]; // Display the current/websize pic print ' '; if ($before_filename) { // Display the before thumb, if it exists print ''; } // Complete the table formatting print " "; if ($after_filename) { // Display the after thumb, if it exists print ''; } } elseif (($movie_array) && (in_array(substr($src, -3), $movie_types))) print '




'; // If the source is a movie, play it else print "

"; } print " "; ?>