Jump to content
xisto Community
killingjoke

How Can I Make A PHP-based Web Gallery

Recommended Posts

how can i make a gallery in php like this one; but it has to show the images in the maps under it too;


<?php   # Do we have a path? if not, it's the current directory   $path = $_GET["path"];   if( !isset( $path ) || $path == "" )  {	 $path = ".";   }   # Initialise list arrays, directories and files separately and array counters for them   $d_arr = array(); $d = 0;   $f_arr = array(); $f = 0;   # Open possibly available directory   if( is_dir( $path ) ) {	 if( $handle = opendir( $path ) ) {		 while( false !== ( $file = readdir( $handle ) ) ) {		   # Make sure we don't push parental directories or dotfiles (unix) into the arrays		   if( $file != "." && $file != ".." && $file[0] != "." ) {			   if( is_dir( $path . "/" . $file ) )				 # Create array for directories				 $d_arr[$d++] = $file;			   else				 # Create array for files				 $f_arr[$f++] = $file;		   }		 }	 }   }   # Wrap things up if we're in a directory   if( is_dir( $handle ) ) closedir( $handle );  # Sort and reset the arrays   sort( $d_arr ); reset( $d_arr );   sort( $f_arr ); reset( $f_arr );   # Print file list   for( $i=0; $i < count( $f_arr ); $i++ ) {	 if ($f_arr[$i] != 'Thumbs.db' && $f_arr[$i] != 'kl1.jpg') {	 print "<center><a href=\"" . $path . "/" . $f_arr[$i] . "\" target=\"_blanc\"><img src=\"" . $path . "/" . $f_arr[$i] . "\" width=\"550\" border=\"0\"></a><br><br>\n</center>";	    }}?><title>.:: Ikhebtetten.be ::. Gallery</title><body bgcolor="3d3d3d" text="#FFFFFF" link="#FF0000" vlink="#FF0000" alink="#FF0000"></body>

Edited by miCRoSCoPiC^eaRthLinG (see edit history)

Share this post


Link to post
Share on other sites

hi
there are many free photo gallery based on php/mysql, i suggest you install that photo galleries in your site
there are two photo galleries script in cpanel, you can install them, for example coppermine photo gallery and 4images.

below are links to their site
coppermine photo gallery http://coppermine-gallery.net/
4images https://www.4homepages.de/

Share this post


Link to post
Share on other sites

I'd like to advice you such a one:

<?php	Error_Reporting(E_ALL & ~E_NOTICE);	if(!$mode||$mode=="prev") {		print "Album\n";		$dh=opendir("photos/nfo");		$file=1;		$i=0;		print "<table class=news><tr>";		while($file) {			  $file=readdir($dh);			  if($file=="."||$file=="..") {				  continue;			  }			  $fp=fopen("photos/nfo/$file", "r");			  while(!feof($fp)) {				$fnfo.=fread($fp,1000);			}			fclose($fp);			$fnfo=explode("|",$fnfo);			if($i<5) {				print "<td><table class=news width=100 height=80><tr><td class=newtitle>".$fnfo[0]."</td></tr>\n";				print "<tr><td><div align=\"center\"><a href="index.php?page=album&mode=see&pict=$fnfo[1]"><img src=\"photos/prev/$fnfo[1]\"></div></td></tr></table></td>  ";			}			else {				print "</tr><tr><table class=news width=100 height=80><tr><td class=newtitle>".$fnfo[0]."</td></tr>\n";				print "<tr><td><div align=\"center\""><a href="index.php?page=album&mode=see&pict=$fnfo[1]"><img src=\"photos/prev/$fnfo[1]\"></a></div></td></tr></table>";				$i=0;			}			$i++;		}		print "</table>";	}?>

And if($mode==see) {
check if file is jpg/bmp/gif etc. file, and than just <img src="photos/<?=$pict;?>">;

As for style, I use my own. Here a part used in album comes:

A:link {	COLOR: #ffffff; FONT-FAMILY: Verdana; TEXT-DECORATION: none;}A:active {	COLOR: #ffffff; FONT-FAMILY: Verdana; TEXT-DECORATION: none;}A:visited {	COLOR: #ffffff; FONT-FAMILY: Verdana; TEXT-DECORATION: none;}A:hover {	color: #faa664; FONT-FAMILY: Verdana; TEXT-DECORATION: none;}body {	scrollbar-face-color : #1D3A46;	scrollbar-shadow-color : #5F5F55;	scrollbar-highlight-color : #5F5F55;	scrollbar-3dlight-color : #B9E6F6;	scrollbar-darkshadow-color : #272A23;	scrollbar-track-color : #1D3A52;	scrollbar-arrow-color : #faa664;	font-family: verdana;	color: #ffffff;	margin-left: 30px;	margin-right: 30px;	margin-top: 1px;	background-color: #1D3A46;}.news {	margin-left: 3px;	margin-top: 3px;	margin-right: 3px;	margin-bottom: 3px;	border: solid white 1px;}.newtitle {	font-family: verdana;	background-color: #256E87;	border-bottom: solid white 1px;	padding: 2px 3px 1px 4px;}.newbody {	font-family: verdana;	font-size: 10pt;	top: 27px;	margin-left: 15px;	padding: 2px;	overflow: auto;	background-color #000000;}.part {	color: #faa664;	font-weight: bold;}Table {	border: solid white 0px;}tr {	border: solid #B9E6F6 1px;}td {	border: solid #B9E6F6 1px;}td.h {	border: solid #B9E6F6 1px;	color: #1D3A46;}

Edited by CrazyPensil (see edit history)

Share this post


Link to post
Share on other sites

An update of the view script:

<?php	$j=0;	$dh=opendir("photos");	while($file=readdir($dh)) {		if($file!="."&&$file!=".."&&$file!="thumbs.db") {			$j++;		}	}	closedir($dh);	print "<table style=\"margin-left: 12px\"><tr>";	print "<td style=\"border: none\"><font class=part>Total photos: $j.</font></td>\n";	if(!$pagenum) {		$pagenum=1;	}	print "<td style=\"border:none\" width=35%><center>\x20</center></td>";	printf("<td style=\"border: none\"><font class=part>Pages: %d of %d.</font></td></tr></table>",$pagenum,$j/15);	print "<center><table class=news>\n";	print "<tr>\n";	$dh=opendir("photos");	$i=0;	while($file=readdir($dh)) {		if($file!="."&&$file!=".."&&$file!="thumbs.db") {			if($i<5) {				print "<td>\n<a href=\"java script:window.open('photos/".$file."'); void 0;\" target=_blank>\n<img border=0 color=#faa664 src=\"photos/$file\" width=100 height=80></a></td>";				$i++;			}			else {				print "</tr><tr><td>\n<a href=\"java script:window.open('photos/".$file."'); void 0;\" target=_blank>\n<img border=0 color=#faa664 src=\"photos/$file\" width=100 height=80></a></td>";				$i=1;			}		}	}	closedir($dh);	print "</tr>\n";	print "</table></center>";?>

Edited by CrazyPensil (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.