dumb2champ Posted November 2, 2014 Share Posted November 2, 2014 Help guys!!!Basically i want to return/display User OS info/name from input field...Below my unfinished scripts.. <?php $user_agent = $_SERVER['HTTP_USER_AGENT']; function getOS() { global $user_agent; $os_platform = "Unknown OS Platform"; $os_array = array( '/windows nt 6.2/i' => 'Windows 8', '/windows nt 6.1/i' => 'Windows 7', '/windows nt 6.0/i' => 'Windows Vista', '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', '/windows nt 5.1/i' => 'Windows XP', '/windows xp/i' => 'Windows XP', '/windows nt 5.0/i' => 'Windows 2000', '/windows me/i' => 'Windows ME', '/win98/i' => 'Windows 98', '/win95/i' => 'Windows 95', '/win16/i' => 'Windows 3.11', '/macintosh|mac os x/i' => 'Mac OS X', '/mac_powerpc/i' => 'Mac OS 9', '/linux/i' => 'Linux', '/ubuntu/i' => 'Ubuntu', '/iphone/i' => 'iPhone', '/ipod/i' => 'iPod', '/ipad/i' => 'iPad', '/android/i' => 'Android', '/blackberry/i' => 'BlackBerry', '/webos/i' => 'Mobile' ); foreach ($os_array as $regex => $value) { if (preg_match($regex, $user_agent)) { $os_platform = $value; } } return $os_platform; } function getBrowser() { global $user_agent; $browser = "Unknown Browser"; $browser_array = array( '/msie/i' => 'Internet Explorer', '/firefox/i' => 'Firefox', '/safari/i' => 'Safari', '/chrome/i' => 'Chrome', '/opera/i' => 'Opera', '/netscape/i' => 'Netscape', '/maxthon/i' => 'Maxthon', '/konqueror/i' => 'Konqueror', '/mobile/i' => 'Handheld Browser' ); foreach ($browser_array as $regex => $value) { if (preg_match($regex, $user_agent)) { $browser = $value; } } return $browser; } $user_os = getOS(); $user_browser = getBrowser(); $device_details = "<strong>Browser: </strong>".$user_browser."<br /><strong>Operating System: </strong>".$user_os.""; print_r($device_details); //detail //echo("<br /><br /><br />".$_SERVER['HTTP_USER_AGENT'].""); ?> Above scripts works well when I run it...It will display my OS versionBut the problem it is, I want to create an input field so user can key in any IP address and the scripts above will display the OS info/name if valid else invalid... Above scripts use.. $user_agent = $_SERVER['HTTP_USER_AGENT']; that automatically display OS info/name...But I want manually key in the IP from input field and the scripts above will display correspond OS info/name from the input field...how to change scripts above...especially $user_agent = $_SERVER['HTTP_USER_AGENT']; so it can return IP address from input field?? I`m greatly honor if you guys would like to help out.. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 2, 2014 Share Posted November 2, 2014 You keep saying IP address but I don't think that's what you mean. Are you saying you want to get the value of $user_agent from the user instead of $_SERVER? Quote Link to comment Share on other sites More sharing options...
dumb2champ Posted November 2, 2014 Author Share Posted November 2, 2014 Yes that right..Can you help me out?? Quote Link to comment Share on other sites More sharing options...
dumb2champ Posted November 2, 2014 Author Share Posted November 2, 2014 I have list of ip on my network(neighbor,staff)...so i want to create a scripts that perform OS name detection from the list table....Help me Quote Link to comment Share on other sites More sharing options...
requinix Posted November 2, 2014 Share Posted November 2, 2014 Alright. First off, please stop saying "IP". This has absolutely nothing to do with IP addresses... unless... Exactly what are you entering? An IP address? Or a user-agent string? If you're thinking that you can enter an IP address and detect their operating system, you are very wrong. Quote Link to comment Share on other sites More sharing options...
dumb2champ Posted November 2, 2014 Author Share Posted November 2, 2014 Ok I`ll will explain to you detail of what i`m trying to achieve...I have a list of IP(sorry) on my network...and I have succeed ping out all the ranges of IP from table list...So what I trying to figure is how to display their OS name???I dont know how to do...I`ve to search out about $user_agent...but i dont know how to used it...i`ll also have try diff function including gethostbyaddr,gethostbyname,etc but with my host, it succed but other host not succed.. If i`ll use $user_agent how to do it to display OS name of my list of network host???Thank for your concern...it been hour try to search at diff forum,google but not succed.... Quote Link to comment Share on other sites More sharing options...
requinix Posted November 2, 2014 Share Posted November 2, 2014 I have a list of IP(sorry) on my network...and I have succeed ping out all the ranges of IP from table list... So what I trying to figure is how to display their OS name??? That is not possible. Quote Link to comment Share on other sites More sharing options...
dumb2champ Posted November 2, 2014 Author Share Posted November 2, 2014 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.