Sigx

We are the future in the past.
It is currently Tue Dec 10, 2019 12:18 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jul 29, 2004 11:48 pm 
Offline

Joined: Mon Apr 05, 2004 8:37 pm
Posts: 335
Location: /home/chair/sitting down/
thanks to PolishPanda for providing me with a link to some code over in this topic: http://forum.yuriy.net/phpbb/viewtopic.php?p=5947 , I have now simplified the process of adding images to the random sigx background thing

here's how I did it (or as best as I can explain)

1) Delete the line that says

Code:
 $backIMG = "something.ext"

where something.ext is an image location

and replace that with

Code:
// Random Skins mod (converted by DarkHorizon)

$folder = "images";
$backIMG = randomimgs($folder);

// End random skins mod


then just change the $folder = "images"; to whatever folder you have your stuff in. Don't worry about adding slashes at the end.

If you want to put the script in the same folder as the images... just change the line to
Code:
 $folder = '.'


2) regardless of what you just did there... go to the very bottom of your script (right before the ?> ) and add an extra line

Paste in the following code in the blank space (next line after the final }, but before the ?>

Code:
function randomimgs($folder=""){

    $extList = array();
    $extList['gif'] = 'image/gif';
    $extList['jpg'] = 'image/jpeg';
    $extList['jpeg'] = 'image/jpeg';
    $extList['png'] = 'image/png';

$img = null;

if (substr($folder,-1) != '/') {
    $folder = $folder.'/';
}

if (isset($_GET['img'])) {
    $imageInfo = pathinfo($_GET['img']);
    if (
        isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
        $img = $folder.$imageInfo['basename'];
    }
} else {
    $fileList = array();
    $handle = opendir($folder);
    while ( false !== ( $file = readdir($handle) ) ) {
        $file_info = pathinfo($file);
        if (
            isset( $extList[ strtolower( $file_info['extension'] ) ] )
        ) {
            $fileList[] = $file;
        }
    }
    closedir($handle);

    if (count($fileList) > 0) {
        $imageNumber = time() % count($fileList);
        $img = $folder.$fileList[$imageNumber];
    }
}

$backIMG = $img;
return $backIMG;
}


and you're done! Hope that was easy enough to understand

_________________
Image
My Site: www.dh5.us
I'll kill you Brian Anderson


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 30, 2004 2:33 am 
Offline

Joined: Mon Jul 26, 2004 4:11 am
Posts: 7
Thank you, I appreciate this a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group