Web Hosting Forum | Lunarpages

Author Topic: How to have a random avatar in Lunarforums  (Read 39786 times)

Offline StephanieŽ

  • Master Jedi
  • *****
  • Posts: 1094
How to have a random avatar in Lunarforums
« Reply #30 on: March 14, 2004, 07:49:28 AM »
Quote

Trey , how's the global domination going?

Resistance is futile   8-)

Danielle

  • Guest
How to have a random avatar in Lunarforums
« Reply #31 on: March 16, 2004, 07:52:48 AM »
Quote from: binary
Just copy the above to a text editor (such as notepad on Windows) and save as index.php. Now open FTP, create a new directory to put this file on your server so that you can access it through the web. Change directory, and upload the index.php you just saved, along with a bunch of gif and/or jpeg images. This script will take all gif/jpeg images in that directory and choose one randomly. It also works with hotlinking on and you don't need to add http://www.lunarforums.com/ to the hotlinking list.

This script's just for fun  :D . Once I get the chance, I might do a script that'll resize stuff. Enjoy!  :thumb:


Hey Ripta, thanks for writing the script and I actually switched over to using it instead.  It has a lot of benefits over the cgi one and this is why I am going to recommend it to people:

1) You can simply place the files in the folder that the index.php script is located in, and you don't have to worry about misspelling the file names, which causes the images not to display sometimes.  Also, any new images simply need to be uploaded and they are automatically available to display; the cgi script required them to be manually typed.
2) Due to it being an index file, you only have to put the folder name for the link (so mine is http://bestgarden.net/Avatar/ for the link)
3) It doesn't have to be in the cgi-bin, so greater flexibility for the script.
3) Heck, it's php and that is so much cooler than cgi/perl anyway.

So, thanks again and hopefully the occasional red x issues with my pics will now disappear forever.  :yey:

Have a Blessed Day

Offline Ripta

  • Master Jedi
  • *****
  • Posts: 1271
How to have a random avatar in Lunarforums
« Reply #32 on: March 28, 2004, 11:38:29 PM »
Woo hoo... my script is Danielle Approved and Recommended :D. *passes out from excitement*.
GetAFreelancer! (This service is not affiliated with Lunarpages)

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #33 on: May 09, 2004, 10:55:10 AM »
Quote from: Ed
Thats an awsome idea! :-) Must confuse alot of people though!

Speaking of confusing people, I've got a bit of a magic trick myself :-)

http://www.jokeawhenever.com/magic

It gets alot of people! :-)


OMG! I tried it 2x and it worked. Freaky. Cool trick.  :yey:
:whip: :love: :whip: :love: :whip: :love:

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #34 on: May 09, 2004, 11:16:50 AM »
Quote from: Ripta
Back to the topic of this thread, I'm using a PHP script I wrote myself.
This script's just for fun :D. Once I get the chance, I might do a script that'll resize stuff. Enjoy! :thumb:


Thanks for sharing your script, Ripta! It worked wonderfully... and was so easy to set up! :yey:
:whip: :love: :whip: :love: :whip: :love:

Offline Ripta

  • Master Jedi
  • *****
  • Posts: 1271
How to have a random avatar in Lunarforums
« Reply #35 on: May 09, 2004, 11:35:47 AM »
Quote from: TranzNDance
Quote from: Ripta
Back to the topic of this thread, I'm using a PHP script I wrote myself.
This script's just for fun :D. Once I get the chance, I might do a script that'll resize stuff. Enjoy! :thumb:


Thanks for sharing your script, Ripta! It worked wonderfully... and was so easy to set up! :yey:


:D Glad you liked it :thumb:
GetAFreelancer! (This service is not affiliated with Lunarpages)

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #36 on: May 09, 2004, 12:59:03 PM »
Quote from: TranzNDance
Quote from: Ed
Thats an awsome idea! :-) Must confuse alot of people though!

Speaking of confusing people, I've got a bit of a magic trick myself :-)

http://www.jokeawhenever.com/magic

It gets alot of people! :-)


OMG! I tried it 2x and it worked. Freaky. Cool trick.  :yey:


awww. I figured it out. It was more fun when I did not know how it worked. I guess the detective in me couldn't accept things at face value.  :| It's still a neat trick. :thumb:
:whip: :love: :whip: :love: :whip: :love:

Danielle

  • Guest
How to have a random avatar in Lunarforums
« Reply #37 on: May 09, 2004, 02:04:53 PM »
Yes, but now the fun comes in showing it to others to see how long it takes them to figure it out ;)

Offline RPG

  • Pong! (the videogame) Master
  • *****
  • Posts: 21
    • http://www.richgannon.net
How to have a random avatar in Lunarforums
« Reply #38 on: May 12, 2004, 05:14:49 PM »
I don't know if it's my stupidty, or what, but the script does not work for me neither on my personal development server or on the webserver

All I get is the all too well known red X.  I uploaded like 5 pictures with jpg and gif extensions, and notta.
http://www.richgannon.net/avatar/

Do the images need special names or am I missing something or what?

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #39 on: May 12, 2004, 05:21:34 PM »
Are the images in the same folder as the index file? They don't need special names, unless they have non-standard names.
:whip: :love: :whip: :love: :whip: :love:

Offline RPG

  • Pong! (the videogame) Master
  • *****
  • Posts: 21
    • http://www.richgannon.net
How to have a random avatar in Lunarforums
« Reply #40 on: May 12, 2004, 05:38:10 PM »
I have 4 images uploaded to the same directory as the index file.

ava1.gif
ava2.jpg
ava3.jpg
ava4.jpg

Are these non-standard names?

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #41 on: May 12, 2004, 05:45:20 PM »
Those seem like reasonable names. Do those images work anywhere else? I was thinking hotlink protection would interfere with them working in these forums, but those images don't show up on your own domain in that folder. :?
:whip: :love: :whip: :love: :whip: :love:

Offline RPG

  • Pong! (the videogame) Master
  • *****
  • Posts: 21
    • http://www.richgannon.net

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11607
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #43 on: May 12, 2004, 06:18:05 PM »
Did you edit the code? Have you tried starting over? Copy the code to a new file, name it index.php? I know you already have one, but it doesn't seem to be working.
:whip: :love: :whip: :love: :whip: :love:

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3084
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #44 on: May 13, 2004, 03:45:57 AM »
I keep getting this error

Quote

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /public_html/rand/index.php on line 2

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /public_html/rand/index.php on line 2

Parse error: parse error in /public_html/rand/index.php on line 2


This is my exact coding from the index file.
Quote

<?

/**
* Change the following array to an array of extensions:
* For example, if your images have the extension gif, use:
* $extensions = array('gif');
* If the extensions are gif and jpg, use:
* $extensions = array('gif', 'jpg');
* And so on. Don't forget the ; in the end of the line!
**/

$extensions = array('gif', 'jpg');



/**
* This script should function properly without any changes below.
**/

$avatars = array();
$dh = opendir('.');
$regex = '\.(' . implode('|', $extensions) . ')$';
while(($filename = readdir($dh)) !== false) {
if (!eregi($regex, $filename)) continue;
array_push($avatars, $filename);
}
$file = rand(0, count($avatars) - 1);

$handle = fopen($avatars[$file], "r");
$content = "";
while(!feof($handle)) $content .= fgets($handle);
fclose($handle);

echo $content;
?>


??? :?
O|||||O

 

Share |