2 vraagjes over bestaande gallery

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Amanda

Amanda

11/05/2004 16:09:00
Quote Anchor link
ik heb het script hier gebruikt van ik geloof bas en het werkt prima alleen wil ik er twee dingen op uitbreiden als dat kan.

- ik wil graag maar 12 thumbs per pagina en de rest op een nieuwe pagina, hoe doe ik dit?
- ik wil graag de fotos op volgorde getoond hebben, dit moet in een array dat weet ik maar ik kom er niet uit.

dit is het script.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>|| Fotoalbums ||</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="system/main.css" type="text/css" rel="stylesheet">
</head>

<style>
body {
background-image: url(../logo.jpg);
background-repeat: no-repeat;
background-position: center top;
}
</style>
<body>
<a href="../intro.php">Home</a><br><br>

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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?


Function Numdirs($dir)
{

    
    if(!$dir)
        $dir = ".";
        
    $handle = opendir($dir);    
    while($file = readdir($handle))
    {

        if(is_dir("$dir/$file") && $file != "thumbs" && $file != "." && $file != ".." && $file != "system")
            $numdirs++;
    }

    return $numdirs;
}

Function
NumPics($dir)
{

    $handle = opendir($dir);    
    while($file = readdir($handle))
    {

        $filetype = substr($file,-3,3);
        if ($filetype == "jpg" || $filetype == "JPG" )
            $numpics++;    
    }

    return $numpics;
}

function
ThumbAvail($file)
{

    $fp = popen("./jhead -st - '$file' 2>&1", "r");
    while (!feof($fp)) {
              $buf .= fread($fp, 1024);
       }

        
       if(strstr($buf,"thumbnail"))
           return 0;
       else
           return 1;    
}  

Function
ImgSize($file)          
{

    $fp = popen("./jhead '$file' 2>&1", "r");
    while (!feof($fp)) {
              $buf .= fread($fp, 1024);
       }

        
       //Resolution : 1536 x 2048
       eregi("Resolution.* ([0-9]{1,}) x ([0-9]{1,})[^0-9]",$buf, $res);

    $res[0] = trim(substr($res[0],12));
        
       return $res;
}

Function
GetNextName($name)
{

    
    if(file_exists($name))
    {

        $handle = opendir('.');    
        while($file = readdir($handle))
        {
    
            
            $filetype = substr($file,-3,3);
            
            if ($filetype == "jpg" || $filetype == "JPG" )
                {

                if($stop)
                    return($file);
                            
                if($file == $name)
                    $stop = 1;
            }    
        
        }
    }
        
}

Function
GetPrevName($name)
{

    
    if(file_exists($name))
    {

        $handle = opendir('.');    
        while($file = readdir($handle))
        {
    
            
            $filetype = substr($file,-3,3);
            
            if ($filetype == "jpg" || $filetype == "JPG" )
                {

                if($file == $name)
                    return($oudefile);    
                else    
                    $oudefile = $file;    
            }
        }    
    }    
    
}


Function
CreateThumb($file)
{

    
    if(!is_dir("thumbs"))
    {

        $res = @mkdir("thumbs",0777);
        
        if(!$res)
        {

            echo "Geen rechten om thumbnails aan te maken.";
            exit();
        }

        else
            chmod("thumbs",0777);
    }

    
    //set_time_limit (30);
    
    $imagehw = GetImageSize("$file");
    $src_width = $imagehw[0];  
    $src_height = $imagehw[1];
            
    // orrigineel
    //$src_width > $src_height ? $dest_width = 100 : $dest_width = 75;

    $src_width > $src_height ? $dest_width = 75 : $dest_width = 50;
    
    $tmp = $src_width / $dest_width;
    $dest_height = $src_height / $tmp;
        
    $src_img = imagecreatefromjpeg("$file");
    $dst_img = imagecreatetruecolor($dest_width,$dest_height);
    
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,    $dest_height, $src_width, $src_height);
    imagejpeg($dst_img, "thumbs/$file", 75);
    imagedestroy($src_img);
    imagedestroy($dst_img);

    
    
    
}


if($dir == "")
    $dir = ".";
