<?php echo '<ul id="navtree">'; echo '<li><h2>Choose gallery:</h2></li>'; $dir = directory('galleries', 'all'); foreach ($dir as $d) { if (preg_match('/^\\.{1,2}/', $d)) { continue; } if (is_dir('galleries/' . $d)) { $imgs = directory('galleries/' . $d, 'jpg,JPG,jpeg,JPEG,jpe,JPE'); if ($cd == '') { $cd = $d; } if ($d == $cd) { $curimgs = $imgs; } $imgs = ditchtn($imgs); echo '<li>'; if ($d == $cd) { echo '<strong><a href="' . $self . '?cd=' . $d . '">' . ucwords($d) . ' (' . sizeof($imgs) . ')</a></strong>'; } else { echo '<a href="' . $self . '?cd=' . $d . '">' . ucwords($d) . ' (' . sizeof($imgs) . ')</a>'; } echo '</li>'; } } echo '</ul>';
<?php if ($_GET["folder"] && (substr($_GET["folder"], 0, 1) == "." || preg_match("/.+\\.\\..+/", $_GET["folder"]))) { echo "no no no."; return; } $imagefolder = $_SERVER["DOCUMENT_ROOT"] . "/images/" . $_GET["folder"]; $thumbsfolder = $_SERVER["DOCUMENT_ROOT"] . "/thumbs/" . $_GET["folder"]; $pics = directory($imagefolder, "jpg,JPG,JPEG,jpeg,png,PNG,gif,GIF"); $pics = ditchtn($pics, "tn_"); if (!file_exists($thumbsfolder)) { mkdir($thumbsfolder); } if ($pics[0] != "") { foreach ($pics as $p) { createthumb($p, "tn_" . $p, 150, 150); } } /* Function ditchtn($arr,$thumbname) filters out thumbnails */ function ditchtn($arr, $thumbname) { foreach ($arr as $item) { if (!preg_match("/^" . $thumbname . "/", $item)) { $tmparr[] = $item; } } return $tmparr; }
<?php $cd = is_dir('galleries/' . $_GET['cd']) ? $_GET['cd'] : ''; $p = file_exists('galleries/' . $cd . '/' . $_GET['p']) ? $_GET['p'] : ''; $start = preg_match('/\\d+/', $_GET['s']) ? $_GET['s'] : 0; $chunksize = 10; $name = 'gallerytools.php'; $allimgs = directory('galleries/' . $cd, 'JPG,jpg,JPEG,jpeg,jpe,JPE'); $temp = ditchtn($allimgs); if ($cd != '' && $p == '') { $imgs = array_slice($temp, $start, $chunksize); echo '<ul id="thumbs">'; foreach ($imgs as $c) { echo '<li><a href="' . $name . '?cd=' . $cd . '&p=' . preg_replace('/^tn_/', '', $c) . '&s=' . $start . '">' . '<img src="galleries/' . $cd . '/' . $c . '" alt="' . $c . '" /></a></li>'; } echo '</ul>'; echo '<ul id="thumbsnav">'; if ($cd != '') { if ($start - $chunksize >= 0) { echo '<li><a href="' . $name . '?cd=' . $cd . '&s=' . ($start - $chunksize) . '" class="prev">previous</a></li>'; } echo '<li>Showing ' . ($start + 1) . ' to ' . ($start + 10 < sizeof($temp) ? $start + 10 : sizeof($temp)) . ' of ' . sizeof($temp) . '</li>'; if ($start + $chunksize <= sizeof($temp)) { echo '<li><a href="' . $name . '?cd=' . $cd . '&s=' . ($start + $chunksize) . '" class="next">next</a></li>'; } } echo '</ul>'; } if ($p != '') { $count = 0; foreach ($temp as $key => $c) {