<?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>DaW - Labs &#187; PHP/HTML/CSS</title>
	<atom:link href="http://www.daw-labs.com/category/programacion/php-html-css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daw-labs.com</link>
	<description>¡La Informática al límite!</description>
	<lastBuildDate>Sat, 19 May 2012 17:56:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Grave vulnerabilidad en PHP-CGI</title>
		<link>http://www.daw-labs.com/grave-vulnerabilidad-en-php-cgi/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=grave-vulnerabilidad-en-php-cgi</link>
		<comments>http://www.daw-labs.com/grave-vulnerabilidad-en-php-cgi/#comments</comments>
		<pubDate>Mon, 07 May 2012 17:30:32 +0000</pubDate>
		<dc:creator>WindHack</dc:creator>
				<category><![CDATA[Inseguridad Informática]]></category>
		<category><![CDATA[Noticias]]></category>
		<category><![CDATA[PHP/HTML/CSS]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[grave]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[vulnerabilidad]]></category>

		<guid isPermaLink="false">http://www.daw-labs.com/?p=1689</guid>
		<description><![CDATA[Grave vulnerabilidad en PHP-CGI Importancia: 5 &#8211; Crítica Fecha de publicación: 03/05/2012 Recursos afectados Servidores web con PHP ejecutándose como CGI. Descripción Posibilita el paso de parámetros al intérprete, lo que permite la ejecución de código arbitrario y la revelación de información confidencial. Solución Ya existen módulos de la herramienta de pentesting y hacking metasploit&#8230;]]></description>
			<content:encoded><![CDATA[<p>Grave vulnerabilidad en PHP-CGI</p>
<p><strong>Importancia:</strong><br />
5 &#8211; Crítica</p>
<p><strong>Fecha de publicación:</strong><br />
03/05/2012</p>
<p><strong>Recursos afectados</strong><br />
Servidores web con PHP ejecutándose como CGI.</p>
<p><strong>Descripción</strong><br />
Posibilita el paso de parámetros al intérprete, lo que permite la ejecución de código arbitrario y la revelación de información confidencial.</p>
<p><strong>Solución</strong><br />
Ya existen módulos de la herramienta de pentesting y hacking metasploit que permiten explotar esta vulnerabilidad por lo que se recomienda actualizar cuanto antes. Se puede hacer a través del código fuente, aunque se recomienda instalarlo a través de los mecanismos de actualización de paquetes de Linux. Para sistemas Windows, se puede descargar de la web <a href="http://windows.php.net/download/">http://windows.php.net/download/</a>.<br />
Como alternativa, si no se puede actualizar, el fabricante propone las siguientes reglas del módulo mod_rewrite de Apache para bloquear las URLs maliciosas:</p>
<pre>RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]</pre>
<p><strong>Detalle</strong><br />
Eindbazen, un equipo de competiciones CTF, ha descubierto una vulnerabilidad en PHP-CGI que permite pasar parámetros al intérprete de PHP, como -s o -r, a través de la URL. Por ejemplo añadiendo la cadena &#8216;?-s&#8217;.<br />
Como resultado de la inyección de estos parámetros en la URL, se puede mostrar el contenido de archivos de código fuente (que puede incluir información confidencial como, por ejemplo, contraseñas de BBDD) o ejecutar código PHP arbitrario.<br />
Aunque el parámetro &#8216;-r&#8217;, para ejecutar código PHP, es filtrado en php5-cgi, dependiendo de las variables de entorno, esta medida de seguridad puede evitarse.<br />
PHP eliminó por error el código que protegía ante este problema en 2004.<br />
FastCGI no es vulnerable.</p>
<p><strong>Impacto:</strong><br />
Ejecución de código malicioso.<br />
Revelación de información confidencial.</p>
<p><strong>Exploit en .rb (Módulo para Metasploit):</strong><br />
<a href="https://github.com/rapid7/metasploit-framework/blob/2d1f4d4f3eb68ee599ac03be4d71e3c0c3443420/modules/exploits/unix/webapp/php_cgi_arg_injection.rb">https://github.com/rapid7/metasploit-framework/blob/2d1f4d4f3eb68ee599ac03be4d71e3c0c3443420/modules/exploits/unix/webapp/php_cgi_arg_injection.rb</a></p>
<p><strong>Ejemplo:</strong><br />
<a href="http://www.facebook.com/?-s">http://www.facebook.com/?-s</a></p>
<p>&nbsp;</p>
<p><em><strong>Fuente</strong></em><br />
<a href="http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/">http://eindbazen.net/2012/05/php-cgi-advisory-cve-2012-1823/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.daw-labs.com/grave-vulnerabilidad-en-php-cgi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Función para crear un enlace corto en PHP</title>
		<link>http://www.daw-labs.com/funcion-para-crear-un-enlace-corto-en-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=funcion-para-crear-un-enlace-corto-en-php</link>
		<comments>http://www.daw-labs.com/funcion-para-crear-un-enlace-corto-en-php/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 15:46:17 +0000</pubDate>
		<dc:creator>WindHack</dc:creator>
				<category><![CDATA[PHP/HTML/CSS]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[corto]]></category>
		<category><![CDATA[crear]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[enlace]]></category>
		<category><![CDATA[funcion]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.daw-labs.com/?p=1617</guid>
		<description><![CDATA[Esta es una función que permite crear un enlace corto mediante la API de TinyURL usando cUrl. &#60;?php /* by .:WindHack:. */ function GetTinyURL&#40;$Url&#41; &#123; $TinyURL = &#34;http://tinyurl.com/api-create.php?url=&#34;.$Url; &#160; $cURL = curl_init&#40;&#41;; curl_setopt&#40;$cURL, CURLOPT_URL, $TinyURL&#41;; curl_setopt&#40;$cURL, CURLOPT_RETURNTRANSFER, 1&#41;; $ShortURL = curl_exec&#40;$cURL&#41;; curl_close&#40;$cURL&#41;; &#160; return $ShortURL; &#125; &#160; /* Ejemplo de uso */ echo GetTinyURL&#40;'http://www.daw-labs.com'&#41;; /* La función devuelve:&#8230;]]></description>
			<content:encoded><![CDATA[<p>Esta es una función que permite crear un enlace corto mediante la API de TinyURL usando cUrl.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/* by .:WindHack:. */</span>
<span style="color: #000000; font-weight: bold;">function</span> GetTinyURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$TinyURL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://tinyurl.com/api-create.php?url=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$Url</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$cURL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$TinyURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<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: #000088;">$ShortURL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cURL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ShortURL</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Ejemplo de uso */</span>
<span style="color: #b1b100;">echo</span> GetTinyURL<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.daw-labs.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/* La función devuelve: http://tinyurl.com/6k2exuy */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.daw-labs.com/funcion-para-crear-un-enlace-corto-en-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Modificación al plugin MyBBPublisher</title>
		<link>http://www.daw-labs.com/modificacion-al-plugin-mybbpublisher/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=modificacion-al-plugin-mybbpublisher</link>
		<comments>http://www.daw-labs.com/modificacion-al-plugin-mybbpublisher/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 01:21:17 +0000</pubDate>
		<dc:creator>WindHack</dc:creator>
				<category><![CDATA[PHP/HTML/CSS]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[foro]]></category>
		<category><![CDATA[modificacion]]></category>
		<category><![CDATA[mybb]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[publicacion]]></category>

		<guid isPermaLink="false">http://www.daw-labs.com/?p=1589</guid>
		<description><![CDATA[Debido a diversas razones y a la sencillez con la que realiza las publicaciones el plugin para difundir los nuevos temas en sitios sociales (Facebook y Twitter), me vi en la obligación de realizar una modificación a MyBBPublisher, la cual está enfocada sólo en Facebook. Basándome en la referencia (API de facebook) y su método &#8216;post&#8216;, encontré los&#8230;]]></description>
			<content:encoded><![CDATA[<p>Debido a diversas razones y a la sencillez con la que realiza las publicaciones el plugin para difundir los nuevos temas en sitios sociales (<em>Facebook y Twitter</em>), me vi en la obligación de realizar una modificación a <strong>MyBBPublisher</strong>, la cual está enfocada sólo en <strong>Facebook.</strong></p>
<p>Basándome en la <a href="http://developers.facebook.com/docs/reference/api/post/" rel="nofollow" target="_blank">referencia (API de facebook)</a> y su método &#8216;<strong>post</strong>&#8216;, encontré los parámetros que pueden ser enviados para publicar contenido en nuestra &#8216;fan page&#8217;.</p>
<p>MyBBPublisher por defecto maneja sólo estos dos valores:</p>
<ul>
<li>access_token (indispensable)</li>
<li>message</li>
</ul>
<p>Sin embargo, esto nos dá muchas limitaciones, ya que el contenido enviado a facebook queda muy vacío.</p>
<p>Revisando un poco más la referencia, se pueden encontrar los siguientes campos:</p>
<ul>
<li>description -&gt; La descripción del enlace.</li>
<li>link -&gt; El enlace adjunto a la publicación.</li>
<li>picture -&gt; Nos permite agregar una imagen a la publicación.</li>
<li>name -&gt; El nombre del enlace.</li>
</ul>
<p>Ahora la cuestión radica en conseguir la información necesaria para cada parámetro. Ya se hace necesario abrir el archivo &#8220;<strong>mybbpublisher.php</strong>&#8221; para comenzar a modificar su contenido.</p>
<p>Primero que todo, buscamos aproximadamente la línea 661 donde se encuentra:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$text_fb</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mythread</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'subject'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y agregamos el siguiente código, el cual nos dará la descripción (texto) del tema recién publicado.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$message_fb</span> <span style="color: #339933;">=</span> htmlspecialchars_uni<span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mythread</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Explicando un poco, esto es fácil&#8230;Aplicamos el mismo método usado para obtener el &#8216;Asunto&#8217; del tema, pero según <a href="http://wiki.mybb.com/index.php/Database_Tables/mybb_posts" rel="nofollow" target="_blank">mybb_posts</a> para obtener el contenido del post se usa el campo &#8216;<strong>message</strong>&#8216;.</p>
<p>Bien, hasta acá ya conseguimos la descripción, el siguiente paso es modificar el array que guarda la información que será enviada a facebook.</p>
<p>Se encuentra aproximadamente entre la línea 665 ~ 668</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$datafb</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'type'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'t'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'id'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$mythread</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'msg'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$text_fb</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$message_fb</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">//Agregamos esta línea, que contiene la descripción.</span>
<span style="color: #0000ff;">'postid'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$mythread</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fb_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'postuid'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$mythread</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fb_uid'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ahora hacemos exactamente lo mismo en las funciones:<br />
<strong>mybbpublisher_editthread()</strong>: Aprox. líneas 765 y 779 ~ 781<br />
<strong>mybbpublisher_approvethreads()</strong>: Aprox. líneas 820 y 833 ~ 835</p>
<p>El siguiente cambio se debe hacer en las líneas 1306 ~ 1316:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$desc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Agregamos este valor.</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'postid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postuid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'postuid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ya casi está terminada la modificación al plugin. El último paso es editar lo siguiente:</p>
<p>Debemos buscar el comentario:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//$message = &quot;A new announcement, '&quot;.$msg.&quot;', has been posted to our forums&quot;.($url!=&quot;&quot; ? &quot; at: &quot;.$url.&quot;.&quot; : &quot;.&quot;);</span></pre></div></div>

<p>Borrar lo que haya ahí, y poner este código:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tpURL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//El enlace del tema</span>
<span style="color: #000088;">$tpName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//El asunto del tema</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Limitar contenido de la descripción</span>
<span style="color: #666666; font-style: italic;">//$tpContent = substr($desc, 0, 384).'...Continúa leyendo en nuestro foro';</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Eliminar BBCode.</span>
<span style="color: #000088;">$tpContent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\[.+?\]/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$desc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y luego, un poco más abajo, está el array que se encarga de reunir todo lo que se enviará y publicará en facebook.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$attachment</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'access_token'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mybb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">settings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mybbpublisher_fb_access_token_page'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>                                                                                <span style="color: #0000ff;">'message'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span>                                                    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En ese array debemos de agregar los siguientes valores.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$attachment</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'access_token'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$mybb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">settings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mybbpublisher_fb_access_token_page'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>                        
<span style="color: #0000ff;">'message'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'¡Hay un nuevo tema en nuestro foro!'</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'picture'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://i43.tinypic.com/wqxxsg.png'</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'link'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tpURL</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tpName</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tpContent</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Recordar que los parámetros message y picture pueden ser libremente cambiados.</p>
<p>Eso es todo, una vez finalizado&#8230;Tendremos algo así:</p>
<div id="attachment_1591" class="wp-caption aligncenter" style="width: 477px"><a href="http://www.daw-labs.com/wp-content/uploads/2012/01/AntesDespues.png"><img class="size-full wp-image-1591" title="AntesDespues" src="http://www.daw-labs.com/wp-content/uploads/2012/01/AntesDespues.png" alt="" width="467" height="291" /></a><p class="wp-caption-text">Antes y después</p></div>
<p>Por cierto, esta es una modificación rápida y funcional, PERO algunas funciones deben ser leídas detenidamente ya que se deben de realizar también algunos cambios en ellas&#8230;</p>
<p>Aquí dejo el plugin, con la modificación anterior realizada.</p>
<p>- <a href="http://db.tt/PiVr6Cun" rel="nofollow" target="_blank">http://db.tt/PiVr6Cun</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.daw-labs.com/modificacion-al-plugin-mybbpublisher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firma «dinámica» en PHP</title>
		<link>http://www.daw-labs.com/firma-en-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=firma-en-php</link>
		<comments>http://www.daw-labs.com/firma-en-php/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 22:58:39 +0000</pubDate>
		<dc:creator>WindHack</dc:creator>
				<category><![CDATA[PHP/HTML/CSS]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Dinámica]]></category>
		<category><![CDATA[Diseño]]></category>
		<category><![CDATA[Firma]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://daw-labs.com/?p=1022</guid>
		<description><![CDATA[¡Buenas tardes! Hace mucho tiempo quería saber cómo hacer esas firmas que tienen datos «dinámicos» ya sea texto, imágenes, entre otras cosas. Investigué un poco y encontré una manera de hacerlo, por lo cuál decidí crear ésta entrada. Necesitamos principalmente un host para alojar el archivo, sea éste pago o gratuito. En todo caso el&#8230;]]></description>
			<content:encoded><![CDATA[<p><em>¡Buenas tardes!</em></p>
<p>Hace mucho tiempo quería saber cómo hacer esas firmas que tienen datos <em>«dinámicos»</em> ya sea texto, imágenes, entre otras cosas. Investigué un poco y encontré una manera de hacerlo, por lo cuál decidí crear ésta entrada.</p>
<p>Necesitamos principalmente un host para alojar el archivo, sea éste pago o gratuito. En todo caso el requisito más importante es que tenga la <strong>librería GD</strong> activada.</p>
<p>Para empezar, hay que tener la imagen que servirá de base y/o fondo. En mi caso elegí ésta:</p>
<div id="attachment_1024" class="wp-caption alignleft" style="width: 460px"><a href="http://daw-labs.com/wp-content/uploads/2010/10/WindHack.png"><img class="size-full wp-image-1024" title="Firma de .:WindHack:." src="http://daw-labs.com/wp-content/uploads/2010/10/WindHack.png" alt="Imagen de fondo para la firma dinámica." width="450" height="150" /></a><p class="wp-caption-text">Imagen de fondo para la firma dinámica.</p></div>
<p>Recuerden elegir una que esté bien estilizada, sea de buenas tonalidades y muy clara para lo que desean hacer.</p>
<p>También pueden darle algunos retoques en la zona donde se mostrará el texto para hacer más énfasis.</p>
<p>Ahora hay que programar el código PHP que se encargará de escribir y «editar» la imagen.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
        <span style="color: #666666; font-style: italic;">/* 
         * Escrito por .:WindHack:.                
         * Agradecimientos: Kenkeiras             
         * www.daw-labs.com &amp; www.cibernodo.net    
         */</span>
&nbsp;
        <span style="color: #000088;">$UserAgent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$IP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/* GetBrowser($UserA)
         * Esta función se encarga de obtener el nombre del navegador
         * usando como medio la cadena del UserAgent.
         */</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> GetBrowser<span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Chrome&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Chrome&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Firefox&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Firefox&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;MSIE&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Internet Explorer&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Opera&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Opera&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Safari&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Safari&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">else</span>
                    <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(?)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$Browser</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/* GetOS($UserA)
         * Esta función usa el mismo método que la anterior,
         * exceptuando que se encarga sólo de obtener el nombre
         * del Sistema Operativo (OS).
         */</span>
        <span style="color: #000000; font-weight: bold;">function</span> GetOS<span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Windows&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Windows&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Linux&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Linux&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strstr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserA</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Mac&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;MAC&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">else</span>
                <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(?)&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$OS</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">/* Tipo de contenido. Puede ser JPEG, GIF, etc. */</span>
        <span style="color: #990000;">Header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: Image/PNG&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #666666; font-style: italic;">/* Crea la imagen desde un PNG. */</span>
        <span style="color: #000088;">$ImageC</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateFromPNG</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;WindHack.png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #666666; font-style: italic;">/* Establece el color. */</span>
        <span style="color: #000088;">$Color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageColorAllocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ImageC</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">18</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">33</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">95</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/* 
         * ImageString(Imagen,Tam.Letra,PosX,PosY,Texto,Color);
         * 
         * Escribe en la imagen.
         */</span>
        <span style="color: #990000;">ImageString</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ImageC</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Tu IP es: <span style="color: #006699; font-weight: bold;">$IP</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$Color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #666666; font-style: italic;">/* Obtenemos valores...*/</span>
        <span style="color: #000088;">$Browser</span> <span style="color: #339933;">=</span> GetBrowser<span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserAgent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$OS</span> <span style="color: #339933;">=</span> GetOS<span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserAgent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*Si el resultado de ambos es diferente a &quot;&quot;, escribimos...*/</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Browser <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">&amp;&amp;</span> OS <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #990000;">ImageString</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ImageC</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Y usas <span style="color: #006699; font-weight: bold;">$Browser</span> en <span style="color: #006699; font-weight: bold;">$OS</span>...&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$Color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/* Se convierte a PNG. */</span>
        <span style="color: #990000;">ImagePNG</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ImageC</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/* Se libera el espacio. */</span>
        <span style="color: #990000;">ImageDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ImageC</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Terminado ésto, tendremos como resultado:<br />
<img src="http://windsign.totalh.com/WindSig.php" alt="Imagen terminada." /></p>
<p>¡Saludos!.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daw-labs.com/firma-en-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

