41 lines
991 B
PHP
41 lines
991 B
PHP
|
<?php
|
||
|
// plante la graine...
|
||
|
@mt_srand ((double) microtime() * 1000000);
|
||
|
|
||
|
function RandomColors()
|
||
|
{
|
||
|
$colors = array("ccccff","cceecc","ffcccc","eeccee","ffccff","cceeee","cceeff");
|
||
|
$color[0] = $color[1] = "000000";
|
||
|
|
||
|
while ($color[0] == $color[1])
|
||
|
{
|
||
|
$color[0] = $colors[mt_rand(0, count($colors)-1)];
|
||
|
$color[1] = $colors[mt_rand(0, count($colors)-1)];
|
||
|
}
|
||
|
|
||
|
@array_splice($colors,0);
|
||
|
|
||
|
return $color;
|
||
|
}
|
||
|
|
||
|
function RandomFile($dirname)
|
||
|
{
|
||
|
$i = 0;
|
||
|
$d = opendir($dirname);
|
||
|
|
||
|
while (false!==($rfile = readdir($d)))
|
||
|
if (($rfile[0] != ".") && is_file($dirname."/".$rfile))
|
||
|
$listfiles[++$i] = $rfile;
|
||
|
closedir($d);
|
||
|
|
||
|
if (count($listfiles) > 1)
|
||
|
$rfile = $listfiles[mt_rand(1, count($listfiles))];
|
||
|
else
|
||
|
$rfile =$listfiles[1];
|
||
|
|
||
|
@array_splice($listfiles,0);
|
||
|
|
||
|
return $rfile;
|
||
|
}
|
||
|
|
||
|
?>
|