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