|
|
How Can I Make A PHP-based Web Gallery | ||
Discussion by killingjoke with 4 Replies.
Last Update: March 21, 2006, 8:38 am | |||
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>
CODE
<?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>
Tue Feb 28, 2006 Reply New Discussion
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.sf.net/
4images www.4images.de
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.sf.net/
4images www.4images.de
Sat Mar 4, 2006 Reply New Discussion
I also used 2b-gal, really simple to install, programs almost as clear as you want. Look here :
http://www.ben3w.com/multimedia/devphp_2bgal.php
Yordan
http://www.ben3w.com/multimedia/devphp_2bgal.php
Yordan
Sat Mar 4, 2006 Reply New Discussion
I'd like to advice you such a one:
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:
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;
}
CODE
<?phpError_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:
CODE
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;
}
Sat Mar 18, 2006 Reply New Discussion
An update of the view script:
$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>";
?>
CODE
<?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>";
?>
Tue Mar 21, 2006 Reply New Discussion
Using PHP: Do I Need To Download It? (13)
|
(8) PHP: How Can I Create An Authentication System?
|
Index




