Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Interesting Sources...

  1. #1
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default Interesting Sources...

    I have a question. Not really a problem. Just something I'm curious about.
    I've been noticing some interesting url's for images and stylesheets and scripts, etc....
    Instead of being .jpg, .css, .js, etc...
    they're query strings.
    Like, instead of image.jpg
    it's images.php?image=iouhvisudbvsu
    or something

    Code:
    http://us.bc.yahoo.com/b?P=31oaEkSOx8a2gYpiRNiwHAD5QTAlkkTqCJIAAp7w&T=15p12rcs0%2fX%3d1156188306%2fE%3d150500014%2fR%3dmail%2fK%3d5%2fV%3d2.1%2fW%3dH%2fY%3dYAHOO%2fF%3d401156405%2fH%3deW12PSIxIiBjb250ZW50PSJ0b3BzdG9yaWVzIiBtYWlsPSJ2ZXNwYSI-%2fQ%3d-1%2fS%3d1%2fJ%3d69C98E44&U=13aorjh9g%2fN%3dWGM9E9j8YnU-%2fC%3d289534.9092402.9857338.8799822%2fD%3dHJAVA%2fB%3d3896300
    For example, that image on Yahoo!...
    Somehow it has to do with databases, yes?
    msql, maybe?

    Ah, I dunno.
    Anyone want to explain HOW they do this?
    And, WHY they do this?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    They're simply using PHP to output the content.
    PHP isn't limited to outputting HTML; one can use it to create stylesheets, scripts, images, and theoretically anything else, dynamically.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    As to the WHY question. Say you have multiple images on your site. They all look the same except they have a different background color. Using PHP you could modify the color "on the fly". That's just an example but if you apply a little creativity, you can create complex, dynamic images.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Such as the randomly-generated CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) images one sees on registration forms.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    That's amazing. Does anyone have any good resources on how to dynamically output stylesheets, etc?
    I'd like to learn how to do this!

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Stylesheets and scripts are plain text, so you generate them the same way you would anything else, but with a different MIME type:
    Code:
    <?php
      header('Content-Type: text/javascript');
      // Use text/css for CSS, or image/<imagetype>
      // for images (e.g. image/png, image/gif, image/jpeg)
      echo(
        'var myvar = 3;' . "\n" .
        'document.write(myvar);' . "\n"
      );
    ?>
    You can include that into an HTML page, and it will behave just like a static script.

    Images are binary, so they're a lot harder. Luckily, most servers have the gd image manipulation library available, which simplifies things considerably. You can find a gd tutorial here.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Ok, so let's say I want to change the text size depending on the number in the url, so something like this, correct?

    PHP Code:
    header('Content-Type: text/css');
    $fontsize $_GET['fontsize'];
    echo (

    'body{
    font-size: '
    .$fontsize.';'); 
    The quotes aren't making a whole lot of sense to me?
    First of all, why're we using the () instead of just a normal echo? And, why are we using single quotes for the text and double quotes for the \n's?

    ps - tried the image thing. Didn't work. It says the header information couldn't be modified because headers were already sent? http://flamehtmlstudios.com/projects/gd/image.php
    you can see it there

    The code I used for that:

    PHP Code:
            header ("Content-type: image/png");
            
    $img_handle ImageCreate (23020) or die ("Cannot Create image");
            
    $back_color ImageColorAllocate ($img_handle01010);
            
    $txt_color ImageColorAllocate ($img_handle233114191);
            
    ImageString ($img_handle3155,  "My first Program with GD"$txt_color);
            
    ImagePng ($img_handle); 
    Last edited by alexjewell; 08-27-2006 at 11:33 PM.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    First of all, why're we using the () instead of just a normal echo?
    Habit. You don't have to if you don't want to; it doesn't make a lot of difference either way.
    And, why are we using single quotes for the text and double quotes for the \n's?
    Single quotes are marginally faster to parse, so they should be used wherever possible, but they won't convert the \n into a newline, so we use double quotes for that.
    so let's say I want to change the text size depending on the number in the url, so something like this, correct?
    You might want to add on the missing end brace for that block. Also, if you really are expecting a
    number in the url
    you'll have to specify units as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Oh yes, forgot the "em" for the font. oops.

    Anyway:

    tried the image thing. Didn't work. It says the header information couldn't be modified because headers were already sent? http://flamehtmlstudios.com/projects/gd/image.php
    you can see it there

    The code I used for that:

    PHP Code:
            header ("Content-type: image/png");
            
    $img_handle ImageCreate (23020) or die ("Cannot Create image");
            
    $back_color ImageColorAllocate ($img_handle01010);
            
    $txt_color ImageColorAllocate ($img_handle233114191);
            
    ImageString ($img_handle3155,  "My first Program with GD"$txt_color);
            
    ImagePng ($img_handle); 

  10. #10
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    your server does not support GD

Bookmarks

Posting Permissions

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