<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>znBlog v4.0 - Coding</title>
    <link>http://znblog.athoim.com/</link>
    <description>Hielo en la Red</description>
    <dc:language>es</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <pubDate>Tue, 29 Apr 2008 09:36:35 GMT</pubDate>

    <image>
        <url>img/rss_big.png</url>
        <title>RSS: znBlog v4.0 - Coding - Hielo en la Red</title>
        <link>http://znblog.athoim.com/</link>
        <width>128</width>
        <height>128</height>
    </image>

<item>
    <title>Diabólico Twitter</title>
    <link>http://znblog.athoim.com/archives/77-Diabolico-Twitter.html</link>
            <category>Web</category>
    
    <comments>http://znblog.athoim.com/archives/77-Diabolico-Twitter.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=77</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=77</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Al final he caído, yo no quería, pero me han obligado  &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/cry.png&quot; alt=&quot;:&#039;(&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://twitter.com/znk3r&quot; title=&quot;http://twitter.com/znk3r&quot;&gt;http://twitter.com/znk3r&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Supongo que al final terminaré poniendo algún módulo en el lateral  &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/dry.gif&quot; alt=&quot;:dry:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; &lt;br /&gt;
&lt;br /&gt;
Por cierto, a partir de la semana que viene (que espero volver a tener dinero) continuare con los artículos sobre HTPCs y como montarte el tuyo propio bajo Linux.  
    </content:encoded>

    <pubDate>Thu, 24 Apr 2008 00:50:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/77-guid.html</guid>
    
</item>
<item>
    <title>Serendipity Atom Bug</title>
    <link>http://znblog.athoim.com/archives/61-Serendipity-Atom-Bug.html</link>
            <category>PHP</category>
    
    <comments>http://znblog.athoim.com/archives/61-Serendipity-Atom-Bug.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=61</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=61</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Parece ser que el creador de feeds Atom del serendipity tiene unos cuantos bugs. Tengo que mirarlo más en profundidad, pero si podéis procurad usar el RSS2.0 en vez del ATOM, por lo que he comprobado funciona mejor y da menos problemas. &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/drop.gif&quot; alt=&quot;:drop:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;  
    </content:encoded>

    <pubDate>Sat, 23 Feb 2008 16:46:16 -0500</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/61-guid.html</guid>
    
</item>
<item>
    <title>Serendipity plugin bug</title>
    <link>http://znblog.athoim.com/archives/59-Serendipity-plugin-bug.html</link>
            <category>PHP</category>
    
    <comments>http://znblog.athoim.com/archives/59-Serendipity-plugin-bug.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=59</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=59</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Como algún lector perspicaz habrá visto en las últimas horas, el blog ha salido con un bug. No se mostraban correctamente los enlaces para ver la entrada anterior y la siguiente.&lt;br /&gt;
&lt;br /&gt;
Para los que no conozcan &lt;a href=&quot;http://www.s9y.org&quot; title=&quot;Serendipity&quot;&gt;serendipity&lt;/a&gt;, les diré que casi todo en este CMS funciona mediante plugins. Es una de las cosas que me gusta de él, ya que a diferencia de otros &lt;a href=&quot;http://wordpress.org/&quot; title=&quot;Wordpress&quot;&gt;CMSs&lt;/a&gt; más prepotentes y caprichosos, no toma decisiones por ti. Si quieres un editor WYSIWYG puedes elegir entre 3 o 4, y si no quieres uno de esos bichos, pues lo descartas.&lt;br /&gt;
&lt;br /&gt;
La funcionalidad para mostrar el link que te permite pasar a la entrada anterior y la siguiente también es un plugin, en este caso: &lt;strong&gt;serendipity_event_entrypaging&lt;/strong&gt;. El bug que impedía pasar al post siguiente venía de la consulta a la base de datos y la diferencia horaria con el servidor (&lt;em&gt;+9 horas&lt;/em&gt;). En lugar de sumar 9 horas a la hora del servidor, las restaba.&lt;br /&gt;
&lt;br /&gt;
Si usáis serendipity y sufrís el mismo problema, revisad el fichero &lt;em&gt;serendipity_event_entrypaging.php&lt;/em&gt;, buscad la definición de la función &lt;strong&gt;timeOffset&lt;/strong&gt; y quitad el &lt;em&gt;true&lt;/em&gt; de la llamada a la función &lt;em&gt;serendipity_serverOffsetHour&lt;/em&gt;. Ese valor booleano define si se debe aplicar un offset negativo o no al tiempo. No se porque extraño motivo los creadores del plugin querían aplicar un tiempo negativo al offset, ya que con configurar la variable a &quot;-9&quot; el cambio estaría hecho.&lt;br /&gt;
&lt;br /&gt;
La nueva función quedará de esta forma.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; timeOffset&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$timestamp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/function_exists&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;function_exists&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;serendipity_serverOffsetHour&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; serendipity_serverOffsetHour&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$timestamp&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$timestamp&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;  
    </content:encoded>

    <pubDate>Fri, 22 Feb 2008 04:42:17 -0500</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/59-guid.html</guid>
    
