What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Random Image Script (Not KSMAS)

Random Image Script (Not KSMAS)
Author: Message:
user27089
Disabled Account


Posts: 6321
Joined: Nov 2003
Status: Away
O.P. Random Image Script (Not KSMAS)
i've been having a lot of trouble lately with the fact that my server doesn't seem to support KSMAS very well, so I was wondering if there were any other free random image scripts out there that I could 'have'... ?
01-19-2005 09:31 PM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: Random Image Script (Not KSMAS)
Heres the one i coded myself for my avatar.
code:
<?php
$dir = "imgs";
$dh = opendir($dir);
$files = array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
array_splice($files, 0, 2);
$filesnum = count($files);
srand( (double) microtime()*1000000 );
$randnum = rand(0, $filesnum - 1);
readfile($dir . "/" . $files[$randnum]);
?>
It basically randomly pics a file from the imgs folder and uses that as the image.
Note: The file structure has to be
avatar.php
imgs/
and dont stick anyother files in the imgs folder, as it uses them all.

This post was edited on 01-20-2005 at 06:45 PM by Plik.
01-19-2005 09:34 PM
Profile PM Find Quote Report
user27089
Disabled Account


Posts: 6321
Joined: Nov 2003
Status: Away
O.P. RE: Random Image Script (Not KSMAS)
Thanks a lot :p...
01-19-2005 09:37 PM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: Random Image Script (Not KSMAS)
Erm apparently theres a security hole in it, ive edited the post with the updated code, that *should* fix the hole
01-20-2005 06:43 PM
Profile PM Find Quote Report
fluffy_lobster
Veteran Member
*****

Avatar
Posts: -2

Posts: 1391
Reputation: 23
36 / Male / Flag
Joined: Nov 2002
RE: Random Image Script (Not KSMAS)
Indeed, nice and secure now :)

Personally, I think it's neater to pick the random image like this though:

code:
<?php
$dir = "imgs";
$dh = opendir($dir);
$files = array();
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
array_splice($files, 0, 2);
srand( (double) microtime()*1000000 );
$key = array_rand($files);
readfile($dir . "/" . $files[$key]);
?>

This post was edited on 01-20-2005 at 06:54 PM by fluffy_lobster.
01-20-2005 06:47 PM
Profile E-Mail PM Web Find Quote Report
user27089
Disabled Account


Posts: 6321
Joined: Nov 2003
Status: Away
O.P. RE: Random Image Script (Not KSMAS)
you could find such things as passwords by adding things like /.. on it :p... lol
01-20-2005 09:34 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On