Request: Signature Script

Discussion in 'The Living Room' started by Mark, Jul 10, 2005.

  1. #1
    Mark

    Mark Canadian Beauty LPA Administrator

    Joined:
    Jul 14, 2002
    Messages:
    24,905
    Likes Received:
    555



    I could use a signature script that portrays a random picture from a set of 5 jpgs upon every refreshing of a webpage. See my box in my signature now? I want to be able to have a red version of that if I refreshed. Or blue, or green, etc. I have the 5 jpgs, I just need the script that changes the picture randomly upon refreshing. I'd search for it myself but I don't know where to look and Googling is futile.

    Thanks in advance.
     
  2. #2
    minusxerø

    minusxerø Overflow Supremacy LPA Addicted VIP

    Joined:
    Aug 24, 2003
    Messages:
    18,969
    Likes Received:
    1,566



    I'd like that too, but also that links the avatar to the signature, so that the two pictures are linked on refresh. Like when you refresh, you get avatar a and sig a, and then refresh again and get avatar c and sig c and so on and so forth.
     
  3. #3
    Cale.

    Cale. Banned

    Joined:
    Jan 20, 2005
    Messages:
    2,723
    Likes Received:
    5



    Note: If you haven't already, you will need to enable .php as a valid image file for signatures.


    • Configuration:
    • Copy and paste the php code into notepad
    • Go into the code and find this:
      Code:
      $source = "./"
      Make a folder on your host called "random_sigs", or whatever you want it to be called, then inside that folder make a folder named "sigs" set $source to "sigs". So the code will then look like this
      Code:
      $source = "./sigs"
    • Save the script as "random.php" and upload it (to a host that supports php) to your "/random_sigs" folder (or whatever you called it).
    • Then upload all your sigs to the "/sigs" folder
    • Back on the forums use
      [IMG]http://myurl.com/myfolder/random.php[/IMG]
      For using the randomizer.


    Code:
    <?php
    
    // seed with microseconds - nabbed straight off php.net
    function make_seed()
    {
      list($usec, $sec) = explode(' ', microtime());
      return (float) $sec + ((float) $usec * 100000);
    }
    mt_srand(make_seed());
    
    $source = "./"; //In which folder are the sigs located? Type "./" for the same folder as this file.
    
    //-----------Don't touch below this line-----------//
    
    $handle=opendir($source);
    $i = 0;
    $sigs = array();
    while (false!==($file = readdir($handle)))
    {
    if ($file != "." && $file != ".." && eregi ( "(gif|png|jpg)" , $file ) )
     { 
       $sigs[$i] = "$file";
       $i = $i + 1;
      }
    }
    
    closedir($handle);
    
    $sig = $sigs[mt_rand(0, count($sigs)-1)];
    
    @header ("Location: $source/$sig");
    
    ?>
     
  4. #4
    Chris

    Chris LPA Addict LPA Addict

    Joined:
    Feb 21, 2003
    Messages:
    24,638
    Likes Received:
    87



    riiiiight. im confused :lol:
     
  5. #5
    Cale.

    Cale. Banned

    Joined:
    Jan 20, 2005
    Messages:
    2,723
    Likes Received:
    5



    I'll try and make it easier to understand. Just a tic.

    Edit: Ok i edited it. If you still can't understand tell me what you can't understand and hopefully I can explain.
     
  6. #6
    Chris

    Chris LPA Addict LPA Addict

    Joined:
    Feb 21, 2003
    Messages:
    24,638
    Likes Received:
    87



    Okay. I think I got it.

    Edit: Yeah.. I got it, but they havent allowed php yet :lol:
     
  7. #7
    Chris.

    Chris. LPA Super Member Über Member

    Joined:
    Jul 13, 2003
    Messages:
    12,474
    Likes Received:
    29



    Alright, I'm having compications with this. I'm not going to use it on this forum, but anyway...I did what you said but the .php file isn't showing up as an image but as the code itself...do you know what i did wrong?
     
  8. #8
    Tomi

    Tomi &nbsp; LPA Addict

    Joined:
    Mar 10, 2004
    Messages:
    16,514
    Likes Received:
    52



    You mean like I had for my PS3 set?

    I'll try and get you the code for it...

    -edit---
    sig.jpg
    Code:
    <?php
    $dh = opendir(".");
    while (false !== ($file = readdir($dh)))
    {
     if (preg_match('/\.jpg$/i', $file) and $file != "avatar.jpg") // sanning for .jpg files only and stopping avatar.jpg being loaded (you will run into errors if this isnt here)
     {
       $filelist[] = $file;
     }
    }
    
    srand((double)microtime()*1000000);
    $picnum = rand(0, sizeof($filelist) - 1);
    
    header("Location: " . $filelist[$picnum]);
    
    closedir($dh);
    ?>
    .htaccess
    Code:
    AddType application/x-httpd-php .jpg
    Just put those two files in a directory together with .jpg files only. I don't think other filetypes work, but if they do, don't shoot me.

    Hope this helped. :)
     
  9. #9
    Chris.

    Chris. LPA Super Member Über Member

    Joined:
    Jul 13, 2003
    Messages:
    12,474
    Likes Received:
    29



    Ok so do I have to save those codes in notepad and then load them to my host? What do I save them as?

    EDIT: Do I save them as sig.jpg and .htaccess?
     
  10. #10
    Tomi

    Tomi &nbsp; LPA Addict

    Joined:
    Mar 10, 2004
    Messages:
    16,514
    Likes Received:
    52



    ^ Yep.
     
  11. #11
    Chris.

    Chris. LPA Super Member Über Member

    Joined:
    Jul 13, 2003
    Messages:
    12,474
    Likes Received:
    29



    Alright. I think my host is the problem then, because it's not working.
     
  12. #12
    Chris

    Chris LPA Addict LPA Addict

    Joined:
    Feb 21, 2003
    Messages:
    24,638
    Likes Received:
    87



    Mine wasnt working either, but my host accepts everything
     
  13. #13
    Chris.

    Chris. LPA Super Member Über Member

    Joined:
    Jul 13, 2003
    Messages:
    12,474
    Likes Received:
    29



    Im using Angelfire and it's not working but Angelfire accepts all of this.
     
  14. #14
    Chris

    Chris LPA Addict LPA Addict

    Joined:
    Feb 21, 2003
    Messages:
    24,638
    Likes Received:
    87



    Well Tomi. Looks like you got explaining to do! :angry: :p
     
  15. #15
    minusxerø

    minusxerø Overflow Supremacy LPA Addicted VIP

    Joined:
    Aug 24, 2003
    Messages:
    18,969
    Likes Received:
    1,566



    Not just about it not working... but a big old WTF in general. :lol:

    Sorry, I am t3h n00b in PHP.
     
  16. #16
    Tomi

    Tomi &nbsp; LPA Addict

    Joined:
    Mar 10, 2004
    Messages:
    16,514
    Likes Received:
    52



    If it's not working, then get a different host that allows PHP and .htaccess files. :p

    I'm pretty sure lycos.co.uk allows it. I can't remember thou.
     
  17. #17
    Chris.

    Chris. LPA Super Member Über Member

    Joined:
    Jul 13, 2003
    Messages:
    12,474
    Likes Received:
    29



    :p

    Are we going to have to do what Skywalker said ALONG with what you said or just what you said?
     
  18. #18
    Cale.

    Cale. Banned

    Joined:
    Jan 20, 2005
    Messages:
    2,723
    Likes Received:
    5



    If Tomi's doesn't work, feel free to use my un-1337 script :whistle:

    :lol:
     
  19. #19
    Tomi

    Tomi &nbsp; LPA Addict

    Joined:
    Mar 10, 2004
    Messages:
    16,514
    Likes Received:
    52



    Funny thing is, it's not my script. :p I just found it on a forum I go on. ;)
     

Share This Page