It shows that you are unregistered. Please register with us by clicking Here
![]() |
|
![]() |
![]() | Register - FAQ - Today's Posts - New Posts - Support - Search | ![]() |
|
|
#1 (permalink) | |
|
Posts: n/a
|
this is a very simple php randome image viewer
it all works and i hope you can understand it it is so simple you should be troubled _________________________________________________ Quote:
|
|
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
|
Hey
Nice Script. Would you mind making it a teeny bit more accessible in its output. Remove the border="0" attribute, ad an alt attribute and close the <img/> tag. The it will be perfect Jamie
__________________
|
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Join Date: Jul 2006
Age: 20
Posts: 24
|
I have a few suggestions as well.
0) Use code tags instead of quote tags. =) 1) It's no longer needed to seed the random functions, so the srand() call it a waste of resources. 2) Perhaps create the image array dynamically by listing all files in a directory, this would be much more newbie friendly than having a user edit the file. php.net/glob will be perfect for that.
__________________
http://dndesign.dk/seph/sig.png |
|
|
|
|
|
#4 (permalink) |
|
Posts: n/a
|
ok notes take but hear me out
1: it is supposed to be fore the simple minded 2: it works fine as it is 3: i wrote it nearly 2 years ago 4: if you want it take it use and and adapt it just let me know if you use it and i will be greatful |
|
|
|
#6 (permalink) |
|
Senior Member
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
|
Code:
<?
function GetFiles($sdir){
$files = array();
$dir = opendir($sdir);
while(($myfile = readdir($dir)) !== false){
if($myfile != '.' & $myfile != '..' & is_file($sdir."/".$myfile)){
$files[] = $myfile;
}else if($myfile != '.' & $myfile != '..' & is_dir($sdir."/".$myfile)){
$filearr = GetFiles($sdir."/".$myfile);
for($i=0;$i<count($filearr);$i++){
$files[] = $sdir."/".$myfile."/".$filearr[$i];
}
}
}
closedir($dir);
return $files;
}
$Files = GetFiles(".");
for($i=0;$i<count($Files);$i++){
echo $Files[$i]."<br/>";
}
?>
Jamie
__________________
|
|
|
|
|
|
#7 (permalink) |
|
Junior Member
Join Date: Jul 2006
Age: 20
Posts: 24
|
Seems like an awful lot of code for such a simple task, perhaps http://www.php.net/glob could shorten it a bit. But hey, if it works then it works. =)
__________________
http://dndesign.dk/seph/sig.png |
|
|
|
|
|
#8 (permalink) |
|
Senior Member
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
|
The actual amount of is quite small, glob() could make it shorter I think if you were looking for a specific file type/name. My function just returns the entire contents of the directory including the contents of sub directories.
oh: ta for the glob tip never heard of it before. Jamie
__________________
|
|
|
|
|
|
#9 (permalink) |
|
Junior Member
|
make a file named image.txt and put links like this
::<img scr="http://abhisar.wen.ru/logo.gif" alt="logo"/> ::<img scr="http://krapwap.com/logo.gif" alt="logo"/> now on page where you want to display random image insert the code <? $xfile = @file("image.txt"); $random_num = rand (0,count($xfile)-1); $udata = explode("::",$xfile[$random_num]); echo $udata[1]; //a random image from the text file will be displayed ?>
__________________
SIMPLY THE BEST |
|
|
|
|
|
#10 (permalink) | |
|
Senior Member
Join Date: Jul 2006
Location: Swansea, Wales, UK
Age: 20
Posts: 239
|
Quote:
Jamie
__________________
|
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| random sig | tomtom111 | Graphics & Multimedia | 4 | 05-12-2006 09:21 PM |
| Random Stuff | Shock v2.0 | Graphics & Multimedia | 2 | 09-27-2005 10:47 AM |
| Random Avatar | threemad3 | Graphics & Multimedia | 7 | 09-10-2005 06:43 AM |
| Buy This Really Random Avator! | Frozen | Buy, Sell or Trade | 1 | 06-08-2005 08:37 AM |