| 
                 
            
            
                    
            
             
                 
                
                 
		
                    
                    
                    Foto Album
                    
                    Auteur: webbiexl - 31 augustus 2004 - 19:47 - Gekeurd door: Dennisvb - Hits: 58397  - Aantal punten: 3.98 (24 stemmen)
                     
                        
        
        
        
 Dit is een perfect foto album dat ik flink verbeterd heb. Het origineel is van Ward Roeffen, dat je het ff weet.
 
Functies van het Album. 
Het album bestaat uit 2 delen. 
- album.php 
- albumlist.php
 
- albumlist.php 
Dit is de pagina die je include op je indexpagina. Ward had op zijn homepage een soort gelijk iets staan alleen had hij dit niet bij zijn script gezet. Dus ik heb dit nagemaakt, omdat hij een overzichtelijke pagina in elkaar had gezet en daar nix mis mee was. 
Deze pagina verwijst naar de verschillende albums (mappen), en komt vervolgens uit op album.php waarover ik het volgende uit te leggen heb.
 
- album.php  
In het album van ward zaten een paar kleine dingen die eruit of er juist in moesten. 
Zo ontbrak er een database connectie en moest je special thumbnails aanmaken. Dit heb ik onderandere veranderd zodat het script completer wordt.
 
album.php werkt heel simpel.  
Je moet je map met foto's uploaden naar je server. Deze map is direct al het album. 
Het enige wat je moet doen om die op te roepen is de link te veranderen in albumlist.php. 
 
Dit gaat als volgt
 
    
    
        
            
                <a href="?page=album&boek=album1">Foto's bekijken</a> 
             
            <a href="?page=album&boek=album1">Foto's bekijken</a> 
 
  
         
          
     
 
Verander in de link hier boven 'album1' in de naam van je map. Wil je bijvoorbeeld 
'mijn verjaardag' als naam hebben noem dan de map 'mijn_verjaardag'. Het script zet _ automatisch om in spaties
 
