Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $imagetypes = array("image/jpeg");
- function getImages($folder) {
- $images = array();
- $directory = dir($folder);
- while(($entry = $directory->read()) !== false) {
- if($entry == '.' || $entry == '..' || !strstr($entry, '.')) {
- continue;
- }
- $images[] = $entry;
- }
- return $images;
- }
- if(isset($_GET['p'])) {
- $pagination_start = intval($_GET['p']);
- } else {
- $pagination_start = 0;
- }
- $images_per_page = 20;
- $path = "tattoos";
- $docroot = "$path";
- $images = getImages($path);
- $images_start = $pagination_start * $images_per_page;
- $images_end = $images_start + $images_per_page;
- $pages_total = ceil(count($images) / $images_per_page);
- for($i = $images_start; $i < $images_end; $i++) {
- $image = $images[$i];
- echo "<a href='{$path}/{$image}'>";
- $filename = explode('.', $image);
- echo "<img src='{$path}/{$filename[0]}th.{$filename[1]}'>";
- echo "</a>\n";
- }
- echo "<div class=\"pagination\"><ul>";
- for($i = 0; $i < $pages_total; $i++) {
- $j = $i + 1;
- echo "<li><a href='index.php?page=gallery&gallery=tattoos&p={$i}'>{$j}</a></li>";
- }
- echo "</ul></div>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement