What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » rotation of avatars

rotation of avatars
Author: Message:
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. rotation of avatars
i've seen ppls avatars they change every so often and some ppl even had a setup so you could change it,
this is done using php am i right?
can some one show/help me do it, i am willing to try and do want to learn,
but last time i tried to learn php i sorta sucked

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














10-08-2007 03:14 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: rotation of avatars
This is one I knocked up myself...

code:
  $path = "http://mywebsite.com/";
  if($_GET['picture']=="avatar"){
     $av[17] = "avatar17.gif";
     $av[16] = "avatar16.png";
     $av[15] = "avatar15.png";
     $av[14] = "avatar14.png";
     $av[13] = "avatar13.png";
     $av[12] = "avatar12.png";
     $av[11] = "avatar11.png";
     $av[10] = "avatar10.png";
     $av[9] = "avatar9.png";
     $av[8] = "avatar8.png";
     $av[7] = "avatar7.png";
     $av[6] = "avatar6.png";
     $av[5] = "avatar5.png";
     $av[4] = "avatar4.png";
     $av[3] = "avatar3.png";
     $av[2] = "avatar2.png";
     $av[1] = "avatar1.png";
     $av[0] = "avatar0.jpg";
     header("Location: ".$path.$av[rand(0,count($av))]);
  }else if($_GET['picture']=="signature"){
     $sig[0] = "signature0.png";

     header("Location: ".$path.$sig[rand(0,count($sig))]);
  }

<Eljay> "Problems encountered: shit blew up" :zippy:
10-08-2007 03:32 AM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: rotation of avatars
quote:
Originally posted by SpunkyLoveMuff
This is one I knocked up myself...
Bug: count($av) will return 18, but $av[18] doesn't exist. :p

You could simplify things by eliminating the hard-coded array keys and using the array_rand() function...

code:
$path = "http://mywebsite.com/";

$av = array(
    "avatar1.gif",
    "avatar2.jpg",
);

header("Location: " . $path . $av[array_rand($av)]);
10-08-2007 04:19 AM
Profile PM Web Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. RE: rotation of avatars
and on the forum in the avatar text box goes the path of the php file?

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














10-08-2007 04:30 AM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: rotation of avatars
quote:
Originally posted by xen0h
and on the forum in the avatar text box goes the path of the php file?
Yes, that's exactly it.

Also instead of hard-coding the array you could just number the pictures and put them all into the one folder and randomly select out of them....
[Image: markee.png]
10-08-2007 04:37 AM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. RE: rotation of avatars
if the avatar is on for example photobucket do i put the path like this

code:
$av = array(
    "http://photobucket.com/someid/avatar1.gif",
    "avatar2.gif",
    "avatar3.gif",
    "avatar4.gif",
    "avatar5.gif",
    "avatar6.gif",


or do i change this line?
[code]
$path = "http://photobucket.com/myuserid/pics";


thanx for years ago was when i learnt html and 2 years after that i tried a bit of javascript then i tried php and my brain exploded

This post was edited on 10-08-2007 at 04:52 AM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














10-08-2007 04:43 AM
Profile E-Mail PM Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
RE: rotation of avatars
quote:
Originally posted by traxor
Why don't you just use this script:

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]);
?>

Make a folder called "avatar" on your server, for example http://skarz.co.uk/avatar/ then in that folder put that code in a .php file (this is where you will link the image to, ie. http://skarz.co.uk/avatar/random.php will go in the avatar url box in the user cp). The images that you want shown should go in the "imgs" folder: http://skarz.co.uk/avatar/imgs.

I doubt it would be that hard to just make seperate folders for different people. You can't be hosting that many people :p.

10-08-2007 05:51 AM
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