Example #1
0
/**
 * This function is used in the sidebar to display a random image
 * from the gallery
 */
function lg_random_image($title)
{
    global $gallery_address, $gallery_root, $user_level, $lg_text_domain, $wp_rewrite;
    $gallery_uri = get_option('lg_gallery_uri');
    // Fix for permalinks
    if ($wp_rewrite->using_permalinks()) {
        $gallery_uri = $gallery_uri . '?';
    } else {
        $gallery_uri = $gallery_uri . '&';
    }
    if ($dir_content = opendir($gallery_root)) {
        echo $title;
        // Gather image files
        $imgfiles = lg_build_img_array();
        // Get a random image
        $img = $imgfiles[rand(0, sizeof($imgfiles) - 1)];
        // Keep track of the folders and separate from file (due to use of "thumbs folder")
        $img_file_path = explode('/', $img);
        $img_index = count($img_file_path) - 1;
        for ($i = 0; $i < count($img_file_path) - 1; $i++) {
            $folder .= $img_file_path[$i] . '/';
            // now $folder contains the path to the file without the filename
            // ie: some/where/
        }
        $img_file = $img_file_path[$img_index];
        // $img_file contains now only the file name
        echo '<div id="lazyest_sidebox">' . "\n";
        // Slide's Cache System code (used for lightbox)
        $slide_folder = get_option('lg_slide_folder');
        // Gather Captions infos
        if (file_exists($gallery_root . $folder . 'captions.xml')) {
            $caption = clean_image_caption($img_file, $folder);
        }
        $title = ereg_replace("<[^>]*>", "", $caption);
        if (!file_exists($gallery_root . $folder . $slide_folder . $img_file) && strlen($img_file) > 0) {
            createCache($folder, $img_file, false);
        }
        /* =============
         * The Right URL
         * ============= */
        // Lightbox Informations
        $lb_enabled = get_option('lg_enable_lb_support');
        $lb_sidebar = get_option('lg_enable_lb_sidebar_support');
        $lb_force = get_option('lg_force_lb_support');
        // Thickbox informations
        $tb_enabled = get_option('lg_enable_tb_support');
        $tb_sidebar = get_option('lg_enable_tb_sidebar_support');
        $tb_force = get_option('lg_force_tb_support');
        // Slides' cache infos
        $lg_scache = get_option('lg_enable_slides_cache');
        // Image URL
        $urlImg = str_replace(" ", "%20", $gallery_address . $folder . $slide_folder . $img_file);
        // Lightbox code
        if ($lb_enabled == "TRUE" && $lb_sidebar == "TRUE" && $lg_scache == "TRUE" && some_lightbox_plugin() || $lb_force == "TRUE") {
            echo "<a href='{$urlImg}' rel='lightbox' title='{$title}'>";
        } elseif ($tb_enabled == "TRUE" && $tb_sidebar == "TRUE" && $lg_scache == "TRUE" && some_thickbox_plugin() || $tb_force == "TRUE") {
            echo '<a href="' . $urlImg . '" class="thickbox" title="' . $title . ' ">';
        } else {
            // $img contains the full path to the file starting from $gallery_root (excluded)
            $urlImg = str_replace(" ", "%20", $img);
            echo '<a href="' . $gallery_uri . 'file=' . $urlImg . '">' . "\n";
        }
        /* ================
         * End of Right URL
         * ================ */
        /* ==============
         * Thumbnail code
         * ============== */
        if ($img) {
            // Gather Captions infos
            if (file_exists($gallery_root . $folder . 'captions.xml')) {
                $caption = clean_image_caption($img_file, $folder);
            } else {
                $caption = "Click to visit my gallery!";
            }
            // This will remove HTML tags (which is incompatible with "title" argument)
            $title = ereg_replace("<[^>]*>", "", $caption);
            // Cache System code
            if (get_option('lg_enable_cache') == "TRUE") {
                $thumb_folder = get_option('lg_thumb_folder');
                if (!file_exists($gallery_root . $folder . $thumb_folder . $img)) {
                    createCache($folder, $img_file, true);
                }
                $url = str_replace(" ", "%20", $gallery_address . $folder . $thumb_folder . $img_file);
                echo '<img src="' . $url . '"  alt="' . $img . '" title="' . $title . '"/>';
            } else {
                $urlImg = str_replace(" ", "%20", $img);
                echo '<img src="' . get_option('siteurl') . '/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=' . $urlImg . '&amp;thumb=1"  style="border: 1px solid #ccc; vertical-align:middle;padding:2px;"  alt="' . $img . '" title="' . $title . '" />';
            }
        }
        echo "</a></div>";
    }
}
Example #2
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>";
                }
            }
        }
    }
}
"><?php 
    _e('File Manager', $lg_text_domain);
    ?>
