Web site creation

Discussion in 'iPod touch' started by blackjak231, Dec 1, 2007.

  1. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    Web site

    Hey everyone!

    SOLVED-I'm currently working on a website, and i was wondering how to hide stuff on the website, so that it will only show on an ipodtouch or iphone, and not on PC nor MAC?

    -Is it possible to put a download link on a page so that when you are on an ipod, it will directly download it in a certain file such as "/summerboard/themes"? if yes How?

    -How do you put a fixed image on a website?(like the top and bottom bar on installer, but installer is an app.....)

    Thank you so much for your help!!!!!!!!!!!!!!!!!!!!!
  2. Scythal

    Scythal New Member

    Joined:
    Nov 27, 2007
    Messages:
    413
    Likes Received:
    4
    Device:
    iPod touch
    You can use the HTTP_USER_AGENT system variable, if you're writing php code - I'm not familiar with the other languages when it comes to web server scripts but I'm pretty sure you can find the same variable there.

    Here is a very simple example:
    PHP:
    <?php

    $agent 
    $_SERVER["HTTP_USER_AGENT"];

    if (
    strpos($agent"Mozilla/5.0 (iPod;") !== FALSE) {
        
    // Current Safari:
        // Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3
        
    print "Hi iPod!";
    } elseif (
    strpos($agent"Mozilla/5.0 (Windows") !== FALSE) {
        
    // Example with Firefox:
        // Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10
        
    print "Hi Firefox!";
    } else {
        print 
    "Hi unknown browser!";
    }

    ?>
    And yes, jailbreakme is certainly using that

    Please Register or Log in to view images



    EDIT: Didn't know about the nifty PHP BBCode

    Please Register or Log in to view images

  3. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    I am actually writing in simple html!
    I'll show you the very simple code i want to hide when somebody is on a computer:

    PHP:
    <ul>

        <
    li><a href="/zip/icons.zip"><p><strong>Download</strong></p></a></li>

    </
    ul>
  4. Scythal

    Scythal New Member

    Joined:
    Nov 27, 2007
    Messages:
    413
    Likes Received:
    4
    Device:
    iPod touch
    You will not really be able to differentiate your website contents in HTML unfortunately.

    An approach you can take is to design the website in HTML as you would like to see it on the different browsers (so mainly iPod/non-iPod I guess), store that in two separate files or directories, and fetch the starting HTML page based on the variable above. That way, your scripts are kept to a minimum and you can focus on the actual design of the website.

    That is, if your host supports PHP (or Python, Perl, ...).
  5. Scythal

    Scythal New Member

    Joined:
    Nov 27, 2007
    Messages:
    413
    Likes Received:
    4
    Device:
    iPod touch
    To clarify, another small example that supposes you have the following HTML files in the same directory:
    • iPod.htm - for iPods with secret contents and so on
    • Firefox.htm - for the lucky users of Firefox
    • Unknown.htm - for the rest of the world

    PHP:
    <?php
    $agent 
    $_SERVER["HTTP_USER_AGENT"];
    if (
    strpos($agent"Mozilla/5.0 (iPod;") !== FALSE) {
        
    // iPod Safari:
        
    $filename "iPod.htm";
    } elseif (
    strpos($agent"Mozilla/5.0 (Windows") !== FALSE) {
        
    // Firefox:
        
    $filename "Firefox.htm"
    } else {
        
    $filename "Unknown.htm";
    }
    print 
    file_get_contents($filename);
    ?>
    Of course, it will never be totally full-proof. You can fool the server into believing you're browsing from an iPod with wget, for example:

    wget -r http://jailbreakme.com -U "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3"

    Hum, if this last bit is doubtful in these forums, please tell me and I'll happily remove that.

    Please Register or Log in to view images

  6. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    Hey, thanks a lot for this!
    I was just wondering if you could PM me the full source code of the ipod page of jailbreakme.com because i dont really understand how to fool the server!

    Thanks!
  7. Mindfield

    Mindfield New Member

    Joined:
    Nov 5, 2007
    Messages:
    1,312
    Likes Received:
    7
    Javascript can be used to dynamically alter page contents on the fly.

    Try expressing your iPod-only download link like this:


    Code:
    <!--
    <script type="text/javascript">
    var browser=navigator.appName;
    if (browser == "Mozilla/5.0 (iPod;")
    {
            document.write('<li><a  href="/zip/icons.zip"><p><strong>Download</strong></p></a></li>');
    }
    //-->
    </script>
    
    Your link should only appear if the script, on doing a client pull, detects that iPod Mozilla (which is what Safari is based on) is the current client viewing your page.

    Like other methods this can easily be fooled by browsers with scripts or options that allow you to change how it reports the browser when it is asked. I don't know of any method that can avoid that.
  8. Scythal

    Scythal New Member

    Joined:
    Nov 27, 2007
    Messages:
    413
    Likes Received:
    4
    Device:
    iPod touch
    Javascript can do that, however it's loaded on the client so it's (1) bigger than server-side generated pages, and (2) much less protected since everyone will see all the sources on their PC. On the positive side, your server doesn't have to support PHP, you can put those pages anywhere.

    Sending the bits I have - I don't have the actual sources of jailbreakme.com, only what is sent to the PC (that you can have with a simple save from IE/Firefox/..., and what is sent to the iPod (that you can get with the commands I gave). That's the point of those PHP scripts, users can't get to them. Maybe the guys who made the website will agree to send their actual sources to you, but it will be very similar to the example above (if you want, I can help you further with this).
  9. Mindfield

    Mindfield New Member

    Joined:
    Nov 5, 2007
    Messages:
    1,312
    Likes Received:
    7
    Yeah, it does become visible to the user if they view the source, which is a drawback if the utmost secrecy is required here, but if you don't give the user a reason to view the source (i.e. hide all references to the file and its download link within the above script) then they won't have any reason to view the source. It's cheap, but it's functional on any web host, so if the host doesn't support PHP or server-side includes, then that's your only option.
  10. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    Thanks for your answers!

    I just want to tell you that i don't really mind people seeing the source code since i myself copied a small part from other websites!
    I'm going to try the javascript, but im not sure i understand what you said, but i only want the download file to show on a pc!!

    EDIT: i just tried it, and it doesn't work! Neither on Ipod nor PC.... I'll look for more info tommorrow!

Share This Page