Introduction

Cette page est en construction ..... Pour toute information, il y a toujours le mail ....

Code Source génération des pages

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"/>
<meta content="Yann Bechet" name="Author"/>
<link rel="stylesheet" href="style.css" media="screen" type="text/css" title="Normal">
<title>Sample page</title>
</head>
<body>
<?
/*--------------------------------------------------
VAR to modify
--------------------------------------------------*/
// ###################################################################
$thisfile="http://172.25.33.29:8080/test/test.php"; // URL of this file
//####################################################################
/*--------------------------------------------------
End of var to modify
-------------------------------------------------*/
$widthThumb=90; //max witdh/height of thumbnail
$widthPics=300; // max width/height of reduce picture
// NOTE : All next message can be a link to a picture or plain text
// Back message
$backS="<img src=\"haut.gif\">";
// previous picture msg
$prevS="<img src=\"left.gif\">";
// next picture msg
$nextS="<img src=\"right.gif\">";
$thumbdir="_thumbnail"; // name of the thubnail directory
$smalldir="_small";
$title="Menu";
include "include.inc";

echo "<div class=\"picscontent\"><div class=\"picstitle\">";
if (isset($_GET["rep"])) echo $_GET["rep"];
else echo $title;
echo "</div> ";
// --------------------------------------------------------------------------
// image to display is set, display it !
// display normal format image : $_GET["rep"](current directory) and $_GET["disp"] (Picture to display) ...
if (isset($_GET["disp"])){
diplayBig();
} else if (isset($_GET["dispsmall"])){
diplaySmall();
}
// --------------------------------------------------------------------------
// image not set, but repertory set, display thumbnail (and create if needed)
else if (isset($_GET["rep"])){
displayRep();
}
//---------------------------------------------------------------
// Image nor directory set, display list of available directories
else {
// generation de la liste des repertoires pour le menu.
$local=array ();
$dir=dir(".");
rewinddir($dir->handle);
while ($file = $dir->read()) {
if (!is_file($file) && $file!="." && $file!="..") {
$local["$file"]= "$thisfile?rep=$file";
}
}
// sort array before display ( revers sort !)
asort($local); reset($local);
while(list ($key, $val) = each ($local)){
echo "<div><a href=\"$val\">$key</a></div>\n";
}
} echo "<div class=\"picsspacer\">&nbsp;</div>
<a class=\"picscopyright\" href=\"http://www.bechet.org\">Generated using Bylb Picture Thumbnail</a>
</div>";
//######################################## END OF SCRIPT ######################
?>
</body>
</html>

Le fichier "include.inc"

