Lunarpages Web Hosting Forum

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

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3050
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #45 on: May 13, 2004, 04:24:55 AM »
Ok, I tried d/ling Danielle's & Ripta's index.php file, but it trying to save as will just save the image file the script is putting out.

I don't know why/how my script isn't working. but if I could compare a working script file to my own perhaps I could figure it out.
O|||||O

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11567
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #46 on: May 13, 2004, 04:32:07 AM »
Yeah, you can't get their index files that way.

I tried the code exactly as you had pasted it, and it works just fine:
http://www.tu2.net/test/avatar/index.php

Do you have the index file in the same folder as the graphics, or was the error message just an example? In the error msg, the index file was in subdir "rand" but your images are in "avatar"

That ascii reference makes me wonder if there was an error in uploading via FTP. Have you been able to upload other php files that worked?
:whip: :love: :whip: :love: :whip: :love:

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3050
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #47 on: May 13, 2004, 04:40:58 AM »
The index file is in the same folder as the images, the images & index file are in the directory /rand.

No, this would be my first php file ever uploaded. I use WS_FTP, should I upload in binary?
O|||||O

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3050
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #48 on: May 13, 2004, 04:43:34 AM »
Bah, I just uploaded in ascii instead of binary, now I'm getting this

Quote
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\sb100\sa100\f0\fs24 \line\line /** \line * Change the following array to an array of extensions: \line * For example, if your images have the extension gif, use: \line * $extensions = array('gif'); \line * If the extensions are gif and jpg, use: \line * $extensions = array('gif', 'jpg'); \line * And so on. Don't forget the ; in the end of the line! \line **/ \line\line $extensions = array('gif', 'jpg'); \line\line\line\line /** \line * This script should function properly without any changes below. \line **/ \line\line $avatars = array(); \line $dh = opendir('.'); \line $regex = '\\.(' . implode('|', $extensions) . ')$'; \line while(($filename = readdir($dh)) !== false) \{ \line if (!eregi($regex, $filename)) continue; \line array_push($avatars, $filename); \line\} \line $file = rand(0, count($avatars) - 1); \line\line $handle = fopen($avatars[$file], "r"); \line $content = ""; \line while(!feof($handle)) $content .= fgets($handle); \line fclose($handle); \line\line echo $content; \line ?>\par \pard\f1\fs20\par }


Err, that was a differently edited file( I tried fixing the problem myself) I uploaded in ascii on the correct file and I still get the same error
O|||||O

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11567
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #49 on: May 13, 2004, 04:51:01 AM »
What did you paste the text to? It looks like a Word or MS-wannabe-html editor. How about just copying and pasting the code to Notepad, save as index.php, and upload via ftp. According to Hush's post, you should use ASCII mode.
:whip: :love: :whip: :love: :whip: :love:

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3050
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #50 on: May 13, 2004, 04:51:44 AM »
:)  :)

All is working now. After seeing
Quote

Times New Roman;}{

In the one error, I guessed it had something to do with wordpad not being written to php, and implementing .doc properties into the file. So I transferred one of my php files over from my forum & just replaced the code with Ripta's.

Works like a charm now  :yey:
O|||||O

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11567
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #51 on: May 13, 2004, 04:57:49 AM »
Ok, when you use Wordpad, make sure to save as text-only. Some people recommend against using wordpad because of the extra properites. However, I prefer the better interface and functionality of WordPad over NotePad. As long as I save as text only, I don't have problems and I don't have the frustrations of working with Notepad.

Glad to know things are working.  :thumb:
:whip: :love: :whip: :love: :whip: :love:

Offline p0tter

  • Village Idiot
  • Quantum Encyclopedia Writer
  • *****
  • Posts: 3050
    • My Pixel Addiction
How to have a random avatar in Lunarforums
« Reply #52 on: May 13, 2004, 05:00:40 AM »
Thanks, me too. I think I'll finally go to sleep now.
(Get stuck on one thing and can't move till I get it figured out)

And thanks for the info on wordpad & notepad, [future reference] now I'll know what to do.
O|||||O

Offline Ripta

  • Master Jedi
  • *****
  • Posts: 1271
How to have a random avatar in Lunarforums
« Reply #53 on: May 13, 2004, 08:19:04 AM »
Additionally, make sure there are NO spaces or newlines before the <? sign or after the ?> in the code.
GetAFreelancer! (This service is not affiliated with Lunarpages)

Offline RPG

  • Pong! (the videogame) Master
  • *****
  • Posts: 21
    • http://www.richgannon.net
How to have a random avatar in Lunarforums
« Reply #54 on: May 13, 2004, 12:27:57 PM »
I still have no luck.  Does it maybe matter on the PHP settings ( heres my PHP info: http://richgannon.net/info.php )?  Any idea what could be casuing this not to work?

And I copied the exact code that Ripta has posted:
Code: [Select]
<?

/**
* 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', 'jpeg');



/**
* 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;
?>


NOTE: I have also tried replacing $dh = opendir('.');  with the full path to directory: $dh = opendir('/homepages/36/d90853950/htdocs/avatar/ '); getting the same output of no images showing up...

Offline TranzNDance

  • Princess of Naboo
  • Berserker Poster
  • *****
  • Posts: 11567
    • Thu Tu's Blog
How to have a random avatar in Lunarforums
« Reply #55 on: May 13, 2004, 12:56:56 PM »
RPG, where did you copy the code? Did you see the problem p0tter had? Could it be related?

I just realized I was talking to 2 different people when I thought it was just one. :oops: That's why I asked p0tter about the 2 different subdirs. Sorry! My brain is fried.
: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 #56 on: May 13, 2004, 01:15:07 PM »
I did see what p0tter had, but it is not related.  The index.php file is parsed correctly, but just for some funny reason does not give me any image, but it seems to be trying to with the red X there.

http://richgannon.net/avatar/

Offline Ripta

  • Master Jedi
  • *****
  • Posts: 1271
How to have a random avatar in Lunarforums
« Reply #57 on: May 14, 2004, 08:22:23 PM »
It seems to be working right now.
GetAFreelancer! (This service is not affiliated with Lunarpages)

Offline RPG

  • Pong! (the videogame) Master
  • *****
  • Posts: 21
    • http://www.richgannon.net
How to have a random avatar in Lunarforums
« Reply #58 on: May 14, 2004, 08:28:20 PM »
If so, then I am at a loss, cause all I see it the red X.

http://richgannon.net/avatar.jpg is exactly what I see when going to the link.

Offline Tracie

  • MR-Disabled
  • Master Jedi
  • *
  • Posts: 1429
How to have a random avatar in Lunarforums
« Reply #59 on: May 14, 2004, 08:39:52 PM »
I see a red x too. Not the answer you want to hear, I know, but at least you know it's not just you.

I'm baffled as to why it's not working though...