Mega Code Archive

 
Categories / Php / Graphics
 

Vdc Photo Gallery

<? //-------------> START OF galleryInstall.php /* "LANGUAGES": - PHP 3.* - JS DOM LEVEL 1 - CSS LEVEL 1 "PACKAGE" : - galleryInstall.php - galleryDetail.php - gallery.php - ico.gif "README" :This simple photo gallery reads the images in the FileSystem from lots of directories, then put them into an Array (); Belove there is an example to see HOW insert new directory in the gallery: $nome="name of directory"; // modify this line array_push( $pathArray, $nome); // do not modify this line $counter++; // cut away this line only if there are no more directories listed belove!! Let me know if can I help you! */ /* S T A R T O F B U I L D I N G P AT H A R R A Y*/ $pathArray=array(); $counter=0; // initialize the number of pathArray' Key $nome="image_upload"; array_push( $pathArray, $nome); $counter++; $nome="ecomuseo/SiteAdmin/uploader/data/images"; array_push( $pathArray, $nome); $counter++; $nome="images"; array_push( $pathArray, $nome); /* E N D O F B U I L D I N G P AT H A R R A Y*/ //# //-------------> START OF gallery.php //# /* <?require ("galleryInstall.php")?> <html> <body> <style> .menuHref { Color: #ffffff; Text-Decoration: none; } .menuHref:visited { color: #00FFCC; } .text{ text-decoratione=none; font-family: serif,"Verdamna"; font-size: x-small; font-variant: normal; font-weight: normal; vertical-alignment: top; text-transformation: none; } td{ background-color:Gray; vertical-align:middle; border-color:#666699; } .button{ color: #ffffff; width:auto; height:14pt; background-color:Gray; border-color:#FAFAFA; } </style> <table align="center" border=1> <tr> <? // S T A R T O F P A G I N G $pager=25; // number of photos in a page $cells=5; //number of horizontal cells if ($h !=""){ $offset=$h+$pager; }else{ $offset=$pager; //number of elements $h=0; } // E N D O F P A G I N G $y=0; $key=0;// key of imgArray while ($counter>= $y) { //loop on directory -->FILESYSTEM $path=$pathArray[$y]; $handle = opendir($path); while ($file = readdir( $handle)) { //loop on files if( $file != "." || $file != ".." || trim($file) !="" ) { $imgArray[$key]= array("file"=>"$file","path"=>"$path"); } $key++; } $y++; } $td=0; while ( $h<$offset ) { //loop on 'files' stored in imgArray[] $file=$imgArray[$h]["file"]; $path=$imgArray[$h]["path"]; $printer=" "; if($td == $cells){ $printer.="</tr><tr>\n"; $td=0; } if ( (trim($path)=="" ) || (trim($file) =="") || ($file==".") || ($file == "..") ) {// check data stability in imgArray $td= $td-1; }else{ $number = $h-1; $printer.="<td valign='middle' align='center' style='vertical-align:top'><table width='100%' border='1' align='center' class='text' cellspacing='0'> \n"; $printer.="\t\t<tr>\n"; $printer.="\t\t\t<td width='10%' style='background-color:#FFFFFF;'>".$number."</td><td style='background-color:#FFFFFF;' width='90%' align='left'><input type='image' src='ico.gif' href='#' onClick=\"javascript:Detail_Img('".$path."/".$file."');\" width='21' height='12' border='0'></td>\n"; $printer.="\t\t</tr>\n"; $printer.="\t\t<tr>\n"; $printer.="\t\t\t<td colspan='2' align='center' ><img src='$path/$file' border='0' height='70'></td>\n"; $printer.="\t\t</tr>\n"; $printer.="</table></td>\n"; } echo $printer; $td++; $h++; } ?> </tr> <tr><td colspan='<?=$cells?>' > <table width="100%" class='text'> <tr> <td align="left" width="50%"> <?if ($h>$pager){ $back= $h-($pager+$pager);?> <INPUT type="button" value="<<" class="button" id="btn" onClick="javascript:document.location.href='gallery.php?h=<?=$back?>&pager=<?=$pager?>' ;"> <?}?> </td> <td align="right" width="50%"> <?if ($h<$key){?> <INPUT type="button" value=">>" class="button" id="btn" onClick="javascript:document.location.href='gallery.php?h=<?=$h?>&pager=<?=$pager?>' ;"> <?}?> </td> </tr> </table> </body> <script language="JavaScript"> function Detail_Img(path){ window.open('galleryDetail.php?path='+path,path,'width=10,height=10,resizable=yes,toolsbat=none'); } </script> </html> <? // //-------------> START OF galleryDetail.php // ?> <html> <div id="box"> <body onLoad="JavaScript:return ImgProperties();" onResize="return ImgProperties();" class="bodyStyle"> <style> .button{ color: #ffffff; width:auto; height:15pt; } .bodyStyle{ margin-top: -0.5ex; margin-right: -0.5ex; margin-left: -0.5ex; margin-bottom: auto; cursor:crosshair; } td{ text-align:center; } </style> <TABLE align="center"> <TR> <TD colspan="2"><IMG src="<?=$path?>" id="img"></TD> </TR> <TR> <TD> <INPUT type="button" value="Stampa" class="button" id="btn" onClick="PrintImg();"> </TD> </TR> <TR> <TD> <INPUT type="button" value="Chiudi" class="button" id="btn" onClick="KillEmAll();"> </TD> </TR> </TABLE> </body> </div> <script language="JavaScript"> function ImgProperties(){ var Img_x= document.getElementById('img').width; var Img_y= document.getElementById('img').height; document.getElementById('box').width=Img_x; document.getElementById('box').height=Img_y; //var X=Img_x; Img_y=Img_y + 60; window.resizeTo(Img_x,Img_y); return true; } function KillEmAll(){ window.close(); } function PrintImg(){ window.print(); } </script> </html>