The gallery block code that I am using on this site -
www.ukmartin.com/phpbb2 is this:
<?php
//
// Change the path to the location of your config.inc.php file
// example this is how my system is setup for the file structure
// /public_html/scripts/cpg131/include/config.inc.php
// the gallery_block.php is located in ths scripts directory
// if you place the script in the Copermine directory the line would look like this
// include ('include/config.inc.php');
// Hope this helps you out with the file name
include ('/home/i-know-where/config.inc.php');
//
//***Enter Path information here***
//***absolute path to main coppermine directory***
// *** example
// ***
http://www.yourdomain.com/scripts/cpg131/index.php is how you start your Photo Gallery
// ** then toy would put the folowinf in here /scripts/cpg131
//
$copperminepath = '
http://www.ukmartin.com/gallery'; //***YOU MUST CHANGE THIS***
//
// Set center Var
// Set Display Album Name above Photo
// 0 = no
// 1 = yes
//
$centvar = "1"; // This Variable sets the photo to Center
$albname = "0"; // This Variable sets the Album Name to appear above the Photo
//
// 0 = random album (this will only display albums that are viewable to the Everybody (Public Photo's)
// 1 = Random Pictures (This will display any file that has been approved Private or Public)
//
$allphoto = "0"; // This Variable set to choose Random Albmus or just Random Pictures
//
// This is to set the Visiabilty for the albums
// 0 = Public Albums
// 2 = Registered Users album
//
$viz = "0";
//
// *************************************************************************
// DO NOT CHANGE ANYTHING BELOW THOS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
// *************************************************************************
//
//
// This sets variables from the config.inc.php file
//
$dbalbum = "albums";
$dbpictures = "pictures";
$cpgver_album = $CONFIG['TABLE_PREFIX'].$dbalbum ;
$cpgver_pictures = $CONFIG['TABLE_PREFIX'].$dbpictures ;
$host = $CONFIG['dbserver'];
$username = $CONFIG['dbuser'];
$userpass = $CONFIG['dbpass'];
$cpgdb = $CONFIG['dbname'];
//
//This connects to the mysql DB
//***change username and password below***
//
$MZrandompic = @mysql_connect("$host", "$username", "$userpass"); //***YOU MUST CHANGE THIS***
if (!$MZrandompic) {
echo( '<p>Unable to connect to the ' .
'database server at this time.</p>' );
exit();
}
//
//select photo DB
//
if (! @mysql_select_db("$cpgdb") ) {
die( '<p>Unable to locate the picture ' .
'database at this time.</p>' );
}
//
// Select Databases to use
//
if ($allphoto == "0") {
$query1 = "SELECT * FROM .$cpgver_album WHERE visibility = '$viz' ORDER BY RAND() LIMIT 0,1";
$result1 = mysql_query($query1) or die("Query failed : " . mysql_error());
//
// Assign Var from sql data base's
//
while ($newarray = mysql_fetch_array($result1)) {
$aid = $newarray['aid'];
$title = $newarray['title'];
if ($centvar == "1") echo ("<center>");
if ($albname == "1") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>$title </a><br>");
if ($centvar == "1") echo ("</center>");
}
}
}
if ($allphoto == "0") {
$query2 = "SELECT * FROM .$cpgver_pictures WHERE aid = '$aid' ORDER BY RAND() LIMIT 0,1";
$result2 = mysql_query($query2) or die("Query failed : " . mysql_error());
}
if ($allphoto == "1") {
$query2 = "SELECT * FROM .$cpgver_pictures WHERE approved = 'YES' ORDER BY RAND() LIMIT 0,1";
$result2 = mysql_query($query2) or die("Query failed : " . mysql_error());
}
while ($newarray1 = mysql_fetch_array($result2)) {
$filepath = $newarray1['filepath'];
$filename = $newarray1['filename'];
if ($centvar == "1") echo ("<center>");
if ($allphoto == "0") {
echo ("<a target '_blank' href= '$copperminepath/thumbnails.php?album=$aid'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
} else {
echo ("<a target '_blank' href= '$copperminepath/index.php'>");
echo ("<img border='0' src= '$copperminepath/albums/$filepath/thumb_$filename' > </a>");
}
if ($centvar == "1") echo ("</center>");
}
?>
A question in two parts follows from this:
1) Coppermine (in ../gallery ) has some multimedia files on display. These pose the gallery block a problem with displaying the thumbnails. Can the script introduce a filter to search for JPG files only?
2) How can the gallery block be set to look for the latest (as opposed to random) JPG photos posted to the gallery?
Thanks in advance
Martin