<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Omnia sunt communia &#187; browser</title>
	<atom:link href="http://www.blog.amrlima.info/archives/tag/browser/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.amrlima.info</link>
	<description>gnu/linux, cultura livre e outras divagações</description>
	<lastBuildDate>Fri, 20 Jan 2012 20:18:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>User&#8217;s browser and platform php class</title>
		<link>http://www.blog.amrlima.info/archives/988</link>
		<comments>http://www.blog.amrlima.info/archives/988#comments</comments>
		<pubDate>Sat, 07 Aug 2010 18:22:14 +0000</pubDate>
		<dc:creator>amrlima</dc:creator>
				<category><![CDATA[Programação]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[user agent]]></category>

		<guid isPermaLink="false">http://www.blog.amrlima.info/?p=988</guid>
		<description><![CDATA[Because I&#8217;ve been working in a drupal website, I tought it would be handy to learn some php so I can make some scripts for it, although I&#8217;m still a long long way from making a working drupal module. For now I&#8217;m using php code input format when I want to include some script.
As parte [...]]]></description>
			<content:encoded><![CDATA[<p>Because I&#8217;ve been working in a drupal website, I tought it would be handy to learn some php so I can make some scripts for it, although I&#8217;m still a long long way from making a working drupal module. For now I&#8217;m using php code input format when I want to include some script.</p>
<p>As parte of my learning I made a class (which I&#8217;me really not using for anythin now) to detect user browser and platform. It uses HTTP_USER_AGENT to obtain the relevant information. Note that te code is mostly untested. I just tested Firefox and Chromium under Linux and Chrome and IE under Windows.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Agent<span style="color: #009900;">&#123;</span>
 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_browser</span><span style="color: #339933;">;</span>
 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_os</span><span style="color: #339933;">;</span>
 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_browsers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;firefox&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;msie&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;chrome&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;opera&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;safari&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mozilla&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_OS</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;windows&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;win32&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;linux&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;machintosh&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __Construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #666666; font-style: italic;">//Get user agent</span>
 		<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
 		<span style="color: #666666; font-style: italic;">//Lower string case for easier matches</span>
 		<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 		<span style="color: #b1b100;">print</span> <span style="color: #000088;">$info</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 		<span style="color: #666666; font-style: italic;">//Search for browser</span>
 		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gt</span><span style="color: #339933;">;</span>_browsers <span style="color: #b1b100;">as</span> <span style="color: #000088;">$browser</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
 			 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 			 	<span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
 			 <span style="color: #009900;">&#125;</span>
&nbsp;
 			 <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
 			 	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser <span style="color: #339933;">=</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">;</span>
&nbsp;
 			 	<span style="color: #666666; font-style: italic;">//We need to change the name os IE from msie to IE</span>
 			 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser <span style="color: #339933;">===</span> <span style="color: #0000ff;">&quot;msie&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Internet &quot;</span> <span style="color: #339933;">.</span>
 			 			<span style="color: #0000ff;">&quot;Explorer&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 			 	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// We've found the browser, leave the loop</span>
 			 <span style="color: #009900;">&#125;</span>
 		<span style="color: #009900;">&#125;</span>
&nbsp;
 		<span style="color: #666666; font-style: italic;">//Search for OS</span>
 		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gt</span><span style="color: #339933;">;</span>_OS <span style="color: #b1b100;">as</span> <span style="color: #000088;">$os</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
 			 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span> <span style="color: #000088;">$os</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
 			 	<span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
 			 <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
 			 	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os <span style="color: #339933;">=</span> <span style="color: #000088;">$os</span><span style="color: #339933;">;</span>
&nbsp;
 			 	<span style="color: #666666; font-style: italic;">//If windows identifies as win32 we change it to Windows</span>
 			 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;win32&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Windows&quot;</span><span style="color: #339933;">;</span>
&nbsp;
 			 	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//We've found our OS, leave loop</span>
 			 <span style="color: #009900;">&#125;</span>
 		<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Make first letter of browser and OS uppercase</span>
 	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser <span style="color: #339933;">=</span> <span style="color: #990000;">ucfirst</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os <span style="color: #339933;">=</span> <span style="color: #990000;">ucfirst</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Selector that returns browser type. The b in Browser is capitalized because of the</span>
 	<span style="color: #666666; font-style: italic;">//library funtion get_browser</span>
 	<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">get_Browser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser<span style="color: #339933;">;</span>
 	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Selector returns os</span>
 	<span style="color: #000000; font-weight: bold;">function</span> get_os<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os<span style="color: #339933;">;</span>
 	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Browser modifier</span>
 	<span style="color: #000000; font-weight: bold;">function</span> set_browser<span style="color: #009900;">&#40;</span>string <span style="color: #000088;">$browser</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser <span style="color: #339933;">=</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">;</span>
 	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Os modifier</span>
 	<span style="color: #000000; font-weight: bold;">function</span> set_os<span style="color: #009900;">&#40;</span>string <span style="color: #000088;">$os</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os <span style="color: #339933;">=</span> <span style="color: #000088;">$os</span><span style="color: #339933;">;</span>
 	<span style="color: #009900;">&#125;</span>
&nbsp;
 	<span style="color: #666666; font-style: italic;">//Print browser and OS</span>
 	<span style="color: #000000; font-weight: bold;">function</span> print_agent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 		<span style="color: #b1b100;">print</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_browser<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;@&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_os<span style="color: #339933;">;</span>
 	<span style="color: #009900;">&#125;</span> 
&nbsp;
 <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.blog.amrlima.info/archives/988/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Opera open source&#8230;</title>
		<link>http://www.blog.amrlima.info/archives/425</link>
		<comments>http://www.blog.amrlima.info/archives/425#comments</comments>
		<pubDate>Sat, 06 Dec 2008 18:19:25 +0000</pubDate>
		<dc:creator>amrlima</dc:creator>
				<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Outros]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[opera]]></category>

		<guid isPermaLink="false">http://www.blog.amrlima.info/?p=425</guid>
		<description><![CDATA[Era bom não era? Ok, foi de mau gosto por este título, mas não é uma notícia, é um desejo meu. Já não experimentava o Opera há bastante tempo e utilizando-o durante 10 minutos, gostei bastante. A renderização parece ser mais rápida que a do Firefox. Parece iniciar mais rapidamente também. Instalar extensões ou skins [...]]]></description>
			<content:encoded><![CDATA[<p>Era bom não era? Ok, foi de mau gosto por este título, mas não é uma notícia, é um desejo meu. Já não experimentava o Opera há bastante tempo e utilizando-o durante 10 minutos, gostei bastante. A renderização parece ser mais rápida que a do Firefox. Parece iniciar mais rapidamente também. Instalar extensões ou skins é muito rápido e não requer reinicio&#8230; Então pensei&#8230; &#8220;se o Opera fosse open-source trocava de browser&#8230;&#8221;</p>
<p>Não quer dizer que não o mantenha por aqui para ir testando de vez em quando e fazendo algumas comparações.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.amrlima.info/archives/425/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

