<?php 
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.2                                            //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002-2004 Gregory DEMAR                  					 //
// http://www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// (http://coppermine.sf.net/team/)                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
// ------------------------------------------------------------------------- //
// Based on a hack from the nuke port for the standalone  version            //
// by gtroll                                                                 //
// modify aid=11                                        						 //
// to fit the album you want to show                                         //
// ------------------------------------------------------------------------- //

define('IN_COPPERMINE', true);

$numberpic=1; // you can change the number of pictures here
global $prefix, $dbi; 
function truncate_string444($str) 
{ 
   $maxlength = 20; // maximum lenght of name in block
    
   if (strlen($str) > $maxlength) 
      return substr($str, 0, $maxlength)." ..."; 
   else 
      return $str; 
} 

$content="<center>"; 
$result = db_query("SELECT count(*) from {$CONFIG['TABLE_PICTURES']} WHERE aid=11", $dbi); 
   $nbEnr = mysql_fetch_array($result); 
   $count = $nbEnr[0]; 
while ($stop<$numberpic) 
{ 
    
   srand(time()+$stop); 
   $random_number = rand(0, $count-1); 
   $result2 = db_query("SELECT pid, aid, filepath, filename  from {$CONFIG['TABLE_PICTURES']} WHERE aid=11 AND approved='YES' LIMIT $random_number,1", $dbi); // aid numbers can be changed as need to respect permissions
  $picture = mysql_fetch_array($result2); 
  
   $img = "<img src=\"albums/{$picture['filepath']}{$picture['filename']}\"  border=\"0\">"; 
   $content .= "<a href=\"displayimage.php?album=11&pos=0\">$img<br></a><br><br>"; 
$stop++; 
} 
$content .= "";
print $content;
?>