files array limiteren
hoi mensen, heb zelf een wat goedkoop fotoalbum gemaakt die geen onderhoud nodig heeft
heb een scriptje dat directories ophaalt, en vervolgens als men een dir aanklikt hier uit de fotos haalt en op een pagina weergeeft,
werkt goed maar 1 probleem, alle fotos komen op een pagina, ik kan wel een limit instelle met if ($i < 25){ script} maar dan heb ik maar 25 fotos
hoe sla ik $i op en zorg ik er voor dat de file array doorgaat bij 25 ... 50 ... 75 enz.
is er voor arrays ook een functie als LIMIT $mypage, 25 ..
script:
heb een scriptje dat directories ophaalt, en vervolgens als men een dir aanklikt hier uit de fotos haalt en op een pagina weergeeft,
werkt goed maar 1 probleem, alle fotos komen op een pagina, ik kan wel een limit instelle met if ($i < 25){ script} maar dan heb ik maar 25 fotos
hoe sla ik $i op en zorg ik er voor dat de file array doorgaat bij 25 ... 50 ... 75 enz.
is er voor arrays ook een functie als LIMIT $mypage, 25 ..
script:
Code (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
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
<?php
$handle = $_GET['handle'];
$next = $_GET['next'];
$prev = $_GET['prev'];
$proportion = $_GET['proportion'];
$num = $_GET['num'];
$width = $_GET['width'];
$height = $_GET['height'];
$fsize = $_GET['fsize'];
$type = $_GET['type'];
$attr = $_GET['attr'];
$dir = $_GET['dir'];
$photos = $_GET['photos'];
$file2 = $_GET['file2'];
$hand = $_GET['hand'];
$site_name = "klen.nl";
$directory2 = $_GET['directory2'];
$file_count = $_GET['file_count'];
print "<html>
<head>
<title></title>
</head>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<table border=0 width=\"100%\" cellpadding=15 cellspacing=0>
<tr>
<td valign=\"top\" width=\"50%\">";
$directory = "/usr/home/klen55/public_html/fotos/";
if($dir=="") {
print "<br><font class='main'><i>Selecteer een album..</i></font>";
}
else {
$files = array();
$dir2 = opendir('/usr/home/klen55/public_html/fotos/'.$dir);
while(($file = readdir($dir2)) !== false)
{
if($file !== '.' && $file !== '..' && !is_dir($file))
{
$files[] = $file;
}
}
closedir($dir2);
sort($files);
for($i=0; $i<count($files); $i++)
{
if (empty($o)){$o=5;}
if ($i==$o){echo "<br>";$o=$i+5;}
$swidth = 80;$sheight = 60;
list($width, $height, $type, $attr) = getimagesize("/usr/home/klen55/public_html/fotos/".$dir."/".$files[$i]);
if($width > $height) {$proportion = ($width / $swidth);}
else {$proportion = ($height / $sheight);}
$width1 = $width / $proportion;$height1 = $height / $proportion;
echo "<a href='http://www.klen.nl/fotos/".$dir."/".$files[$i]."' target='_blank'><img src='fotos/".$dir."/".$files[$i]."' width='$width1' height='$height1'></img></a> ";
}
}
print "<hr><font class='header'>Foto Albums:</font><br>
<font class='main'>";
if ($handle = opendir("$directory")) {
while (false !== ($file = readdir($handle))) {
$file_count = $file_count++;
if($file != "." && $file != ".." && is_dir("$file")) {
if($h = opendir("$file")) {
while (false !== ($f = readdir($h))) {
if($f != "." && $f != "..") {
$f_count = $f_count + 1;
}
}
print "<a href='?goto=Foto Album2&dir=$file&num=0'>/$file</a> ($f_count)<br>";
$f_count = 0;
}
}
}
}
// CLOSE DIRECTORY
closedir($handle);
// END TABLE
print "</td></tr></table>";
?>
$handle = $_GET['handle'];
$next = $_GET['next'];
$prev = $_GET['prev'];
$proportion = $_GET['proportion'];
$num = $_GET['num'];
$width = $_GET['width'];
$height = $_GET['height'];
$fsize = $_GET['fsize'];
$type = $_GET['type'];
$attr = $_GET['attr'];
$dir = $_GET['dir'];
$photos = $_GET['photos'];
$file2 = $_GET['file2'];
$hand = $_GET['hand'];
$site_name = "klen.nl";
$directory2 = $_GET['directory2'];
$file_count = $_GET['file_count'];
print "<html>
<head>
<title></title>
</head>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<table border=0 width=\"100%\" cellpadding=15 cellspacing=0>
<tr>
<td valign=\"top\" width=\"50%\">";
$directory = "/usr/home/klen55/public_html/fotos/";
if($dir=="") {
print "<br><font class='main'><i>Selecteer een album..</i></font>";
}
else {
$files = array();
$dir2 = opendir('/usr/home/klen55/public_html/fotos/'.$dir);
while(($file = readdir($dir2)) !== false)
{
if($file !== '.' && $file !== '..' && !is_dir($file))
{
$files[] = $file;
}
}
closedir($dir2);
sort($files);
for($i=0; $i<count($files); $i++)
{
if (empty($o)){$o=5;}
if ($i==$o){echo "<br>";$o=$i+5;}
$swidth = 80;$sheight = 60;
list($width, $height, $type, $attr) = getimagesize("/usr/home/klen55/public_html/fotos/".$dir."/".$files[$i]);
if($width > $height) {$proportion = ($width / $swidth);}
else {$proportion = ($height / $sheight);}
$width1 = $width / $proportion;$height1 = $height / $proportion;
echo "<a href='http://www.klen.nl/fotos/".$dir."/".$files[$i]."' target='_blank'><img src='fotos/".$dir."/".$files[$i]."' width='$width1' height='$height1'></img></a> ";
}
}
print "<hr><font class='header'>Foto Albums:</font><br>
<font class='main'>";
if ($handle = opendir("$directory")) {
while (false !== ($file = readdir($handle))) {
$file_count = $file_count++;
if($file != "." && $file != ".." && is_dir("$file")) {
if($h = opendir("$file")) {
while (false !== ($f = readdir($h))) {
if($f != "." && $f != "..") {
$f_count = $f_count + 1;
}
}
print "<a href='?goto=Foto Album2&dir=$file&num=0'>/$file</a> ($f_count)<br>";
$f_count = 0;
}
}
}
}
// CLOSE DIRECTORY
closedir($handle);
// END TABLE
print "</td></tr></table>";
?>
Er zijn nog geen reacties op dit bericht.




