n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/include/random.inc.php

43 lines
993 B
PHP
Raw Normal View History

2023-04-30 21:28:42 +02:00
<?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;
}
?>