Web Hosting Forum | Lunarpages

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

Offline S.R.U.

  • LP LOVER!
  • Pong! (the videogame) Master
  • *****
  • Posts: 21
How to have a random avatar in Lunarforums
« Reply #120 on: May 10, 2005, 05:59:28 AM »
i did that with my sig:

well the url shows http://www.srudesigns.com/sig.jpg but atually the url is http://www.srudesigns.com/sig.jpg/index.php
so sig.jpg is the name of the folder

Offline Rowan

  • hamburglar
  • Über Jedi
  • *****
  • Posts: 1663
  • I used to be Human....2.0b
    • http://row1.info
How to have a random avatar in Lunarforums
« Reply #121 on: May 14, 2005, 03:53:07 AM »
yay  :yey:
i just wrote my own dynamic signature!!!!
It needs work, i.e the graphic and font, but im just glad i got the content there:
it parses RSS (xml file) on my site and displays the lastest entry.
Couldnt have done it without this thread.
Thanks!

Offline GMTurner

  • Berserker Poster
  • *****
  • Posts: 7499
    • Turner's Lounge
How to have a random avatar in Lunarforums
« Reply #122 on: May 14, 2005, 06:37:23 AM »
Good job :)
The above information may or may not reflect current policy, opinions, or views since it was likely made almost 10 years ago.

Offline Chelle

  • Spaceship Captain
  • *****
  • Posts: 103
How to have a random avatar in Lunarforums
« Reply #123 on: June 12, 2005, 06:35:00 PM »
Quote from: Lupine1647
What i did was create a redirect from a .gif file to point it to the script.


How? .htaccess?  I'm thinking this method will help solve something and want to give it a whirl.
"The axe forgets.  The tree remembers" -African Proverb

Lupine1647

  • Guest
How to have a random avatar in Lunarforums
« Reply #124 on: June 12, 2005, 06:38:19 PM »
The redirect option in the Cpanel will do, in hence the CPanel redirect thing modifies the htaccess file.

Lupine1647

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #125 on: October 24, 2006, 03:19:47 PM »
Tis' some code for RAT.

Code: [Select]
<?
header('Content-type: image/jpeg');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

// ex. /home/cpanel/av/
$directory="PATH TO FOLDER";

$dir=opendir($directory);

$pattern="\.(gif|jpg|jpeg|png)$";
if(!$dir)
{
die("Failed to read directory");
}
$s=readdir($dir);
$count="0";
$image;
while($s)
{
if(ereg($pattern, $s))
{
$image[$count]=$s;
$count++;
}
$s=readdir($dir);
}
closedir($dir);

//Spit it out
$limit=count($image);
$limit--;
$randNum=rand(0,$limit);
$size=getimagesize("$directory$image[$randNum]");
$av=readfile("$directory$image[$randNum]");
echo "$av";
?>

RandyT

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #126 on: October 24, 2006, 08:24:48 PM »
OK, here is the code I am trying to use:

Code: [Select]
<?
header('Content-type: image/jpeg');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

// ex. /home/cpanel/av/
$directory="/home/cpanelusername(not included for security reasons)/public_html/randomimages/
";

$dir=opendir($directory);

$pattern="\.(gif|jpg|jpeg|png)$";
if(!$dir)
{
die("Failed to read directory");
}
$s=readdir($dir);
$count="0";
$image;
while($s)
{
if(ereg($pattern, $s))
{
$image[$count]=$s;
$count++;
}
$s=readdir($dir);
}
closedir($dir);

//Spit it out
$limit=count($image);
$limit--;
$randNum=rand(0,$limit);
$size=getimagesize("$directory$image[$randNum]");
$av=readfile("$directory$image[$randNum]");
echo "$av";
?>

there is a folder inside my public_html called "randomimages" that contains the images, then I added this to my .htaccess:

Code: [Select]
RewriteEngine On  RewriteRule ^images.jpg /images.php [L]


and put this link in my forum profile:

http://mydomain.com/images.php

which gives the following error:

Warning: opendir(/home/cpanelusername(left out for security reasons)/public_html/randomimages/ ) [function.opendir]: failed to open dir: No such file or directory in /home/cpanelusername/public_html/images.php on line 19
Failed to read directory

Any ideas on why this isnt working ?

thanks,
RandyT






« Last Edit: October 24, 2006, 08:32:39 PM by RandyT »

Offline Rowan

  • hamburglar
  • Über Jedi
  • *****
  • Posts: 1663
  • I used to be Human....2.0b
    • http://row1.info
Re: How to have a random avatar in Lunarforums
« Reply #127 on: October 25, 2006, 01:06:05 AM »
the link in your forum profile should be http://mydomain.com/images.jpg and not .php, that probably won't help.
I looked at your site and it wasn't giving me that error, just displaying the link.

Lupine1647

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #128 on: October 25, 2006, 05:10:30 PM »
Randy, I'll make some new code for ya in a bit.

RandyT

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #129 on: October 25, 2006, 05:35:57 PM »
Awesome, thanks  :thumb:

RandyT

Lupine1647

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #130 on: October 25, 2006, 06:14:40 PM »
I modified it a little bit:

Code: [Select]
<?
// Set type
header('Content-type: image/gif');
// Headers to not cache the image
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");

// CONFIGURATIONS
$directory="/home/CP/public_html/randomimages/";
$pattern="\.(gif|jpg|jpeg|png)$";

// Get file list
if(!is_dir($directory)){
die("Directory: $directory is not valid.");
}

$dir=@opendir($directory);
if(!$dir)
{
die("Failed to read directory");
}
$s=readdir($dir);
$count="0";
$image;
while($s)
{
if(ereg($pattern, $s))
{
$image[$count]=$s;
$count++;
}
$s=readdir($dir);
}
closedir($dir);

//Spit it out
$limit=count($image);
$limit--;
$randNum=rand(0,$limit);
readfile("$directory$image[$randNum]");
?>

RandyT

  • Guest
Re: How to have a random avatar in Lunarforums
« Reply #131 on: October 25, 2006, 06:30:53 PM »
Working like a charm now Ryan  :thumb:

Many thanks and Happy Halloween !

RandyT

Offline beltalcom

  • Newbie
  • *
  • Posts: 1
Great!!!
« Reply #132 on: December 05, 2007, 09:21:19 PM »
I did it ! Great !

 

Share |