</item>
<item>
    <title>Curso de creacion de video juegos</title>
    <link>http://znblog.athoim.com/archives/53-Curso-de-creacion-de-video-juegos.html</link>
            <category>Coding</category>
    
    <comments>http://znblog.athoim.com/archives/53-Curso-de-creacion-de-video-juegos.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=53</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=53</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Acabo de hacer la pre-inscripción para un curso de creación de vídeo-juegos que va a dar la UPV. El curso va a durar toda una semana de 10 de la mañana a 2 de la tarde (20 horitas en total). No es mucho tiempo para tratar un tema tan extenso, pero el &lt;a href=&quot;http://www.cfp.upv.es/cfp-posei2-web/inicio/curso_datos.jsp?idioma=es&amp;amp;boletin=true&amp;amp;codigo=40162&amp;amp;cid=15919&quot; title=&quot;Temario&quot;&gt;temario&lt;/a&gt; se plantea mas que interesante &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; Una de las cosas que mas destaco, es que se usarán APIs y herramientas libres. Y lo segundo a destacar es el precio: 120€, el precio no esta nada mal.&lt;br /&gt;
&lt;br /&gt;
Siempre he querido meterme a saco en el mundo de los vídeo-juegos. Al final no lo he conseguido (y lo veo difícil a estas alturas), pero va a ser un curso muy interesante. Tendré que ir recordando cosas de C++, que tanto programa en C me ha carcomido secuencialmente el cerebro xDDD  
    </content:encoded>

    <pubDate>Tue, 22 May 2007 22:21:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/53-guid.html</guid>
    
</item>
<item>
    <title>Novedades del CMS</title>
    <link>http://znblog.athoim.com/archives/37-Novedades-del-CMS.html</link>
            <category>Web</category>
    
    <comments>http://znblog.athoim.com/archives/37-Novedades-del-CMS.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=37</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=37</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    El nuevo CMS estaba terminado desde hace mas de un mes, pero hasta hace unas semanas no he tenido tiempo de terminar el diseño de mi blog &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/blink.gif&quot; alt=&quot;:blink:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; El nuevo blog de &lt;a href=&quot;http://i-dream.allyenna.net&quot; title=&quot;Illussion Dream&quot;&gt;Ally&lt;/a&gt; aun tardará un poco en salir, porque tiene algunos problemas con su diseño y anda muy agobiada en clase.&lt;br /&gt;
&lt;br /&gt;
Bueno, el nuevo CMS tiene muchas novedades, una de ellas es la posibilidad de tener introducciones (como esta) y mensajes ampliados, así que pulsad por ahí abajo para ver el mensaje completo &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/laugh.png&quot; alt=&quot;:D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; ¿Ya estáis aquí? Perfecto!  &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/china.gif&quot; alt=&quot;:china:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; &lt;br /&gt;
Empecemos un poco con las novedades:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;margin-left: 30px&quot;&gt;&lt;li&gt;2 tipos de mensajes (posts y minipost)&lt;/li&gt;&lt;li&gt;Categorías y subcategorías múltiples para cada post&lt;/li&gt;&lt;li&gt;Cada mensaje tiene un valor de importancia (solo lo cambia el blogger &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;)&lt;/li&gt;&lt;li&gt;Admite trackbacks y pingbacks&lt;/li&gt;&lt;li&gt;Nuevo script para las imágenes&lt;/li&gt;&lt;li&gt;Sistema de identificación para los comentarios&lt;/li&gt;&lt;li&gt;Avatares en los comentarios y algunas pijaditas más&lt;/li&gt;&lt;li&gt;Ahora se puede dar formato a los comentarios (negritas, cursivas, tachado, subrayado), poner quotes, insertar listas y poner emoticones&lt;/li&gt;&lt;li&gt;Preview para los comentarios&lt;/li&gt;&lt;li&gt;Ahora el blog tiene emoticones &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/laugh.png&quot; alt=&quot;:D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;/li&gt;&lt;li&gt;Bloque especial para código con coloreado automático (gracias a geshi)&lt;/li&gt;&lt;li&gt;Feeds en atom, rss2 y rdf&lt;/li&gt;&lt;li&gt;Sistema de búsqueda (estoy muy orgulloso de el &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/laugh.png&quot; alt=&quot;:D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; )&lt;/li&gt;&lt;li&gt;El aspecto del blog se puede cambiar con themes&lt;/li&gt;&lt;li&gt;Banneo de gente (por IP y según ciertas reglas malignas, juasjuasjuas)&lt;/li&gt;&lt;li&gt;Ahora tengo un blogroll decente xD&lt;/li&gt;&lt;li&gt;Sistema de estadísticas propio (aunque no lo podáis ver)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Seguro que se me olvidan mas cosas.. muchísimas más, pero es que al final no he podido llevar un ChageLog mientras trabajaba &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/drop.gif&quot; alt=&quot;:drop:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
Bueno, para que veáis las peculiaridades de mi theme (el de Ally es distinto), voy a jugar un poco con el CMS:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Hola mundo!!&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$_SERVER&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;REMOTE_ADDR&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;#160; === &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;127.0.0.1&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Bienvenido gran diox th1nk3r&amp;#160; xD&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;glugluglu...&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora una cita:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;th1nk3r ha dicho:&lt;br /&gt;
Creo que es el código más inútil que he escrito en mi vida xD&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Actualización (19 Feb 2008)&lt;/strong&gt;&lt;br /&gt;
Este mensaje hace referencia al CMS antiguo. A partir de ahora uso &lt;a href=&quot;http://www.s9y.org/&quot; title=&quot;Serendipity&quot;&gt;Serendipity&lt;/a&gt;. El motivo del cambio se debe principalmente a la falta de tiempo para actualizar mi CMS. Ha quedado desfasado y no he tenido tiempo (ni ganas) para solucionar varios bugs y problemas con los que me he ido encontrando. 
    </content:encoded>

    <pubDate>Sun, 26 Feb 2006 22:42:00 -0500</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/37-guid.html</guid>
    
