Hallo; ik ben bezig met een fotoalbum te schrijven die per jaar fotos uit een bepaalde map haalt.
Ik weet niet juist wat er mis is aan de code maar het zit zo: Er is geen parse of fatal error ofzo maar de pagina laad gewoon niet, altijd als ik er heen ga zit ik vast. Wat is er dan mis aan deze code????
<?php
require "header.php";
#########################################################################################
// hoofdvariabelen en dircheck
#########################################################################################
if (is_numeric($_GET['jaar'])){
$GLOBALS['map'] = "fotos/" . $_GET['jaar'] . "/";
$GLOBALS['picmap'] = $GLOBALS['map'] . $_GET['jaar'] . "/";
} elseif (!isset($_GET['jaar'])){
echo "<script>location.href = 'error.php?number=404';</script>";
} else {
echo "<script>location.href = 'error.php?number=400';</script>";
}
//map checken
$dir = opendir($GLOBALS['picmap']);
while (false !== ($bes = readdir($dir))){
if($file == '.' || $file == '..')
continue;
else
$result_array[]=$bes;
}
closedir ($dir);
$readed = array_multisort($result_array, SORT_DESC);
if (!$readed){
echo "Error: er is een foute map opgegeven, hier staan geen pics in!<br>";
}
$GLOBALS['count'] = count($result_array);
#########################################################################################
// mensen aanzetten tot eigen fotos posten
#########################################################################################
function postitdude(){
echo "Als je zelf nog fotos hebt van het vrijpodium (eender welke editie)";
echo ". Laat het ons weten via het contact gedeelte.";
}
#########################################################################################
// aantal posts tellen
#########################################################################################
function countpics($total){
$pics = $total/20;
for($x=0; $x>=$pics; $x++){
$rel = $x+1;
$xer = $x*20;
if ($xer != $_GET['start']){
echo "[<a href='?jaar=".$_GET['jaar']."&start=".$xer."'>". $rel ."</a>] ";
} else {
echo "[*] ";
}
}
echo "totaal aantal fotos van het jaar ".$_GET['jaar'].": ".$total."<hr>";
}
#########################################################################################
// slideshow script
#########################################################################################
function slide(){
global $readed;
echo "<a href='?jaar=".$_GET['jaar']."'>Bezie fotos in gewone mode!</a><br>";
echo "<center><img src='images/pics.gif' alt='the images!' name='dapic'><br>";
echo "<a href='javascript:nog()'>«vorige</a> || ";
echo "<a href='".$_SERVER['PHP_SELF']."'>home</a>";
echo "<a href='javascript:niemeer()'> || »volgende</a></center>";
echo "<script>
var img = new array();
var num = 0;";
$num = 0;
while ($file = $readed){
$filename = $GLOBALS['picmap'] . $file;
echo "img[".$num."] = '".$GLOBALS['picmap'].$file."';";
$num++;
}
echo "
function niemeer()
{
if (num>0)
{
num--;
document.images.dapic.src=photos[num];
}
}
function nog()
{
if (num<=photos.length-1)
{
num++;
document.images.photoslider.src=photos[num];
}
else {num=0; nog();}
}
</script>";
$num++;
}
#########################################################################################
// normale modus; gewoon enkele paginas met 20 fotos
#########################################################################################
function normalmode(){
global $readed;
echo "<a href='?jaar=".$_GET['jaar']."&mode=slideshow'>Bezie slideshow!</a><br>";
if (!isset($_GET['start'])){
$_GET['start'] = 0;
} elseif (!is_numeric($_GET['start'])){
echo "<script>location.href = 'error.php?number=400';</script>";
}
$geknipt = array_slice( $readed, $_GET['start'], 20 );
$i = $_GET['start'] + 1;
while ($file = $geknipt) {
$filename = $GLOBALS['picmap'] . $file;
if (is_file ($filename)) {
echo '<a href="javascript:popup(\'' . $GLOBALS['picmap'] . $file . '\', 500, 500)" title="picture '.$i.'">';
echo "<img src='" . $GLOBALS['picmap'] . $file . "' width='250' alt='picture ".$i."'></a><br>";
} else {
echo "Error: Er was een fout met het openen van de foto!<br>";
}
$i++;
}
}
#########################################################################################
// vanonder links naar vorige jaren:
#########################################################################################
function other(){
$openhet = opendir($GLOBALS['map']);
while (false !== ($bestand = readdir($openhet))){
if ($bestand != $_GET['jaar']){
echo "<a href='".$_SERVER['PHP_SELF']."?jaar=".$bestand."'>Fotos jaar".$bestand."</a><br>";
} else {
echo "Fotos jaar ".$bestand;
}
}
closedir($openhet);
}
#########################################################################################
// sluit de dir en maak een switch voor te zien wanneer je wat moet gebruiken!
#########################################################################################
switch ($_GET['mode']){
case "slideshow":
slide();
echo "<hr>";
other();
echo "<hr>";
postitdude();
break;
default:
countpics();
normalmode();
countpics();
echo "<hr>";
other();
echo "<hr>";
postitdude();
break;
}
require "footer.php";
?>
thanks
ps: voorbeeld op http://members.lycos.nl/fauvee/vrijpodium/site/fotos.php?jaar=2003
pas wel op: loopt vast!
860 views