function processJSONFile($conn, $lang, $category, $topic, $file) { $content = file_get_contents($file); echo 'import ' . $lang . ', ' . $category . ', ' . $topic . ', ' . $file . ':'; $result = createCache($conn, $category, $lang, $topic, $content); if (!$result) { die("mysql error: " . $conn->error); } echo $result . '<br>'; unlink($file); }
/** * 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 . '&thumb=1" style="border: 1px solid #ccc; vertical-align:middle;padding:2px;" alt="' . $img . '" title="' . $title . '" />'; } } echo "</a></div>"; } }
function cache($query, $time, $folder = '', $server = array(), $name = '') { global $settings; $md5 = md5($query); if ($folder == '' && empty($name)) { $file = $md5; } else { if ($folder != '' && empty($name)) { $file = $folder . '/' . $md5; } else { if ($folder != '' && !empty($name)) { $file = $folder . '/' . $name; } else { if ($folder == '' && !empty($name)) { $file = $name; } } } } if ($settings['debug']['sqlcache'] == true) { echo "<pre>"; echo substr($query, 0, 1000); echo "</pre>"; } if ($settings['apc_enabled']) { if (apc_exists($file)) { return apc_fetch($file); } else { return createCache($query, $server, $file, $time); } } else { $file = IN_PATH . 'cache/' . $file . '.php'; if ($folder != '' && !is_dir(IN_PATH . 'cache/' . $folder)) { mkdir(IN_PATH . 'cache/' . $folder, 0777, true); } if (file_exists($file)) { if (time() - filemtime($file) > $time) { // Needs recache return createCache($query, $server, $file); // Return the fresh data } else { // Serve the cache return unserialize(file_get_contents($file, NULL, NULL, 16)); } } else { // Cache needs creating return createCache($query, $server, $file); // Return the fresh data } } }
/** * This function builds the page relative to the caption system */ function lg_build_captions_form() { global $gallery_root, $gallery_address, $lg_text_domain; $capdir = $_GET['captions']; // main container div echo '<div class="wrap">'; /* ========== * Upload div * ========== */ $folder = $gallery_root . $capdir; $allowed_types = explode(' ', trim(strtolower(get_option('lg_fileupload_allowedtypes')))); if ($_POST['upload']) { $action = 'upload'; } if (!is_writable($folder)) { $action = 'not-writable'; } switch ($action) { case 'not-writable': ?> <p><?php printf(__("It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code>%s</code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos.", $lg_text_domain), $folder); ?> </p> <?php break; case 'upload': $imgalt = basename(isset($_POST['imgalt']) ? $_POST['imgalt'] : ''); $img1_name = strlen($imgalt) ? $imgalt : basename($_FILES['img1']['name']); $img1_name = preg_replace('/[^a-z0-9_.]/i', '', $img1_name); $img1_size = $_POST['img1_size'] ? intval($_POST['img1_size']) : intval($_FILES['img1']['size']); $img1_type = strlen($imgalt) ? $_POST['img1_type'] : $_FILES['img1']['type']; $pi = pathinfo($img1_name); $imgtype = strtolower($pi['extension']); if (in_array($imgtype, $allowed_types) == false) { die(sprintf(__('File %1$s of type %2$s is not allowed.', $lg_text_domain), $img1_name, $imgtype)); } if (strlen($imgalt)) { $pathtofile = $folder . $imgalt; $img1 = $_POST['img1']; } else { $pathtofile = $folder . $img1_name; $img1 = $_FILES['img1']['tmp_name']; } // makes sure not to upload duplicates, rename duplicates $i = 1; $pathtofile2 = $pathtofile; $tmppathtofile = $pathtofile2; $img2_name = $img1_name; while (file_exists($pathtofile2)) { $pos = strpos(strtolower($tmppathtofile), '.' . trim($imgtype)); $pathtofile_start = substr($tmppathtofile, 0, $pos); $pathtofile2 = $pathtofile_start . '_' . zeroise($i++, 2) . '.' . trim($imgtype); $img2_name = explode('/', $pathtofile2); $img2_name = $img2_name[count($img2_name) - 1]; } if (file_exists($pathtofile) && !strlen($imgalt)) { $i = explode(' ', get_option('lg_fileupload_allowedtypes')); $i = implode(', ', array_slice($i, 1, count($i) - 2)); $moved = move_uploaded_file($img1, $pathtofile2); if (!$moved) { $moved = copy($img1, $pathtofile2); } if (!$moved) { die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile2)); } else { chmod($pathtofile2, 0666); @unlink($img1); } // // duplicate-renaming function contributed by Gary Lawrence Murphy ?> <p><strong><?php __('Duplicate File?'); ?> </strong></p> <p><b><em><?php printf(__("The filename '%s' already exists!"), $img1_name); ?> </em></b></p> <p><?php printf(__("Filename '%1\$s' moved to '%2\$s'"), $img1, "{$pathtofile2} - {$img2_name}"); ?> </p> <p><?php _e('Confirm or rename:'); ?> </p> <form action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_option('lg_fileupload_maxk') * 1024; ?> " /> <input type="hidden" name="img1_type" value="<?php echo $img1_type; ?> " /> <input type="hidden" name="img1_name" value="<?php echo $img2_name; ?> " /> <input type="hidden" name="img1_size" value="<?php echo $img1_size; ?> " /> <input type="hidden" name="img1" value="<?php echo $pathtofile2; ?> " /> <?php _e('Alternate name:'); ?> <br /><input type="text" name="imgalt" size="30" class="uploadform" value="<?php echo $img2_name; ?> " /><br /> <br /> <input type="submit" name="submit" value="<?php _e('Rename'); ?> " class="search" /> </form> <?php die; } if (!strlen($imgalt)) { @($moved = move_uploaded_file($img1, $pathtofile)); //Path to your images directory, chmod the dir to 777 // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't // include your tmp directory. Try copy instead? if (!$moved) { $moved = copy($img1, $pathtofile); } // Still couldn't get it. Give up. if (!$moved) { die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile)); } else { chmod($pathtofile, 0666); @unlink($img1); } } else { rename($img1, $pathtofile) or die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile)); } if (ereg('image/', $img1_type)) { $piece_of_code = "[[Image:" . $capdir . $img1_name . "]]"; } else { $piece_of_code = "<a href='" . $gallery_address . $capdir . $img1_name . "'>{$img1_name}</a>"; } $piece_of_code = htmlspecialchars($piece_of_code); ?> <div id="message" class="updated fade"><p><?php _e('File uploaded!', $lg_text_domain); ?> </p></div> <p><?php printf(__("Your file <code>%s</code> was uploaded successfully!", $lg_text_domain), $img1_name); ?> </p> <p><?php _e('Here’s the code to display it in your posts:', $lg_text_domain); ?> </p> <p><code><?php echo $piece_of_code; ?> </code></p> <p> <strong><?php _e('Image Details'); ?> </strong>: <br /> <?php _e('Name:'); ?> <?php echo $img1_name; ?> <br /> <?php _e('Size:'); ?> <?php echo round($img1_size / 1024, 2); ?> <?php _e('<abbr title="Kilobyte">KB</abbr>', $lg_text_domain); ?> <br /> <?php _e('Type:'); ?> <?php echo $img1_type; ?> </p> <p><a href="options-general.php?page=lazyest-gallery/lazyest-admin.php&captions=<?php echo $capdir; ?> "><?php _e('Upload another'); ?> </a></p> <?php break; } /* ================= * End of Upload div * ================= */ /* ================= * Confirmations div * ================= */ if (isset($_POST['yes'])) { if (!is_dir($_POST['delete_this'])) { if (@unlink($_POST['delete_this'])) { echo '<div id="message" class="updated fade"><p>' . __('File deleted successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot delete file, maybe it has already been deleted or have wrong permissions', $lg_text_domain) . '</p></div>'; } } else { if (lg_remove_directory($_POST['delete_this'])) { echo '<div id="message" class="updated fade"><p>' . __('Folder deleted successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot delete folder: maybe it is already empty or have bad permissions', $lg_text_domain) . '</p></div>'; } } // Unsetting informations unset($_POST); unset($_GET); } if (isset($_POST['no'])) { echo '<div id="message" class="updated fade"><p>' . __('Nothing Changed', $lg_text_domain) . '</p></div>'; // Unsetting informations unset($_POST); unset($_GET); } /* ================= * file deletion div * ================= */ if (isset($_GET['file_to_delete']) && !isset($_POST['update_captions']) && !isset($_POST['upload'])) { ?> <div style="padding:10px;"> <div style="text-align:center;padding:0px;color:red;border:1px solid #ff0000;background:#ffdddd"> <?php _e('You are about to delete', $lg_text_domain); echo " <code>" . basename($_GET['file_to_delete']) . "</code><br />"; echo __('Are you sure?', $lg_text_domain) . "<br />"; ?> <form name="delete_image_file" method="post" action="" style="padding:5px;"> <div class="submit" style="text-align:center"> <input type="submit" name="yes" value="<?php _e('Yes', $lg_text_domain); ?> " style="width:80px;" /> <input type="submit" name="no" value="<?php _e('No', $lg_text_domain); ?> " style="width:80px;" /> <input type="hidden" name="delete_this" value="<?php echo $_GET['file_to_delete']; ?> " /> </div> </form> <?php echo "</div>\n</div>"; } $imgfiles = get_imgfiles($capdir); $act_current = $capdir; ?> <fieldset class="options"> <h2><?php echo sprintf(__('Captions page for <code>%s</code>', $lg_text_domain), $act_current); ?> </h2> <!-- Shortcuts--> <div style="padding:5px;display:block;background:#efefef;border:1px solid #ccc;height:20px;"> <a href="options-general.php?page=lazyest-gallery/lazyest-admin.php">« <?php _e('Admin page', $lg_text_domain); ?> </a> </div> <!-- End of Shortcuts--> <br /> <!-- Tip div --> <div style="padding:5px;border:1px solid #3fbd3f;background:#beffbe;color:#088000;"> <?php _e('You can use HTML links but be sure to use "[" and "]" instead of "<" and ">"; something like [a href="somewhere"]Link[/a]', $lg_text_domain); ?> </div> <!-- End of tip div --> <form name="gallery_captions" method="post" action=""> <input type="hidden" name="folder" value="<?php echo $act_current; ?> "/> <table summary="thumbs" cellspacing="1" cellpadding="10"> <tr> <!-- Folder Caption code --> <td colspan='2'><b>» <?php _e("Folder's description:", $lg_text_domain); ?> </b> <?php $foldcap = clean_folder_caption($act_current, false); echo '<input type="text" name="folder_caption" value="' . $foldcap . '" size="80" style="width:98%" />'; ?> <ul> <li>» <a href="?page=lazyest-gallery/lazyest-admin.php&captions=<?php echo $act_current; ?> &file_to_delete=<?php echo $gallery_root . $act_current . get_option('lg_thumb_folder'); ?> " class="delete" style="display:inline;"><?php _e('Empty thumbs cache', $lg_text_domain); ?> </a></li> <li>» <a href="?page=lazyest-gallery/lazyest-admin.php&captions=<?php echo $act_current; ?> &file_to_delete=<?php echo $gallery_root . $act_current . get_option('lg_slide_folder'); ?> " class="delete" style="display:inline;"><?php _e('Empty slides cache', $lg_text_domain); ?> </a></li> </ul> </td> </tr> <tr> <td colspan="2" style="text-algin: left;" ><b>» <?php _e('Minimum level to access this folder:', $lg_text_domain); ?> </b> <select name="folder_minimum_level"> <?php for ($i = 1; $i < 11; $i++) { if ($i == get_minimum_folder_level($act_current)) { $selected = " selected='selected'"; } else { $selected = '0'; } echo "\n\t<option value='{$i}' {$selected}>{$i}</option>"; } ?> </select> <span style="font-size:x-small;text-align:center;padding:2px;color:red;border:1px solid #ff0000;background:#ffdddd"> <?php _e('EXPERIMENTAL: Folder will be still browsable (if full path is known).', $lg_text_domain); ?> </span> </td> </tr> <!-- End of Folder Caption code --> <?php if (isset($imgfiles)) { foreach ($imgfiles as $img) { // clean_image_caption() function is in lazyest-gallery.php file // and checks if xml file exists, if not it returns false // we need a "clean" (with "<" and ">") caption $caption = clean_image_caption($img, $capdir); // this will removes HTML tags and used as title argument $title = ereg_replace("<[^>]*>", "", $caption); $righturl = urlencode($act_current . $img); echo '<tr><td><a href="' . get_option('lg_gallery_uri') . '&file=' . $righturl . '">'; // If thumbs cache system is enabled if (get_option('lg_enable_cache') == "TRUE") { // we check if thumbs exist if (!file_exists($gallery_root . $act_current . get_option('lg_thumb_folder') . $img)) { // keeping track of subfolders $img_file_path = explode('/', $img); $img_index = count($img_file_path) - 1; $img_file = $img_file_path[$img_index]; // If there are subfolders if ($img_index > 1) { for ($i = 1; $i < count($img_file_path) - 1; $i++) { // set the new "current" directory $act_current .= $img_file_path[$i] . "/"; } } // if thumbs do not exist we create them createCache($act_current, $img, true); } // trimming spaces (XHTML Urls) $righturl = str_replace(" ", "%20", $gallery_address . $act_current . get_option('lg_thumb_folder') . $img); echo '<img src="' . $righturl . '" alt="' . $img . '" title="' . $title . '" />'; } else { // otherwise $righturl = str_replace(" ", "%20", get_option('siteurl') . "/wp-content/plugins/lazyest-gallery/lazyest-img.php?file=" . $act_current . $img . "&thumb=1"); echo "<img src=" . $righturl . " alt=" . $img . " title=" . $title . " />"; } // this time we need a "rebuilded" (with "" and "") caption $caption = clean_image_caption($img, $capdir, false); // this is a dynamic form name construct that we need for the captions system $form_name = str_replace('.', '_', $img); $form_name = str_replace(' ', '_', $form_name); echo '</a></td>'; echo '<td>» ' . $img . '<br />'; // Inputs ?> <input type="text" name="<?php echo $form_name; ?> " value="<?php echo $caption; ?> " size="90" style="width:88%" /> <a href="?page=lazyest-gallery/lazyest-admin.php&captions=<?php echo $act_current; ?> &file_to_delete=<?php echo $gallery_root . $act_current . $img; ?> " class="button" style="display:inline;"><?php _e('Delete', $lg_text_domain); ?> </a> <?php } } ?> </table> <div class="submit"> <input type="hidden" name="directory" value="<?php echo $act_current; ?> " /> <input type="submit" name="update_captions" value="<?php _e('Update Folder', $lg_text_domain); ?> " /> </div> </form> </fieldset> <!-- Upload section --> <fieldset class="dbx-box"> <h3 title="click-down and drag to move this box" class="dbx-handle"><?php _e('Upload Image', $lg_text_domain); ?> </h3> <div class="dbx-content"> <?php upload_page($act_current); ?> </div><br /><br /> </fieldset> <!-- Gallery structure section --> <fieldset class="dbx-box"> <h3 title="click-down and drag to move this box" class="dbx-handle"><?php _e('Image Captions', $lg_text_domain); ?> </h3> <div class="dbx-content"> <?php lg_show_gallery_structure(); ?> </div> </fieldset> </div> <?php }
function al_build_captions_form() { global $gallery_root, $gallery_address, $lg_text_domain; $capdir = $_GET['captions']; if (strlen($capdir) == 0) { $capdir = $_POST['upload_folder']; } $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 . '&'; } // main container div echo '<div class="wrap">'; // Button: save captions (lazyest-captions.php) if (isset($_POST['update_captions'])) { al_generate_xml($_POST['directory']); } /* ========== * Upload div * ========== */ $folder = $gallery_root . $capdir; // $_POST['upload_folder']; $allowed_types = explode(' ', trim(strtolower(get_option('lg_fileupload_allowedtypes')))); if ($_POST['upload']) { $action = 'upload'; if (!is_writable($folder)) { $action = 'not-writable'; } switch ($action) { case 'not-writable': ?> <p><?php printf(__("It doesn't look like you can use the file upload feature at this time because the directory you have specified (<code>%s</code>) doesn't appear to be writable by WordPress. Check the permissions on the directory and for typos.", $lg_text_domain), $folder); ?> </p> <?php break; case 'upload': $imgalt = basename(isset($_POST['imgalt']) ? $_POST['imgalt'] : ''); $img1_name = strlen($imgalt) ? $imgalt : basename($_FILES['img1']['name']); $img1_name = preg_replace('/[^a-z0-9_.]/i', '', $img1_name); $img1_size = $_POST['img1_size'] ? intval($_POST['img1_size']) : intval($_FILES['img1']['size']); $img1_type = strlen($imgalt) ? $_POST['img1_type'] : $_FILES['img1']['type']; $pi = pathinfo($img1_name); $imgtype = strtolower($pi['extension']); if (in_array($imgtype, $allowed_types) == false) { die(sprintf(__('File %1$s of type %2$s is not allowed.', $lg_text_domain), $img1_name, $imgtype)); } if (strlen($imgalt)) { $pathtofile = $folder . $imgalt; $img1 = $_POST['img1']; } else { $pathtofile = $folder . $img1_name; $img1 = $_FILES['img1']['tmp_name']; } // makes sure not to upload duplicates, rename duplicates $i = 1; $pathtofile2 = $pathtofile; $tmppathtofile = $pathtofile2; $img2_name = $img1_name; while (file_exists($pathtofile2)) { $pos = strpos(strtolower($tmppathtofile), '.' . trim($imgtype)); $pathtofile_start = substr($tmppathtofile, 0, $pos); $pathtofile2 = $pathtofile_start . '_' . zeroise($i++, 2) . '.' . trim($imgtype); $img2_name = explode('/', $pathtofile2); $img2_name = $img2_name[count($img2_name) - 1]; } if (file_exists($pathtofile) && !strlen($imgalt)) { $i = explode(' ', get_option('lg_fileupload_allowedtypes')); $i = implode(', ', array_slice($i, 1, count($i) - 2)); $moved = move_uploaded_file($img1, $pathtofile2); if (!$moved) { $moved = copy($img1, $pathtofile2); } if (!$moved) { die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile2)); } else { chmod($pathtofile2, 0666); @unlink($img1); } // // duplicate-renaming function contributed by Gary Lawrence Murphy ?> <p><strong><?php __('Duplicate File?'); ?> </strong></p> <p><b><em><?php printf(__("The filename '%s' already exists!", $lg_text_domain), $img1_name); ?> </em></b></p> <p><?php printf(__("Filename '%1\$s' moved to '%2\$s'", $lg_text_domain), $img1, "{$pathtofile2} - {$img2_name}"); ?> </p> <p><?php _e('Confirm or rename:'); ?> </p> <form action="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo $capdir; ?> " method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_option('lg_fileupload_maxk') * 1024; ?> " /> <input type="hidden" name="img1_type" value="<?php echo $img1_type; ?> " /> <input type="hidden" name="img1_name" value="<?php echo $img2_name; ?> " /> <input type="hidden" name="img1_size" value="<?php echo $img1_size; ?> " /> <input type="hidden" name="img1" value="<?php echo $pathtofile2; ?> " /> <?php _e('Alternate name:'); ?> <br /><input type="text" name="imgalt" size="30" class="uploadform" value="<?php echo $img2_name; ?> " /><br /> <br /> <input type="submit" name="submit" value="<?php _e('Rename', $lg_text_domain); ?> " class="search" /> </form> <?php die; } if (!strlen($imgalt)) { @($moved = move_uploaded_file($img1, $pathtofile)); //Path to your images directory, chmod the dir to 777 // move_uploaded_file() can fail if open_basedir in PHP.INI doesn't // include your tmp directory. Try copy instead? if (!$moved) { $moved = copy($img1, $pathtofile); } // Still couldn't get it. Give up. if (!$moved) { die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile)); } else { chmod($pathtofile, 0666); @unlink($img1); } } else { rename($img1, $pathtofile) or die(sprintf(__("Couldn't upload your file to %s.", $lg_text_domain), $pathtofile)); } if (ereg('image/', $img1_type)) { $piece_of_code = "[[Image:" . $capdir . $img1_name . "]]"; } else { $piece_of_code = "<a href='" . $gallery_address . $capdir . $img1_name . "'>{$img1_name}</a>"; } $piece_of_code = htmlspecialchars($piece_of_code); ?> <div id="message" class="updated fade"><p><?php _e('File uploaded!', $lg_text_domain); ?> </p></div> <p><?php printf(__("Your file <code>%s</code> was uploaded successfully!", $lg_text_domain), $img1_name); ?> </p> <p><?php _e('Here’s the code to display it in your posts:', $lg_text_domain); ?> </p> <p><code><?php echo $piece_of_code; ?> </code></p> <p> <strong><?php _e('Image Details'); ?> </strong>: <br /> <?php _e('Name:'); ?> <?php echo $img1_name; ?> <br /> <?php _e('Size:'); ?> <?php echo round($img1_size / 1024, 2); ?> <?php _e('<abbr title="Kilobyte">KB</abbr>', $lg_text_domain); ?> <br /> <?php _e('Type:'); ?> <?php echo $img1_type; ?> </p> <p><a href="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo $capdir; ?> "><?php _e('Upload another'); ?> </a></p> <?php break; } } /* ================= * End of Upload div * ================= */ /* ==================== * Confirm deletion div * ==================== */ if (isset($_POST['yes'])) { $hirez_to_delete = $gallery_root . $act_current . $capdir . basename($_POST['delete_this']); $thumb_to_delete = $gallery_root . $act_current . $capdir . get_option('lg_thumb_folder') . basename($_POST['delete_this']); if (!is_dir($hirez_to_delete)) { if (@unlink($hirez_to_delete)) { @unlink($thumb_to_delete); echo '<div id="message" class="updated fade"><p>' . __('File deleted successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot delete file, maybe it has already been deleted or have wrong permissions', $lg_text_domain) . '</p></div>'; } } else { if (lg_remove_directory($_POST['delete_this'])) { echo '<div id="message" class="updated fade"><p>' . __('Folder deleted successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot delete folder: maybe it is already empty or have bad permissions', $lg_text_domain) . '</p></div>'; } } /* if (!is_dir($_POST['delete_this'])) { if(@unlink($_POST['delete_this'])) { echo '<div id="message" class="updated fade"><p>'. __('File deleted successfully', $lg_text_domain) .'</p></div>'; } else { echo '<div id="message" class="error fade"><p>'. __('Cannot delete file, maybe it has already been deleted or have wrong permissions', $lg_text_domain) .'</p></div>'; } } else { if(lg_remove_directory($_POST['delete_this'])) { echo '<div id="message" class="updated fade"><p>'. __('Folder deleted successfully', $lg_text_domain) .'</p></div>'; } else { echo '<div id="message" class="error fade"><p>'. __('Cannot delete folder: maybe it is already empty or have bad permissions', $lg_text_domain) .'</p></div>'; } } */ // Unsetting informations unset($_POST); unset($_GET); } if (isset($_POST['no'])) { echo '<div id="message" class="updated fade"><p>' . __('Nothing Changed', $lg_text_domain) . '</p></div>'; // Unsetting informations unset($_POST); unset($_GET); } /* ================= * file deletion div * ================= */ if (isset($_GET['file_to_delete']) && !isset($_POST['update_captions']) && !isset($_POST['upload']) && !isset($_POST['create_new_folder']) && !isset($_POST['rename_the_folder']) && !isset($_POST['yes']) && !isset($_POST['no'])) { ?> <div style="padding:10px;"> <div style="text-align:center;padding:0px;color:red;border:1px solid #ff0000;background:#ffdddd"> <?php _e('You are about to delete', $lg_text_domain); echo " <code>" . basename($_GET['file_to_delete']) . "</code><br />"; echo __('Are you sure?', $lg_text_domain) . "<br />"; ?> <form name="delete_image_file" method="post" action="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo $capdir; ?> " style="padding:5px;"> <div class="submit" style="text-align:center"> <input type="submit" name="yes" value="<?php _e('Yes', $lg_text_domain); ?> " style="width:80px;" /> <input type="submit" name="no" value="<?php _e('No', $lg_text_domain); ?> " style="width:80px;" /> <input type="hidden" name="folder" value="<?php echo $_POST['folder']; ?> " /> <input type="hidden" name="delete_this" value="<?php echo $_GET['file_to_delete']; ?> " /> </div> </form> <?php echo "</div>\n</div>"; } /* ================= * Rename folder div * ================= */ if (isset($_POST['rename_the_folder'])) { if (strlen($_POST['new_file_name']) > 0) { $oldname = $_POST['actual_folder']; $newname = $gallery_root . $_POST['new_file_name']; if (lg_rename_file($oldname, $newname)) { echo '<div id="message" class="updated fade"><p>' . __('Renamed successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot rename.', $lg_text_domain) . '</p></div>'; } } else { echo '<div id="message" class="error fade"><p>' . __('Provide a new name.', $lg_text_domain) . '</p></div>'; } unset($_POST); unset($_GET); } /* ======================= * New folder creation div * ======================= */ if (isset($_POST['create_new_folder'])) { if (strlen($_POST['new_folder_name']) > 0) { $folder_name = $_POST['actual_folder'] . $_POST['new_folder_name']; $new_folder_path = $gallery_root . $folder_name; if (lg_make_directory($new_folder_path)) { echo '<div id="message" class="updated fade"><p>' . __('Folder created successfully', $lg_text_domain) . '</p></div>'; } else { echo '<div id="message" class="error fade"><p>' . __('Cannot create folder: maybe it already exists or have bad permissions', $lg_text_domain) . '</p></div>'; } } else { echo '<div id="message" class="error fade"><p>' . __('Cannot create an empty named folder.', $lg_text_domain) . '</p></div>'; } unset($_POST); unset($_GET); } $imgfiles = get_imgfiles($capdir); $act_current = $capdir; // Provide eventual icons to the image array if (file_exists($gallery_root . $capdir . substr($capdir, 0, strlen($capdir) - 1) . ".jpg")) { $capdir_icon = substr($capdir, 0, strlen($capdir) - 1) . ".jpg"; $imgfiles[] = $capdir_icon; } else { if (file_exists($gallery_root . $capdir . substr($capdir, 0, strlen($capdir) - 1) . ".jpeg")) { $capdir_icon = substr($capdir, 0, strlen($capdir) - 1) . ".jpeg"; $imgfiles[] = $capdir_icon; } else { if (file_exists($gallery_root . $capdir . substr($capdir, 0, strlen($capdir) - 1) . ".png")) { $capdir_icon = substr($capdir, 0, strlen($capdir) - 1) . ".png"; $imgfiles[] = $capdir_icon; } else { if (file_exists($gallery_root . $capdir . substr($capdir, 0, strlen($capdir) - 1) . ".gif")) { $capdir_icon = substr($capdir, 0, strlen($capdir) - 1) . ".gif"; $imgfiles[] = $capdir_icon; } } } } /* ========= * Main Page * ========= */ echo '<h2>' . __('Подписать и отправить на сайт', $lg_text_domain) . '</h2>'; if (strlen($capdir) > 0) { ?> <fieldset class="options"> <h3><?php echo sprintf(__('Список картинок в папке %s', $lg_text_domain), $act_current); ?> </h3> <!-- Shortcuts--> <div style="padding:5px;display:block;background:#efefef;border:1px solid #ccc;height:20px;"> <a href="<?php echo AL_FLM_PAGE; ?> ">« <?php _e('Назад к списку папок', $lg_text_domain); ?> </a> </div> <!-- End of Shortcuts--> <br /> <!-- Tip div --> <!-- <div style="padding:5px;border:1px solid #3fbd3f;background:#beffbe;color:#088000;"> <?php _e('You can use HTML links but be sure to use "[" and "]" instead of "<" and ">"; something like [a href="somewhere"]Link[/a]', $lg_text_domain); ?> </div> --> <!-- End of tip div --> <form name="gallery_captions" method="post" action="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo $capdir; ?> "> <input type="hidden" name="folder" value="<?php echo $act_current; ?> "/> <table summary="thumbs" cellspacing="1" cellpadding="10"> <!-- End of Folder Caption code --> <?php if (isset($imgfiles)) { foreach ($imgfiles as $img) { // clean_image_caption() function is in lazyest-gallery.php file // and checks if xml file exists, if not it returns false // we need a "clean" (with "<" and ">") caption $caption = clean_image_caption($img, $capdir); // this will removes HTML tags and used as title argument $title = ereg_replace("<[^>]*>", "", $caption); $righturl = str_replace(" ", "%20", $act_current . $img); echo '<tr><td><a href="' . $gallery_uri . 'file=' . $righturl . '">'; // If thumbs cache system is enabled if (get_option('lg_enable_cache') == "TRUE") { // we check if thumbs exist if (!file_exists($gallery_root . $act_current . get_option('lg_thumb_folder') . $img)) { // keeping track of subfolders $img_file_path = explode('/', $img); $img_index = count($img_file_path) - 1; $img_file = $img_file_path[$img_index]; // If there are subfolders if ($img_index > 1) { for ($i = 1; $i < count($img_file_path) - 1; $i++) { // set the new "current" directory $act_current .= $img_file_path[$i] . "/"; } } // if thumbs do not exist we create them createCache($act_current, $img, true); } // trimming spaces (XHTML Urls) $righturl = str_replace(" ", "%20", $gallery_address . $act_current . get_option('lg_thumb_folder') . $img); echo '<img src="' . $righturl . '" alt="' . $img . '" title="' . $title . '" />'; echo '<br />» ' . $img; $size = getimagesize($gallery_root . $act_current . $img); echo '<br />' . $size[0] . "x" . $size[1] . " px"; ?> <br /><br /><a href="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo str_replace(" ", "%20", $act_current); ?> &file_to_delete=<?php echo $righturl; ?> " class="button" style="width:50px;display:block;"><?php _e('Delete', $lg_text_domain); ?> </a> <?php } else { // otherwise $righturl = str_replace(" ", "%20", get_option('siteurl') . "/wp-content/plugins/lazyest-gallery/" . basename(__FILE__) . ".php?file=" . $act_current . $img . "&thumb=1"); echo "<img src='" . $righturl . "' alt='" . $img . "' title='" . $title . "' />"; } // this time we need a "rebuilded" (with "" and "") caption $caption = clean_image_caption($img, $capdir, false); // this is a dynamic form name construct that we need for the captions system $form_name = str_replace('.', '_', $img); $form_name = str_replace(' ', '_', $form_name); echo '</a></td>'; echo '<td align=right>'; $righturl = str_replace(" ", "%20", $gallery_root . $act_current . $img); // Inputs ?> <form id="ImageUploadToDB" method="post" action="<?php echo AL_FLM_PAGE; ?> &captions=<?php echo $capdir; ?> "> Название: <input type="text" name="img_title" style="width:95%;"><br /> Описание: <textarea name="img_description" rows="3" cols="20" style="width:95%;"></textarea><br /> Ключевые слова:<input type="text" name="img_tags" style="width:95%;"><br /> Категория: <?php echo topcategorylist(0); ?> <br /> <!-- categ<input type="hidden" name="category" value="3" /> --> <input type="submit" name="submit" value="Сохранить"> <input type="hidden" name="artist_id" value="<?php echo get_artist_id_by_folder_name(); ?> " /> <input type="hidden" name="img_path" value="<?php echo $gallery_root . $act_current . $img; ?> " /> <br /> </form> <?php } } ?> </table> <!-- <div class="submit"> <input type="hidden" name="directory" value="<?php echo $act_current; ?> " /> <input type="submit" name="update_captions" value="<?php _e('Update Folder', $lg_text_domain); ?> " /> </div> --> </form> </fieldset> <!-- Upload section --> <!-- <fieldset class="dbx-box"> <h3 class="dbx-handle"><?php _e('Upload Image', $lg_text_domain); ?> </h3> <div class="dbx-content"> <?php upload_page($act_current); ?> </div><br /><br /> </fieldset> --> <?php } // Closes the main page if ?> <!-- Gallery structure section --> <fieldset class="dbx-box"> <h3 class="dbx-handle"><?php _e('Список папок с картинками', $lg_text_domain); ?> </h3> <div class="dbx-content"> <?php al_show_gallery_structure(); ?> </div> </fieldset> </div> <?php }
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’ 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 . '&'; } $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">' . __('« Prev', $lg_text_domain) . '</a> <a href="' . $gallery_uri . 'file=' . $currdir . $next . '" class="alignright">' . __('Next »', $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 . "&captions=" . $currdir . "'>"; echo "» " . __('Write a caption for ', $lg_text_domain) . $slide; echo "</a>"; echo "</div>"; } } } } }
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 . '&'; } $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" /> » ' . __("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' . '&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' . '&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' . '&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' . '&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 . '&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 '» ' . $folder_caption . '</a> (F)</td>'; } else { echo '» ' . $dir . '</a> (F)</td>'; } } else { // "#" if there are images instead if (get_option('lg_use_folder_captions') == "TRUE" && strlen($folder_caption) != 0) { echo '» ' . $folder_caption . '</a> (' . sizeof($imgfiles) . ')</td>'; } else { echo '» ' . $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"; } } }
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 . '&'; } // 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' . '&thumb=1" alt="" class="icon" />» ' . $folder_caption . "\n"; } else { echo '<img src="' . $gallery_address . $currentdir . $category . '.png" alt="' . $category . '" class="icon"/> » ' . $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' . '&thumb=1" alt="" class="icon" />» ' . $folder_caption . "\n"; } else { echo '<img src="' . $gallery_address . $currentdir . $category . '.jpg" alt="' . $category . '" class="icon"/> » ' . $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' . '&thumb=1" alt="" class="icon" />» ' . $folder_caption . "\n"; } else { echo '<img src="' . $gallery_address . $currentdir . $category . '.jpeg" alt="' . $category . '" class="icon"/> » ' . $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' . '&thumb=1" alt="" class="icon" />» ' . $folder_caption . "\n"; } else { echo '<img src="' . $gallery_address . $currentdir . $category . '.gif" alt="' . $category . '" class="icon"/> » ' . $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 . '&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 . '&offset=' . ($offset - $thumbs_page) . '" title="previous">' . __('« 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 . '&offset=' . ($i - 1) * $thumbs_page . '" >' . $i . '</a> '; } else { echo " {$i} "; } } } if (count($imgfiles) > $thumbs_page + $offset) { echo ' <a href="' . $gallery_uri . 'file=' . $currdir . '&offset=' . $end . '" title="next">' . __('Next »', $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 . "&captions=" . $currdir . "'>"; echo "» "; _e("Write captions for images in ", $lg_text_domain); echo " " . substr($currentdir, 0, strlen($currentdir) - 1); echo "</a>"; echo "</div>"; } } } } }