[PHP][snippet] Random Dynamic Forum Signature

Discussion in 'Web Programming' started by Arizane, Sep 15, 2008.

[PHP][snippet] Random Dynamic Forum Signature
  1. Unread #1 - Sep 15, 2008 at 4:27 AM
  2. Arizane
    Joined:
    Jul 19, 2008
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    Arizane Newcomer

    [PHP][snippet] Random Dynamic Forum Signature

    This code well let you have a random dynamic image in your forum signature.

    PHP:
    <?php
    $folder 
    '';

    $exts 'jpg jpeg png gif';

    $files = array(); $i = -1;
    if (
    '' == $folder$folder './';

    $handle opendir($folder);
    $exts explode(' '$exts);
    while (
    false !== ($file readdir($handle))) {
       foreach(
    $exts as $ext) {
           if (
    preg_match('/\.'.$ext.'$/i'$file$test)) {
               
    $files[] = $file// it's good
               
    ++$i;
               }
           }
       }
    closedir($handle);
    mt_srand((double)microtime()*1000000);
    $rand mt_rand(0$i); // $i was incremented as we went along

    $rimg $files[$rand];

    header('Last-Modified: '.gmdate('D, d M Y H:i:s'filemtime($fn)).' GMT'true200);
    header('Content-Length: '.filesize($rimg));
    header('Content-Type: image/png');
    print 
    file_get_contents($rimg);
    ?>
    This basically loads all .png file types into it and outputs it randomly so if you load the page. it might display image1.png then if you reload it, it will display a differnt image say image3.png or whatever.

    Currently this is used for png file types but that can be easily changed by changing
    PHP:
    header('Content-Type: image/png');
    to something like
    PHP:
    header('Content-Type: image/gif');
    To see it in use just look at my signiture or go to http://arizanegamesltd.vndv.com/index.php

    To use it just use.
    Remember to change it to your website and the name of the file u saved the php page as.

    Originate on Cruels.Net
    http://cruels.net/index.php?showtopic=7092&hl=

    Enjoy ^_^ Ill be posting more stuff soon.
     
  3. Unread #2 - Sep 15, 2008 at 8:54 AM
  4. Matthew
    Joined:
    Nov 12, 2005
    Posts:
    5,153
    Referrals:
    42
    Sythe Gold:
    5,377
    Wait, do you not have an Archer rank? (5) Doge (3) Smashing Why is there BACON in the SOAP!? Literally nothing I saw Matthew Live Free or Die (3) Cool Kid (6) Poképedia Homosex (4)

    Matthew Probably breaking stuff

    [PHP][snippet] Random Dynamic Forum Signature

    [mod]In the future, when posting PHP, use the [ php ] tag. Otherwise, if you use [ code ] you fuck up the template somehow and kill your thread.[/mod]
     
  5. Unread #3 - Sep 15, 2008 at 2:13 PM
  6. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    [PHP][snippet] Random Dynamic Forum Signature

    well thats good to know... thanks.. D:
     
  7. Unread #4 - Sep 16, 2008 at 8:46 AM
  8. Arizane
    Joined:
    Jul 19, 2008
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    Arizane Newcomer

    [PHP][snippet] Random Dynamic Forum Signature

    I added it, im sure i did, because i all i did is copy it from my thread on cruels

    -.-

    Sorry anyways.
     
  9. Unread #5 - Sep 18, 2008 at 6:40 PM
  10. AADude
    Joined:
    Apr 3, 2008
    Posts:
    43
    Referrals:
    0
    Sythe Gold:
    0

    AADude Member

    [PHP][snippet] Random Dynamic Forum Signature

    Instead of:
    PHP:
    header('Content-Type: image/png');
    You could try:
    PHP:
    $size getimagesize($rimg);
    header('Content-Type: ' $size['mime']);
    And maybe you could use glob instead of the open_dir and read_dir things.
     
  11. Unread #6 - Sep 18, 2008 at 7:32 PM
  12. Matthew
    Joined:
    Nov 12, 2005
    Posts:
    5,153
    Referrals:
    42
    Sythe Gold:
    5,377
    Wait, do you not have an Archer rank? (5) Doge (3) Smashing Why is there BACON in the SOAP!? Literally nothing I saw Matthew Live Free or Die (3) Cool Kid (6) Poképedia Homosex (4)

    Matthew Probably breaking stuff

    [PHP][snippet] Random Dynamic Forum Signature

    Dynamic PHP images are lotsa fun =O

    My sig is dynamic >_>
     
  13. Unread #7 - Sep 18, 2008 at 7:45 PM
  14. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    [PHP][snippet] Random Dynamic Forum Signature

    I really should learn how to do this. It would be fun, and quite useful.
     
  15. Unread #8 - Sep 19, 2008 at 1:06 PM
  16. Supah Fly
    Joined:
    Aug 22, 2007
    Posts:
    202
    Referrals:
    1
    Sythe Gold:
    0

    Supah Fly Active Member
    Banned

    [PHP][snippet] Random Dynamic Forum Signature

    Using Stephen (AADude)'s function..

    Usage: All your files named with ONLY numbers, in order, 1 through whatever.

    Could have used GLOB but I wrote this a while ago and didn't know what it was till a bit ago.

    Cant use php tags, they fuck up my code.

    God damnit. Fuck your tags. http://supahfly.net/sig/src.php there is the source code Ive been trying to post for 10 minutes. They all screw up my code. -.-
     
  17. Unread #9 - Sep 19, 2008 at 9:10 PM
  18. AADude
    Joined:
    Apr 3, 2008
    Posts:
    43
    Referrals:
    0
    Sythe Gold:
    0

    AADude Member

    [PHP][snippet] Random Dynamic Forum Signature

    Also since I wrote that awhile ago @ supah, I would suggest to integrate getimagesize instead of the separate headers.
     
< Need help. | Cgi:irc >

Users viewing this thread
1 guest


 
 
Adblock breaks this site