Readily downloadable to YOUR O/S ?

Discussion in 'Web Design and Development' started by EvanLugh, Feb 29, 2008.

  1. EvanLugh macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #1
    I'm pretty sure I could use User Agents but nethertheless,
    I would like to have downloads on a certain project, but only the download for YOUR operating system would show.
    Example:
    1. I'm using 10.5.2
    2. I go to my download page
    3. "Download for Mac OS"

    Thanks :eek:
     
  2. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #2
    do you mean something similar to the firefox site how it shows the download link for your OS when you view it. If it is, it would require some javascript or php to check the user agent and display the correct link
     
  3. EvanLugh thread starter macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #3
    Yep, perfect example. Can anyone help me out, please? :rolleyes:
     
  4. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #4
    language? :rolleyes:
     
  5. EvanLugh thread starter macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #5
    I'm English :D

    Preferably html/php/java if possible, Thankyouu!
     
  6. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #6
    just found this in google, you would have to modify it so it said the right os, but...
    PHP:
    <?
    $os getenv ("HTTP_USER_AGENT");
    if (
    strstr($os'Linux'))
    {
    print(
    "<b>LINUX</b>");
    }
    else
    {
    print(
    "NOT LINUX");
    }
    ?>
     
  7. EvanLugh thread starter macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #7
    Thanks tominated but I need it to print an image as well as being linked.
     
  8. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
  9. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #9
    in the print bit you can put any html
     
  10. EvanLugh thread starter macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #10
    Code:
    [B]if(eregi("linux",$_SERVER['HTTP_USER_AGENT'])){$system = "Linux";}
            elseif(eregi("win32",$_SERVER['HTTP_USER_AGENT'])){$system = "Windows";}[/B]
            elseif(eregi("Win 9x 4.90",$_SERVER['HTTP_USER_AGENT'])){$system = "Windows Me";}
    elseif(eregi("windows 2000",$_SERVER['HTTP_USER_AGENT']) || eregi("(windows nt)( ){0,1}
    (5.0)",$_SERVER['HTTP_USER_AGENT']) ){$system = "Windows 2000";}
    elseif(eregi("(windows nt)( ){0,1}(5.1)",$_SERVER['HTTP_USER_AGENT']) ){$system = "Windows
    XP";}
            elseif( (eregi("(win)([0-9]{2})",$_SERVER['HTTP_USER_AGENT'],$regs)) || (eregi
    ("(windows) ([0-9]{2})",$_SERVER['HTTP_USER_AGENT'],$regs)) ){$system = "Windows $regs[2]";}
            elseif(eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs) )
    {$system = "Windows NT $regs[2]";}
            elseif(eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER
    ['HTTP_USER_AGENT'],$regs) ){$system = "Windows NT $regs[3]";}
            elseif(eregi("mac",$_SERVER['HTTP_USER_AGENT'])){$system = "Macintosh";}
            elseif(eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER
    ['HTTP_USER_AGENT'],$regs)){$system = "SunOS $regs[2]";}
            elseif(eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs))
    {$system = "BeOS $regs[2]";}
            elseif(eregi("freebsd",$_SERVER['HTTP_USER_AGENT'])){$system = "FreeBSD";}
            elseif(eregi("openbsd",$_SERVER['HTTP_USER_AGENT'])){$system = "OpenBSD";}
            elseif(eregi("irix",$_SERVER['HTTP_USER_AGENT'])){$system = "IRIX";}
            elseif(eregi("os/2",$_SERVER['HTTP_USER_AGENT'])){$system = "OS/2";}
            elseif(eregi("plan9",$_SERVER['HTTP_USER_AGENT'])){$system = "Plan9";}
            elseif(eregi("unix",$_SERVER['HTTP_USER_AGENT']) || eregi("hp-ux",$_SERVER
    ['HTTP_USER_AGENT']) || eregi("X11",$_SERVER['HTTP_USER_AGENT']) ){$system = "Unix";}
            elseif(eregi("osf",$_SERVER['HTTP_USER_AGENT'])){$system = "OSF";}
            else{$system = "Unknown";}
            [B]if (eregi("mac"))
    		{
    		print("<b>MAC</b>");
    		}
    		else
    		print ("<a href=http://www.m......com/joomla/>Download For Mac</a>");
    		echo "You are using $browser on a $system system<br>";		
    	  	if (eregi("linux"))
    		{
    		print("<b>linux</b>");
    		}
    		else
    		print ("<a href=http://www.my.......com/joomla/>Download For Linux</a>");
    		echo "You are using $browser on a $system system<br>";[/B]
    This is what i've been making up.. unfortunatly it displays both Mac and linux even though i have everything in order. Help please? Thanks
     
  11. EvanLugh thread starter macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land

Share This Page