PDA

View Full Version : Random avator for a specific user


Thomas Heretic
07-05-2004, 10:00 PM
I use this for changing a specific user. It goes in functions_showthread.php after line.
}
else
{
$avatarurl = '';
}

}

if ($post['userid']==##) {

header("Expires: " . gmdate("D, d M Y H:i:s",time()) . "GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s",time()) . "GMT");
if ($dir = @opendir('{full directory path}')) {
$filecount=0;
while (($file = readdir($dir)) !== false) {
if ($file != ".." && $file != ".") {
$filelist[] = $file;
$filecount++; //Keep track of the total number of files.

}
}
closedir($dir);
}
mt_srand ((double) microtime() * 1000000);

$filebreak = rand(1,$filecount);
$filecount2=0;


while (list ($key, $val) = each ($filelist)) {
$val;
$filecount2++;
if ($filebreak==$filecount2) {
$avatarurl = '{relative path}'.$val;
}
}



}


Does anybody else do something similiar or have a better way to do it?

Gaffer
07-06-2004, 04:46 PM
i can't tell just yet cause i've not installed it (plus i'm tired as) but i made a random avatar for vb2..... i'd have trandscribed it to vb3 but i've been to busy to do it.

so if i can't find the time to convert it i might just use yours.....

RixiuS
07-06-2004, 06:45 PM
i can't tell just yet cause i've not installed it (plus i'm tired as) but i made a random avatar for vb2..... i'd have trandscribed it to vb3 but i've been to busy to do it.

so if i can't find the time to convert it i might just use yours.....
I used to just do this with template modifications, to give people with no avatar, a random one.

Thomas Heretic
07-06-2004, 07:08 PM
I used to just do this with template modifications, to give people with no avatar, a random one.

How did you do it with pure template modification?
One of the things I like with this is it reads the file list so it you don't need to change anything to add new files and they don't need to be named anything special. It also is random per post.

To see a specific example go Here* (http://www.nothingland.com/showthread.php?t=3418) Look at the user Squirrel Nutkin.

*There is swearing in that thread.

Bad Bunny
07-07-2004, 03:06 AM
How did you do it with pure template modification?
One of the things I like with this is it reads the file list so it you don't need to change anything to add new files and they don't need to be named anything special. It also is random per post.

To see a specific example go Here* (http://www.nothingland.com/showthread.php?t=3418) Look at the user Squirrel Nutkin.

*There is swearing in that thread.
I gotta say...it didn't seem like all that special at first, but knowing it works for a random pic for each post in the same thread...well, that is cool!

Gaffer
07-07-2004, 04:56 PM
thought it would be similar to the one i did.... mine was Java script though.....

looks like i don't need to remake it then.... thanks tom.... *wishes weekend would hurry up so it can be installed.*

rinkrat
07-20-2004, 05:30 PM
This would be good for a certain usergroup so I could give it to usenet posts. How can I limit it to one usergroup?

Thomas Heretic
07-20-2004, 05:50 PM
This would be good for a certain usergroup so I could give it to usenet posts. How can I limit it to one usergroup?

Change ($post['userid']==##) to ($post['displaygroupid'] = ##)

Where ## is the usergroup id that you want to target.

Berethorn
01-31-2005, 12:19 AM
Hmm.I'm having a problem...in a thread it says:

Warning: Variable passed to each() is not an array or object in /home/bere/public_html/forum/includes/functions_showthread.php on line 430