Results 1 to 12 of 12

Thread: embedding html isn't allowed, so....now what?

  1. #1
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin embedding html isn't allowed, so....now what?

    I suppose this is a tad bit unnecessary, but I'd like to have different signatures load up, sort of like that thingie where different avatars can load up by using some sort of script I can't remember. I'm sure I can make a webpage that loads a (small) something every time I refresh, but since I can't embed html here, I can't use that method (though FG is another matter...I'll do that for FG)

    So what am I left with? If it's not possible, can I at least get a tutorial/information on how to get random images to show up in the signature? (I'm speaking about a script or something that loads a random image based on a list of urls).

  2. #2
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Perl is your friend. You can write a Perl script that returns image data instead of text data.

    Code:
    #!/usr/bin/perl -T
    
    use strict;
    use warnings;
    
    use CGI;
    
    my $filename = int(rand(2));
    
    ($filename == 1) ? ($filename = 'tux2.png') : ($filename = 'tux.png');
    
    if(open FILE, "<", $filename) {
    	print CGI::header('image/png');
    	binmode FILE;
    	print while(<FILE>);
    	close FILE;
    } else {
    	print CGI::header();
    	print "Error: $!";
    }
    Now if you use an IMG tag and put the .cgi script as the URL, if you refresh this page and it should show a random picture.

    <img src="http://chwombat.net/cgi-bin/picture.cgi">

    gives

    <img src="http://chwombat.net/cgi-bin/picture.cgi">

  3. #3
    Prinny God Recognized Member Endless's Avatar
    Join Date
    Aug 2000
    Location
    Prinny Moon
    Posts
    2,641
    Contributions
    • Former Cid's Knight

    Default

    PHP allows the same kind of trick.
    If you have a dir full of gifs, rename them all to start with "banner" (banner_blah.gif for example) and this script will output the image for you, cycling through the available images depending on the time of the day:

    PHP Code:
    <?php

    function imagesel$max )
    {
    $h=strftime("%H");
    $m=strftime("%M");
    $t=($h*60)+$m;
    $n=1440/$max;
    $r=$t/$n;
    $r=floor($r);
            return 
    $r;
    }

    $i 0;
    $d   dir(".");
    while(
    $entry=$d->read())
            if (
    substr($entry,0,6) == "banner") {
                    
    $array[$i++] = $entry;
            }
    $d->close();

    /* pick a banner at random
    */
    $r imagesel$i );

    /* Send a no-cache header, and the gif type header, and output the file.
    */
    Header"Pragma: no-cache" );
    Header"Expires: Monday 01-Jan-80 12:00:00 GMT" );
    Header"Content-type:  image/gif");
    $im fopen("./".$array[$r], "r");
    fpassthru($im);
    ?>
    It only needs a small modification of the imagesel function to make it random.

    And then there is Death

  4. #4
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Another thing for the programming-impaired: see the image/gif and image/png in the code? Those need to correspond to the kinds of images you're displaying. If you send GIF data as image/png, your browser will probably either choke on it, or else do some magic to display it as a GIF anyways (which may be what IE does, and which is the WRONG thing to do, but anyways).

    On a side note, why in the world did they make the "php" vB tag so hard to read? Do those colors look good in ANY color scheme? Because they make my eyes bleed on this color scheme.

  5. #5
    pirate heartbreaker The Man's Avatar
    Join Date
    Mar 2002
    Location
    Sarasota, FL
    Posts
    10,946

    Default

    Originally posted by Dr Unne
    On a side note, why in the world did they make the "php" vB tag so hard to read? Do those colors look good in ANY color scheme? Because they make my eyes bleed on this color scheme.
    It looks fine in the default vBulletin colour scheme, but crap in any light-on-dark colour scheme. It also seems to be hard-coded into PHP itself, because I've been entirely unable to find those colour codes anywhere in the vB source. What they SHOULD have done is put a white background behind the php tag so that you could read it no matter what the background colours were. Or else written their own function that allows you to change the colours, that would have been better.
    Don't delay, add The Pimp today! Don't delay, add The Pimp today!
    Fool’s Gold tlsfflast.fm (warning: album artwork may sometimes be nsfw)

  6. #6
    Prinny God Recognized Member Endless's Avatar
    Join Date
    Aug 2000
    Location
    Prinny Moon
    Posts
    2,641
    Contributions
    • Former Cid's Knight

    Default

    It's done by the built-in highlight_string() php function. So, in order to modify it, you would have to write a syntax highlighter and then change the function call to the one you wrote. It's doable, but requires hacking, a bit of a pita (mainly to code the new highlighter) imho.
    Basicly for the curious, search for <i>phphighlite</i> in admin/functions.php, that's the part that needs to be modified.

    Edit: minor hacking should let you put a white background (just change the return line).

    And then there is Death

  7. #7
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin

    Okay I copied Dr Unne's code, set up a webserver here on my computer, and put the cgi file in there. I then put two images in the directory.

    It doesn't work. I get a red 'x' when I run the html file that has the image tag.

    Code:
    #!/usr/bin/perl -T
    
    use strict;
    use warnings;
    
    use CGI;
    
    my $filename = int(rand(2));
    
    ($filename == 1) ? ($filename = 'F_H.jpg') : ($filename = 'takebacktheweb_large.jpg');
    
    if(open FILE, "<", $filename) {
    	print CGI::header('image/png');
    	binmode FILE;
    	print while(<FILE>);
    	close FILE;
    } else {
    	print CGI::header();
    	print "Error: $!";
    }
    Code:
    [html]
    [body]
    [img src="http://192.168.2.103/pics.cgi" /]
    [/body]
    [/html]

  8. #8
    Prinny God Recognized Member Endless's Avatar
    Join Date
    Aug 2000
    Location
    Prinny Moon
    Posts
    2,641
    Contributions
    • Former Cid's Knight

    Default

    Originally posted by Dr Unne
    Another thing for the programming-impaired: <b>see the image/gif and image/png in the code? Those need to correspond to the kinds of images you're displaying.</b> If you send GIF data as image/png, your browser will probably either choke on it, or else do some magic to display it as a GIF anyways (which may be what IE does, and which is the WRONG thing to do, but anyways).

    On a side note, why in the world did they make the "php" vB tag so hard to read? Do those colors look good in ANY color scheme? Because they make my eyes bleed on this color scheme.

    And then there is Death

  9. #9
    Your very own Pikachu! Banned Peegee's Avatar
    Join Date
    Mar 2001
    Posts
    19,488
    Blog Entries
    81

    Grin

    oops. Okay it's image/jpg now and still doesn't show up

  10. #10
    Hypnotising you crono_logical's Avatar
    Join Date
    May 2001
    Location
    Back in Time
    Posts
    9,313
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    Have you got Perl installed on your machine, seeing as it's a Perl script you copy/pasted?
    Problems playing downloaded videos? Try CCCP


  11. #11
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    Tell what OS and web server you're using. Look in your web server logs and see what error it's giving you. Post the HTML code you're using to display the image.

  12. #12
    Prinny God Recognized Member Endless's Avatar
    Join Date
    Aug 2000
    Location
    Prinny Moon
    Posts
    2,641
    Contributions
    • Former Cid's Knight

    Default

    In the HTML code you posted, it's a local network IP, so other people than you wouldn't see it, and cgi scripts have to be in the cgi-bin directory. If you're on XP, you need to download and install the perl module. If you're on linux, it most likely is already here, and you just need to use the cgi-bin folder which should be /var/www/cgi-bin

    And then there is Death

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •