picture-gallery-generaten-uit-map

Gesponsorde koppelingen

PHP script bestanden

  1. picture-gallery-generaten-uit-map

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
error_reporting(E_ALL) ;

$dirname= "." ;
$page_limit = 12 ;

function
check_file($filename,$extensionlist)
{

    $file_array = explode(".",$filename) ;
    if (count($file_array) > 2)
    {

        return false ;
    }

    else
    {
        $extension = $file_array[1] ;
        if (in_array($extension,$extensionlist))
        {

            return true ;
        }

        else
        {
            return false;
        }
    }
}


function
get_file_array($dir)
{

    $img_extensions = array("jpeg","jpg","gif","tiff","bmp") ;
    $file_array = array() ;
    if($handle = opendir($dir)) {
     while(false !== ($file = readdir($handle))){
      if(check_file($file,$img_extensions)){
       //Het is een plaatje, laat hem zien...
        $file_array[] = $file ;
       }
      }

     closedir($handle);
    }

    return $file_array;
}

function
showImages($image_array,$begin = false, $eind = false)
{

    $begin_check = $begin ;    
    $return = "<tr>" ;
    if ($begin+12 > count($image_array))
    {

        $eind = count($image_array)-1 ;
    }

    
    while ($begin <= $eind)
    {

        if ($begin%3 == 0 && $begin != $begin_check)    
        {

            $return .= "</tr><tr>" ;
        }

        $return .= "<td><img src=".$image_array[$begin]." width='100'></td>";
        $begin++ ;
    }

    return $return."</tr>" ;
}

function
genPages($number_of_files,$page_limit)
{

    $pages = $number_of_files/$page_limit ;
    $pages++ ;
    $i = 1 ;
    $return = "<table><tr>" ;
    while ($i <= $pages)
    {

        $return .= "<td><a href=?page=".$i.">".$i."</td>" ;
        $i++ ;
    }

    $return .= "</tr></table>" ;
    return $return ;
}


echo "<table>" ;

$file_list = get_file_array($dirname) ;
$page_limit-- ;
if (count($file_list) > $page_limit)
{

    if(!isset($_GET["page"]))
    {

        $page = 1 ;
    }

    else
    {
        $page = $_GET["page"] ;
    }

    $begin = ($page * 12) - 12 ;
    $eind = $page * 12 ;
    $display = showImages($file_list,$begin,$eind) ;
}

else
{
    $display = showImages($file_list,0,count($file_list)-1) ;
}

echo "<html>
<body>"
;
echo $display ;
echo "</table>";
if (count($file_list) > $page_limit)
{

    echo genPages(count($file_list),$page_limit) ;
}

echo "
</body>
</html>"
;
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.