</a></li>
								<li><a href="?page=lazyest-gallery/lazyest-admin.php&amp;edit_css=true"><?php 
    _e('Edit LG Style Sheet', $lg_text_domain);
    ?>
</a></li>
							</ul>
						</div>
					</fieldset>
					<!-- End of Main Menu -->

					<!-- Lightbox support div	 -->
					<?php 
    if (some_lightbox_plugin() || get_option('lg_force_lb_support') == "TRUE") {
        ?>
						<fieldset id="lightbox-div" class="dbx-box">
							<h3 title="click-down and drag to move this box" class="dbx-handle"><?php 
        _e('Lightbox Options', $lg_text_domain);
        ?>
</h3>
							<div class="dbx-content" style="font-size:x-small">
								<div style="font-size:x-small;text-align:center;padding:0px;color:red;width:95%;border:1px solid #ff0000;background:#ffdddd">
									<?php 
        _e('EXPERIMENTAL', $lg_text_domain);
        ?>
								</div>
								<br />
								<input type="checkbox" name="enable_lb_support" value="TRUE" <?php 
        if (get_option('lg_enable_lb_support') == "TRUE") {
Example #4
0
function lg_update_options()
{
    global $user_level, $lg_text_domain;
    get_currentuserinfo();
    if ($user_level < 8) {
        die(__('Are You Cheatin&#8217; uh?'));
    }
    /*
     * updating the option values in the database
     * no need to check wether it has changed,
     * this is done by the function update_option()
     */
    $galleryfolder = $_POST['gallery_folder'];
    if (isset($_POST['gallery_folder']) && strlen($galleryfolder) != 0) {
        // a "/" is needed at the end of $galleryfolderto
        // add it if necessary
        if ($galleryfolder[strlen($galleryfolder) - 1] != "/") {
            $galleryfolder .= "/";
        }
        update_option('lg_gallery_folder', $galleryfolder);
    }
    if (isset($_POST['gallery_uri'])) {
        update_option('lg_gallery_uri', $_POST['gallery_uri']);
    }
    if (isset($_POST['sort_alphabetically']) && ereg("TRUE|FALSE", $_POST['sort_alphabetically'])) {
        update_option('lg_sort_alphabetically', $_POST['sort_alphabetically']);
    }
    if (isset($_POST['thumbspage']) && is_numeric($_POST['thumbspage'])) {
        update_option('lg_thumbs_page', abs(intval($_POST['thumbspage'])));
    }
    if (isset($_POST['folderscolumns']) && is_numeric($_POST['folderscolumns'])) {
        update_option('lg_folders_columns', abs(intval($_POST['folderscolumns'])));
    }
    if (isset($_POST['thumbnailscolumns']) && is_numeric($_POST['thumbnailscolumns'])) {
        update_option('lg_thumbs_columns', abs(intval($_POST['thumbnailscolumns'])));
    }
    if (isset($_POST['pictwidth']) && is_numeric($_POST['pictwidth'])) {
        update_option('lg_pictwidth', abs(intval($_POST['pictwidth'])));
    }
    if (isset($_POST['pictheight']) && is_numeric($_POST['pictheight'])) {
        update_option('lg_pictheight', abs(intval($_POST['pictheight'])));
    }
    if (isset($_POST['thumbwidth']) && is_numeric($_POST['thumbwidth'])) {
        update_option('lg_thumbwidth', abs(intval($_POST['thumbwidth'])));
    }
    if (isset($_POST['thumbheight']) && is_numeric($_POST['thumbheight'])) {
        update_option('lg_thumbheight', abs(intval($_POST['thumbheight'])));
    }
    if (isset($_POST['thumbfolder'])) {
        $thumbfolder = $_POST['thumbfolder'];
        // a "/" is needed at the end of $thumbfolder
        // add it if necessary
        if ($thumbfolder[strlen($thumbfolder) - 1] != "/") {
            $thumbfolder .= "/";
        }
        update_option('lg_thumb_folder', $thumbfolder);
    }
    if (isset($_POST['slidefolder'])) {
        $slidefolder = $_POST['slidefolder'];
        // a "/" is needed at the end of $thumbfolder
        // add it if necessary
        if ($slidefolder[strlen($slidefolder) - 1] != "/") {
            $slidefolder .= "/";
        }
        update_option('lg_slide_folder', $slidefolder);
    }
    // Use Slides popup
    if (isset($_POST['use_slides_popup'])) {
        update_option('lg_use_slides_popup', "TRUE");
        update_option('lg_enable_lb_slides_support', "FALSE");
    } else {
        if (!isset($_POST['use_slides_popup'])) {
            update_option('lg_use_slides_popup', "FALSE");
        }
    }
    if (isset($_POST['excludefolder'])) {
        $excludefolder = explode(',', $_POST['excludefolder']);
        // add the folder of cached thumbnails here already
        // but maybe he's already in the array
        if (isset($_POST['thumbfolder'])) {
            $thumbfolder = $_POST['thumbfolder'][strlen($_POST['thumbfolder']) - 1] == '/' ? substr($_POST['thumbfolder'], 0, strlen($_POST['thumbfolder']) - 1) : $_POST['thumbfolder'];
            $thumbfolder_found = FALSE;
        }
        // remove any trailing '/'
        for ($i = 0; $i < sizeof($excludefolder); $i++) {
            if ($excludefolder[$i][strlen($excludefolder[$i]) - 1] == '/') {
                $excludefolder[$i] = substr($excludefolder[$i], 0, strlen($excludefolder[$i]) - 1);
            }
            // check this element if it's the thumbfolder
            if (!$thumbfolder_found && $excludefolder[$i] == $thumbfolder) {
                $thumbfolder_found = TRUE;
            }
        }
        // if it wasn't already in the array, add it here
        if (!$thumbfolder_found) {
            $excludefolder[] = $thumbfolder;
        }
        update_option('lg_excluded_folders', $excludefolder);
        // arrays get serialized automatically (also unserialized when retrieving the option)
    }
    /* ==============
     * Advanced Stuff
     * ============== */
    // Cache for thumbnails
    if (isset($_POST['use_cache'])) {
        update_option('lg_enable_cache', "TRUE");
    } else {
        if (!isset($_POST['use_cache'])) {
            update_option('lg_enable_cache', "FALSE");
            update_option('lg_use_cropping', "FALSE");
        }
    }
    // Cache for slides
    if (isset($_POST['use_slides_cache'])) {
        update_option('lg_enable_slides_cache', "TRUE");
    } else {
        if (!isset($_POST['use_slides_cache'])) {
            update_option('lg_enable_slides_cache', "FALSE");
        }
    }
    // Disable fullsize image link
    if (isset($_POST['disable_full_size'])) {
        update_option('lg_disable_full_size', "TRUE");
    } else {
        if (!isset($_POST['disable_full_size'])) {
            update_option('lg_disable_full_size', "FALSE");
        }
    }
    // Cropping
    if (isset($_POST['use_cropping'])) {
        update_option('lg_use_cropping', "TRUE");
        update_option('lg_enable_cache', "TRUE");
    } else {
        if (!isset($_POST['use_cropping'])) {
            update_option('lg_use_cropping', "FALSE");
        }
    }
    // Resample quality
    if (isset($_POST['resample_quality']) && is_numeric($_POST['resample_quality'])) {
        if ($_POST['resample_quality'] <= 100 || $_POST['resample_quality'] >= 0) {
            update_option('lg_resample_quality', abs(intval($_POST['resample_quality'])));
        }
    }
    if (isset($_POST['buffer_size'])) {
        $mem = $_POST['buffer_size'];
        // a "M" is needed at the end of buffer_size
        // add it if necessary
        if ($mem[strlen($mem) - 1] != "M") {
            $mem .= "M";
        }
        update_option('lg_buffer_size', $mem);
    }
    if (isset($_POST['folder_image'])) {
        update_option('lg_folder_image', $_POST['folder_image']);
    }
    /* ====================
     * ExIF Data and Fields
     * ==================== */
    // Enable ExIF Data
    if (isset($_POST['enable_exif'])) {
        update_option('lg_enable_exif', "TRUE");
    } else {
        if (!isset($_POST['enable_exif'])) {
            update_option('lg_enable_exif', "FALSE");
        }
    }
    // Show Errors
    if (isset($_POST['exif_errors'])) {
        update_option('lg_exif_print_error', "TRUE");
    } else {
        if (!isset($_POST['exif_errors'])) {
            update_option('lg_exif_print_error', "FALSE");
        }
    }
    // Show if it's a valid Jpeg
    if (isset($_POST['exif_valid_jpeg'])) {
        update_option('lg_exif_valid_jpeg', "TRUE");
    } else {
        if (!isset($_POST['exif_valid_jpeg'])) {
            update_option('lg_exif_valid_jpeg', "FALSE");
        }
    }
    // Show if there are valid jfif data
    if (isset($_POST['exif_valid_jfif_data'])) {
        update_option('lg_exif_valid_jfif_data', "TRUE");
    } else {
        if (!isset($_POST['exif_valid_jfif_data'])) {
            update_option('lg_exif_valid_jfif_data', "FALSE");
        }
    }
    // Show jfif size
    if (isset($_POST['exif_jfif_size'])) {
        update_option('lg_exif_jfif_size', "TRUE");
    } else {
        if (!isset($_POST['exif_jfif_size'])) {
            update_option('lg_exif_jfif_size', "FALSE");
        }
    }
    // Show jfif identifier
    if (isset($_POST['exif_jfif_identifier'])) {
        update_option('lg_exif_jfif_identifier', "TRUE");
    } else {
        if (!isset($_POST['exif_jfif_identifier'])) {
            update_option('lg_exif_jfif_identifier', "FALSE");
        }
    }
    // Show extension code
    if (isset($_POST['exif_jfif_extension_code'])) {
        update_option('lg_exif_jfif_extension_code', "TRUE");
    } else {
        if (!isset($_POST['exif_jfif_extension_code'])) {
            update_option('lg_exif_jfif_extension_code', "FALSE");
        }
    }
    // Show JFIF data
    if (isset($_POST['exif_jfif_data'])) {
        update_option('lg_exif_jfif_data', "TRUE");
    } else {
        if (!isset($_POST['exif_jfif_data'])) {
            update_option('lg_exif_jfif_data', "FALSE");
        }
    }
    // Show exif valid data
    if (isset($_POST['exif_valid_exif_data'])) {
        update_option('lg_exif_valid_exif_data', "TRUE");
    } else {
        if (!isset($_POST['exif_valid_exif_data'])) {
            update_option('lg_exif_valid_exif_data', "FALSE");
        }
    }
    // Show app1 size
    if (isset($_POST['exif_app1_size'])) {
        update_option('lg_exif_app1_size', "TRUE");
    } else {
        if (!isset($_POST['exif_app1_size'])) {
            update_option('lg_exif_app1_size', "FALSE");
        }
    }
    // Show endien
    if (isset($_POST['exif_endien'])) {
        update_option('lg_exif_endien', "TRUE");
    } else {
        if (!isset($_POST['exif_endien'])) {
            update_option('lg_exif_endien', "FALSE");
        }
    }
    // Show ifd0 number of array tags
    if (isset($_POST['exif_ifd0_num_tags'])) {
        update_option('lg_exif_ifd0_num_tags', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_num_tags'])) {
            update_option('lg_exif_ifd0_num_tags', "FALSE");
        }
    }
    // Show IFD0 orientation
    if (isset($_POST['exif_ifd0_orientation'])) {
        update_option('lg_exif_ifd0_orientation', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_orientation'])) {
            update_option('lg_exif_ifd0_orientation', "FALSE");
        }
    }
    // Show X resolution
    if (isset($_POST['exif_ifd0_x_res'])) {
        update_option('lg_exif_ifd0_x_res', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_x_res'])) {
            update_option('lg_exif_ifd0_x_res', "FALSE");
        }
    }
    // Show Y Resolution
    if (isset($_POST['exif_ifd0_y_res'])) {
        update_option('lg_exif_ifd0_y_res', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_y_res'])) {
            update_option('lg_exif_ifd0_y_res', "FALSE");
        }
    }
    // Show Resolution Unit
    if (isset($_POST['exif_ifd0_res_unit'])) {
        update_option('lg_exif_ifd0_res_unit', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_res_unit'])) {
            update_option('lg_exif_ifd0_res_unit', "FALSE");
        }
    }
    // Show Software tag
    if (isset($_POST['exif_ifd0_software'])) {
        update_option('lg_exif_ifd0_software', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_software'])) {
            update_option('lg_exif_ifd0_software', "FALSE");
        }
    }
    // Show time
    if (isset($_POST['exif_ifd0_time'])) {
        update_option('lg_exif_ifd0_time', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_time'])) {
            update_option('lg_exif_ifd0_time', "FALSE");
        }
    }
    // Show IFD0 Offset
    if (isset($_POST['exif_ifd0_offset'])) {
        update_option('lg_exif_ifd0_offset', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd0_offset'])) {
            update_option('lg_exif_ifd0_offset', "FALSE");
        }
    }
    //Show IFD1 Main Offset
    if (isset($_POST['exif_ifd1_main_offset'])) {
        update_option('lg_exif_ifd1_main_offset', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_main_offset'])) {
            update_option('lg_exif_ifd1_main_offset', "FALSE");
        }
    }
    // Show sub ifd0 number of array tags
    if (isset($_POST['exif_sub_ifd_num_tags'])) {
        update_option('lg_exif_sub_ifd_num_tags', "TRUE");
    } else {
        if (!isset($_POST['exif_sub_ifd_num_tags'])) {
            update_option('lg_exif_sub_ifd_num_tags', "FALSE");
        }
    }
    // Show Color Space
    if (isset($_POST['exif_sub_ifd_color_space'])) {
        update_option('lg_exif_sub_ifd_color_space', "TRUE");
    } else {
        if (!isset($_POST['exif_sub_ifd_color_space'])) {
            update_option('lg_exif_sub_ifd_color_space', "FALSE");
        }
    }
    // Show ifd width
    if (isset($_POST['exif_sub_ifd_width'])) {
        update_option('lg_exif_sub_ifd_width', "TRUE");
    } else {
        if (!isset($_POST['exif_sub_ifd_width'])) {
            update_option('lg_exif_sub_ifd_width', "FALSE");
        }
    }
    // Show ifd height
    if (isset($_POST['exif_sub_ifd_height'])) {
        update_option('lg_exif_sub_ifd_height', "TRUE");
    } else {
        if (!isset($_POST['exif_sub_ifd_height'])) {
            update_option('lg_exif_sub_ifd_height', "FALSE");
        }
    }
    // Show ifd0 number of array tags
    if (isset($_POST['exif_ifd1_num_tags'])) {
        update_option('lg_exif_ifd1_num_tags', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_num_tags'])) {
            update_option('lg_exif_ifd1_num_tags', "FALSE");
        }
    }
    // Show ifd1 compression
    if (isset($_POST['exif_ifd1_compression'])) {
        update_option('lg_exif_ifd1_compression', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_compression'])) {
            update_option('lg_exif_ifd1_compression', "FALSE");
        }
    }
    // Show ifd1 X resolution
    if (isset($_POST['exif_ifd1_x_res'])) {
        update_option('lg_exif_ifd1_x_res', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_x_res'])) {
            update_option('lg_exif_ifd1_x_res', "FALSE");
        }
    }
    // Show ifd1 Y resolution
    if (isset($_POST['exif_ifd1_y_res'])) {
        update_option('lg_exif_ifd1_y_res', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_y_res'])) {
            update_option('lg_exif_ifd1_y_res', "FALSE");
        }
    }
    // Show ifd1 resolution unit
    if (isset($_POST['exif_ifd1_res_unit'])) {
        update_option('lg_exif_ifd1_res_unit', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_res_unit'])) {
            update_option('lg_exif_ifd1_res_unit', "FALSE");
        }
    }
    // Show ifd1 jpeg offset
    if (isset($_POST['exif_ifd1_jpeg_if_offset'])) {
        update_option('lg_exif_ifd1_jpeg_if_offset', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_jpeg_if_offset'])) {
            update_option('lg_exif_ifd1_jpeg_if_offset', "FALSE");
        }
    }
    // Show byte count
    if (isset($_POST['exif_ifd1_jpeg_if_byte_count'])) {
        update_option('lg_exif_ifd1_jpeg_if_byte_count', "TRUE");
    } else {
        if (!isset($_POST['exif_ifd1_jpeg_if_byte_count'])) {
            update_option('lg_exif_ifd1_jpeg_if_byte_count', "FALSE");
        }
    }
    /* ===========================
     *	End of ExIF Data and Fields
     * =========================== */
    /* ========
     * Captions
     * ======== */
    if (isset($_POST['enable_captions'])) {
        update_option('lg_enable_captions', "TRUE");
    } else {
        if (!isset($_POST['enable_captions'])) {
            update_option('lg_enable_captions', "FALSE");
        }
    }
    if (isset($_POST['use_folder_captions'])) {
        update_option('lg_use_folder_captions', "TRUE");
    } else {
        if (!isset($_POST['use_folder_captions'])) {
            update_option('lg_use_folder_captions', "FALSE");
        }
    }
    /* ================
     * Lightbox support
     * ================ */
    // Main
    if (isset($_POST['enable_lb_support']) && some_lightbox_plugin()) {
        update_option('lg_enable_lb_support', "TRUE");
        update_option('lg_enable_slides_cache', "TRUE");
    } else {
        if (!isset($_POST['enable_lb_support'])) {
            update_option('lg_enable_lb_support', "FALSE");
        }
    }
    // Forcing
    if (isset($_POST['force_lb_support'])) {
        update_option('lg_force_lb_support', "TRUE");
        update_option('lg_enable_lb_support', "TRUE");
        update_option('lg_enable_slides_cache', "TRUE");
    } else {
        if (!isset($_POST['force_lb_support'])) {
            update_option('lg_force_lb_support', "FALSE");
        }
    }
    // Thumbs
    if (isset($_POST['enable_lb_thumbs_support'])) {
        update_option('lg_enable_lb_thumbs_support', "TRUE");
    } else {
        if (!isset($_POST['enable_lb_thumbs_support'])) {
            update_option('lg_enable_lb_thumbs_support', "FALSE");
        }
    }
    // Slides
    if (isset($_POST['enable_lb_slides_support'])) {
        update_option('lg_enable_lb_slides_support', "TRUE");
        update_option('lg_use_slides_popup', "FALSE");
    } else {
        if (!isset($_POST['enable_lb_slides_support'])) {
            update_option('lg_enable_lb_slides_support', "FALSE");
        }
    }
    // Sidebar
    if (isset($_POST['enable_lb_sidebar_support'])) {
        update_option('lg_enable_lb_sidebar_support', "TRUE");
    } else {
        if (!isset($_POST['enable_lb_sidebar_support'])) {
            update_option('lg_enable_lb_sidebar_support', "FALSE");
        }
    }
    // Posts
    if (isset($_POST['enable_lb_posts_support'])) {
        update_option('lg_enable_lb_posts_support', "TRUE");
    } else {
        if (!isset($_POST['enable_lb_posts_support'])) {
            update_option('lg_enable_lb_posts_support', "FALSE");
        }
    }
    /* ================
     * Thickbox support
     * ================ */
    // Main
    if (isset($_POST['enable_tb_support']) && some_thickbox_plugin()) {
        update_option('lg_enable_tb_support', "TRUE");
        update_option('lg_enable_slides_cache', "TRUE");
    } else {
        if (!isset($_POST['enable_tb_support'])) {
            update_option('lg_enable_tb_support', "FALSE");
        }
    }
    // Forcing
    if (isset($_POST['force_tb_support'])) {
        update_option('lg_force_tb_support', "TRUE");
        update_option('lg_enable_tb_support', "TRUE");
        update_option('lg_enable_slides_cache', "TRUE");
    } else {
        if (!isset($_POST['force_tb_support'])) {
            update_option('lg_force_tb_support', "FALSE");
        }
    }
    // Thumbs
    if (isset($_POST['enable_tb_thumbs_support'])) {
        update_option('lg_enable_tb_thumbs_support', "TRUE");
    } else {
        if (!isset($_POST['enable_tb_thumbs_support'])) {
            update_option('lg_enable_tb_thumbs_support', "FALSE");
        }
    }
    // Slides
    if (isset($_POST['enable_tb_slides_support'])) {
        update_option('lg_enable_tb_slides_support', "TRUE");
        update_option('lg_use_slides_popup', "FALSE");
    } else {
        if (!isset($_POST['enable_tb_slides_support'])) {
            update_option('lg_enable_tb_slides_support', "FALSE");
        }
    }
    // Sidebar
    if (isset($_POST['enable_tb_sidebar_support'])) {
        update_option('lg_enable_tb_sidebar_support', "TRUE");
    } else {
        if (!isset($_POST['enable_tb_sidebar_support'])) {
            update_option('lg_enable_tb_sidebar_support', "FALSE");
        }
    }
    // Posts
    if (isset($_POST['enable_tb_posts_support'])) {
        update_option('lg_enable_tb_posts_support', "TRUE");
    } else {
        if (!isset($_POST['enable_tb_posts_support'])) {
            update_option('lg_enable_tb_posts_support', "FALSE");
        }
    }
    /* ==============
     * Upload options
     * ============== */
    // fileupload_maxk fileupload_allowedtypes fileupload_minlevel
    // lg_fileupload_maxk lg_fileupload_allowedtypes lg_fileupload_minlevel
    // File size
    if (isset($_POST['fileupload_maxk']) && is_numeric($_POST['fileupload_maxk'])) {
        update_option('lg_fileupload_maxk', abs(intval($_POST['fileupload_maxk'])));
    }
    // Allowed files to upload
    if (isset($_POST['fileupload_allowedtypes'])) {
        update_option('lg_fileupload_allowedtypes', $_POST['fileupload_allowedtypes']);
    }
    // User level who can upload
    if (isset($_POST['fileupload_minlevel']) && is_numeric($_POST['fileupload_minlevel'])) {
        update_option('lg_fileupload_minlevel', abs(intval($_POST['fileupload_minlevel'])));
    }
    // Microsoft Wizard Publisher
    if (isset($_POST['enable_mwp_support'])) {
        update_option('lg_enable_mwp_support', "TRUE");
    } else {
        if (!isset($_POST['enable_mwp_support'])) {
            update_option('lg_enable_mwp_support', "FALSE");
        }
    }
    lg_options_success(__('Options Updated Successfully', $lg_text_domain));
}
Example #5
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>";
                }
            }
        }
    }
}