| Code: |
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
//***************EDIT FROM HERE*********************
//Any directory name should end by the trailing "/"
$your_dirname="images/randomimage/";//replace the "images/" by the name
// of the directory where you image files are placed, note that the trailing "/" is mandatory
//You can change this if you want but it is not mendatory
$your_alt_tag="random image and Flash movies";// You may change this line
//
/*
********************* STOP EDITING HERE ***********************************
*
* aaPHPrandomImage, version 1.1.2.1
* November 2002, Arcadius Ahouansou.
* for any comment or suggestion please email me at:
* A simple function for displaying random images and flash movies.
* a working demo of this script is running at:
* http://ahouans.sh.cvut.cz/projects/aaPHPrandomImage/
*
*10-JAN-2003: Little bug fix... on a solaris box running PHP4.06, the script displays
*always the same file... to fix this mt_rand() is dropped... rand() is used instead
*
*30-NOV-2002: New release:
*Bug fix: PHP till today doesn't "see" the Flash MX file as a swf file
*(it doean't assign the value 4 to $imageSize[2] ) a workaround have been found
*Thanks to the report submitted by Yuri K. Stembera <ug_nikon@ugleague.com>
*
*08-NOV-2002: FOr gererating random number, the script now use mt_rand() instead of rand()...
* and the script check whether there is any file in the image directory before generating the
* random images... so if there is no image, it will print out an error message
*
*
*15-OCT-2002: Bug fix: On some server, "Warning: stat failed for (errno=2 - No such file or directory)"
*This have been fixed using @is_dir() instead of is_dir [Thanks to Ben Weinberger, Digitalsmith.com]
*
* First release in July 2002.
*/
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
function displayAaPHPrandomImage($dirname, $alt){
$dirhandle = opendir($dirname);
while (false !== ($file = readdir($dirhandle))) {
if ($file != "." && $file != ".." && !@is_dir($file) ) {
$filelist[] = $file;
}
}
closedir($dirhandle);
if(sizeof($filelist) ==0) {
echo "No file was found in the directory!";
exit;
}
srand((double)microtime()*1000000);
$picnum = @rand(0, sizeof($filelist) - 1);
$imageName=$dirname.$filelist[$picnum];
$imageSize = getimagesize($imageName);
if($imageSize[2]==4 || eregi(".swf$", $imageName) ) {
$result="\n<center><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" ".$imageSize[3]."></center>";
$result .="\n<center><param name=\"movie\" value=\"".$imageName ."\"></center>";
$result .="\n<center><param name=\"quality\" value=\"high\"></center>";
$result .="\n<center><embed src=\"".$imageName ."\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" ".$imageSize[3]. "></embed></object></center>";
} else $result="\n<center><img src=\"".$imageName ."\" ". $imageSize[3] ."alt=\"". $alt. "\"></center>";
return $result;
}
$content .=displayAaPHPrandomImage($your_dirname, $your_alt_tag)
?> |