</item>
<item>
    <title>Google Oculto</title>
    <link>http://znblog.athoim.com/archives/34-Google-Oculto.html</link>
            <category>Web</category>
    
    <comments>http://znblog.athoim.com/archives/34-Google-Oculto.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=34</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=34</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Desde hace algún tiempo se conocen las &quot;utilidades secretas&quot; de google para buscar todo tipo de información, pero a menudo lo que nos falta es la búsqueda correcta.&lt;br /&gt;
&lt;br /&gt;
El secreto esta en que google rastrea los servidores web, y hay muchos servidores con administradores vagos que dejan configuraciones por defecto o que incluso usan el sistema de indexado de ficheros del server (apache, xitami, IIS, etc) para directorios sin fichero indice (index.html, index.htm, etc). Esta mala costumbre suele ser común en directorios con imágenes, documentos y otros ficheros multimedia &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Google se encarga de buscar por nosotros, así que solo tenemos que saber &lt;em&gt;&quot;cómo&quot;&lt;/em&gt; hacer la pregunta correcta para que goolge nos desvele sus secretos. &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/laugh.png&quot; alt=&quot;:D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; Primera búsqueda, vamos a buscar libros electrónicos con google (es una sola linea!!!):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;-inurl:htm&amp;#160; -inurl:html intitle:&amp;quot;index of&amp;quot;&amp;#160; +(&amp;quot;/ebooks&amp;quot;|&amp;quot;/book&amp;quot;)&amp;#160; +(chm|pdf|zip)&amp;#160; + &amp;quot;Nombre&amp;#160; del autor&amp;quot; &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Bueno, como veis es muy sencillo crear este tipo de búsquedas. Aquí, buscamos cualquier página índice del servidor que liste un directorio con libros en formato chm, pdf o zip. Si miráis un poco, veréis rápidamente como ampliar las búsquedas &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
Por ejemplo.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;-inurl:htm&amp;#160; -inurl:html intitle:&amp;quot;index of&amp;quot;&amp;#160; +(&amp;quot;/ebooks&amp;quot;|&amp;quot;/book&amp;quot;)&amp;#160; +(chm|pdf|zip)&amp;#160; + &amp;quot;Asimov&amp;quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Nos da como resultado unos cuantos libros interesantes. A pesar de que algunos resultados no son buenos, otros son perfectos &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/pirate.png&quot; alt=&quot;P-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
Pero, ¿cómo funciona exactamente todo esto?&lt;br /&gt;
&lt;br /&gt;
Bien, lo que hacemos es buscar páginas con el texto &lt;em&gt;&quot;index of&quot;&lt;/em&gt;, que suelen ser páginas como esta. Como veis aparece todo el contenido del directorio. Son páginas creadas automáticamente por los servidores web. Para afinar mas la búsqueda suele ser recomendable evitar las direcciones con htm, html, php, asp, txt o similares. Así pulimos mucho mas la búsqueda. Bueno, el resto es bastante descriptivo por si solo. Con solo cambiar el tipo de fichero o el nombre del directorio podemos realizar otras búsquedas (vídeos, mp3s, documentos, imágenes, etc...)&lt;br /&gt;
Por ejemplo, para buscar MP3s de Macross, podemos usar:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;intitle:index.of&amp;#160; + mp3&amp;#160; + &amp;quot;macross&amp;quot;&amp;#160; -html -htm -php -asp -txt -pls&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
O para encontrar trailers antiguos de Matrix:&lt;br /&gt;
 &lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;intitle:index.of&amp;#160; + (&amp;quot;avi&amp;quot;|&amp;quot;mov&amp;quot;|&amp;quot;rm&amp;quot;|&amp;quot;wmv&amp;quot;|&amp;quot;asf&amp;quot;) +&amp;#160; &amp;quot;trailer&amp;quot; +&amp;#160; &amp;quot;matrix&amp;quot;&amp;#160; -html -htm -php -asp -txt -pls&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Bueno, ya habéis aprendido otra cosa nueva hoy &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/cool.png&quot; alt=&quot;8-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; En &lt;a href=&quot;http://www.oxygen-inc.com/google.html&quot; title=&quot;Oxygen-inc.com&quot;&gt;Oxygen Inc&lt;/a&gt; tenéis información adicional sobre estas técnicas. 
    </content:encoded>

    <pubDate>Thu, 29 Sep 2005 22:27:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/34-guid.html</guid>
    
</item>
<item>
    <title>firma.php v2.0</title>
    <link>http://znblog.athoim.com/archives/30-firma.php-v2.0.html</link>
            <category>PHP</category>
    
    <comments>http://znblog.athoim.com/archives/30-firma.php-v2.0.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=30</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=30</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Esta tarde, en 15 minutillos que tenía aburridos, me he puesto a rehacer mi script de firma para foros &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/smile.png&quot; alt=&quot;:)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