chdir($dir);

    
if($show == "")
{
    
    if($dir == ".")
        $showdir = "";
    elseif(substr($dir,0,2) == "./")
        $showdir = substr($dir,2,strlen($dir));
    else
        $showdir = $dir;    

         echo "<table border=0 cellpadding=3 cellspacing=0 width=80% align=center>\n\n";
    if($showdir != "")
    {

        $lastslash = strrpos($dir,"/");
        $tmpdir = substr($dir,0,$lastslash);
        $back = "<a href=\"$PHP_SELF?dir=$tmpdir\">Terug naar de albums</a>";
    }

         
    echo    "<tr><td align=right>$back</td></tr>";
    echo "<tr class=row0><td align=center>$showdir</td></tr>";
    echo "</table>";    
    
    
    $numdirs = NumDirs("");
    if($numdirs)
    {
    
        //Eventuele dirs laten zien
        echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 width=80% align=center>\n\n";
        echo "<tr class=row0><td colspan=3>Albums</td></tr>\n";
        
        
        $handle = opendir('.');    
        while($file = readdir($handle))
        {

            $bgclass == "row1" ? $bgclass = "row2" : $bgclass = "row1";
            if(is_dir($file) && $file != "thumbs" && $file != "." && $file != ".." && $file != "system")
            {

                $numpics = Numpics($file);
                $numdirs = Numdirs($file);
                
                $shownumpics = "";
                if($numpics)
                    $numpics == 1 ? $shownumpics = "1 foto" : $shownumpics = "$numpics foto's";
                
                $shownumdirs = "";
                if($numdirs)
                    $numdirs == 1 ? $shownumdirs = "1 subcategorie" : $shownumdirs = "$numdirs subcategorieen";    
                    
                echo "<tr class=$bgclass><td align=center width=60><a href=\"$PHP_SELF?dir=$dir/$file\"><img src=system/arrow.gif border=0></a></td><td><a href=\"$PHP_SELF?dir=$dir/$file\">$file</a></td><td width=100 align=center>$shownumpics$numdiv $shownumdirs</td></tr>\n";    
            }
        
        }

        
        echo "</table>";
    }
    
    
    
    $numpics = NumPics(".");
        
    if($numpics)
    {

        //Losse Foto's laten zien
        echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 width=80% align=center>\n\n";
        echo "<tr><td>";
        echo "<table border=0 cellpadding=5 cellspacing=0 width=100%>\n\n";
        //echo "<tr class=row0><td>Thumbnail</td><td>Filename</td><td>Filesize</td><td>Size</td></tr>\n";
          
        $handle = opendir('.');    
        while($file = readdir($handle)) {
        
    
    $filetype = substr($file,-3,3);
                
            if ($filetype == "jpg" || $filetype == "JPG" )
                {

                $bgclass == "row1" ? $bgclass = "row2" : $bgclass = "row1";
                
                $filesize = round(filesize($file)/1024);
                         $namelength= strlen($file)-4;
                          $file = substr($file,0,$namelength);
                
                $imagehw = GetImageSize("$file.$filetype");
                $width = $imagehw[0];  
                $height = $imagehw[1];
                    
                    
                       if(!file_exists("thumbs/$file.$filetype"))
                           CreateThumb("$file.$filetype");
                      
                    
                    if(!$width)
                    {

                        $imghw = ImgSize("$file.$filetype");
                        $width = $imghw[1];
                        $height = $imghw[2];
                }

                    
                    //-- edited by me..
                    
                    
                    if (!$count)
                        $count = 1;
                    
                    if ($count == 1)
                    {

                        echo "<tr class=$bgclass>\n";
                        echo "<td align=center width=\"25%\" ><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=><a/></td>\n";
                    }

                    elseif ($count == 2)
                        echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
                    elseif ($count == 3)
                        echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
                    elseif ($count == 4)
                    {

                        echo "<td align=center width=\"25%\"><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
                        echo "</tr>\n";
                        $count = "0";
                    }

                    
                    
                        
                        
                      /*    
                    echo "<tr class=$bgclass>\n";
                    echo "<td align=center width=100><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\"><img src=\"$dir/thumbs/$file.$filetype\" border=0><a/></td>\n";
                    echo "<td><a href=\"$PHP_SELF?dir=$dir&show=img&file=".rawurlencode("$file.$filetype")."\">$file</a></td>\n";
                    echo "<td>$filesize kB</td>";
                    echo "<td>$width&nbspx&nbsp;$height</td>";
                    echo "</tr>";
                    */

                    
                    $count++;
            
                $totalfilesize += $filesize;
                $totalwidth += $width;
                $totalheight += $height;
                $numimg++;
            }
            
            
        }
    }

    
    if($numimg)
    {

        $avgwidth = round($totalwidth / $numimg);
        $avgheight = round($totalheight / $numimg);
        $avgfilesize = round($totalfilesize / $numimg);
        $totalfilesize = round($totalfilesize / 1000,2);
        
        echo "<tr class=row0><td colspan=4 align=center>Statistieken</td></tr>\n";
        echo "<tr class=row1><td colspan=2>Totaal aantal foto's</td><td colspan=2>$numimg</td></tr>\n";
        echo "<tr class=row2><td colspan=2>Gemiddelde foto</td><td colspan=2>$avgfilesize kB</td></tr>\n";
        echo "<tr class=row1><td colspan=2>Gemiddelde afmetingen</td><td colspan=2>$avgwidth x $avgheight</td></tr>\n";
        echo "<tr class=row2><td colspan=2>Totaal foto's</td><td colspan=2>$totalfilesize MB</td></tr>\n";
    }


    
    if ($dir != ".")
        echo "</table></td></tr></table>";
    
}

