PHP Web Host - Quality Web Hosting For All PHP Applications Just Great Software
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
j4rdin
Regular
Regular


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

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

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 to the forums!

* 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: 15221
Location: Kansas

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

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 Visit poster's website AIM Address Yahoo Messenger
j4rdin
Regular
Regular


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

PostPosted: Mon May 05, 2008 11:27 am Reply with quote Back to top

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
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2008 by Raven
Proud to be listed at Lobo Links Web Directory

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::

:: fisubice Theme Recoded To 100% W3C CSS & HTML 4.01 Transitional Compliance by Raven and 64bitguy ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum