Post by MarvinRules on Jun 19, 2005 12:22:50 GMT -8
Random Image
This requires a hosting service that supports PHP scripts. RipWay is a good free service that works with this.
Change this to the directory of your images. (DO not use the same directory that the index.php file is in)
This is the name of the PHP file itself.
All you need to do then place the URL to the PHP file in where you want the random image to be displayed. Place a bunch of images in your image directory, (Try to keep them all the same size if using for avatar or the like).
File Name "index.php"
PBV4 Update!
The above code is not compatable with ProBoards V4. But with a few modifications you can get this to work with PBV4!
Modification #1:
You need a webhost that supports .HTACCESS files.
In the directory you have placed the above .PHP file you need to place a file that is called .HTACCESS. (This file is really a TXT file but without the .TXT at the end)
This file should contain the following:
Modification #2:
Rename index.php to index.gif
Now you just link to the index.gif the same way as the original instructions say to link to index.php.
OR all you have to do is put the index.php in a directory that ends in .GIF, .PNG, or .JJPG:
avatar.jpg\index.php
Then you do not need the HTACCESS file.
This requires a hosting service that supports PHP scripts. RipWay is a good free service that works with this.
Change this to the directory of your images. (DO not use the same directory that the index.php file is in)
This is the name of the PHP file itself.
All you need to do then place the URL to the PHP file in where you want the random image to be displayed. Place a bunch of images in your image directory, (Try to keep them all the same size if using for avatar or the like).
File Name "index.php"
<?php
$dir = "pics/";
$dh = opendir("$dir");
while (false !== ($file = readdir($dh)))
{
if (preg_match(('/\.gif/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
elseif(preg_match(('/\.jpg/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
elseif(preg_match(('/\.png/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
}
srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);
header("Location: " . $filelist[$picnum]);
closedir($dh);
?>
$dir = "pics/";
$dh = opendir("$dir");
while (false !== ($file = readdir($dh)))
{
if (preg_match(('/\.gif/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
elseif(preg_match(('/\.jpg/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
elseif(preg_match(('/\.png/i'), $file) and $file != "index.php")
{
$filelist[] = "$dir$file";
}
}
srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);
header("Location: " . $filelist[$picnum]);
closedir($dh);
?>
PBV4 Update!
The above code is not compatable with ProBoards V4. But with a few modifications you can get this to work with PBV4!
Modification #1:
You need a webhost that supports .HTACCESS files.
In the directory you have placed the above .PHP file you need to place a file that is called .HTACCESS. (This file is really a TXT file but without the .TXT at the end)
This file should contain the following:
AddType application/x-httpd-php .gif
Modification #2:
Rename index.php to index.gif
Now you just link to the index.gif the same way as the original instructions say to link to index.php.
OR all you have to do is put the index.php in a directory that ends in .GIF, .PNG, or .JJPG:
avatar.jpg\index.php
Then you do not need the HTACCESS file.