[php]» alle plaatjes uit dir lezen?

Pagina: 1
Acties:

  • CdRwin
  • Registratie: Juni 2001
  • Laatst online: 27-09-2024
Ik ben nieuw met php, en ben bezig met site in (html.
Ik wil daarin een pagina maken waar ik alle foto's in zet. Maar nu zou het natuurlijk fijn zijn als je met php een dir kan uitlezen waar alle plaatjes in staan en ze dan automatisch op de html pagina zetten. Zodat ik alleen maar het plaatje in de dir hoef te uppen, en dat het dan automatisch erbij op de pagina staat.

Heeft iemand zo'n scripie toevallig liggen of kan iemand dat zelf snel in elkaar flansen?

Je zou me er enorm mee helpen.
---------------------------------
Ok ik heb nu een script gevonden, maar wie kan dat script een beetje opschonen? Want dit zou toch korter kunnen??
PHP:
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?
 



require("photogallery-config.php");

if (! $included )
{
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
    echo "<HTML><HEAD><TITLE>Photogallery</TITLE></HEAD><BODY>\n";
}

if (! $number)
    $number = $defnumber;

if (! $pagenum)
    $pagenum = 1;


/* Some helper functions */

function get_pictinfo($picture)
{
    global $infofile;
    # Read the infofile

    $fp=fopen($infofile,"r");
    $contents=fread($fp, filesize($infofile));
    fclose($fp);
    $start = strpos($contents,$picture) + strlen($picture);
    $tmpstr = substr($contents,$start,strlen($contents));
    $stop = strpos($tmpstr, "\n");
    $pictinfo = substr($contents,$start,$stop);

    return $pictinfo;
}

function num2picture($num)
{
    global $thumbdir;
    $othumbdir = dir($thumbdir);
    for($count=0; $count<=($num+1); $count++)
    {
        $entry=$othumbdir->read();
    }
    
    $othumbdir->close;
    return $entry;
}

function picture2num($picture)
{
    global $thumbdir;
    $count = 0;
    
    $othumbdir = dir($thumbdir);

    while($entry=$othumbdir->read())
    {
        $count++;
        if($entry == $picture)
            break;
    }
    $othumbdir->close;
    return $count - 2;
}

/* -- Gallery function ---------------------------------------------------- */

function thumbnails() 
{
    global  $number, $pagenum, $languages, $thumbdir, $imgdir, $othumbdir, $oimgdir, 
                    $thisfile, $help, $backtogallery, $header, $lang, $tablestart,
                    $lines_in_row, $pagestr, $included;

    # Define the next and previous pages
    $prev  = $pagenum - 1;
    $next  = $pagenum + 1;

    # Pages start with 0, but we start with 1 so substract 1
//    $pagenum--;

    # Define when a new page starts
    $start = ($pagenum - 1) * $number + 1;
    $stop = $start + $number;
    
// echo "DEBUG: number: $number, start: $start, stop: $stop\n total: " . ($stop - $start) . "\n";

    
    # Loop through all the images in the directory
    while($entry=$othumbdir->read())
    {
        $total++;

        if(is_file("$thumbdir/$entry"))
        {
            $count = picture2num($entry);
            /*
            echo " DEBUG: count: $count start: $start, stop: $stop, tulos: " . 
                    ($count < $stop &amp;&amp; $count >= $start) . "\n";
            */
            if($count < $stop &amp;&amp; $count >= $start)
            {
                $newline = $count - $start;
                $countloop++;

                if ($newline == 0 || $countloop == $lines_in_row)
                {
                    $countloop=0;
                    if ($newline < ($lines_in_row - 1)) 
                    {
                        echo "$tablestart\n";
                    }
                    else
                    {
                        echo "</TR><TR>\n";
                    }
                }
        
                echo "<TD><P ALIGN=\"center\">";
                echo "<B>$count. </B><SMALL>" . get_pictinfo($entry) . "</SMALL><BR>";
                if(is_file("$imgdir/$entry"))
                {
                    echo "<A HREF=\"" . $thisfile . "?action=full&amp;picture=$entry&amp;lang=$lang\">" . 
                        "[img]\"$thumbdir/$entry\"></A>";
[/img]</TD>\n";
                }
                else
                {
                    echo "[img]\"$thumbdir/$entry\">";
[/img]</TD>\n";
                }
                $count++;
            }
        }
    }

    echo "</TD></TR></TABLE>\n";

    $gallery_prev  = "<A HREF=\"$thisfile?action=gallery&amp;pagenum=$prev&amp;number=$number&amp;lang=$lang\">" .
                                            "[&amp;lt;&amp;lt;]</A>";
    $gallery_next  = "<A HREF=\"$thisfile?action=gallery&amp;pagenum=$next&amp;number=$number&amp;lang=$lang\">" .
                                            "[&amp;gt;&amp;gt;]</A>";
    
    $totalpages = ceil(($total - 2) / $number); // -2 = we don't count "." and ".."
    $gallery_pages = 1;

    while ( $totalpages >= $gallery_pages )
    {
        if ($gallery_pages == $pagenum)
            $gallery_number = "$gallery_number$gallery_pages&amp;nbsp;&amp;nbsp;\n";
        else
            $gallery_number = "$gallery_number<A HREF=\"$thisfile?action=gallery&amp;pagenum=" 
                . "$gallery_pages&amp;number=$number&amp;lang=$lang\">$gallery_pages</A>&amp;nbsp;&amp;nbsp;\n";
        $gallery_pages++;
    }

    if ( $pagenum == 1 )
    {
        $gallery_prev = "[&amp;lt;&amp;lt;]";
    }

    if ( $pagenum == $totalpages )
    {
        $gallery_next = "[&amp;gt;&amp;gt;]";
    }

    echo "\n<P>\n\n";
    echo "$gallery_prev\n&amp;nbsp;&amp;nbsp;&amp;nbsp;\n\n";
    echo "<B>" . $pagestr[$lang] . ":</B>\n\n&amp;nbsp;$gallery_number\n";
    echo "&amp;nbsp;&amp;nbsp;&amp;nbsp;\n$gallery_next\n"; 

}

/* -- Show full size picture -------------------------------------- */

function fullsize() 
{

    global $picture, $infofile, $languages, $thumbdir, $imgdir, $othumbdir, 
                    $oimgdir, $thisfile, $help, $backtogallery, $lang, 
                    $tablestart,$number, $included;
    
    # Find previous and next
    $current = picture2num($picture);

    $count = picture2num("dontfindme.xyz") - 2 ;

    $prev = num2picture($current - 1);
    $next = num2picture($current + 1);


    $pagenum = ceil($current / $number);

    echo "<CENTER><H1><B>$current.</B> " . get_pictinfo($picture) . "</H1>";

    $thumb_prev  = "<A HREF=\"$thisfile?action=full&amp;picture=$prev&amp;lang=$lang\">" . 
                                        "[&amp;lt;&amp;lt;]</a>&amp;nbsp;&amp;nbsp;&amp;nbsp;";
    $thumb_index = "<A HREF=\"$thisfile?action=gallery&amp;number=$number&amp;pagenum=$pagenum&amp;lang=$lang\">"
                                 . "<B>" . $backtogallery[$lang] .  "</B></A>";
    $thumb_next  =  "&amp;nbsp;&amp;nbsp;&amp;nbsp;<A HREF=\" $thisfile?action=full&amp;picture=$next&amp;lang=$lang\">" 
                                 .    "[&amp;gt;&amp;gt;]</A>";
        
    if ($current == 1)
    {
        $thumb_prev = "[&amp;lt;&amp;lt;]&amp;nbsp;&amp;nbsp;&amp;nbsp;";
    }

    if ($next == "")
    {
        $thumb_next = "&amp;nbsp;&amp;nbsp&amp;nbsp;[&amp;gt;&amp;gt;]";
    }
        
    $browsestr = "$thumb_prev $thumb_index $thumb_next";
        
    echo "<P>$browsestr<BR><BR>\n";
    echo "[img]\"$imgdir/$picture\"><BR>\n";
[/img]$browsestr\n";

}

/* -- Switches ------------------------------------------------------------ */

function gallery()
{
    global $version, $action, $oimgdir, $othumbdir, $imgdir, $thumbdir;
    $othumbdir    = dir($thumbdir);
    $oimgdir    = dir($imgdir);
    switch($action) 
    {
        case "gallery" :
            thumbnails();
            break;
        case "full" :
            fullsize();
            break;
        default :
            thumbnails();
            break;
    }
    
    $othumbdir->close();
    $oimgdir->close();
}

if(! $included)
{    
    gallery();
    echo "</BODY></HTML>";
}
?>

www.Qbox.nl


  • me1299
  • Registratie: Maart 2000
  • Laatst online: 19:37

me1299

$ondertitel

Ben je hondje niet >:)

ga maar naar www.hotscripts.com om een betere te zoeken

Het maakt eigenlijk niet uit wat je bewuste geest doet, omdat je onderbewuste automatisch precies dat doet wat het moet doen


  • Annie
  • Registratie: Juni 1999
  • Laatst online: 25-11-2021

Annie

amateur megalomaan

Heb je toevallig al in de manual gekeken? Daar staat precies wat je nodig hebt.
Kijk ook de usernotes effe door voor wat extra opties.

Today's subliminal thought is:


Verwijderd

Stinkt een beetje naar een script request...

  • RdeTuinman
  • Registratie: Mei 2001
  • Laatst online: 16-08 07:25
Op maandag 12 november 2001 09:23 schreef Tranqi het volgende:
Stinkt een beetje naar een script request...
Een beetje? t'Is een typisch geval van...

Deze gaat binnenkort dicht >:)

  • CdRwin
  • Registratie: Juni 2001
  • Laatst online: 27-09-2024
Laatmaar ik heb een een oplossing gevonden. Dus laat de stank maar weer weg trekken |:(

www.Qbox.nl

Pagina: 1