Re: (help)random image??

From: Date: Fri, 22 Mar 2002 06:07:40 +0000
Subject: Re: (help)random image??
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-12726@lists.php.net to get a copy of this message
I actually just hacked one up. This hooks into a Gallery (gallery.sourceforge.org) album directory and picks out files with the string, "sized", in their filenames. It then creates an array such that the more recent pictures get more entries in the array which means when I pick a random image I am more likely to see a recent image. <? $base = '/some/dir/albums/name'; $dir = opendir($base); $chance=0; $i=0; while($entry=readdir($dir)) { if(strstr($entry,'sized')) { if(!($i%3)) $chance++; for($j=0; $j<$chance; $j++) { $pics[]=$entry; } $i++; } } closedir($dir); $max = count($pics); $val = rand(0,$max-1); Header("Content-Type: image/jpeg"); $size = filesize($base.'/'.$pics[$val]); Header("Content-Length: $size"); Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); Header("Pragma: no-cache"); readfile($base.'/'.$pics[$val]); ?> On Thu, 14 Mar 2002, KONUS wrote: > I was wondering is there a way to generate image random with php? > I need it...I am new to php, all i can do is only basic of php. > I also using MySQL for the database system. > > Is there a site who explaining about this? > or someone know how to make the script? > > Thank's > > --Zeus-- > > Mutimedia staf of NGO KONUS, > www.konus.or.id >

« previous php.windows (#12726) next »