{"id":4,"date":"2007-06-27T13:45:03","date_gmt":"2007-06-27T18:45:03","guid":{"rendered":"http:\/\/www.tigoe.com\/pcomp\/code2\/?p=4"},"modified":"2008-01-21T21:31:29","modified_gmt":"2008-01-22T02:31:29","slug":"browser-sniffer","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/PHP\/4\/","title":{"rendered":"Browser Sniffer"},"content":{"rendered":"<p>Here&#8217;s a short PHP script that gathers info about the browser and the IP address of the client and returns it via email. I used it to gather data on cell phone browsers, and got the results seen at the bottom over the course of a day. Thanks to all those folks who hit it.<\/p>\n<p><!-- technorati tags start --><\/p>\n<p style=\"text-align:right;font-size:10px;\">Technorati Tags: <a href=\"http:\/\/www.technorati.com\/tag\/networked objects\" rel=\"tag\">networked objects<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/networks\" rel=\"tag\">networks<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/PHP\" rel=\"tag\">PHP<\/a><\/p>\n<p><!-- technorati tags end --><br \/>\n<!--more--><\/p>\n<pre>\n&lt;?php\n\/*\n\tPhone Finder\n\tLanguage: PHP  \n\n\tIdentifies the user agent and IP address.  Runs on mobile phones.\n\n*\/\n  $userAgent =  $_ENV[\"HTTP_USER_AGENT\"];\n  $ipAddress =  $_ENV[\"REMOTE_ADDR\"];\n  sendEmail('you@yourserver.com', 'user agent', \"$userAgent $ipAddress\");\n\n  \techo &lt;&lt;&lt;END\n&lt;html&gt;\n&lt;head&gt;&lt;\/head&gt; \n\n&lt;body&gt;\n\t&lt;h2&gt;Hi There&lt;\/h2&gt;\n\t\tYour IP: $ipAddress&lt;br&gt;\n\t\tYour browser: $userAgent&lt;br&gt;\n\t\tThanks!\n&lt;\/body&gt;\n&lt;\/html&gt;\nEND;\n  end;\n\nfunction sendEmail($to, $subject, $message) {\n\t$from = \"phone@yourserver.com\";\n\tmail($to, $subject, $message, \"From: $from\");\n}\n  ?&gt;<\/pre>\n<hr \/>\n<p> Here&#8217;s a sampling of some of the phones that hit it.  IP addresses deleted to protect the innocent:<\/p>\n<pre>\nMozilla\/5.0 (SymbianOS\/9.1; U; en-us) AppleWebKit\/413 (KHTML, like Gecko) Safari\/\nNokiaN73-1\/2.0628.0.0.1 S60\/3.0 Profile\/MIDP-2.0 Configuration\/CLDC-1.1\nNokiaN93-1\/20.0.058 SymbianOS\/9.1 Series60\/3.0 Profile\/MIDP-2.0 Configuration\/CLDC-1.1\nNokia6230\/2.0 (05.51) Profile\/MIDP-2.0 Configuration\/CLDC-1.1 UP.Link\/6.3.0.0.0\nBlackBerry8100\/4.2.0 Profile\/MIDP-2.0 Configuration\/CLDC-1.1 VendorID\/100\nBlackBerry7230\/3.7.0\nBlackBerry7290\/4.1.0 Profile\/MIDP-2.0 Configuration\/CLDC-1.1 VendorID\/100 216.9.250.99\nLGE-PM325\/1.0 UP.Browser\/6.2.3.2 (GUI) MMP\/2.0\nPalm680\/RC1 Mozilla\/4.0 (compatible; MSIE 6.0; Windows 98; PalmSource\/Palm-D053; Blazer\/4.5) 16;320x320 UP.Link\/6.3.0.0.\nMozilla\/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320) BlackBerry8100\/4.2.0 Profile\/MIDP-2.0 Configuration\/CLDC-1.1 VendorID\/100\nMozilla\/4.0 (compatible; MSIE 6.0; Windows 98; PalmSource\/Palm-D052; Blazer\/4.5) 16;320x320 68.28.123.118\nSAMSUNG-SGH-A707\/1.0 SHP\/VPP\/R5 NetFront\/3.3 SMM-MMS\/1.2.0 profile\/MIDP-2.0 configuration\/CLDC-1.1 UP.Link\/6.3.0.0.0\nMozilla\/4.0 (MobilePhone RL-4920\/US\/1.0) NetFront\/3.1 MMP\/2.0\nMozilla\/4.0 Sprint:MotoQ (compatible; MSIE 4.01; Windows CE; Smartphone; 176x220)\nSonyEricssonW810i\/R4CE Browser\/NetFront\/3.3 Profile\/MIDP-2.0 Configuration\/CLDC-1.1 UP.Link\/6.3.1.17.0\nNokia6682\/2.0 (4.62.0) SymbianOS\/8.0 Series60\/2.6 Profile\/MIDP-2.0 Configuration\/CLDC-1.1 UP.Link\/6.3.0.0.0\nMOT-RAZRV3xx\/96.71.95R BER2.2 Mozilla\/4.0 (compatible; MSIE 6.0; 11063081) Profile\/MIDP-2.0 Configuration\/CLDC-1.1  Opera 8.00 [en] UP.Link\/6.3.0.0.0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a short PHP script that gathers info about the browser and the IP address of the client and returns it via email.  I used it to gather data on cell phone browsers, and got the results seen at the bottom over the course of a day.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4","post","type-post","status-publish","format-standard","hentry","category-PHP"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/4","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":0,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}