[thelist] A tip with PHP

Damien Cola damien.cola at synaptique.co.uk
Tue Jul 17 06:52:29 CDT 2001


Hi, I've just done a little script in PHP and I thought I'd share it with
you to thank you for your previous help:

It's a script that should sit in a folder and be nammed 'index.php'
in this folder you can have as many other HTML files as you want. (be
careful not to have the images in the same folder, create a subfolder)

The script will look up the number of files and will take one at random and
display it. so you can add and remove pages at your will..
for a index.php which has a different face each time !

Hope you like it.

Damien COLA - Synaptique
Synaptique (UK) Ltd.
Eurogate Business Park
TN24 8XW, Ashford, Kent
Tel: +44 (0)870 777 0026
Fax: +44 (0)870 777 0027
http://www.synaptique.co.uk
Offices: Ashford, Brussels, Helsinki
Milan, Montreal, Paris, Rabat, Toulouse

<?php
function listFiles($dir)
{
$x = 0;
if(is_dir($dir))
{
$thisdir = dir($dir);
while($entry=$thisdir->read())
{if(($entry!='.')&&($entry!='..')&&($entry!='index.php') &&
(is_file("$dir$entry"))) {
$result[$x] = $entry; $x++;} }
}
return $result;
}

$d = listFiles("./");
//$d = listFiles(getcwd());

$temp = count($d);

mt_srand ((double) microtime() * 1000000);
$num= (int) mt_rand(0,$temp);
if ($num > 0) $num--;
$fichier = $d[$num];
$page = join ('', file ($fichier));

echo $page;
?>





More information about the thelist mailing list