PDA

View Full Version : Random Profile Picture


xgromx
03-26-2010, 11:27 PM
I am wanting to setup a random profile picture to show on the page when the page is loaded. How can I access the photos of the users that have a photo set?

Or has some one else set this up and has similar code that i could start with?

I am working with a 3.6 vB Board.

xgromx
03-29-2010, 01:05 AM
no one?

Kaasie
04-07-2010, 03:30 AM
Assuming you are using vbadvanced and you want it to use in a module..
Make a PHP module for vbadvanced using the following code

else

delete the footer for eval template, save as a phpfile index.php and place this in the directory with pictures and call it from the template mentioned below then iframe to the index.php file

<?php

#$imagedir is the directory that holds your images.
#Be SURE to include the trailing slash in the name.
$imagedir = "../../images/chicks/";
################################################## #######
#Editing below is not required. #
################################################## #######
$images = array();
#Locate and all of the existing images
$directory = opendir($imagedir);
while($filename = readdir($directory)){
if(strlen($filename) > 2){ #ignore . and ..
$localext = substr($filename, -3);
if(!((strcasecmp($localext, "gif") == 0) || (strcasecmp($localext, "jpg") == 0) || (strcasecmp($localext, "bmp") == 0) || (strcasecmp($localext, "png") == 0)))
continue;
array_push($images, $filename);
}
}
#choose a random image from the array
srand((double)microtime() * 1000000);
$selection = $images[rand(0, sizeof($images)-1)];
#display the image
echo "<img src=\"$imagedir$selection \" alt=\"$selection (" . filesize("$imagedir/$selection") . " bytes)\">";



eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_randomchickblock') . '";');
?>
This one works with .bmp,.gif,.jpg and png files

Make sure that you use the correct path and at the bottom of this script we call a template 'adv_portal_randomchickblock' but you can use whatever name you like ofcourse..


I had this running on several sites for years


good luck