Creo que ya comenté hace algún tiempo lo de este script, es muy sencillo. Recoge información del sistema, y la monta junto con una imagen aleatoria, lo mete en un JPG y lo envía al solicitante.&lt;br /&gt;
&lt;br /&gt;
Hasta ahora solo mostraba la versión del kernel, el uptime, el número de usuarios en el sistema y la cantidad de ram y swap libres. Me he cansado un poco de toda esa información, y he decidido cambiar lo que se muestra. Ahora aparece la versión del kernel de mi servidor, el uptime y la ram libre, y como extra la última canción escuchada (información sacada de audioscrobber &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/laugh.png&quot; alt=&quot;:D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;).&lt;br /&gt;
Aun me falta darle algunos retoques a ese script, de momento es bastante cutre, pero hace muy bien su función. Mi principal problema es que la mayoría de canciones tienen o el title o el autor en caracteres asiáticos (japoneses, chinos o coreanos), así que no se muestran bien. A petición de Kebrantador, pongo parte del código, aunque no esperéis demasiado.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160;$rs&amp;#160; es&amp;#160; un&amp;#160; objeto&amp;#160; que uso&amp;#160; para&amp;#160; acceder a&amp;#160; la&amp;#160; base&amp;#160; de&amp;#160; datos&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160;en este caso ya he leido&amp;#160; los datos. Cada firma&amp;#160; tiene&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160;un formato&amp;#160; diferente,&amp;#160; por eso&amp;#160; guardo&amp;#160; la&amp;#160; info&amp;#160; en&amp;#160; una tabla.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160;Entre&amp;#160; la&amp;#160; info&amp;#160; estan las&amp;#160; coordenadas donde&amp;#160; va&amp;#160; a ir el texto&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160;el color, la fuente,&amp;#160; el&amp;#160; nivel de compresion de la imagen,&amp;#160; etc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;image&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$compress&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;compress&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$fotn_name&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;text_font&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$acolor&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/explode&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;explode&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;:&#039;&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;text_color&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x_pos&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;text_x&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$y_pos&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;text_y&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$altura&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;altura&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$special&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$rs&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;fields&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;special&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagedir&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;/dir/dir/dir/imagenes/firmas/&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$imagedir&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/getimagesize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;getimagesize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;switch&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;:&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefromgif&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;:&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefromjpeg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;:&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefrompng&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Color del&amp;#160; texto&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$color&lt;/span&gt;&amp;#160; = imagecolorallocate&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$acolor&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$acolor&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$acolor&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Seleccionar fuente&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$font&lt;/span&gt; =&amp;#160; imageloadfont&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagedir&lt;/span&gt; .&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;fonts/&#039;&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$font_name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Version&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; En&amp;#160; el&amp;#160; cron&amp;#160; he&amp;#160; indicado&amp;#160; que a&amp;#160; los 5&amp;#160; minutos &lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; de&amp;#160; reiniciar se ejecute:&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; /usr/bin/uname&amp;#160; -r&amp;#160; &amp;gt; /dir/dir/firma_kernel.txt&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$version&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/file_get_contents&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;file_get_contents&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;/firma_kernel.txt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Gentoo GNU/Linux&amp;#160; &#039;&lt;/span&gt; .&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$version&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$special&lt;/span&gt;==&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;center&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$x_pos&lt;/span&gt; +&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;40&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$x_pos&lt;/span&gt;;&lt;br /&gt;&amp;#160;imagestring&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$font&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y_pos&lt;/span&gt;&amp;#160; + &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &amp;lt;strong&amp;gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$altura&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$text&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; RAM y&amp;#160; Uptime&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Se&amp;#160; obtienen&amp;#160; de&amp;#160; forma muy&amp;#160; parecida, los&amp;#160; omito&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; lastsong&amp;#160; played&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Mediante&amp;#160; un&amp;#160; script&amp;#160; shell que&amp;#160; se&amp;#160; ejecuta cada minuto&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; en&amp;#160; el&amp;#160; crontab,&amp;#160; descargo&amp;#160; el&amp;#160; ficherito:&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; http://ws.audioscrobbler.com/txt/recent/th1nk3r&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; y lo renombro como &amp;quot;firma_audio.txt&amp;quot;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&amp;#160; = @&lt;a href=&quot;http://www.php.net/file&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;file&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;/dir/dir/firma_audio.txt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt; != &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/trim&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;trim&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Comprobamos si se esta escuchando ahora, aunque es&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; una tonteria con&amp;#160; el&amp;#160; lag tan&amp;#160; tremendo&amp;#160; que hay&amp;#160; entre&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; que audioscrobbler publica&amp;#160; los cambios&amp;#160; y el script los&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; descarga...&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;#160; !=&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;[&#039;&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;]&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;[&#039;&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #0000ff;&quot;&gt;$trackData&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;#160; . &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;]&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/html_entity_decode&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;html_entity_decode&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/trim&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;trim&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Audioscrobbler&amp;#160; data&amp;#160; error&#039;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Este&amp;#160; error se produce&amp;#160; cuando&amp;#160; se&amp;#160; esta&amp;#160; actualizando&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; el&amp;#160; fichero firma_audio.txt...&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$special&lt;/span&gt;==&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;center&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$x_pos&lt;/span&gt; +&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;25&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$x_pos&lt;/span&gt;&amp;gt;;&lt;br /&gt;&amp;#160;imagestring&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$font&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y_pos&lt;/span&gt;&amp;#160; + &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt; &amp;lt;/strong&amp;gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$altura&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$track&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Enviamos&amp;#160; la&amp;#160; imagen&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type: image/jpeg&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt; =&amp;#160; imagecreatetruecolor&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;500&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;150&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;500&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;150&lt;/span&gt;,&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;imageinterlace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;imagejpeg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$compress&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;imagedestroy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;imagedestroy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Este código forma parte del script que genera las imágenes. Los directorios y alguna otra info es inventada, pero cambiando esos datos debería funcionar. Como ya he dicho, son firmas dinámicas y algunos foros no las admiten. Sin embargo, es fácil saltarse esa protección, lo dejo a vuestra imaginación. 
    </content:encoded>

    <pubDate>Wed, 24 Aug 2005 02:58:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/30-guid.html</guid>
    
