예제 #1
0
function lg_user_can_access($folder)
{
    global $user_level;
    // This is for gallery_root
    if ($folder == "") {
        return true;
    }
    $upper_level = explode('/', $folder);
    for ($i = 0; $i < count($upper_level) - 2; $i++) {
        $top .= $upper_level[$i] . '/';
    }
    $folder_level = get_minimum_folder_level($folder);
    if (($user_level >= $folder_level || $folder_level == 1) && lg_user_can_access($top)) {
        return true;
    } else {
        return false;
    }
}
예제 #2
0
function showDirs()
{
    // Builds folders view page
    global $gallery_address, $gallery_root, $currentdir, $file, $lg_text_domain, $user_level;
    if (!lg_user_can_access($currentdir)) {
        echo "<p>";
        _e("It doesn't look like you can access this folder at this time because the directory you have specified doesn't appear to be browsable.", $lg_text_domain);
        echo "</p>";
    } else {
        $gallery_uri = get_option('lg_gallery_uri');
        // Fix for permalinks
        if (strlen(get_option('permalink_structure')) != 0) {
            $gallery_uri = $gallery_uri . '?';
        } else {
            $gallery_uri = $gallery_uri . '&amp;';
        }
        $columns = get_option("lg_folders_columns");
        $runonce = false;
        $col_count = 1;
        if ($dir_content = opendir($gallery_root . $currentdir)) {
            $directory_to_sort = array();
            for ($i = 0; false !== ($dir = readdir($dir_content)); $i++) {
                $directory_to_sort[$i] = $dir;
            }
            if (get_option('lg_sort_alphabetically') == "TRUE") {
                sort($directory_to_sort);
            }
            foreach ($directory_to_sort as $dir) {
                if (is_dir($gallery_root . $currentdir . $dir) && !in_array($dir, get_option("lg_excluded_folders")) && $dir != '.' && $dir != '..') {
                    if (!$runonce) {
                        echo '<!-- Lazyest Gallery ' . LG_VERSION . ' -->' . "\n" . '
						<div class="folders">' . "\n" . '
							<table summary="Categories" class="dir_view">' . "\n" . '
								<tr>' . "\n" . '
									<td colspan="' . $columns . '" class="folder"><img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/images/folders.png" alt="Folders" class="icon" /> &raquo; ' . __("Folders", $lg_text_domain) . '</td>' . "\n" . '
								</tr>' . "\n" . '
								<tr>';
                        $runonce = true;
                    }
                    if ($col_count <= $columns) {
                        $imgfiles = get_imgfiles($dir);
                        if (get_option('lg_sort_alphabetically') == "TRUE") {
                            sort($imgfiles);
                        }
                        $xhtmlurl = str_replace(" ", "%20", $currentdir . $dir);
                        echo '<td><a href="' . $gallery_uri . 'file=' . $xhtmlurl . '/">';
                        switch (get_option('lg_folder_image')) {
                            case 'icon':
                                // this will prevent some unshown thumb
                                $mem = get_option('lg_buffer_size');
                                ini_set("memory_limit", $mem);
                                // Display Category's images (if any) (Keytwo)
                                // PNG
                                if (file_exists($gallery_root . $currentdir . $dir . '/' . $dir . '.png')) {
                                    $resource = $gallery_root . $currentdir . $dir . '/' . $dir . '.png';
                                    $resource = imagecreatefrompng($resource);
                                    if (imagesx($resource) > get_option('lg_thumbwidth')) {
                                        echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $dir . '/' . $dir . '.png' . '&amp;thumb=1" alt=""/><br />' . "\n";
                                    } else {
                                        echo '<img src="' . $gallery_address . $currentdir . $dir . '/' . $dir . '.png" alt="" class="category_icon" /><br />' . "\n";
                                    }
                                } else {
                                    if (file_exists($gallery_root . $currentdir . $dir . '/' . $dir . '.gif')) {
                                        $resource = $gallery_root . $currentdir . $dir . '/' . $dir . '.gif';
                                        $resource = imagecreatefromgif($resource);
                                        if (imagesx($resource) > get_option('lg_thumbwidth')) {
                                            echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $dir . '/' . $dir . '.gif' . '&amp;thumb=1" alt=""/><br />' . "\n";
                                        } else {
                                            echo '<img src="' . $gallery_address . $currentdir . $dir . '/' . $dir . '.gif" alt="" class="category_icon" /><br />' . "\n";
                                        }
                                    } else {
                                        if (file_exists($gallery_root . $currentdir . $dir . '/' . $dir . '.jpg')) {
                                            $resource = $gallery_root . $currentdir . $dir . '/' . $dir . '.jpg';
                                            $resource = imagecreatefromjpeg($resource);
                                            if (imagesx($resource) > get_option('lg_thumbwidth')) {
                                                echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $dir . '/' . $dir . '.jpg' . '&amp;thumb=1" alt=""/><br />' . "\n";
                                            } else {
                                                echo '<img src="' . $gallery_address . $currentdir . $dir . '/' . $dir . '.jpg" alt="" class="category_icon" /><br />' . "\n";
                                            }
                                        } else {
                                            if (file_exists($gallery_root . $currentdir . $dir . '/' . $dir . '.jpeg')) {
                                                $resource = $gallery_root . $currentdir . $dir . '/' . $dir . '.jpeg';
                                                $resource = imagecreatefromjpeg($resource);
                                                if (imagesx($resource) > get_option('lg_thumbwidth')) {
                                                    echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $dir . '/' . $dir . '.jpeg' . '&amp;thumb=1" alt=""/><br />' . "\n";
                                                } else {
                                                    echo '<img src="' . $gallery_address . $currentdir . $dir . '/' . $dir . '.jpeg" alt="" class="category_icon" /><br />' . "\n";
                                                }
                                            }
                                        }
                                    }
                                }
                                break;
                            case 'random_image':
                                // display a random image of this foldery (jan831)
                                $img = $imgfiles[rand(0, sizeof($imgfiles) - 1)];
                                if ($img) {
                                    if (file_exists($gallery_root . $currentdir . $dir . '/captions.xml')) {
                                        $captions = clean_image_caption($img, $currentdir . $dir);
                                    }
                                    // This will removes HTML tags (which are incompatible with "title" argument)
                                    $title = ereg_replace("<[^>]*>", "", $caption);
                                    if (get_option('lg_enable_cache') == "TRUE") {
                                        $thumb_folder = get_option('lg_thumb_folder');
                                        if (!file_exists($gallery_root . $currentdir . $dir . '/' . $thumb_folder . $img)) {
                                            createCache($currentdir . $dir . '/', $img, true);
                                        }
                                        $urlImg = str_replace(" ", "%20", $gallery_address . $currentdir . $dir . '/' . $thumb_folder . $img);
                                        echo '<img src="' . $urlImg . '"  style="vertical-align:middle;padding:2px;"  alt="' . $img . '" title="' . $title . '"/><br />' . "\n";
                                    } else {
                                        $urlImg = str_replace(" ", "%20", $currentdir . $dir . '/' . $img);
                                        echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $urlImg . '&amp;thumb=1"  style="vertical-align:middle;padding:2px;"  alt="' . $img . '" title="' . $title . '" /><br />' . "\n";
                                    }
                                }
                                break;
                        }
                        $file_counter = sizeof($imgfiles);
                        $folder_caption = clean_folder_caption($currentdir . $dir);
                        if ($file_counter == 0) {
                            // "F" if there are folders only inside
                            if (get_option('lg_use_folder_captions') == "TRUE" && strlen($folder_caption) != 0) {
                                echo '&raquo; ' . $folder_caption . '</a> (F)</td>';
                            } else {
                                echo '&raquo; ' . $dir . '</a> (F)</td>';
                            }
                        } else {
                            // "#" if there are images instead
                            if (get_option('lg_use_folder_captions') == "TRUE" && strlen($folder_caption) != 0) {
                                echo '&raquo; ' . $folder_caption . '</a> (' . sizeof($imgfiles) . ')</td>';
                            } else {
                                echo '&raquo; ' . $dir . '</a>  (' . sizeof($imgfiles) . ')</td>';
                            }
                        }
                        $col_count++;
                    }
                    if ($col_count > $columns) {
                        echo '</tr><tr>';
                        $col_count = 1;
                    }
                }
            }
        } else {
            echo "<div class='quote'>" . __('Something goes wrong. Make sure of your Gallery Root folder.', $lg_text_domain) . "</div>";
        }
        if ($runonce) {
            echo '<td></td></tr></table></div><br/>' . "\n";
        }
    }
}
예제 #3
0
function showSlide($slidefile)
{
    // Builds slides view page
    global $gallery_root, $gallery_address, $currentdir, $file, $user_level, $lg_text_domain;
    $folder_level = get_minimum_folder_level($currentdir);
    if (!lg_user_can_access($currentdir)) {
        echo "<p>";
        _e("Are You Cheatin&#8217; uh?", $lg_text_domain);
        echo "</p>";
    } else {
        $gallery_uri = get_option('lg_gallery_uri');
        // Fix for permalinks
        if (strlen(get_option('permalink_structure')) != 0) {
            $gallery_uri = $gallery_uri . '?';
        } else {
            $gallery_uri = $gallery_uri . '&amp;';
        }
        $imgfiles = get_imgfiles($dir);
        if (get_option('lg_sort_alphabetically') == "TRUE") {
            sort($imgfiles);
        }
        // Pager Code
        $prev = '';
        $slide = '';
        $next = '';
        $arraysize = count($imgfiles);
        for ($i = 0; $i < $arraysize; $i++) {
            if ($currentdir . $imgfiles[$i] == $slidefile) {
                $slide = $imgfiles[$i];
                // Set prev
                if ($i == 0) {
                    $prev = $imgfiles[$arraysize - 1];
                } else {
                    $prev = $imgfiles[$i - 1];
                }
                // Set Next
                if ($i + 1 == $arraysize) {
                    $next = $imgfiles[0];
                } else {
                    $next = $imgfiles[$i + 1];
                }
                break;
            }
        }
        // XHTML formatting
        $prev = str_replace(" ", "%20", $prev);
        $next = str_replace(" ", "%20", $next);
        $slideUrl = str_replace(" ", "%20", $slide);
        /* ========================
         *		Navigator HTML Code
         * ======================== */
        // This is because XHTML compiling
        $currdir = str_replace(" ", "%20", $currentdir);
        echo '<div id="lazyest_navigator">
					<a href="' . $gallery_uri . 'file=' . $currdir . $prev . '" class="alignleft">' . __('&laquo; Prev', $lg_text_domain) . '</a>
					<a href="' . $gallery_uri . 'file=' . $currdir . $next . '" class="alignright">' . __('Next &raquo;', $lg_text_domain) . '</a>
				</div>';
        /* =====================
         *		Image slide Code
         * ===================== */
        // Removes HTML tags
        $title = ereg_replace("<[^>]*>", "", $caption);
        echo '<div class="lazyest_image">';
        if (get_option('lg_use_slides_popup') == "TRUE") {
            //PopUp Window
            // Get picture info
            $img = $gallery_root . $currentdir . $slide;
            $path = pathinfo($img);
            // this will prevent some unshown thumb
            $mem = get_option('lg_buffer_size');
            ini_set("memory_limit", $mem);
            switch (strtolower($path["extension"])) {
                case "jpeg":
                case "jpg":
                    $img = imagecreatefromjpeg($img);
                    break;
                case "gif":
                    $img = imagecreatefromgif($img);
                    break;
                case "png":
                    $img = imagecreatefrompng($img);
                    break;
                default:
                    break;
            }
            $xsize = imagesx($img);
            $ysize = imagesy($img);
            imagedestroy($img);
        }
        if (get_option('lg_enable_slides_cache') == "TRUE") {
            $slidesfolder = get_option('lg_slide_folder');
            if (!file_exists($gallery_root . $currentdir . $slidesfolder . $slide)) {
                createCache($currentdir, $slide, false);
            }
            if (get_option('lg_use_slides_popup') == "TRUE") {
                // Popup
                echo '<a href="javascript:void(window.open(\'' . get_option('home') . '/wp-content/plugins/lazyest-gallery/lazyest-popup.php?image=' . $slide . '&folder=' . $currentdir . '\',\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=yes,width=' . $xsize . ',height=' . $ysize . ',left=50,top=50\'))"><img src="' . $gallery_address . $currentdir . $slidesfolder . $slide . '" alt="' . $slide . '" title="' . $title . '"/></a>';
            } else {
                if (file_exists($gallery_root . $currentdir . 'captions.xml')) {
                    $caption = clean_image_caption($slide, $currentdir);
                }
                // Removing HTML tags
                $title = ereg_replace("<[^>]*>", "", $caption);
                // Lightbox informations
                $lb_enabled = get_option('lg_enable_lb_support');
                $lb_slides = get_option('lg_enable_lb_slides_support');
                $lb_force = get_option('lg_force_lb_support');
                // Thickbox informations
                $tb_enabled = get_option('lg_enable_tb_support');
                $tb_slides = get_option('lg_enable_tb_slides_support');
                $tb_force = get_option('lg_force_tb_support');
                // Slides' hrefs
                $hrefs = true;
                if (get_option('lg_disable_full_size') == "TRUE") {
                    $hrefs = false;
                }
                // Slides' cache infos
                $lg_cache = get_option('lg_enable_slides_cache');
                // Image link
                $urlImg = str_replace(" ", "%20", $gallery_address . $currentdir . $slide);
                // Lightbox
                if ($lb_enabled == "TRUE" && $lb_slides == "TRUE" && $lg_cache == "TRUE" && some_lightbox_plugin() || $lb_force == "TRUE") {
                    if ($hrefs) {
                        echo '<a href="' . $urlImg . '" rel="lightbox" title="' . $title . '">';
                    }
                    echo '<img src="' . $gallery_address . $currdir . $slidesfolder . $slide . '" alt="' . $slide . '"  title="' . $title . '" />';
                    if ($hrefs) {
                        echo '</a>';
                    }
                } elseif ($tb_enabled == "TRUE" && $tb_slides == "TRUE" && $lg_cache == "TRUE" && some_thickbox_plugin() || $tb_force == "TRUE") {
                    if ($hrefs) {
                        echo '<a href="' . $urlImg . '" class="thickbox" title="' . $title . ' ">';
                    }
                    echo '<img src="' . $gallery_address . $currdir . $slidesfolder . $slide . '" alt="' . $slide . '"   />';
                    if ($hrefs) {
                        echo '</a>';
                    }
                } else {
                    if ($hrefs) {
                        echo '<a href="' . $urlImg . '" >';
                    }
                    echo '<img src="' . $gallery_address . $currdir . $slidesfolder . $slideUrl . '" alt="' . $slide . '"  title="' . $title . '" />';
                    if ($hrefs) {
                        echo '</a>';
                    }
                }
            }
        } else {
            if (get_option('lg_use_slides_popup') == "TRUE") {
                // PopUp
                echo '<a href="javascript:void(window.open(\'' . $gallery_address . $currentdir . $slide . '\',\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=yes,width=' . $xsize . ',height=' . $ysize . ',left=50,top=50\'))"><img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $slide . '" alt="' . $currentdir . $slide . '" title="' . $title . '" /></a>';
            } else {
                // In window
                echo '<a href="' . $gallery_address . $currdir . $slideUrl . '" ><img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currdir . $slideUrl . '" alt="' . $currentdir . $slide . '" title="' . $title . '" /></a>';
            }
        }
        /* =============
         * Captions Code
         * ============= */
        if (get_option('lg_enable_captions') == "TRUE") {
            $caption = clean_image_caption($slide, $currentdir);
            if (strlen($caption) != 0) {
                echo '<div class="caption">' . $caption . '</div>';
            }
        }
        echo '</div><br/>';
        // closes "image" class
        /* =========================
         *		Image Exif Data Code
         * ========================= */
        if (get_option('lg_enable_exif') == "TRUE") {
            include_once 'lazyest-exinfos.php';
        }
        if (get_option('lg_enable_captions') == "TRUE") {
            get_currentuserinfo();
            if (strlen($currentdir) != 0) {
                if ($user_level >= 8) {
                    echo "<div class='lg_admin'>";
                    echo "<a href='" . get_option('siteurl') . "/wp-admin/" . LG_FLM_PAGE . "&amp;captions=" . $currdir . "'>";
                    echo "&raquo; " . __('Write a caption for ', $lg_text_domain) . $slide;
                    echo "</a>";
                    echo "</div>";
                }
            }
        }
    }
}
예제 #4
0
function showThumbs()
{
    // Builds thumbnails view page
    global $gallery_root, $currentdir, $file, $gallery_address, $user_level, $lg_text_domain;
    if (!lg_user_can_access($currentdir)) {
        echo "<p>";
        _e('You cannot browse this folder.', $lg_text_domain);
        echo "</p>";
    } else {
        $gallery_uri = get_option('lg_gallery_uri');
        // Fix for permalinks
        if (strlen(get_option('permalink_structure')) != 0) {
            $gallery_uri = $gallery_uri . '?';
        } else {
            $gallery_uri = $gallery_uri . '&amp;';
        }
        // gathering pagination infos
        $thumbs_page = get_option('lg_thumbs_page');
        if ($thumbs_page != 0 && isset($_GET['offset']) && is_numeric($_GET['offset'])) {
            $offset = floor(abs(intval($_GET['offset'])) / $thumbs_page) * $thumbs_page;
        } else {
            $offset = 0;
        }
        $folder_caption = clean_folder_caption($currentdir . $dir);
        $category = substr($currentdir, 0, strlen($currentdir) - 1);
        // Icons code
        // This section will display proper icon for each folder
        echo "<div class='folder_caption'>";
        if (is_file($gallery_root . $currentdir . $category . '.png')) {
            $resource = imagecreatefrompng($gallery_root . $currentdir . $category . '.png');
            if (imagesx($resource) > get_option('lg_thumbwidth')) {
                echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $category . '.png' . '&amp;thumb=1" alt="" class="icon" />&raquo; ' . $folder_caption . "\n";
            } else {
                echo '<img src="' . $gallery_address . $currentdir . $category . '.png"  alt="' . $category . '" class="icon"/> &raquo; ' . $folder_caption;
            }
        } else {
            if (is_file($gallery_root . $currentdir . $category . '.jpg')) {
                $resource = imagecreatefromjpeg($gallery_root . $currentdir . $category . '.jpg');
                if (imagesx($resource) > get_option('lg_thumbwidth')) {
                    echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $category . '.jpg' . '&amp;thumb=1" alt="" class="icon" />&raquo; ' . $folder_caption . "\n";
                } else {
                    echo '<img src="' . $gallery_address . $currentdir . $category . '.jpg"  alt="' . $category . '" class="icon"/> &raquo; ' . $folder_caption;
                }
            } else {
                if (is_file($gallery_root . $currentdir . $category . '.jpeg')) {
                    $resource = imagecreatefromjpeg($gallery_root . $currentdir . $category . '.jpeg');
                    if (imagesx($resource) > get_option('lg_thumbwidth')) {
                        echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $category . '.jpeg' . '&amp;thumb=1" alt="" class="icon" />&raquo; ' . $folder_caption . "\n";
                    } else {
                        echo '<img src="' . $gallery_address . $currentdir . $category . '.jpeg" alt="' . $category . '" class="icon"/> &raquo; ' . $folder_caption;
                    }
                } else {
                    if (is_file($gallery_root . $currentdir . $category . '.gif')) {
                        $resource = imagecreatefromgif($gallery_root . $currentdir . $category . '.gif');
                        if (imagesx($resource) > get_option('lg_thumbwidth')) {
                            echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currentdir . $category . '.gif' . '&amp;thumb=1" alt="" class="icon" />&raquo; ' . $folder_caption . "\n";
                        } else {
                            echo '<img src="' . $gallery_address . $currentdir . $category . '.gif"  alt="' . $category . '" class="icon"/> &raquo; ' . $folder_caption;
                        }
                    }
                }
            }
        }
        echo "</div>";
        // End of Icons code
        // Here begins thumbs table
        echo '<table class="lazyest_thumb_view" summary="thumbs"><tr>';
        $tcol_count = 1;
        $tcolumns = get_option('lg_thumbs_columns');
        $imgfiles = get_imgfiles($dir);
        // Sort the files
        if (get_option('lg_sort_alphabetically') == "TRUE") {
            sort($imgfiles);
        }
        if (isset($imgfiles)) {
            if ($thumbs_page == 0) {
                // no pagination, display all
                $end = count($imgfiles);
                $offset = 0;
            } else {
                $end = $thumbs_page + $offset;
                if (count($imgfiles) < $end) {
                    $end = count($imgfiles);
                }
            }
            // This is because XHTML compiling
            $currdir = str_replace(" ", "%20", $currentdir);
            // Main cycle
            for ($i = $offset; $i < $end; $i++) {
                $img = $imgfiles[$i];
                if (file_exists($gallery_root . $currentdir . 'captions.xml')) {
                    $caption = clean_image_caption($img, $currentdir);
                }
                // Removing HTML tags
                $title = ereg_replace("<[^>]*>", "", $caption);
                // Tumbs Cache code
                if (get_option('lg_enable_cache') == "TRUE") {
                    if (!file_exists($gallery_root . $currentdir . get_option('lg_thumb_folder') . $img)) {
                        createCache($currentdir, $img, true);
                    }
                    /* =============
                     * The Right URL
                     * ============= */
                    // Lightbox informations
                    $lb_enabled = get_option('lg_enable_lb_support');
                    $lb_thumbs = get_option('lg_enable_lb_thumbs_support');
                    $lb_force = get_option('lg_force_lb_support');
                    // Thickbox informations
                    $tb_enabled = get_option('lg_enable_tb_support');
                    $tb_thumbs = get_option('lg_enable_tb_thumbs_support');
                    $tb_force = get_option('lg_force_tb_support');
                    // Slides' cache infos
                    $lg_scache = get_option('lg_enable_slides_cache');
                    // Lightbox URL
                    if ($lb_enabled == "TRUE" && $lb_thumbs == "TRUE" && $lg_scache == "TRUE" && some_lightbox_plugin() || $lb_force == "TRUE") {
                        $slide_folder = get_option('lg_slide_folder');
                        if (!file_exists($gallery_root . $currentdir . $slide_folder . $img)) {
                            createCache($currentdir, $img, false);
                        }
                        $urlImg = str_replace(" ", "%20", $gallery_address . $currentdir . $slide_folder . $img);
                        echo '<td><a href="' . $urlImg . '" rel="lightbox[' . $currentdir . ']" title="' . $title . '"><img src="' . $gallery_address . $currdir . get_option('lg_thumb_folder') . $img . '" alt="' . $img . '"  title="' . $title . '" /></a></td>';
                    } elseif ($tb_enabled == "TRUE" && $tb_thumbs == "TRUE" && $lg_scache == "TRUE" && some_thickbox_plugin() || $tb_force == "TRUE") {
                        $slide_folder = get_option('lg_slide_folder');
                        if (!file_exists($gallery_root . $currentdir . $slide_folder . $img)) {
                            createCache($currentdir, $img, false);
                        }
                        $thumb_folder = get_option('lg_thumb_folder');
                        $xhthumbs = str_replace(" ", "%20", $currdir . $thumb_folder . $img);
                        $xhurl = str_replace(" ", "%20", $currdir . $img);
                        $xhslides = str_replace(" ", "%20", $currdir . $slide_folder . $img);
                        echo '<td><a href="' . $gallery_address . $xhslides . '" class="thickbox" title="' . $title . ' "><img src="' . $gallery_address . $xhthumbs . '" alt="' . $img . '"   /></a></td>';
                    } else {
                        $thumb_folder = get_option('lg_thumb_folder');
                        $xhthumbs = str_replace(" ", "%20", $currdir . $thumb_folder . $img);
                        $xhurl = str_replace(" ", "%20", $currdir . $img);
                        echo '<td><a href="' . $gallery_uri . 'file=' . $xhurl . '"><img src="' . $gallery_address . $xhthumbs . '" alt="' . $img . '"  title="' . $title . '" /></a></td>';
                    }
                    /* ================
                     * End of Right URL
                     * ================ */
                    $tcol_count++;
                } else {
                    // this will prevent some unshown thumb
                    $mem = get_option('lg_buffer_size');
                    ini_set("memory_limit", $mem);
                    $resource = $gallery_root . $currentdir . $img;
                    $path = pathinfo($resource);
                    switch (strtolower($path["extension"])) {
                        case "jpeg":
                        case "jpg":
                            $resource = imagecreatefromjpeg($resource);
                            break;
                        case "gif":
                            $resource = imagecreatefromgif($resource);
                            break;
                        case "png":
                            $resource = imagecreatefrompng($resource);
                            break;
                        default:
                            break;
                    }
                    if (imagesx($resource) > get_option('lg_thumbwidth')) {
                        echo '<td><a href="' . $gallery_uri . 'file=' . $currdir . $img . '"><img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $currdir . $img . '&amp;thumb=1" alt="' . $img . '" title="' . $title . '"/></a></td>';
                    } else {
                        echo '<td><a href="' . $gallery_uri . 'file=' . $currdir . $img . '"><img src="' . $gallery_address . $currdir . $img . '" alt="' . $img . '" title="' . $title . '"/></a></td>';
                    }
                    $tcol_count++;
                }
                if ($tcol_count > $tcolumns) {
                    echo '</tr><tr>';
                    $tcol_count = 1;
                }
            }
        }
        echo '<td></td></tr></table>';
        // Pagination's navigatior code
        if ($thumbs_page != 0) {
            $pages = ceil(sizeof($imgfiles) / $thumbs_page);
            echo '<div id="pagination">';
            if ($offset > 0) {
                echo '<a href="' . $gallery_uri . 'file=' . $currdir . '&amp;offset=' . ($offset - $thumbs_page) . '"  title="previous">' . __('&laquo; Prev', $lg_text_domain) . '</a> ' . "\n";
            }
            if ($pages > 1) {
                for ($i = 1; $i <= $pages; $i++) {
                    if ($offset != ($i - 1) * $thumbs_page) {
                        echo ' <a href="' . $gallery_uri . 'file=' . $currdir . '&amp;offset=' . ($i - 1) * $thumbs_page . '" >' . $i . '</a> ';
                    } else {
                        echo " {$i} ";
                    }
                }
            }
            if (count($imgfiles) > $thumbs_page + $offset) {
                echo ' <a href="' . $gallery_uri . 'file=' . $currdir . '&amp;offset=' . $end . '"  title="next">' . __('Next &raquo;', $lg_text_domain) . '</a> ';
            }
            echo '</div>';
        }
        // End of Pagination's navigatior code
        // Admin links
        if (get_option('lg_enable_captions') == "TRUE") {
            get_currentuserinfo();
            if (strlen($currentdir) != 0) {
                if ($user_level >= 8) {
                    echo "<div class='lg_admin'>";
                    echo "<a href='" . get_option('siteurl') . "/wp-admin/" . LG_FLM_PAGE . "&amp;captions=" . $currdir . "'>";
                    echo "&raquo; ";
                    _e("Write captions for images in ", $lg_text_domain);
                    echo " " . substr($currentdir, 0, strlen($currentdir) - 1);
                    echo "</a>";
                    echo "</div>";
                }
            }
        }
    }
}