<?
//##############################################################################
// GENERATE THUMBNAIL OR SMALLEST
//##############################################################################
function createthumb($name,$filename,$new_w){
$new_h = $new_w;
$system=explode(".",$name);
if (preg_match("/jpg|JPG|jpeg|JPEG/",$system[2])){
$src_img=imagecreatefromjpeg($name);
}
else{
$src_img=imagecreatefrompng($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
// create thumbnail in JPEG, smaller size than PNG
imagejpeg($dst_img,$filename);
imagedestroy($dst_img);
imagedestroy($src_img);
}
//##############################################################################
// GENERATE THUMBNAIL pictures, including dir creation
//##############################################################################
function generateThumbnails($rep){
global $widthThumb,$thumbdir, $smalldir;
$dir2=dir("./$rep");
rewinddir($dir2->handle);
if ( !file_exists("./$rep/$thumbdir")) {
mkdir ("./$rep/$thumbdir", 0700);
}
while ($file = $dir2->read()) {
if ($file !=$thumbdir && $file!=$smalldir){
$system=explode(".",$file);
if (!file_exists("./".$_GET["rep"]."/$thumbdir/$file") ){
createthumb("./$rep/$file","./$rep/$thumbdir/$file",$widthThumb);
}
}
}
} //##############################################################################
// GENERATE SMALLEST picture, including dir creation
//##############################################################################
function generateSmall($rep, $imgname){
global $widthPics,$smalldir;
if ( !file_exists("./$rep/$smalldir")) {
mkdir ("./$rep/$smalldir", 0700);
}
if (!file_exists("./".$_GET["rep"]."/$smalldir/$imgname") ){
createthumb("./$rep/$imgname","./$rep/$smalldir/$imgname",$widthPics);
}
} //##############################################################################
// DISPLAY REPERTORY THUMBNAIL. GENERATE IT IF NOT EXIST
//##############################################################################
function displayRep(){
global $backS,$thisfile,$thumbdir, $widthPics, $smalldir;
generateThumbnails($_GET["rep"]);
echo "<div class=\"picsback\"><a href=\"$thisfile\">$backS</a>\n</div>\n";
$dir2=dir("./".$_GET["rep"]);
rewinddir($dir2->handle);
while ($file = $dir2->read()) {
if ($file !=$thumbdir && $file!=$smalldir){
$system=explode(".",$file);
if (preg_match("/jpg|jpeg|png|JPEG|JPG|PNG/",$system[1])){
echo "<span class=\"picsflottante\">\n
<a href=\"$thisfile?rep=".$_GET["rep"]."&dispsmall=$file\">
<img class=\"picsthumb\" \"alt=\"./".$_GET["rep"]."/$thumbdir/$file\" src=\"./".$_GET["rep"]."/$thumbdir/$file\">
</a>
<div class=\"picspicName\">$system[0]</div>
<div class=\"picssize\">
<a href=\"$thisfile?rep=".$_GET["rep"]."&dispsmall=$file\"> Small</a>
-
<a href=\"$thisfile?rep=".$_GET["rep"]."&disp=$file\">Normal</a>
</div>\n
</span>\n";
}
}
}
} //##############################################################################
// DISPLAY THE NORMAL SIZE PICTURE
//##############################################################################
function diplayBig(){
global $backS,$nextS,$prevS,$thisfile,$thumbdir,$smalldir;
// generate list of directory, for next and previous....
$prev="";
$next="";
$dir2=dir("./".$_GET["rep"]);
rewinddir($dir2->handle);
while ($file = $dir2->read()) {
if ($file==$_GET["disp"]){
//search next, parsing for end and thumbnail directory...
$next=$dir2->read();
while ((is_dir($next) || $next==$thumbdir || $next==$smalldir) && $next!==false ){
$next=$dir2->read();
}
break;
}
//check that current is not thumbdir
if (!is_dir($file) && $file!=$thumbdir && $file!=$smalldir ){
$prev= $file;
}
}
if ($prev != "") {
echo "<a class=\"picsprev\" href=\"$thisfile?rep=".$_GET["rep"]."&disp=$prev\">$prevS<img src=\"./".$_GET["rep"]."/$thumbdir/$prev\"></a>";
} echo "<a class=\"picsback\" href=\"$thisfile?rep=".$_GET["rep"]."\">$backS</a> </td>\n";
if ($next != "" && $next !== false) {
echo "<a class=\"picsnext\" href=\"$thisfile?rep=".$_GET["rep"]."&disp=$next\" alt=\"$next\"><img src=\"./".$_GET["rep"]."/$thumbdir/$next\">$nextS</a>";
}
echo "\n<div class=\"picsspacer\">&nbsp;</div>
<a href=\"$thisfile?rep=".$_GET["rep"]."&dispsmall=".$_GET["disp"]."\">
<img alt=\"./".$_GET["rep"]."/".$_GET["disp"]."\"
src=\"./".$_GET["rep"]."/".$_GET["disp"]."\">
<div>".$_GET["disp"]."</div>
</a>";
} //#############################################################################
// DISPLAY SMALL PICTURE SIZE
//##############################################################################
function diplaySmall(){
global $backS,$nextS,$prevS,$thisfile,$thumbdir,$smalldir;
//generate small pics if not exit
generateSmall($_GET["rep"],$_GET["dispsmall"]);
// generate list of directory, for next and previous....
$prev="";
$next="";
$dir2=dir("./".$_GET["rep"]);
rewinddir($dir2->handle);
while ($file = $dir2->read()) {
if ($file==$_GET["dispsmall"]){
//search next, parsing for end and thumbnail directory...
$next=$dir2->read();
while ((is_dir($next) || $next==$thumbdir || $next==$smalldir) && $next!==false ){
$next=$dir2->read();
}
break;
}
//check that current is not thumbdir
if (!is_dir($file) && $file!=$thumbdir && $file!=$smalldir) {
$prev= $file;
}
} if ($prev != "" && $prev != $thumbdir && $prev != $smalldir) {
echo "<a class=\"picsprev\" href=\"$thisfile?rep=".$_GET["rep"]."&dispsmall=$prev\">$prevS<img src=\"./".$_GET["rep"]."/$thumbdir/$prev\"></a>\n";
}
echo "<a class=\"picsback\" href=\"$thisfile?rep=".$_GET["rep"]."\">$backS</a>\n";
if ($next != "" && $next !== false) {
echo "<a class=\"picsnext\" href=\"$thisfile?rep=".$_GET["rep"]."&dispsmall=$next\" alt=\"$next\"><img src=\"./".$_GET["rep"]."/$thumbdir/$next\">$nextS</a>\n";
}
echo "\n<div class=\"picsspacer\">&nbsp;</div>
<a href=\"$thisfile?rep=".$_GET["rep"]."&disp=".$_GET["dispsmall"]."\">
<img alt=\"./".$_GET["rep"]."/$smalldir/".$_GET["dispsmall"]."\"
src=\"./".$_GET["rep"]."/$smalldir/".$_GET["dispsmall"]."\">
<div>".$_GET["dispsmall"]."</div>
</a>
";
} ?>

Le fichier style.css

.picscontent{
position:relative;
top:0px;
left:0px;
margin: 0px;
padding: 0px;
text-align:center;
width:100%;
font-family:"Trebuchet MS",Verdana,Geneva,Arial,Helvetica,sans-serif;
}
.picscontent a, .picscontent a:visited{
text-decoration:none;
border:none;
}
.picscontent img {
text-decoration:none;
border:none;
}
.picstitle {
width:50%;
font-size:120%;
margin:10px auto 10px auto;
border:none ;
border-top: 1px solid #888;
border-bottom:1px solid #777;
}
.picscopyright {
font-size:70%;
margin:10px 0px 5px 0px;
}
.picsflottante{
font-size:70%;
padding:1px ;
margin:0px;
border:none;
float: left;
text-align: center;
width: 130px;
height:140px;
}
.picsspacer { clear: both;}
.picsnext {
position: absolute;
top: 1px;
right: 2px;
margin:30px 2px;
padding:0px;
}
.picsback { margin:10px 0px 10px 0px; }
.picsprev {
position: absolute;
top: 1px;
left: 2px;
margin:30px 2px;
}
.picsprev img, .picsnext img {
vertical-align:top;
}
.picspicName, .picssize {
margin:0px;
padding:0px;
line-height:90%;
}

	
	
	

Téléchargement des sources

BylbThumbnails.zip

Derniere mise a jour: 17 mars 2004
webmaster@bechet.org