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

<channel>
	<title>¿Más código? &#187; PHP</title>
	<atom:link href="http://www.mascodigo.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mascodigo.com</link>
	<description>Mantenlo simple, estúpido</description>
	<lastBuildDate>Wed, 14 Sep 2011 14:40:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Supervisar directorios con PHP</title>
		<link>http://www.mascodigo.com/2011/09/14/supervisar-directorios-con-php/</link>
		<comments>http://www.mascodigo.com/2011/09/14/supervisar-directorios-con-php/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 14:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[seguridad]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=216</guid>
		<description><![CDATA[Si tenemos una web que permite a los visitantes subir archivos, debemos controlar que no se suba nada inadecuado. Lo primero sería programar la web de forma segura, intentando que sea “imposible” que un usuario malintencionado suba ficheros maliciosos. Si hemos realizado lo anterior correctamente es muy probable que no tengamos ningún problema, pero si [...]]]></description>
			<content:encoded><![CDATA[<p>Si tenemos una web que permite a los visitantes subir archivos, debemos controlar que no se suba nada inadecuado.</p>
<p>Lo primero sería programar la web de forma segura, intentando que sea “imposible” que un usuario malintencionado suba ficheros maliciosos.</p>
<p>Si hemos realizado lo anterior correctamente es muy probable que no tengamos ningún problema, pero si deseamos un poco mas de seguridad (o control) podemos <span style="text-decoration: underline;">supervisar el directorio</span> donde esta la web. De esta forma si detectamos cambios en ficheros o ficheros nuevos podemos saber cuales son y actuar en consecuencia.</p>
<p>En el caso de que la web permita subir imágenes, quizás debamos modificar este código para filtrar las imágenes, de lo contrario, cada imagen que se suba nos generará una alerta.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Europe/Madrid'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Timezone soportados: http://www.php.net/manual/es/timezones.php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> FileLog
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_baseDir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Directorio que se controla</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_numSubDir</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Número de subdirectorios</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_numFiles</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Número de ficheros</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_fileMod</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Número de archivos modificados</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_time</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Fecha base desde la que se registran cambios</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_badFiles</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Ficheros nuevos o modificados desde la fecha base</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseDir <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Leer todos los ficheros de un directorio de forma recursiva.
	 * @param String $dir directorio base
	 * @param boolean $review indica si se estan buscando ficheros nuevos/modificados
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">readDir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$review</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$openDir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$openDir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;..&quot;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;fileLog.txt&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>			
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$review</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readDir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readDir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numSubDir<span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>					
&nbsp;
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> 
&nbsp;
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$review</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #990000;">clearstatcache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000088;">$ftime</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
&nbsp;
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ftime</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_time<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_badFiles<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d/m/Y H:i:s&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_time<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; - &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d/m/Y H:i:s&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ftime</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; | &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fileMod<span style="color: #339933;">++;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>				
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles<span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * 
	 * Crea un archivo (si no existe) y guarda la información de el directorio
	 * que se esta supervisando. La información se guarda con este formato:
	 * fecha&amp;dir&amp;file
	 * 
	 * fecha en formato unix
	 * dir el número de subdirectorios dentro de el directorio supervisado
	 * file el número de ficheros dentro del directorio supervisado
	 * 
	 * @return boolean
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _writeFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/fileLog.txt&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numSubDir <span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$fopen</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fopen</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fopen</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Genera los avisos cuando hay nuevos ficheros o ficheros modificados
	 * @param int $dir número de directorios en el registro base
	 * @param int $files número de ficheros en el registro base
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _alert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$log</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Avisar de los nuevos ficheros</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Hay directorios o ficheros nuevos.<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Directorios nuevos: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numSubDir <span style="color: #339933;">-</span> <span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Ficheros nuevos: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles <span style="color: #339933;">-</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>	
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;En breve recibirá un email con los cambios en los ficheros&quot;</span><span style="color: #339933;">;</span>	
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_send<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Buscar fichero nuevos</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readDir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_baseDir<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Avisar de los ficheros nuevos y modificados</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_badFiles <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$log</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Informe de cambios en ficheros<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Directorios nuevos: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numSubDir <span style="color: #339933;">-</span> <span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Ficheros nuevos: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles <span style="color: #339933;">-</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Archivos modificados: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_fileMod <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles <span style="color: #339933;">-</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_send<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$log</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Procesa los mensajes generados. En este ejemplo los muestra en pantalla.
	 * Pero si este fichero es ejecutado por un cron la mejor opción sería enviar
	 * estos mensajes por email on crear un archivo log.
	 * @param String $msg
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _send<span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #990000;">nl2br</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;hr&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$pathFileLog</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/fileLog.txt&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pathFileLog</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pathFileLog</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_time <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numSubDir <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_numFiles <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_alert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_writeFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Exec</span>
<span style="color: #000088;">$read</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileLog<span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$read</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">readDir</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2011/09/14/supervisar-directorios-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ejecutar archivos PHP desde consola (windows)</title>
		<link>http://www.mascodigo.com/2011/09/13/ejecutar-archivos-php-desde-consola-windows/</link>
		<comments>http://www.mascodigo.com/2011/09/13/ejecutar-archivos-php-desde-consola-windows/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 14:45:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Documentación]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[comandos]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=213</guid>
		<description><![CDATA[Primero tenemos que localizar el archivo php.exe, su localización depende de cada instalación. Cuando lo tengamos localizado abrimos una consola. Inicio – Ejecutar – cmd Ahora vamos al directorio donde esta el archivo php.exe. Cuando estemos en el mismo directorio podremos ejecutar los archivos php. &#62;php.exe -f “Ruta al fichero php” Ejemplo:  &#62;php.exe -f “c:\hola_mundo.php” Nos [...]]]></description>
			<content:encoded><![CDATA[<p>Primero tenemos que localizar el archivo php.exe, su localización depende de cada instalación. Cuando lo tengamos localizado abrimos una consola.</p>
<p><strong>Inicio – Ejecutar – cmd</strong></p>
<p>Ahora vamos al directorio donde esta el archivo <em>php.exe</em>. Cuando estemos en el mismo directorio podremos ejecutar los archivos php.</p>
<p><strong>&gt;php.exe -f “Ruta al fichero php”</strong></p>
<p>Ejemplo:</p>
<p><strong> &gt;php.exe -f “<a href="file:///c:/hola_mundo.php">c:\hola_mundo.php</a>”</strong></p>
<p>Nos puede ocurrir que un fichero php que funciona correctamente ejecutado desde un navegador, no funcione desde consola. Esto puede ser debido a que el fichero utilice funciones de alguna extensión (MySQL, cUrl, SimpleXML, …) que se estén cargando como modulo de apache.</p>
<p>Para saber que extensiones (módulos) esta cargando php y no apache podemos ejecutar el comando:</p>
<p><strong>&gt;php.exe -m</strong></p>
<p>Para terminar, indicaros el comando necesario para acceder a la ayuda de <em>php.exe</em>.</p>
<p><strong>&gt;php.exe -h</strong></p>
<p>Enlaces interesantes:</p>
<p><strong>Instalación de Apache, PHP y MySQL por separado</strong></p>
<p><strong></strong><a href="http://www.clubdesarrolladores.com/articulos/mostrar/27-como-instalar-y-configurar-apache-php-y-mysql-en-windows">http://www.clubdesarrolladores.com/articulos/mostrar/27-como-instalar-y-configurar-apache-php-y-mysql-en-windows</a></p>
<p><strong>Ayuda para el CLI de php</strong></p>
<p><a href="http://www.php.net/manual/en/features.commandline.options.php">http://www.php.net/manual/en/features.commandline.options.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2011/09/13/ejecutar-archivos-php-desde-consola-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtener el día de la semana correspondiente a una fecha especificada con php (mktime y date).</title>
		<link>http://www.mascodigo.com/2009/12/11/obtener-el-dia-de-la-semana-correspondiente-a-una-fecha-especificada-con-php-mktime-y-date/</link>
		<comments>http://www.mascodigo.com/2009/12/11/obtener-el-dia-de-la-semana-correspondiente-a-una-fecha-especificada-con-php-mktime-y-date/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 10:45:22 +0000</pubDate>
		<dc:creator>Webmaster</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[fechas]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=195</guid>
		<description><![CDATA[A continuación dejo una simple función que permite realizar lo ya indicado en el titulo. Es algo realmente simple, pero cuando yo necesite este dato, tuve que buscar durante unos minutos en la documentación de php y después preparar la función. Como es un trozo muy pequeño de código, es posible que este se pierda. [...]]]></description>
			<content:encoded><![CDATA[<p>A continuación dejo una simple función que permite realizar lo ya indicado en el titulo. Es algo realmente simple, pero cuando yo necesite este dato, tuve que buscar durante unos minutos en la documentación de php y después preparar la función.</p>
<p>Como es un trozo muy pequeño de código, es posible que este se pierda. Para evitar que esto ocurra y para aquellos usuarios que lo necesiten expongo el código.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Obtener el día de la semana para una fecha concreta.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> diaSemana<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ano</span><span style="color: #339933;">,</span><span style="color: #000088;">$mes</span><span style="color: #339933;">,</span><span style="color: #000088;">$dia</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// 0-&gt;domingo	 | 6-&gt;sabado</span>
	<span style="color: #000088;">$dia</span><span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mes</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dia</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ano</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$dia</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Ejemplo de uso
 */</span>
<span style="color: #000088;">$diaSemana</span> <span style="color: #339933;">=</span> diaSemana<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;2009&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$diaSemana</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Imprime:
 * 4 | El cuatro corresponde a Jueves
 */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/12/11/obtener-el-dia-de-la-semana-correspondiente-a-una-fecha-especificada-con-php-mktime-y-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buscar enlaces en una cadena y convertirlos en enlaces HTML con php (preg_replace_callback).</title>
		<link>http://www.mascodigo.com/2009/12/10/buscar-enlaces-en-una-cadena-y-convertirlos-en-enlaces-html-con-php-preg_replace_callback/</link>
		<comments>http://www.mascodigo.com/2009/12/10/buscar-enlaces-en-una-cadena-y-convertirlos-en-enlaces-html-con-php-preg_replace_callback/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 02:00:57 +0000</pubDate>
		<dc:creator>Webmaster</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Enlaces]]></category>
		<category><![CDATA[parsear]]></category>
		<category><![CDATA[preg_replace_callback]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=191</guid>
		<description><![CDATA[Actualmente casi todos los sitios webs tiene algún método para reconocer enlaces. Da igual donde dejemos un comentario. Puede ser un foro, un chat, un blog, etc. Seguro que cuando enviemos un mensaje, si este contiene algún enlace, una vez publicado podremos pinchar sobre él. Yo como usuario, lo encuentro bastante útil y cómodo. Por [...]]]></description>
			<content:encoded><![CDATA[<p>Actualmente casi todos los sitios webs tiene algún método para reconocer enlaces. Da igual donde dejemos un comentario. Puede ser un foro, un chat, un blog, etc. Seguro que cuando enviemos un mensaje, si este contiene algún enlace, una vez publicado podremos pinchar sobre él.</p>
<p>Yo como usuario, lo encuentro bastante útil y cómodo. Por un lado, si soy un visitante, es algo incomodo copiar y pegar el enlace en la barra de direcciones. Es mucho mas fácil hacer &#8220;click&#8221; sobre el enlace.</p>
<p>Por otro lado, si soy el autor de un comentario y quiero dejar un enlace, solo tengo que escribirlo, no tengo que preocuparme de hacer que sea pinchable.</p>
<p>Por ese motivo, dejo a vuestra disposición una clase en php para leer un texto y convertir en etiquetas HTML todos los enlaces que contenga el texto.</p>
<p>Actualmente solo reconoce los enlaces que comienzan por &#8220;http://&#8221; pero puede mejorarse para que detecte mas enlaces o realice mas operaciones, esto ya depende de las necesidades de cada uno.</p>
<p>A continuación el código y un ejemplo de uso.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Con esta clase podemos convertir los enlaces de un texto.
 * Por ejemplo si escribirmos:
 * http://www.ejemplo.com
 * se convertirá automáticamente en:
 * &lt;a href=&quot;http://www.ejemplo.com&quot;&gt;http://www.ejemplo.com&lt;/a&gt;
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Enlaces
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_texto</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_logs</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_debug</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_existen</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$texto</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$debug</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//Saber si hay que mostar los mensajes de debug por pantalla o no.</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$debug</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_debug <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Verificar que se indicó un texto a parsear</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$texto</span> <span style="color: #339933;">||</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$texto</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_logs <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error! Usted no indico la cadena a parsear. rn&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_texto <span style="color: #339933;">=</span> <span style="color: #000088;">$texto</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Parsear texto</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parsear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_logs <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Error! El texto indicado no se puede parsear o no
        tiene enlaces. rn&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_logs <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Texto parseado correctamente&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Parsear el texto buscando enlaces. Se buscan las cadenas que comienzan por:
 * &quot;http://&quot; sin comillas.
 *
 * Retorna: true si se parsea correctamente, false si no se parsea o
 * si no existen enlaces en el texto.
 */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> parsear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_texto <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace_callback</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/(http://[w/*?*&amp;*=*.*]+)/&quot;</span><span style="color: #339933;">,</span>
                             <span style="color: #0000ff;">&quot;Enlaces::enlacesDetectados&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_texto<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_texto <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;NULL&quot;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_existen <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Convierte los enlaces en enlaces HTML. Si queremos añadir atributos a los enlaces generados, debemos
 * hacerlo aquí.
 */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> enlacesDetectados<span style="color: #009900;">&#40;</span><span style="color: #000088;">$coincidencias</span><span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$coincidencias</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$enlace</span><span style="color: #009900;">&#41;</span>
         <span style="color: #009900;">&#123;</span>
             <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_existen <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
             <span style="color: #000088;">$enlace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$enlace</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$enlace</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #000088;">$enlace</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Devuelve el texto con los enlaces convertidos.
 */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTexto<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_texto<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Devuelve el logs generado durante la ejecución. Solo devuelve el logs si se indico previamente.
 */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getLogs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_debug<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_logs<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * EJEMPLO DE USO
 */</span>
 <span style="color: #000088;">$texto</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot; Este es un texto de prueba. Con un enlace a http://www.google.es y
otro enlace a http://google.com, &amp;iquest; Que te parece ?&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$enlaces</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Enlaces<span style="color: #009900;">&#40;</span><span style="color: #000088;">$texto</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$enlaces</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTexto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Se imprime:
 *
Este es un texto de prueba. Con un enlace a &lt;a href='http://www.google.es'&gt;http://www.google.es&lt;/a&gt; y
otro enlace a &lt;a href='http://google.com'&gt;http://google.com&lt;/a&gt;, &amp;iquest; Que te parece ?
&nbsp;
 */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/12/10/buscar-enlaces-en-una-cadena-y-convertirlos-en-enlaces-html-con-php-preg_replace_callback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Añadir marco a las imágenes con php y GD</title>
		<link>http://www.mascodigo.com/2009/06/27/anadir-marco-a-las-imagenes-con-php-y-gd/</link>
		<comments>http://www.mascodigo.com/2009/06/27/anadir-marco-a-las-imagenes-con-php-y-gd/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 11:44:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[marcos]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=119</guid>
		<description><![CDATA[La función mostrada a continuación permite la creación de un marco a las imágenes que queramos. Podemos elegir el ancho del marco y el color. Ademas también podremos indicar el prefijo para la nueva imagen creada, ya con el marco. La imagen que genera esta función es algo mas grande que la imagen original. Si [...]]]></description>
			<content:encoded><![CDATA[<p>La función mostrada a continuación permite la creación de un marco a las imágenes que queramos. Podemos elegir el ancho del marco y el color. Ademas también podremos indicar el prefijo para la nueva imagen creada, ya con el marco.</p>
<p>La imagen que genera esta función es algo mas grande que la imagen original. Si queremos cambiar el tamaño de la imagen para que tenga el mismo que la original u otro tamaño podemos utilizar <a href="http://www.mascodigo.com/creacion-de-thumbnails-con-php.html">esta clase </a> mencionada ya en mascodigo.</p>
<p>A continuación facilito el código fuente.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Ejemplo de uso
 */</span>
crearMarco<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;img.jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;48,192,255&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Crear un marco para una imagen
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> crearMarco<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rutaImagen</span><span style="color: #339933;">,</span> <span style="color: #000088;">$anchoDelMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$colorRGBMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$prefijo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;marco_&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//Crear imagen</span>
    <span style="color: #000088;">$imagen</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rutaImagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//obtener ancho y alto de la imagen</span>
    <span style="color: #000088;">$ancho</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$alto</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//crear imagen que utilizaremos de marco</span>
    <span style="color: #000088;">$anchoNuevaImagen</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ancho</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchoDelMarco</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$anchoDelMarco</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$altoNuevaImagen</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$alto</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchoDelMarco</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$anchoDelMarco</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$imagenMarco</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchoNuevaImagen</span><span style="color: #339933;">,</span> <span style="color: #000088;">$altoNuevaImagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//poner color a  la imagen</span>
    <span style="color: #000088;">$colores</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$colorRGBMarco</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagenMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$colores</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$colores</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$colores</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">imagefill</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagenMarco</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//añadir marco a la imagen</span>
    <span style="color: #990000;">imagecopymerge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagenMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$imagen</span><span style="color: #339933;">,</span> <span style="color: #000088;">$anchoDelMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$anchoDelMarco</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ancho</span><span style="color: #339933;">,</span> <span style="color: #000088;">$alto</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//guardar imagen en fichero</span>
    <span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagenMarco</span><span style="color: #339933;">,</span> <span style="color: #000088;">$prefijo</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$rutaImagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/06/27/anadir-marco-a-las-imagenes-con-php-y-gd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enviar datos POST en PHP sin formulario, utilizando fsockopen.</title>
		<link>http://www.mascodigo.com/2009/06/21/enviar-datos-post-en-php-sin-formulario-utilizando-fsockopen/</link>
		<comments>http://www.mascodigo.com/2009/06/21/enviar-datos-post-en-php-sin-formulario-utilizando-fsockopen/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 12:29:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[fgets]]></category>
		<category><![CDATA[fputs]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=112</guid>
		<description><![CDATA[Hace unos días, me encontré con la necesidad de enviar una serie de datos, a una página, utilizando el método POST. Al principio pensé en realizar esto con la función “header” pero no lo conseguí. Entonces comencé a buscar en google y encontré algunos sitios que utilizaban “curl” para el envió de datos. Los ejemplos [...]]]></description>
			<content:encoded><![CDATA[<p>Hace unos días, me encontré con la necesidad de enviar una serie de datos, a una página, utilizando el método POST.</p>
<p>Al principio pensé en realizar esto con la función “header” pero no lo conseguí. Entonces comencé a buscar en google y encontré algunos sitios que utilizaban “curl” para el envió de datos.</p>
<p>Los ejemplos que encontré con “curl”, parecían sencillos de implementar, el único problema es que hay que tener “curl” instalado en el servidor.</p>
<p>Seguí buscando en google y encontré otras páginas que explicaban como hacer esto con “fsockopen”.</p>
<p>Una vez utilice “fsockopen” para conectar a un servidor POP3 y obtuve buenos resultados, a si que, me decidí a intentar conseguir mi objetivo inicial utilizando esta función.</p>
<p>A continuación muestro el código de dos ficheros php. Un fichero llamado “enviarPOST.php” y otro llamado “variablesPOST.php”.</p>
<p>Como podréis imaginar por el nombre de los ficheros “enviarPOST.php” se encarga de enviar a “variablesPOST.php” los datos que este espera.</p>
<p><strong>enviarPOST.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * CONFIGURACIÓN
 */</span>
<span style="color: #000088;">$carpeta</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/tmp/a/variablesPOST.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$datos</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;variable=correctoOK&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fsockopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;80&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Enviar datos POST</span>
<span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;POST &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$carpeta</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; HTTP/1.0rn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Content-Type: application/x-www-form-urlencodedrn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Content-Length: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$size</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;rn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Connection: close rrnn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fputs</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> <span style="color: #000088;">$datos</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;rn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Obtener datos</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$datoss</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$datoss</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>variablesPOST.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;La variable es: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;variable&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/06/21/enviar-datos-post-en-php-sin-formulario-utilizando-fsockopen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instalación fácil ( 4 pasos ) de eclipse con soporte php</title>
		<link>http://www.mascodigo.com/2009/05/27/instalacion-facil-4-pasos-de-eclipse-con-soporte-php/</link>
		<comments>http://www.mascodigo.com/2009/05/27/instalacion-facil-4-pasos-de-eclipse-con-soporte-php/#comments</comments>
		<pubDate>Wed, 27 May 2009 20:22:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[IDE]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=99</guid>
		<description><![CDATA[&#160; Página de descarga: &#160; http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/RC1/eclipse-php-galileo-RC1-linux-gtk.tar.gz &#160; Descargamos el archivo. La descarga tardará unos minutos, puesto que el tamaño del archivo es de 138MB aproximadamente. Una vez descargado, abrimos un terminal (Menú → accesorios → terminal ). &#160; Desde el terminar con el comando ls ( ver los archivos y directorios ) y cd ( [...]]]></description>
			<content:encoded><![CDATA[<div>&nbsp;</div>
<p>Página de descarga:
<div>&nbsp;</div>
<p><a href="http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/RC1/eclipse-php-galileo-RC1-linux-gtk.tar.gz">http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/RC1/eclipse-php-galileo-RC1-linux-gtk.tar.gz</a></p>
<div>&nbsp;</div>
<p style="margin-bottom: 0cm;">Descargamos el archivo. La descarga tardará unos minutos, puesto que el tamaño del archivo es de 138MB aproximadamente.</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Una vez descargado, abrimos un terminal (<strong>Menú → accesorios → terminal</strong> ).
<div>&nbsp;</div>
<p> Desde el terminar con el comando ls ( ver los archivos y directorios ) y cd ( cambiar de directorio) nos situamos en el directorio donde descargamos el archivo.</p>
<div>&nbsp;</div>
<p>El nombre del archivo será parecido a este “<em>eclipse-php-galileo-RC1-linux-gtk.tar.gz</em>”. Cuando ya estemos en el directorio, descomprimimos el archivo con la siguiente instrucción:</p>
<p><strong>tar -zxvf NombreDelArchivo</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Después de descomprimir, entramos en la carpeta creada (en este caso la carpeta creada se llama eclipse).</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>cd eclipse</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Ahora ejecutamos el programa.</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>./eclipse</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Al ejecutarse nos pregunta nuestro espacio de trabajo. Le indicamos el que nosotros queramos.</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Una vez iniciado el programa, vamos a:</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>windows → open perspective → other → php(default)</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Y listo. Ya podemos trabajar con php en eclipse.</p>
<div>&nbsp;</div>
<p style="margin-bottom: 0cm;">Ahora para tener un poco de orden en nuestro ordenador realizamos lo siguiente.</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">* Vamos al directorio donde descargamos el programa. Renombramos la carpeta que se creo (eclipse) por “<em>.eclipse</em>”:</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>mv eclipse .eclipse</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">Le añadimos un punto delante, para convertir el directorio en oculto.</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;">* Ahora copiamos el directorio a nuestro home, en mi caso “<strong>/home/felipe/</strong>”:</p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>cp -a .eclipse /home/felipe/</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm; font-weight: normal;">* Para terminar creamos un acceso directo al programa en nuestro escritorio:</p>
<p style="margin-bottom: 0cm; font-weight: normal;">
<p style="margin-bottom: 0cm;"><strong>ln -s /home/felipe/.eclipse/eclipse /home/felipe/Escritorio/eclipsePHP</strong></p>
<p style="margin-bottom: 0cm;"><strong><br />
</strong></p>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm; font-weight: normal;">Ahora vamos al escritorio, botón secundario sobre el acceso directo, propiedades y le ponemos el icono que queramos.</p>
<p style="margin-bottom: 0cm; font-weight: normal;">
]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/05/27/instalacion-facil-4-pasos-de-eclipse-con-soporte-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creación de thumbnails con PHP</title>
		<link>http://www.mascodigo.com/2009/03/22/creacion-de-thumbnails-con-php/</link>
		<comments>http://www.mascodigo.com/2009/03/22/creacion-de-thumbnails-con-php/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 13:43:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://www.mascodigo.com/?p=37</guid>
		<description><![CDATA[La creación de thumbnails es algo muy utilizado en las aplicaciones web, en las páginas y en algunos otros sitios. Frecuentemente desarrollo web que serán auto-gestionadas por el usuario final, por lo tanto, intento hacer el administrador del sitio lo mas cómodo y fácil posible. Una de las cosas que me ocupa mas tiempo es [...]]]></description>
			<content:encoded><![CDATA[<p>La creación de thumbnails es algo muy utilizado en las aplicaciones web, en las páginas y en algunos otros sitios.</p>
<p>Frecuentemente desarrollo web que serán auto-gestionadas por el usuario final, por lo tanto, intento hacer el administrador del sitio lo mas cómodo y fácil posible.</p>
<p>Una de las cosas que me ocupa mas tiempo es la posibilidad de que puedan subir imágenes. Lo malo de esta opción para los usuarios finales del sitio, es que, normalmente no se preocupan por subirlas con un tamaño y peso adecuado para su visualización.</p>
<p>Entonces aquí me encuentro con dos posibilidades, que son:</p>
<p>- intentar concienciar al usuario de como debe subir las imágenes. Esta opción la descarto por que el solo hecho de tener que indicarle esto, seguramente acarreara que según su punto de vista el sitio no sea bueno o el programador no es lo suficientemente bueno. Además si algún día no respeta las normas indicadas y la web se muestra de forma incorrecta, ¿ a quien llamara ?.</p>
<p>- Programar la web para que trate las imágenes de forma transparente al usuario. Y es aquí donde quería llegar, creación automática de thumbnails.</p>
<p>Para utilizar la clase imágenes mostrada al final del articulo debemos seguir los siguientes pasos:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Ejemplo de uso
 */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//añadir la clase</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./class_imagenes.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//imagen origen (1280px)</span>
<span style="color: #000088;">$imagen</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./fondo.jpg&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//crear objeto</span>
<span style="color: #000088;">$thumbnails</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Imagenes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//indicar la imagen origen</span>
<span style="color: #000088;">$thumbnails</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setImagen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagen</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//indicar el formato de la imagen origen</span>
<span style="color: #000088;">$thumbnails</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFormato</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//indicar el nivel de compresión. Segun este nivel la imagen</span>
<span style="color: #666666; font-style: italic;">//tendra mayor o menos calidad.</span>
<span style="color: #000088;">$thumbnails</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCompresion</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//indicar donde se creará y con que nombre el thumbnails</span>
<span style="color: #000088;">$thumbnails</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setNombre</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./thumb_fondo.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//indicar el tamaño del thumbnails (250)</span>
<span style="color: #000088;">$thumbnails</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">reducir</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>La clase (class_imagenes.php):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Creación de thumbnails ( creación de imágenes en miniatura )
 *
*/</span>
<span style="color: #000000; font-weight: bold;">class</span> Imagenes
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Propiedades de la clase</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_imagen</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_formato</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'jpg'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_nuevaImagen</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_compresion</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">90</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_nombre</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Verificar si la libreria GD esta instalada.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>		
		<span style="color: #000088;">$gd</span><span style="color: #339933;">=</span><span style="color: #990000;">gd_info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$gd</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$valor</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$valor</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
				<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'La libreria GD no esta disponible.'</span><span style="color: #339933;">;</span> 
			<span style="color: #009900;">&#125;</span> 
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Indicar a la clase con que imagen vamos a trabajar, es decir, a que
	 * imagen le vamos a crear un thumbnails.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setImagen<span style="color: #009900;">&#40;</span><span style="color: #000088;">$urlImagen</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen <span style="color: #339933;">=</span> <span style="color: #000088;">$urlImagen</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * Indicar el formato de que tiene la imagen. La indicada en el 
	 * método &quot;setImagen&quot;.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setFormato<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>				
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;jpeg&quot;</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_formato <span style="color: #339933;">=</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span> 
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefromjpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_formato <span style="color: #339933;">=</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span> 
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatefrompng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_formato <span style="color: #339933;">=</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span> 
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;Formato de imagen NO soportado.[jpeg|jpg|png]&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>		
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Obtener el ancho (width) de la imagen.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getImagenX<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Obtener el alto (height) de la imagen.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getImagenY<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Nivel de compresión de la nueva imagen.
	 * Máximo 100.
	 * Cuanto mayor sea este valor mejor sera la calidad, 
	 * pero tambien aumentara el tamaño.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setCompresion<span style="color: #009900;">&#40;</span><span style="color: #000088;">$compresion</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_compresion <span style="color: #339933;">=</span> <span style="color: #000088;">$compresion</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Idicar nombre y ruta para la nueva imagen.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setNombre<span style="color: #009900;">&#40;</span><span style="color: #000088;">$nombre</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nombre <span style="color: #339933;">=</span> <span style="color: #000088;">$nombre</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * Redimensionar imagen.
	 * Este método recibe el ancho (x) y el alto (y) que tendra 
	 * la nueva imagen.
	 * Si $y no se indica, este se añadira con un ancho proporcinal.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> reducir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>		
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$y</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//Obtener el alto proporcionalmente.</span>
			<span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$x</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$y</span> <span style="color: #339933;">/</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nuevaImagen <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #990000;">imagecopyresampled</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nuevaImagen<span style="color: #339933;">,</span>
				   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #339933;">,</span>
				   <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
				   <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
				   <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
			           <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
				   <span style="color: #000088;">$x</span><span style="color: #339933;">,</span>
			           <span style="color: #000088;">$y</span><span style="color: #339933;">,</span>
				   <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				   <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_imagen<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_formato<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>				
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;jpeg&quot;</span><span style="color: #339933;">:</span> <span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nuevaImagen<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nombre<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_compresion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #339933;">:</span> <span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nuevaImagen<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nombre<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_compresion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #339933;">:</span> <span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nuevaImagen<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_nombre<span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_compresion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">default</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;Formato de imagen NO soportado.[jpeg|jpg|png]&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>				
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.mascodigo.com/2009/03/22/creacion-de-thumbnails-con-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

