How To Setup Random Images (Sigs)

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Alpha Member iod is offline
    MemberRank
    Feb 2004 Join Date
    2,583Posts

    How To Setup Random Images (Sigs)


    If you want to setup random sigs or an avatar there are two ways you can go about it. The first way is easier so I'm sure you'll all do it.

    EDIT: ** in the code means ] with shift held down (its disabled in here for some reason).

    First Method
    Go to www.cutandpastescripts.com and signup for an account, then when you've gotten your email from them and logged into the member area go to Random Images under Choose a Script. You have to have your images uploaded somewhere first and you paste the URLs to them on the site. Then they give you a code that looks like this:

    Code:
    <!- Random Images Script, by Cut and Paste Scripts.  Hosted CGI, with NO adverts and FREE. http://www.cutandpastescripts.com -!><img src="http://www.cutandpastescripts.com/cgi-bin/randomimages/randomimages.pl?username=iouser" alt="Random Images"><!- Copyright Cut and Paste Scripts -!>
    Pasting that into your sig on here won't work because its HTML no BBcode, so what you have to do is erase everything up to and including <img src=" and everything after and including " alt so you should have something like this now:

    Code:
    http://www.cutandpastescripts.com/cgi-bin/randomimages/randomimages.pl?username=iouser
    Now just put the [img] tag before it and [/img] after and you're all set.

    Second Method
    This method takes some more time but is worth it as it can do alot more. It envolves using a php script, this script takes an inventory of all the image files in a directory and displays one at random.

    What you need to do is copy this script to notepad and save it as a .php file (index.php is recomended but not required) and upload it to a directory that has your images.

    To put it in your signature here again just put the URL to the file (or if you named it index.php the folder) in [img] tags and you're done.

    Code:
    <?php
    if ($dir = opendir(\".\"))
    {
         $list = buildimagearray($dir);
         displayrandomimage($list);
    **
    
    // This function reads all the files in the current directory and adds all image files to the array $list[]
    function buildimagearray($dir)
    {
         while (false !== ($file = readdir($dir)))
         {
              if (!is_dir($file) && getimagesize($file))
              {
                   $list[] = $file;
             **
         **
         return $list;
    **
    
    // This function selects a random image, determines the mime type, opens the file for reading,
    // and then outputs the image
    function displayrandomimage($list)
    {
         srand ((double) microtime() * 10000000);
         $sig = array_rand ($list);
    
         $size = getimagesize ($list[$sig]);
         $fp = fopen($list[$sig], \"rb\");
    
         if ($size && $fp)
         {
              header(\"Content-type: {$size[\'mime\']**\");
              fpassthru($fp);
              exit;
         **
    **
    ?>
    Modification were made to the code in response to a problem when using PHP version 4.2.2 when array_rand isn't working properly.

    The original code (above) is recomended if you don't have this problem, if you do use this one:

    Code:
    <?php
    if ($dir = opendir(\".\"))
    {
         $list = buildimagearray($dir);
         displayrandomimage($list);
    **
    
    // This function reads all the files in the current directory and adds all image files to the array $list[]
    function buildimagearray($dir)
    {
         while (false !== ($file = readdir($dir)))
         {
              if (!is_dir($file) && getimagesize($file))
              {
                   $list[] = $file;
              **
         **
         return $list;
    **
    
    // This function selects a random image, determines the mime type, opens the file for reading,
    // and then outputs the image
    function displayrandomimage($list)
    {
         $maxrand = sizeof($list)-1;
         $sig = rand(0, $maxrand);
    
         $size = getimagesize ($list[$sig]);
         $fp = fopen($list[$sig], \"rb\");
    
         if ($size && $fp)
         {
              header(\"Content-type: {$size[\'mime\']**\");
              fpassthru($fp);
              exit;
         **
    **
    ?>
    Comparing Method One to Method Two

    The first method though easy is not hosted by you so it can be shutdown, removed, etc. also adding new images in is more of a problem because you have to go through their website each time and upload the images to another site. The second method needs a server with php support (hard to find one without php these days) the advantages to it are that you can have as many random images as you want (different sets) with the first method it's one random image set per account, secondly with the php script you don't have to add files just upload them to your server which you can use an upload script with to make even easier. The php script is a lot more customizable in other ways, you could modify it to say how many times each image has been viewed, almost anything.
    Last edited by iod; 21-11-04 at 03:52 AM.


  2. #2
    Alpha Member RuDoLpH is offline
    MemberRank
    Jul 2004 Join Date
    de_dust2Location
    1,544Posts
    great guide it work just refresh the page and look at mine and io* sigs


    sometie it take long to load
    Last edited by RuDoLpH; 07-11-04 at 06:13 PM.

  3. #3
    Account Upgraded | Title Enabled! Dune is offline
    MemberRank
    Mar 2003 Join Date
    NetherlandsLocation
    446Posts
    cool, thx man

  4. #4
    Proficient Member Trigun is offline
    MemberRank
    Aug 2004 Join Date
    Whatever God Takes ME ..Location
    179Posts
    good guide helped me aswell :)

  5. #5
    Enthusiast B-Real is offline
    MemberRank
    Oct 2004 Join Date
    Hell...Location
    34Posts
    Good guide but won't work for me for some reason o-O

    [.IMG]http://www.cutandpastescripts.com/cgi-bin/randomimages/randomimages.pl?username=my_username[/IMG.]

    excluding the "my_username" and the dots part, that's exactly and all i have in my signature. however, i get a problem back:

    You are not allowed to use that image extension on this board. A valid format is: http://www.domain.com/picture.gif, an invalid format is: http://www.domain.com/picture.one.gif

    what can i do to fix that?

  6. #6
    Account Upgraded | Title Enabled! MrD. is offline
    MemberRank
    Feb 2003 Join Date
    EnglandLocation
    394Posts
    PHP Script wont work for me, i get a broken image link when linking and when i open the PHP file i get these errors:
    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /path/to/index.php on line 2

    Parse error: parse error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /path/to/index.php on line 8

    I get this error with both of the above files.

    Ne1 know why?

  7. #7
    Alpha Member iod is offline
    MemberRank
    Feb 2004 Join Date
    2,583Posts
    k whever you see ** replace it with ] while holding shift, you should get { but flipped around

  8. #8
    Alpha Member Hybr!d is offline
    MemberRank
    Sep 2004 Join Date
    Sydney NSW AustLocation
    2,960Posts
    just go to the site www.cutandpastescripts.com. Register go to random images add all your links and then just add the link in your Signature option in User cp with the [IMG] tags.. That was my link and you should find a link there when you finish. Thats it, thats how you set up one.
    Last edited by Hybr!d; 25-01-05 at 01:37 AM.

  9. #9
    Account Upgraded | Title Enabled! Salt O_o is offline
    MemberRank
    Dec 2004 Join Date
    205Posts
    cool! its working!nice thingy!

  10. #10
    Account Upgraded | Title Enabled! Shift is offline
    MemberRank
    Dec 2003 Join Date
    USALocation
    582Posts
    Nice :P But not exactly new :-/

  11. #11
    Account Upgraded | Title Enabled! MrD. is offline
    MemberRank
    Feb 2003 Join Date
    EnglandLocation
    394Posts
    Quote Originally Posted by iod
    k whever you see ** replace it with ] while holding shift, you should get { but flipped around
    Tried that... still get the errors

  12. #12
    Alpha Member iod is offline
    MemberRank
    Feb 2004 Join Date
    2,583Posts
    if its the same errors you still ave a ] somewhere

  13. #13
    SP | phakeme.isithombe Jhewt is offline
    LegendRank
    Dec 2004 Join Date
    BRC, ArgentinaLocation
    3,282Posts
    great guide Io

  14. #14
    Account Upgraded | Title Enabled! MrD. is offline
    MemberRank
    Feb 2003 Join Date
    EnglandLocation
    394Posts
    Now i get different errors:

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

    Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /path/to/index.php on line 33

    Parse error: parse error, unexpected $ in /path/to/index.php on line 38

  15. #15
    Account Upgraded | Title Enabled! fream12 is offline
    MemberRank
    Oct 2005 Join Date
    My Home,EarthLocation
    296Posts
    good one iod



Page 1 of 2 12 LastLast

Advertisement