</item>
<item>
    <title>Transparencias con GD</title>
    <link>http://znblog.athoim.com/archives/26-Transparencias-con-GD.html</link>
            <category>PHP</category>
    
    <comments>http://znblog.athoim.com/archives/26-Transparencias-con-GD.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=26</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=26</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Me he pasado el día peleando con las librerías &lt;a href=&quot;http://es.php.net/gd&quot; title=&quot;Image Functions&quot;&gt;GD de PHP&lt;/a&gt;. ¿Cual es el problema?&lt;br /&gt;
Tengo un script que comprueba la dirección IP del referer cada vez que se solicita una imagen, para evitar el robo de estas. También me permite manipular imágenes, re-dimensionarlas, re-comprimirlas, etc, sin tener que tener varias versiones guardadas a la vez.&lt;br /&gt;
&lt;br /&gt;
El script lo tenía terminado, pero me di cuenta de un bug muy grabe, terrible. Al re-dimensionar las imágenes no se conservan las transparencias ni en GIF ni en PNG. Es posible, que tampoco se pillen bien los GIFs animados (tengo que comprobarlo aun &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/drop.gif&quot; alt=&quot;:drop:&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;), ya veremos...&lt;br /&gt;
Después de mucho leer y probar he conseguido solucionar el problema. Os copio la función que he creado y que permite re-dimensionar imágenes GIF, PNG y JPG, re-comprimiendolas y usando transparencias (y por supuesto, sin hacer uso de programas externos tipo imagemagick &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;). Me ha costado, pero al fin he solucionado el bug (la batalla con los gifs animados lo doy por perdida &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/cry.png&quot; alt=&quot;:&#039;(&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; ). Disfrutad la función.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/**&lt;br /&gt;&amp;#160; &amp;#160;$imagepath =&amp;#160; ruta&amp;#160; y nombre de la imagen&lt;br /&gt;&amp;#160; &amp;#160;$compress&amp;#160; = nivel&amp;#160; de&amp;#160; compresion&amp;#160; para&amp;#160; la&amp;#160; img resultado&lt;br /&gt;&amp;#160; &amp;#160;$x =&amp;#160; anchura deseada&amp;#160; para&amp;#160; la&amp;#160; img resultado&lt;br /&gt;&amp;#160; &amp;#160;$y =&amp;#160; altura&amp;#160; deseada para la img&amp;#160; resultado&lt;br /&gt;&amp;#160; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160;Anteriormente&amp;#160; ya&amp;#160; se&amp;#160; ha&amp;#160; calculado la anchura&amp;#160; y altura&lt;br /&gt;&amp;#160; &amp;#160;para esa&amp;#160; imagen&amp;#160; en&amp;#160; concreto&amp;#160; (de forma&amp;#160; que se mantengan&lt;br /&gt;&amp;#160; &amp;#160;las&amp;#160; proporciones).&lt;br /&gt;&amp;#160; &amp;#160;*/&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt;&amp;#160; readImg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$compress&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/getimagesize&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;getimagesize&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;switch&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;:&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; GIF&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefromgif&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type: image/gif&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-transfer-encoding:&amp;#160; binary&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Pixels&amp;#160; esquina&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$tr_color&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$tl_color&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$br_color&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$bl_color&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt; =&amp;#160; imagecreate&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; pixel con&amp;#160; color negro&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagepalettecopy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptr_over_black&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptl_over_black&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbr_over_black&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbl_over_black&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; pixel con&amp;#160; color blanco&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$bg&lt;/span&gt; =&amp;#160; imagecolorallocate&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;255&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;255&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagefilledrectangle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$bg&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptr_over_white&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptl_over_white&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbr_over_white&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbl_over_white&lt;/span&gt; =&amp;#160; imagecolorat&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptr_over_black&lt;/span&gt;&amp;#160; !=&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$ptr_over_white&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagefilledrectangle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$tr_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecolortransparent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$tr_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;elseif&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$ptl_over_black&lt;/span&gt;&amp;#160; !=&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$ptl_over_white&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagefilledrectangle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$tl_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecolortransparent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$tl_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;elseif&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbr_over_black&lt;/span&gt;&amp;#160; !=&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$pbr_over_white&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagefilledrectangle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$br_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecolortransparent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$br_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;elseif&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$pbl_over_black&lt;/span&gt;&amp;#160; !=&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$pbl_over_white&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagefilledrectangle&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$bl_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecolortransparent&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$bl_color&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imageinterlace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagegif&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;:&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; JPEG&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefromjpeg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type: image/jpeg&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-transfer-encoding:&amp;#160; binary&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt; =&amp;#160; imagecreatetruecolor&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imageinterlace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagejpeg&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&#039;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$compress&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt;:&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; PNG&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&amp;#160; = imagecreatefrompng&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$imagepath&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-Type: image/png&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;Content-transfer-encoding:&amp;#160; binary&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt; =&amp;#160; imagecreatetruecolor&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;,&lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imageAlphaBlending&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagecopyresampled&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;,&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$attr&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imageinterlace&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagesavealpha&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;,&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;imagepng&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;imagedestroy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$image&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;imagedestroy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$newimage&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt; 
    </content:encoded>

    <pubDate>Sat, 16 Jul 2005 21:09:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/26-guid.html</guid>
    
</item>
<item>
    <title>Árbol de categorías</title>
    <link>http://znblog.athoim.com/archives/25-rbol-de-categorias.html</link>
            <category>PHP</category>
    
    <comments>http://znblog.athoim.com/archives/25-rbol-de-categorias.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=25</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=25</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    Ademas de estudiar y jugar al Dynasty Warriors 5, me he vuelto a poner con la programación del nuevo CMS. Aun estoy esperando que Ally termine con los diseños de su weblog y el mio, pero yo ya estoy a saco con la programación de la sección de administración. Aun falta para que este todo listo, pero espero tenerlo todo para la Euskal. Últimamente he codificado las categorías de los posts. Ahora ya no habrá unas categorías fijas guardadas en el código php, sino que serán accesibles a través de un complejo árbol extensible (categorías y sub-categorías infinitas) dentro de una tabla de mysql.&lt;br /&gt;
 Para complacer un poco a BenKo voy a explicar un poco como he creado todo el tema del árbol. No es fácil, así que cuidado con perderse.&lt;br /&gt;
La tabla en la base de datos solo tiene 6 campos:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;id -&gt; Identificador&lt;br /&gt;
parent -&gt; Nodo padre (categoria de la que depende)&lt;br /&gt;
title -&gt; Nombre de la categoria&lt;br /&gt;
lft -&gt; lo explicare luego&lt;br /&gt;
rgt -&gt; tambien lo explicare luego xD&lt;br /&gt;
active -&gt; 1 para categoria activa, 0 para inactiva&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;lightbox&#039; href=&#039;http://znblog.athoim.com/uploads/arbol_categorias.png&#039;&gt;&lt;!-- s9ymdb:33 --&gt;&lt;img width=&quot;200&quot; height=&quot;156&quot; style=&quot;float: right; border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://znblog.athoim.com/uploads/arbol_categorias.s9yThumb.png&quot; alt=&quot;&quot;  /&gt;&lt;/a&gt;Los datos fundamentales son el id, el id del padre, y lft/rgt. ¿Pero qué demonios son lft y rgt? Vamos a verlo con un ejemplo:&lt;br /&gt;
En la imagen podéis ver un árbol de ejemplo, con sus valores lft en rojo y rgt en verde. lft y rgt son índices que nos ayudan a comprender la estructura del árbol y a mostrarlo con una sola consulta a la base de datos. Si solo guardáramos el valor de &lt;em&gt;pid&lt;/em&gt; y &lt;em&gt;pid padre&lt;/em&gt;, tendríamos que recorrer todo el árbol con llamadas recursivas, lo que sería una perdida absoluta de recursos y tiempo.&lt;br /&gt;
&lt;br /&gt;
¿Qué sub-categorías pertenecen a Informática? Fácil, ¿no?. Solo hay que preguntarle a la base de datos que categorías tienen su lft entre 10 y 21, es decir:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt;&amp;#160; id&amp;#160; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt;&amp;#160; nombretabla &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt;&amp;#160; lft &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;BETWEEN&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;AND&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;21&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;ORDER&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;BY&lt;/span&gt;&amp;#160; lft &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;ASC&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Sencillo, ¿verdad? Con esos IDs devueltos podemos borrar, buscar o hacer lo que necesitemos. Voy a explicar algunas operaciones:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Imprimir arbol a partir del nodo xxx&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt;&amp;#160; print_tree&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$root&lt;/span&gt;=&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Obtenemos de la BD el valor&amp;#160; lft y&amp;#160; rgt del&amp;#160; nodo&amp;#160; $root&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;SELECT&amp;#160; lft,&amp;#160; rgt FROM `tabla_categ`&amp;#160; WHERE id=&#039;$root&#039; &quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$lft&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lft&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rgt&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;rgt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; obtenemos todos&amp;#160; los hijos&amp;#160; del nodo $root&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;SELECT&amp;#160; id, title, lft, rgt, active FROM `tabla_categ`&amp;#160; WHERE `lft`&amp;#160; BETWEEN $lft AND&amp;#160; $rgt&amp;#160; ORDER BY lft&amp;#160; ASC&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; solo&amp;#160; comprobar el vector $right si existe)&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&amp;gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;rgt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/array_pop&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array_pop&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lft&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;==&lt;span style=&quot;color: #0000ff;&quot;&gt;$lft&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$str&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/str_repeat&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;str_repeat&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&#039;&lt;/span&gt;,&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$str&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/str_repeat&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;str_repeat&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&amp;amp;#160;&amp;amp;#160;&amp;amp;#160;&amp;amp;#160;&amp;amp;#160;&#039;&lt;/span&gt;,&lt;a href=&quot;http://www.php.net/count&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;count&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;|--&amp;gt; &#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$str&lt;/span&gt;&amp;#160; .&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;title&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&amp;#160; &quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;!&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;active&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot; (Inactiva)&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt;&amp;#160; &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;rgt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Reconstruir valores rgt&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Muy útil porque después de mover valores, tendremos los &lt;em&gt;lft&lt;/em&gt; correctos, pero no los &lt;em&gt;rgt&lt;/em&gt;. Esta función recursiva reescribirá los valores &lt;em&gt;rgt&lt;/em&gt; (una gran ayuda &lt;img src=&quot;http://znblog.athoim.com/templates/znblue/img/emoticons/tongue.png&quot; alt=&quot;:P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;)&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt;&amp;#160; rebuild_tree&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$parent&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$left&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;!&lt;a href=&quot;http://www.php.net/is_numeric&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;is_numeric&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$parent&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; || !&lt;a href=&quot;http://www.php.net/is_numeric&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;is_numeric&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$left&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; el&amp;#160; valor rgt&amp;#160; de&amp;#160; un&amp;#160; nodo&amp;#160; final es lft+1&amp;#160; &amp;#160; &lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$left&lt;/span&gt;&amp;#160; + &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; obtener todos&amp;#160; los hijos&amp;#160; de&amp;#160; ese nodo&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;SELECT&amp;#160; id, title&amp;#160; FROM&amp;#160; `tabla_categ` WHERE&amp;#160; parent=&#039;$parent&#039;&amp;#160; ORDER BY title&amp;#160; ASC&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; Viva&amp;#160; la&amp;#160; recursividad!!! xD&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&amp;#160; = rebuild_tree&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;id&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;,&lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft` =&amp;#160; &#039;$left&#039;,&amp;#160; `rgt` =&amp;#160; &#039;$right&#039;&amp;#160; WHERE `id`=&#039;$parent&#039;&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; devolver&amp;#160; right+1&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$right&lt;/span&gt;+&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Mover un nodo&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// $idOrigen&amp;#160; -&amp;gt;&amp;#160; El&amp;#160; nodo&amp;#160; a mover&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// $idDentroDe&amp;#160; -&amp;gt;&amp;#160; Dentro&amp;#160; de&amp;#160; que nodo (=nodo padre)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; queremos moverlo&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt;&amp;#160; moveNode&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$idOrigen&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$idDentroDe&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; obtenemos lft&amp;#160; y rgt&amp;#160; del elemento a&amp;#160; mover&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;SELECT&amp;#160; `lft`,`rgt` FROM `tabla_categ`&amp;#160; WHERE `id`=&#039;$idOrigen&#039;&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$lftorigen&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lft&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rgtorigen&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;rgt&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; obtenemos lft&amp;#160; del padre&amp;#160; destino&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;SELECT&amp;#160; `lft` FROM `tabla_categ`&amp;#160; WHERE `id`=&#039;$idDentroDe&#039;&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&amp;#160; = &lt;a href=&quot;http://www.php.net/mysql_fetch_array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; el&amp;#160; nodo&amp;#160; movido&amp;#160; terminara teniendo lft&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; igual a&amp;#160; la&amp;#160; del padre&amp;#160; + 1&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$lftdestino&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;lft&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;+&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; $distancia&amp;#160; a mover&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$distancia&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$lftdestino&lt;/span&gt;&amp;#160; - &lt;span style=&quot;color: #0000ff;&quot;&gt;$lftorigen&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; amplitud&amp;#160; del intervalo&amp;#160; a mover&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; (el nodo a&amp;#160; mover puede&amp;#160; tener hijos!)&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt; =&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rgtorigen&lt;/span&gt; -&amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;$lftorigen&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; +&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$distancia&lt;/span&gt;&amp;#160; &amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; desplazamos nodos&amp;#160; para&amp;#160; dejar hueco&amp;#160; en&amp;#160; destino&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft+$amplitud&#039;,&amp;#160; `rgt`=&amp;#160; &#039;rgt+$amplitud&#039; WHERE&amp;#160; `lft` &amp;gt;=$lftdestino&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; cambiamos lft&amp;#160; y rgt&amp;#160; a los&amp;#160; del destino&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft+$distancia&#039;, `rgt`= &#039;rgt+$distancia&#039; WHERE&amp;#160; `lft` BETWEEN&amp;#160; $lftorigen&amp;#160; AND $rgtorigen&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; quitamos&amp;#160; el&amp;#160; hueco dejado en el origen&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; tras&amp;#160; el&amp;#160; desplazamiento&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft-$amplitud&#039;,&amp;#160; `rgt`=&amp;#160; &#039;rgt-$amplitud&#039; WHERE&amp;#160; `lft` &amp;gt;$rgtorigen&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #b1b100;&quot;&gt;elseif&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$distancia&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; desplazamos nodos&amp;#160; para&amp;#160; dejar hueco&amp;#160; en&amp;#160; destino&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft+$amplitud&#039;,&amp;#160; `rgt`=&amp;#160; &#039;rgt+$amplitud&#039; WHERE&amp;#160; `lft` &amp;gt;=$lftdestino&quot;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; cambiamos lft&amp;#160; yrgt&amp;#160; a los&amp;#160; del destino&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; NOTA: en este caso los&amp;#160; lft y&amp;#160; rgt han&amp;#160; sido&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; desplazados por&amp;#160; el&amp;#160; UPDATE&amp;#160; anterior&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft-&quot;&lt;/span&gt;.&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$distancia&lt;/span&gt;+&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&#039;, `rgt`= &#039;rgt-&quot;&lt;/span&gt;.&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$distancia&lt;/span&gt;+&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&#039; WHERE&amp;#160; `lft` BETWEEN&amp;#160; &quot;&lt;/span&gt;.&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$lftorigen&lt;/span&gt;+&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&amp;#160; AND &quot;&lt;/span&gt;.&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rgtorigen&lt;/span&gt;+&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; quitamos&amp;#160; el&amp;#160; hueco dejado en el origen&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; tras&amp;#160; el&amp;#160; desplazamiento&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `lft`=&amp;#160; &#039;lft-$amplitud&#039;,&amp;#160; `rgt`=&amp;#160; &#039;rgt-$amplitud&#039; WHERE&amp;#160; `lft` &amp;gt;&quot;&lt;/span&gt;.&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$rgtorigen&lt;/span&gt;+&lt;span style=&quot;color: #0000ff;&quot;&gt;$amplitud&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&amp;#160; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;UPDATE&amp;#160; `tabla_categ` SET&amp;#160; `parent`=&#039;$idDentroDe&#039;&amp;#160; WHERE `id`=&quot;&lt;/span&gt;.&lt;span style=&quot;color: #0000ff;&quot;&gt;$idOrigen&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;$result&lt;/span&gt; =&amp;#160; &lt;a href=&quot;http://www.php.net/mysql_query&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;mysql_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//&amp;#160; ¡¡IMPORTANTE!!&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;rebuild_tree&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
¿Como lo enlazamos con los mensajes? Bien, dependiendo de la base de datos, y de como guardemos los mensajes, cada uno de estos tendrá asociado un id de categoría. Si estamos dispuestos a hacer uso de otra tabla, podemos guardar en otra tabla:&lt;br /&gt;
&lt;br /&gt;
id -&gt; Índice único de la tabla (no nos interesa)&lt;br /&gt;
id_msg -&gt; Identificador de la entrada del weblog&lt;br /&gt;
id_categ -&gt; Identificador de categoría&lt;br /&gt;
&lt;br /&gt;
¿Qué conseguimos con esto? Pues que con una consulta sencilla podamos obtener todas las posibles categorías a las que pertenezca un mensaje. Un poco complicado, ¿no? Imaginad este trozo de tabla:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshiCode&quot; style=&quot;text-align: left&quot;&gt;|----------------------|&lt;br /&gt;| id | id_msg | id_cat |&lt;br /&gt;|----------------------|&lt;br /&gt;|&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt; |&amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt; |&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;6&lt;/span&gt; |&lt;br /&gt;|&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt; |&amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt; |&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt; |&lt;br /&gt;|&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;3&lt;/span&gt; |&amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;101&lt;/span&gt; |&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;4&lt;/span&gt; |&lt;br /&gt;|&amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;4&lt;/span&gt; |&amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;102&lt;/span&gt; |&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt; |&lt;br /&gt;|----------------------|&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Es fácil hacer una consulta que nos diga a que categorías pertenece el mensaje 100, ¿verdad? Gracias a esta estructura de árbol, también sabemos que todos los mensajes de KDE pertenecen también a Linux y a su vez a Informática, por lo que al realizar la búsqueda en la base de datos de un mensaje con categoría informática, podríamos buscar (una consulta compleja pero posible) todos los mensajes que tengan una categoría cuyo valor lft este entre 10 y 21 (el lft y el rgt de Informática).&lt;br /&gt;
&lt;br /&gt;
El mayor problema con el que me he encontrado es a la hora de borrar categorías. ¿Que pasa con los mensajes huérfanos (=sin categoría)? No me apetece comerme la cabeza con este asunto de poca importancia, así que lo que he decidido es que no se pueden borrar categorías. Se les puede cambiar el nombre, mover y se pueden desactivar (al desactivar un nodo, se desactiva también toda la rama que cuelga de el), pero no se pueden borrar (para evitar un caos con los IDs). Si nos sobra una categoría podemos cambiarle el nombre, el padre y la posición y emplearla para otra cosa (habrá que cambiar las categorías de los mensajes que dependan de esa categoría, pero es un problema menor).Creo que me ha quedado un tutorial un poco complicado... espero que alguien pueda entender algo. Voy a rehacerlo unas cuantas veces para ver si queda mas útil.... 
    </content:encoded>

    <pubDate>Sun, 26 Jun 2005 19:53:00 -0400</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/25-guid.html</guid>
    
</item>
<item>
    <title>Problemas y soluciones en C++</title>
    <link>http://znblog.athoim.com/archives/22-Problemas-y-soluciones-en-C++.html</link>
            <category>C++</category>
    
    <comments>http://znblog.athoim.com/archives/22-Problemas-y-soluciones-en-C++.html#comments</comments>
    <wfw:comment>http://znblog.athoim.com/wfwcomment.php?cid=22</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://znblog.athoim.com/rss.php?version=2.0&amp;type=comments&amp;cid=22</wfw:commentRss>
    

    <author>nospam@example.com (th1nk3r)</author>
    <content:encoded>
    &lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;lightbox&#039; href=&#039;http://znblog.athoim.com/uploads/exceptionalc.jpg&#039;&gt;&lt;!-- s9ymdb:31 --&gt;&lt;img width=&quot;160&quot; height=&quot;200&quot; style=&quot;float: right; border: 0px; padding-left: 5px; padding-right: 5px; margin-left: 10px;&quot; src=&quot;http://znblog.athoim.com/uploads/exceptionalc.s9yThumb.jpg&quot; alt=&quot;&quot;  /&gt;&lt;/a&gt;Hoy he estado hojeando un libro que me gustaría recomendar &lt;a href=&quot;http://www.aw-bc.com/catalog/academic/product/0,1144,0201615622,00.html&quot; title=&quot;Exceptional C++&quot;&gt;Exceptional C++: 47 Engineering Puzzles, Programming Problems and Solutions&lt;/a&gt;.&lt;br /&gt;
Se trata de un libro de C++ de un nivel aceptable, no es el típico manual de C++ para tontos que tanto abunda por ahí. En este libro se comentan múltiples soluciones para problemas que surgen comúnmente al programar en C++, como por ejemplo la comparación de strings sin diferenciar May y min., muchos ejemplos sobre código con excepciones, reducción del tiempo de compilado, administración de memoria, creación y destrucción de objetos, conversión automática de clases y tipos, etc&lt;br /&gt;
&lt;br /&gt;
Quizás lo más interesante es que te muestra el problema y te explica las distintas soluciones que hay (y los nuevos problemas que pueden surgir con esas soluciones). Te explica porque la gente las usa o porque no deben usarse. Muy interesante para cualquier programador de C++, aunque creo que es más indicado para los que ya saben C++ y quieren mejorar su código.  
    </content:encoded>

    <pubDate>Thu, 10 Mar 2005 17:26:00 -0500</pubDate>
    <guid isPermaLink="false">http://znblog.athoim.com/archives/22-guid.html</guid>
    
</item>

</channel>
</rss>