elseif($show == "img")
{

    
    $showfile = substr($file,0,-4);
    echo "<table border=1 bordercolor=#E4E2Ed style=\"border-color: #E4E2ED; border-width: 1px;\" cellpadding=5 cellspacing=0 class=contenttable width=80% align=center>\n\n";
    
    
    $nextimg = GetNextName($file);
    if($nextimg)
        $next = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$nextimg\">[ Volgende ]</a>";
    $previmg = GetPrevName($file);
    if($previmg)
        $prev = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$previmg\">[ Vorige ]</a>";
    
    
    if($nextimg)
        $img = "<a href=\"$PHP_SELF?dir=$dir&show=img&file=$nextimg\"><img border=0 src=\"$dir/$file\"></a>";
    else
        $img = "<img src=\"$dir/$file\">";    
    
    $prev && $next ? $div = " | " : $div = "";
    echo "<tr class=row0><td align=right><a href=\"$PHP_SELF?dir=$dir\">Terug naar de thumbs</a></td></tr>\n";
    echo "<tr><td colspan=2 align=center>$prev$div$next</td></tr>\n";
    echo "<tr class=row1><td colspan=2 align=center>$img</td></tr>";
    echo "<tr><td colspan=2 align=center>$prev$div$next</td></tr>\n";
    
    echo "</table>";
    
    
    
    $lastslash = strrpos($HTTP_SERVER_VARS[SCRIPT_FILENAME],"/");
    $root = substr($HTTP_SERVER_VARS[SCRIPT_FILENAME],0,$lastslash+1);
    
    
    
    
    
    $fp = popen("$root/system/./jhead -se '$file' 2>&1", "r");
    while (!feof($fp)) {
              $buf .= fread($fp, 1024);
       }

        
        
        
       // echo $buf;    
       /*      
       if(!strstr($buf,"denied"))
       {
           $tmp = explode("\n",$buf);
           for($i = 0; $i <= count($tmp); $i++)
           {
               if($tmp[$i] != "")
               {
                   $tmp2 = explode(": ",$tmp[$i]);
                   $info[$i][key] = trim($tmp2[0]);
                   $info[$i][val] = trim($tmp2[1]);
               }    
           }
            
           echo "<table border=0 cellpadding=3 cellspacing=1 class=contenttable width=100%>\n\n";
        echo "<tr><td height=20>&nbsp;</td></tr>\n";
        echo "<tr class=row0><td colspan=2>Camera Instellingen</td></tr>\n";
        for($i = 0; $i <= count($info); $i++)
        {
            
            if($info[$i][key] && $info[$i][val])
                echo "<tr class=row1><td width=100>{$info[$i][key]}</td><td>{$info[$i][val]}</td></tr>\n";
            elseif($info[$i][key] && !$info[$i][val])    
                echo "<tr class=row1><td colspan=2>{$info[$i][key]}</tr>\n";
                
           }
    }
    echo "</table>";
    */

}

    if ($dir == ".")
    {

        $path = "..";
        $imgpath = "..";
        //echo "</tr></table>";
    }
    else
    {
        $path = "../..";
        $imgpath = "..";
    }

?>

</body>
</html>
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

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.