SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | $imagetypes = array("image/jpeg"); | |
3 | ||
4 | function getImages($folder) { | |
5 | $images = array(); | |
6 | $directory = dir($folder); | |
7 | while(($entry = $directory->read()) !== false) { | |
8 | if($entry == '.' || $entry == '..' || !strstr($entry, '.')) { | |
9 | continue; | |
10 | } | |
11 | $images[] = $entry; | |
12 | } | |
13 | return $images; | |
14 | } | |
15 | ||
16 | if(isset($_GET['p'])) { | |
17 | $pagination_start = intval($_GET['p']); | |
18 | } else { | |
19 | $pagination_start = 0; | |
20 | } | |
21 | ||
22 | $images_per_page = 20; | |
23 | $path = "tattoos"; | |
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++) { |
40 | + | for($i = 0; $i < $pages_total; $i++) { |
41 | - | echo "<li><a href='index.php?page=gallery&gallery=tattoos&p={$i}'>{$i}</a></li>"; |
41 | + | $j = $i + 1; |
42 | echo "<li><a href='index.php?page=gallery&gallery=tattoos&p={$i}'>{$j}</a></li>"; | |
43 | } | |
44 | echo "</ul>"; | |
45 | ||
46 | ?> |