line 444 of lib-custom is the beginning of the gallery block coding added to lib-custom and is (from 444 onwards) follows:
<?
/**
* Ver 1.2
* packetmad October 14, 2003 www.lanside.net
*
* Blaine Lang March 21/02 www.langfamily.ca
* Ver 1.1
* This Geeklog PHP function uses the Gallery Random Block code contibuted by Bharat Mediratta - Gallery Developer
*
* The Gallery random photo block will display a random photo from your Gallery in a geeklog block.
* The photo is displayed along with its caption and clicking the photo will take you directly to that photo in the appropriate album.
* This version of the random photo code only displays public photos - for which gallery has granted everyboddy access.
* Once a day it scans all your albums to see which ones are viewable by the general public.
* Then it saves that data and uses it for the rest of the day.
* If you change permissions on an album, add or delete albums the changes won't be reflected right away in the random photo block.
* You must have Gallery v1.2 or better to use this block.
*
* This block will also display the photo caption. This is nice when you add comments as a photo caption
* But if you have not, the block may display the default photo caption which gallery defaulted to which is your digicam IMAGE ID
* I have added a check and exclude these captions. Modify this as required - about halfway down in this function.
*
*/
function phpblock_galleryRandomPhoto() {
global $_CONF, $GALLERY_BASEDIR, $GALLERY_NO_SESSIONS, $gallery;
$GALLERY_NO_SESSIONS=true;
$GALLERY_BASEDIR = "C:/Program Files/Apache Group/Apache2/htdocs/geeklog2/main/gallery/";
define(CACHE_FILE, "C:/Program Files/Apache Group/Apache2/htdocs/geeklog2/main/gallery/block-random.cache"
;
define(CACHE_EXPIRED, 86400);
require_once($GALLERY_BASEDIR ."init.php"
;
include_once($_CONF['path_html'] . "/block-random.php"
;
if ($profile) {
$timer = time();
}
/* Initializing the seed */
srand ((double) microtime() * 1000000);
// Check the cache file to see if it's up to date
$rebuild = 1;
if (fs_file_exists(CACHE_FILE)) {
$stat = fs_stat(CACHE_FILE);
$mtime = $stat[9];
if (time() - $mtime < CACHE_EXPIRED) {
$rebuild = 0;
}
}
if ($rebuild) {
scanAlbums();
saveCache();
} else {
readCache();
}
$album = chooseAlbum();
if ($album) {
$index = choosePhoto($album);
}
if (isset($index)) {
$id = $album->getPhotoId($index);
$retval = ""
."<a href=" .makeAlbumUrl($album->fields["name"], $id) .">"
.$album->getThumbnailTag($index)
."</a>";
$caption = $album->getCaption($index);
// Add any exclusions that you want for captions. I don't always add an caption and Gallery use the default image name
// which I don't want to display. My Cannon digicam uses IMG_XXXX and my Kodak uses DCP_XXXX
if (($caption) AND(!strstr($caption,"IMG_"
) AND (!strstr($caption,"DCP_"
)) {
$retval .= "<br><center>$caption</center>";
} else {
$retval .= "<br>";
}
$retval .= "<br><center>From: "
."<a href=" .makeAlbumUrl($album->fields["name"]) .">"
.$album->fields["title"]
."</a></center>";
} else {
$retval = "No photo chosen.";
}
if ($profile) {
$elapsed = time() - $timer;
$retval .= "<br>Elapsed: $elapsed secs";
}
return $retval;
}
?>
. ' Feed: ' . $A['title'] . '" href="' . $baseurl
. $A['filename'] . '">' . LB;
}
}
}
$header->set_var( 'feed_url', $feed_url );
if( empty( $pagetitle ) && isset( $_CONF['pagetitle'] ))
{
$pagetitle = $_CONF['pagetitle'];
}
if( empty( $pagetitle ))
{
if( empty( $topic ))
{
$pagetitle = $_CONF['site_slogan'];
}
else
{
$pagetitle = stripslashes( DB_getItem( $_TABLES['topics'], 'topic',
"tid = '$topic'" ));
}
}
if( !empty( $pagetitle ))
{
$pagetitle = ' - ' . $pagetitle;
}
$header->set_var( 'page_title', $_CONF['site_name'] . $pagetitle );
if( isset( $_CONF['advanced_editor'] ) && ( $_CONF['advanced_editor'] == 1 )
&& file_exists( $_CONF['path_layout']
. 'advanced_editor_header.thtml' ))
{
$header->set_file( 'editor' , 'advanced_editor_header.thtml'
;
$header->parse( 'advanced_editor', 'editor' );
}
else
{
$header->set_var( 'advanced_editor', '' );
}
$header->set_var( 'background_image', $_CONF['layout_url']
. '/images/bg.' . $_IMAGE_TYPE );
$header->set_var( 'site_url', $_CONF['site_url'] );
$header->set_var( 'layout_url', $_CONF['layout_url'] );
$header->set_var( 'site_mail', "mailto:{$_CONF['site_mail']}" );
$header->set_var( 'site_name', $_CONF['site_name'] );
$header->set_var( 'site_slogan', $_CONF['site_slogan'] );
$rdf = substr_replace( $_CONF['rdf_file'], $_CONF['site_url'], 0,
strlen( $_CONF['path_html'] ) - 1 );
$header->set_var( 'rdf_file', $rdf );
$header->set_var( 'rss_url', $rdf );
$msg = $LANG01[67] . ' ' . $_CONF['site_name'];
if( !empty( $_USER['username'] ))
{
$msg .= ', ' . $_USER['username'];
}