Howto Random Images
From LinphaWiki
If you don't save this code into a file in the the linpha directory, you have to edit $linpha_dir variable,
for example $linpha_dir = './linpha';
If you access this file without parameters the random images are taken from all available folders but you can also access this script with the parameter album, for example:
random.php?album=album1
Which, as a result will only show random images from album1
<?php
$linpha_dir = '.';
$number_random_images = 5;
$image_width = 300;
if(!defined('TOP_DIR')) { define('TOP_DIR',$linpha_dir); }
ini_set('include_path', TOP_DIR); // set in include path because in db_connect.php isn't TOP_DIR used to include adodb.inc.php!
include_once(TOP_DIR.'/include/session.php');
if(isset($_GET['album']))
{
$str_where = P.".prev_path = 'albums/".linpha_addslashes($_GET['album'])."'";
}
else
{
$str_where = "1 = 1";
}
$sql = sql_query_str(Array('id','prev_path','filename'),$str_where,$order_by='rand()');
$query = $GLOBALS['db']->SelectLimit($sql,$number_random_images);
while($data = $query->FetchRow())
{
$stage = get_stage_from_prev_path($data[1]);
$albid = get_albid($data[1],$stage);
echo "<a href='".TOP_DIR.'/viewer.php?imgid='.$data[0].'&albid='.$albid.'&stage='.$stage."'>";
echo "<img width='".$image_width."' ' title=\"".$data[1]."/".$data[2]."\" ".
"src='".TOP_DIR."/get_thumbs_on_fly.php?imgid=".$data[0]."&nw=".$image_width.
"&nh=0' border='0' alt='photo'></a> ";
}
?>