Some time ago, with an earlier coppermine version, I used the code below to display random images of my gallery on my website:
http://www.dophan.com (http://www.dophan.com)
// this was found in coppermine forum at http://coppermine.sourceforge.net/board/index.php?topic=1196.msg6902#msg6902
//***Enter Path information here*** 
//***absolute path to main coppermine directory*** 
$copperminepath = 'path';  //***YOU MUST CHANGE THIS*** 
//This connects to the mysql DB 
//***change username and password below*** 
$MZrandompic = @mysql_connect('XXXX', 'XXXX', 'XXXX'); //***YOU MUST CHANGE THIS*** 
if (!$MZrandompic) {  
echo( '<p>Unable to connect to the ' .  
'database server at this time.</p>' );  
exit();  
}  
//select photo DB 
//***YOU MUST CHANGE THIS*** 
if (! @mysql_select_db('XXXX') ) { 
die( '<p>Unable to locate the picture ' .  
'database at this time.</p>' );  
}  
//This gets a random picture record from the database and 
//the picture's location and displays it 
$MZresult = @mysql_query("SELECT * FROM cpg11d_pictures ORDER BY RAND() LIMIT 0,4");  
if (!$MZresult) {  
die('<p>Error performing query: ' . mysql_error() .  
'</p>');  
}  
while ( $MZrow = mysql_fetch_array($MZresult) ) {  
// $albumid = $MZrow['aid'];  //This gets the picture's associated album name 
$pos = $MZrow['pid'];      //This finds the picture's coppermine location 
// echo('<P ALIGN=center>');  
//old: target opens in new window
//echo('<a target = "_new" href="' . $copperminepath . '/displayimage.php?album=' . $albumid .  
//'&pos=-' . $pos . '">'); //make thumbnail clickable 
//new: target opens in same window
echo('<a href="' . $copperminepath . '/displayimage.php?album=' . $albumid .  
'&pos=-' . $pos . '">'); //make thumbnail clickable 
echo('<IMG SRC="' . $copperminepath . '/albums/');           //append base dir structure 
echo($MZrow['filepath'].thumb_.$MZrow['filename'] . 
     '" alt=' . $MZrow['filename'] . ' '. 'border=0 height=100>' . '</a>   '); //outputs path from /userspics 
}  
//This displays the picture's album name and 
//links it to the coppermine album 
$MZalbumresult = @mysql_query("SELECT * FROM cpg11d_albums WHERE aid = '$albumid'");  
if (!$MZalbumresult) {  
die('<p>Error performing query: ' . mysql_error() .  
'</p>');  
}  
while ( $MZalbumname = mysql_fetch_array($MZalbumresult) ) {  
echo('<FONT SIZE=1>'); 
echo('<P ALIGN=center>');  
echo('<a href="' . $copperminepath .  
'/thumbnails.php?album=' . $albumid . '">' .  
$MZalbumname['title'] . '</a>' . '</p>');  
}  
if (! @mysql_select_db('XXXX') ) {  
die( '<p>Unable to reload the main website ' .  
'database at this time.</p>' );  
}  
?>  
It's been working every until now. But after upgrading to CPG 4.1.3 I have the following question/issues:
1) Will the code above show pictures from albums which are password protected (new feature in CPG 4.1.3).
If yes, how can I prevent this?
2) How could I force image displayed to be only from my own albums (not from user gallery albums)
3) How can I choose only particular albums to be used in the random function?
Thanks
			
			
			
				use cpmFetch: http://forum.coppermine-gallery.net/index.php?board=57.0