Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
j4rdin
Worker
Worker


Joined: May 26, 2006
Posts: 153
Location: West Sussex - UK

PostPosted: Sun May 04, 2008 10:54 am Reply with quote

I have found this random image script on the web to display random images from a directory list. In the past I used Gallery but after my web host changed security settings t didn't work and I needed something else.

I have two questions, is the block ok to use with RN2.20.01 or does it need more mods to make it safe. Also as it is written when it load a flash file, it doesn't seem to recognise the size and cuts of the bottom of the image, seems ok with gif and jpeg images. I have made some changes already so that it will work in a block.

This is the code:

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: Only registered users can see links on this board! Get registered or login!
* 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)

?>
 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Sun May 04, 2008 11:08 pm Reply with quote

I would recommend changing this line

FROM:
$filelist[] = $file;

TO:
$filelist[] = basename($file);

Other than that it looks ok to me Smile
 
View user's profile Send private message
j4rdin
PostPosted: Mon May 05, 2008 11:27 am Reply with quote

Raven wrote:
I would recommend changing this line

FROM:
$filelist[] = $file;

TO:
$filelist[] = basename($file);

Other than that it looks OK to me Smile


Hi Raven, have made the changes above and tried running the block for Admins only.
Seems to load the images OK, centered in the block including Flash.

The block is on the home page. Sometimes it loads OK, most times the block loads OK, but the page doesn't finish loading. I'm running Shoutbox and the NukeSentinel scrolling side box, which work OK together normally but hang when the page doesn't load.

Any ideas?

-----------------------------------------------------------------------
UPDATED:

Ok have tried again and it looks like my web host must have been updating the server or something when I was testing the block. Checked today and seems to be loading Ok in both IE and FF.

Thanks

John Evil or Very Mad
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©