View difference between Paste ID: GD7Uzuwr and wtgc8N7C
SHOW: | | - or go back to the newest paste.
1-
<?
1+
<?php
2-
    $imagetypes = array("image/jpeg"); 
2+
$imagetypes = array("image/jpeg");
3
4-
    function getImages($folder) {
4+
function getImages($folder) {
5-
            $images = array();
5+
        $images = array();
6-
            $directory = dir($folder);
6+
        $directory = dir($folder);
7-
            while(($entry = $directory->read()) !== false) {
7+
        while(($entry = $directory->read()) !== false) {
8-
                    if($entry == '.' || $entry == '..' || !strstr($entry, '.')) {
8+
                if($entry == '.' || $entry == '..' || !strstr($entry, '.')) {
9-
                            continue;
9+
                        continue;
10-
                    }
10+
                }
11-
                    $images[] = $entry;
11+
                $images[] = $entry;
12-
            }
12+
        }
13-
            return $images;
13+
        return $images;
14-
    }
14+
}
15-
    
15+
16-
    $path = "tattoos";
16+
if(isset($_GET['p'])) {
17-
    $docroot = "$path"; 
17+
    $pagination_start = intval($_GET['p']);
18
} else {
19-
    $images = getImages($path);
19+
    $pagination_start = 0;
20-
    foreach($images as $image) {
20+
}
21-
        echo "<a href='{$path}/{$image}'>";
21+
22-
        $filename = explode('.', $image);
22+
$images_per_page = 20;
23-
        echo "<img class='photo' src='{$path}/{$filename[0]}th.{$filename[1]}'>";
23+
$path = "tattoos";
24-
        echo "</a>\n";    }
24+
$docroot = "$path";
25
26
$images = getImages($path);
27
$images_start = $pagination_start * $images_per_page;
28
$images_end = $images_start + $images_per_page;
29
$pages_total = ceil(count($images) / $images_per_page);
30
31
for($i = $images_start; $i < $images_end; $i++) {
32
    $image = $images[$i];
33
    echo "<a href='{$path}/{$image}'>";
34
    $filename = explode('.', $image);
35
    echo "<img class='photo' src='{$path}/{$filename[0]}th.{$filename[1]}'>";
36
    echo "</a>\n";    
37
}
38
39
echo "<ul>";
40
for($i = 1; $i <= $pages_total; $i++) {
41
    echo "<li><a href='index.php?page=gallery&gallery=tattoos&p={$i}'>{$i}</a></li>";
42
}
43
echo "</ul>";
44
 
45
?>