album.php verwerkt, dankzij veranderingen, alle foto's in de geplaatste mappen tot thumbnails. Deze thumbnails dienen als link om naar de foto zelf te gaan. 
Ook kan je onder elke foto reacties plaatsen, maar dan moet je wel eerst even deze tabel aanmaken.
 
    
    
        
            
                CREATE TABLE fotosreacties (
id int(11) NOT NULL auto_increment,
boek varchar(60) NOT NULL default '',
foto varchar(60) NOT NULL default '',
naam varchar(30) NOT NULL default '',
datum int(11) NOT NULL default '0',
reactie text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM; 
             
            CREATE TABLE fotosreacties ( id int(11) NOT NULL auto_increment, boek varchar(60) NOT NULL default '', foto varchar(60) NOT NULL default '', naam varchar(30) NOT NULL default '', datum int(11) NOT NULL default '0', reactie text NOT NULL, ) TYPE=MyISAM; 
 
  
         
          
     
 
Ik hoop dat jullie er gebruik van zullen maken en laat ff weten wat je er van vindt! 
 
grtz Webbie XL
  
                     | 
                     
                 
                 
                
                    
                    | Code: | 
                     
                    
                    
                    albumlist.php 
 
    
    
        
            
                <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Foto Album</title>
</head>
<body>Foto's<br>
<table cellspacing="0" border="0" cellpadding="0" width="90%">
<tr><td colspan="2"><hr></td></tr>
<tr>
       <td rowspan="2" align="center" width="200"><a href="album.php?page=album&boek=album1"><img src="" height="100" alt="Album 1" border="0"></a></td>
       <td valign="top"><font face="Arial" size="2">Album 1<br>
        </font><font face="Arial" size="1">Foto's van bijvoorbeeld je schoonmoeder.</font><br>
     </td>
</tr>
<tr>
       <td valign="bottom"><a href="album.php?page=album&boek=album1">Foto's bekijken</a></td>
</tr>
<tr><td colspan="2"><hr></td></tr>
<tr>
       <td rowspan="2" align="center" width="200"><a href="album.php?page=album&boek=album2"><img src="" height="100" alt="Album 2" border="0"></a></td>
       <td valign="top"><font face="Arial" size="2">Album 2<br>
        </font><font face="Arial" size="1">Foto's van bijvoorbeeld je zomervakantie.</font><br>
     </td>
</tr>
<tr>
       <td valign="bottom"><a href="album.php?page=album&boek=album2">Foto's bekijken</a></td>
</tr>
<tr><td colspan="2"><hr></td></tr>
</table>
 
</body>
</html>
             
            <html>   <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Foto Album</title> </head>   <body>Foto's<br> <table cellspacing="0" border="0" cellpadding="0" width="90%"> <tr><td colspan="2"><hr></td></tr> <tr>        <td rowspan="2" align="center" width="200"><a href="album.php?page=album&boek=album1"><img src="" height="100" alt="Album 1" border="0"></a></td>        <td valign="top"><font face="Arial" size="2">Album 1<br>         </font><font face="Arial" size="1">Foto's van bijvoorbeeld je schoonmoeder.</font><br>      </td> </tr> <tr>        <td valign="bottom"><a href="album.php?page=album&boek=album1">Foto's bekijken</a></td> </tr> <tr><td colspan="2"><hr></td></tr> <tr>        <td rowspan="2" align="center" width="200"><a href="album.php?page=album&boek=album2"><img src="" height="100" alt="Album 2" border="0"></a></td>        <td valign="top"><font face="Arial" size="2">Album 2<br>         </font><font face="Arial" size="1">Foto's van bijvoorbeeld je zomervakantie.</font><br>      </td> </tr> <tr>        <td valign="bottom"><a href="album.php?page=album&boek=album2">Foto's bekijken</a></td> </tr> <tr><td colspan="2"><hr></td></tr>     </table>     </body>   </html> 
 
  
         
          
     
   
 
album.php 
 
    
    
        
            
                <? 
$host="localhost"; 
$user="naam"; 
$password="w8woord"; 
$dbnaam="DBnaam"; 
$db=mysql_connect($host,$user,$password) or die(mysql_error()); 
mysql_select_db($dbnaam,$db) or die("mysql_errno():mysql_error()"); 
 
if(is_dir($_GET['boek'])){ 
// configuratie 
$aantalFotos = 18;                                           // aantal fotos per pagina 
$originalPath = $_GET['boek'];                            //de map aangeroepen in de url 
$path = $_GET['boek'];                        // path naar de foto 
$fotoArray = array(); 
$d = dir("$path");   
while($entry=$d->read()) {   
           if(eregi(".jpg|.jpeg|.gif|.bmp|.png", $entry)){ 
                ClearStatCache();   
      
                 $foto = $path . "/" . $entry ; 
             $fotoArray[] = $foto; 
          
            } 
          
}   
$d->close();   
$count = count($fotoArray); 
$pathspatie = str_replace("_", " ", $originalPath); 
// reactie Plaatsen 
if(isset($_POST["submitreactie"])){ 
    $query = "insert into fotosreacties (boek,foto,naam,datum,reactie) values "; 
    $query .= "('" . $_GET['boek'] . "','" . $fotoArray[$_GET["fotoID"]] . "','" . $_POST["naam"] . "','" . time() . "','" . $_POST["reactie"] . "')"; 
if($result = mysql_query($query)){ 
    echo "Je reactie is geplaatst"; 
    } // end if 
else { 
    echo "Sorry, je reactie kon niet geplaatst worden."; 
    } // end else         
    } // end if 
     
     
     
// kijken hoeveel reacties iedere foto heeft 
$reacties; 
$query = "select foto from fotosreacties where boek = '" . $_GET['boek'] . "'"; 
if($result = mysql_query($query)){ 
    while ($r = mysql_fetch_array($result)){ 
        while ($foto = current($fotoArray)) { 
               if ($foto==$r["foto"]){ 
                   $key = key($fotoArray); 
                   } // end if 
               next($fotoArray); 
            } // end while 
        if(!isset($reacties[$key])){ 
            $reacties[$key] = 1; 
            } // end if     
        else { 
            $reacties[$key]++; 
            } // end else     
            reset($fotoArray); 
        } // end while 
    } // end if     
?> 
<html> 
<head> 
    <title>Fotos</title> 
</head> 
<body> 
<table width="100%"><tr><td align="center" width="100%"> 
<? 
// 1 FOTO PER PAGINA 
if((isset($_GET['fotoID'])) AND (intval($_GET['fotoID']>=0)) AND (intval($_GET['fotoID'] < $count))){ 
    $showFoto = intval($_GET['fotoID']); 
echo "<table width='40%'><tr><td colspan='3' align='center'><b>" . $pathspatie . "</b> 
<br><br><small>Foto " . ($showFoto + 1) . " / " . $count . "</small></big></font> </td></tr><tr>"; 
echo "<tr><td colspan='3'  align='center'><a href='" . $fotoArray[$showFoto] . "' target='_blanc'><img src='" . $fotoArray[$showFoto] . "' height='300' border='0'></a></td></tr>"; 
echo "<tr><td  width='40%'>"; 
if($showFoto!=0){ 
         $prevFoto = ($showFoto - 1); 
         echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $prevFoto . "'>prev</a> "; 
} //  end if 
echo "</td><td  width='33%'>"; 
$pageNR = floor($_GET['fotoID'] / $aantalFotos); 
$pageNR = $pageNR * 18; 
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>list</a> "; 
echo "</td><td  align='right'>"; 
if($showFoto!=($count -1)){ 
         $nextFoto = ($showFoto + 1); 
         echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $nextFoto . "'>next</a> "; 
} //  end if 
echo "</td></tr></table>"; 
echo "<br><br><b>Reacties</b>"; 
$reacties; 
$query = "SELECT * FROM fotosreacties where foto = '" . $fotoArray[$showFoto] . "' order by datum ASC"; 
if($result = mysql_query($query)){ 
    if(mysql_numrows($result)==0){ 
        echo "<br><br>Er zijn nog geen reacties"; 
        } // end if 
    else {     
        echo "<table width='40%' cellspacing='0' border='0'  cellpadding='0'>"; 
        echo "<tr><td  colspan='2'><hr></td></tr>"; 
        while ($r = mysql_fetch_array($result)){ 
             echo "<tr><td><b>" . $r["naam"] . "</b> "; 
              echo "</td><td width='40%'><small>[ " . date("d/m/Y @ H:i",$r["datum"]) . " ]</small></td><tr>"; 
             echo "<tr><td  colspan='2'>" . $r["reactie"] . "</td></tr>"; 
              echo "<tr><td  colspan='2'><hr></td></tr>"; 
             } // end while 
        echo "</table>"; 
        } // end else 
    } // end if 
echo "<form method='post' action=''>"; 
echo "<table>"; 
echo "<tr>"; 
echo "<td>Naam:<br><input type='text' name='naam'></td></tr>"; 
echo "<tr><td>Jouw Reactie:<br><textarea name='reactie' cols='30' rows='5'></textarea><br></td></tr>"; 
echo "<tr><td><input type='submit' name='submitreactie' value='Verzenden'></td></tr>"; 
echo "</table>";     
echo "</form>"; 
} // end if 
// X FOTOS PER PAGINA 
else { 
// configuratie 
$clm = "3";                                                                      // Aantal kolommen 
$countFotos = count($fotoArray); 
$thumbPath = $path . "/";                                             //Path naar thumps 
$path2 = $path . "/";         
echo "<br><table ><tr>"; 
echo "<td align='center' colspan='" . $clm . "'>"; 
// navigatie 
$navigation; 
if($countFotos < ($aantalFotos + 1)){ 
               $begin = 0; 
               $eind = $countFotos; 
                
} // end if 
else { 
$aantalPages =  ceil($countFotos / $aantalFotos) ; 
for($i=1; $i < $aantalPages + 1; $i++){ 
          $pageNR = ($i - 1) * $aantalFotos; 
           
          if($pageNR==$_GET["vanafFoto"]){ 
           $navigation .= "<small><font color='#990000'>" . $i . "</font></small> "; 
          } 
            else { 
            $navigation .= "<a href='?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>" . $i . "</a> "; 
            } 
} // end for 
if((isset($_GET['vanafFoto'])) AND (intval($_GET['vanafFoto']>=0)) AND (intval($_GET['vanafFoto'] < $countFotos))){ 
        $begin = intval($_GET['vanafFoto']); 
     
       if(($begin + $aantalFotos) <= $countFotos){ 
                     $eind = ($begin + $aantalFotos); 
           } // end if 
      else { 
                   $eind = $countFotos; 
           } // end else 
            
} // end if 
else { 
     $begin = 0; 
     $eind = $aantalFotos; 
} // end else 
                                             
$countFotos = count($fotoArray); 
                                                 // path naar echte foto 
} // end else 
echo "<table border='0' cellpadding='0' cellspacing='2'><tr><td ><b>" . $pathspatie . "</b> <small>(" . $count . ")</small> 
<br><br><center><small>Pictures " . ($begin + 1) . " - " . $eind . "</small></center></td></tr></table>"; 
if(($begin - $aantalFotos) >= 0){ 
             $navigation = "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin - $aantalFotos) . "'><</a> " . $navigation;             
    } // end if 
             
         
if(($begin + $aantalFotos) < $count){ 
             $navigation .= " <a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin + $aantalFotos) . "'>></a>";             
   } // end if 
echo $navigation . "<br><br>"; 
echo "</td></tr><tr>"; 
$fotonr = 1; 
for($i=$begin; $i < $eind; $i++){ 
$thumb = str_replace($path2, $thumbPath, $fotoArray[$i]); 
    echo "<td align='center'><a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $i . "'><img border='0' src='" . $thumb . "' height='100'><br>"; 
echo "<small>reacties ("; 
if($reacties[$i]==0){ 
    echo "0"; 
    } // end if 
else { 
    echo $reacties[$i]; 
    } // end else     
echo ")</small>"; 
echo "</a></td>"; 
    $fotonr++; 
    if($fotonr == ($clm + 1)){ 
    echo "</tr>\n<tr>"; 
     $fotonr = 1; 
} // end if 
     
         
} // end for 
echo "</tr>"; 
echo "<td align='center' colspan='" . $clm . "'>"; 
echo $navigation; 
echo "</td></tr><tr>"; 
echo "</table>";   
} // end else if 
} // end if 
else { 
    echo "Dit fotoalbum bestaat niet"; 
    } // end else 
 
 
?>
</td></tr></table> 
</body> 
</html> 
             
            <?    $host="localhost";  $user="naam";  $password="w8woord";  $dbnaam="DBnaam";    // configuratie  $aantalFotos = 18;                                           // aantal fotos per pagina  $originalPath = $_GET['boek'];                            //de map aangeroepen in de url  $path = $_GET['boek'];                        // path naar de foto        while($entry=$d->read()) {               if(eregi(".jpg|.jpeg|.gif|.bmp|.png", $entry)){                     $foto = $path . "/" . $entry ;               $fotoArray[] = $foto;                }    }      $d->close();    $count = count($fotoArray);    $pathspatie = str_replace("_", " ", $originalPath);      // reactie Plaatsen  if(isset($_POST["submitreactie"])){      $query = "insert into fotosreacties (boek,foto,naam,datum,reactie) values ";      $query .= "('" . $_GET['boek'] . "','" . $fotoArray[$_GET["fotoID"]] . "','" . $_POST["naam"] . "','" . time() . "','" . $_POST["reactie"] . "')";        echo "Je reactie is geplaatst";      } // end if  else {      echo "Sorry, je reactie kon niet geplaatst worden.";      } // end else                } // end if        // kijken hoeveel reacties iedere foto heeft  $reacties;  $query = "select foto from fotosreacties where boek = '" . $_GET['boek'] . "'";          while ($foto = current($fotoArray)) {                 if ($foto==$r["foto"]){                     } // end if              } // end while          if(!isset($reacties[$key])){              $reacties[$key] = 1;              } // end if              else {              $reacties[$key]++;              } // end else                } // end while      } // end if      ?>    <html>  <head>      <title>Fotos</title>  </head>    <body>      <table width="100%"><tr><td align="center" width="100%">    <?      // 1 FOTO PER PAGINA    if((isset($_GET['fotoID'])) AND  (intval($_GET['fotoID']>=0)) AND  (intval($_GET['fotoID'] < $count))){      $showFoto = intval($_GET['fotoID']);    echo "<table width='40%'><tr><td colspan='3' align='center'><b>" . $pathspatie . "</b>  <br><br><small>Foto " . ($showFoto + 1) . " / " . $count . "</small></big></font> </td></tr><tr>";    echo "<tr><td colspan='3'  align='center'><a href='" . $fotoArray[$showFoto] . "' target='_blanc'><img src='" . $fotoArray[$showFoto] . "' height='300' border='0'></a></td></tr>";  echo "<tr><td  width='40%'>";  if($showFoto!=0){           $prevFoto = ($showFoto - 1);           echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $prevFoto . "'>prev</a> ";  } //  end if  echo "</td><td  width='33%'>";  $pageNR = floor($_GET['fotoID'] / $aantalFotos);  $pageNR = $pageNR * 18;  echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>list</a> ";  echo "</td><td  align='right'>";  if($showFoto!=($count -1)){           $nextFoto = ($showFoto + 1);           echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $nextFoto . "'>next</a> ";  } //  end if  echo "</td></tr></table>";      echo "<br><br><b>Reacties</b>";    $reacties;  $query = "SELECT * FROM fotosreacties where foto = '" . $fotoArray[$showFoto] . "' order by datum ASC";          echo "<br><br>Er zijn nog geen reacties";          } // end if      else {              echo "<table width='40%' cellspacing='0' border='0'  cellpadding='0'>";          echo "<tr><td  colspan='2'><hr></td></tr>";               echo "<tr><td><b>" . $r["naam"] . "</b> ";                echo "</td><td width='40%'><small>[ " . date("d/m/Y @ H:i",$r["datum"]) . " ]</small></td><tr>";               echo "<tr><td  colspan='2'>" . $r["reactie"] . "</td></tr>";                echo "<tr><td  colspan='2'><hr></td></tr>";               } // end while          } // end else      } // end if    echo "<form method='post' action=''>";  echo "<td>Naam:<br><input type='text' name='naam'></td></tr>";  echo "<tr><td>Jouw Reactie:<br><textarea name='reactie' cols='30' rows='5'></textarea><br></td></tr>";  echo "<tr><td><input type='submit' name='submitreactie' value='Verzenden'></td></tr>";        } // end if    // X FOTOS PER PAGINA    else {    // configuratie  $clm = "3";                                                                      // Aantal kolommen      $countFotos = count($fotoArray);  $thumbPath = $path . "/";                                             //Path naar thumps  $path2 = $path . "/";                  echo "<td align='center' colspan='" . $clm . "'>";      // navigatie  $navigation;  if($countFotos < ($aantalFotos + 1)){                 $begin = 0;                 $eind = $countFotos;    } // end if  else {    $aantalPages =  ceil($countFotos / $aantalFotos) ;  for($i=1; $i < $aantalPages + 1; $i++){            $pageNR = ($i - 1) * $aantalFotos;              if($pageNR==$_GET["vanafFoto"]){             $navigation .= "<small><font color='#990000'>" . $i . "</font></small> ";            }              else {              $navigation .= "<a href='?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>" . $i . "</a> ";              }  } // end for      if((isset($_GET['vanafFoto'])) AND  (intval($_GET['vanafFoto']>=0)) AND  (intval($_GET['vanafFoto'] < $countFotos))){          $begin = intval($_GET['vanafFoto']);           if(($begin + $aantalFotos) <= $countFotos){                       $eind = ($begin + $aantalFotos);             } // end if        else {                     $eind = $countFotos;             } // end else    } // end if  else {       $begin = 0;       $eind = $aantalFotos;  } // end else    $countFotos = count($fotoArray);                                                       // path naar echte foto    } // end else    echo "<table border='0' cellpadding='0' cellspacing='2'><tr><td ><b>" . $pathspatie . "</b> <small>(" . $count . ")</small>  <br><br><center><small>Pictures " . ($begin + 1) . " - " . $eind . "</small></center></td></tr></table>";        if(($begin - $aantalFotos) >= 0){               $navigation = "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin - $aantalFotos) . "'><</a> " . $navigation;                  } // end if      if(($begin + $aantalFotos) < $count){               $navigation .= " <a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin + $aantalFotos) . "'>></a>";                 } // end if    echo $navigation . "<br><br>";  $fotonr = 1;  for($i=$begin; $i < $eind; $i++){      $thumb = str_replace($path2, $thumbPath, $fotoArray[$i]);          echo "<td align='center'><a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $i . "'><img border='0' src='" . $thumb . "' height='100'><br>";  echo "<small>reacties (";  if($reacties[$i]==0){      } // end if  else {      } // end else          $fotonr++;      if($fotonr == ($clm + 1)){       $fotonr = 1;  } // end if          } // end for    echo "<td align='center' colspan='" . $clm . "'>";            } // end else if  } // end if  else {      echo "Dit fotoalbum bestaat niet";      } // end else        ?> </td></tr></table>        </body>  </html> 
 
  
         
          
     
    Download code (.txt)
                     | 
                     
                 
                 
                
                    
                       | 
                     
                 
                
            
            
                    
            
                              | 
            
                
                  Stemmen | 
                 
                
                | Niet ingelogd. | 
                 
             
             
            
             |