<?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>FabioRicali.it &#187; PHP</title>
	<atom:link href="http://www.fabioricali.it/blog/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fabioricali.it/blog</link>
	<description>Tecnologia, PHP, JQuery, CSS</description>
	<lastBuildDate>Mon, 21 Jun 2010 20:46:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rinominare un file con php</title>
		<link>http://www.fabioricali.it/blog/rinominare-un-file-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/rinominare-un-file-con-php.html#comments</comments>
		<pubDate>Mon, 21 Jun 2010 20:20:21 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=84</guid>
		<description><![CDATA[Per rinominare un file con php basta questa semplice funzione

&#60;?php
rename&#40;&#34;/path/file.tx&#34;, &#34;/path/newfile.txt&#34;&#41;;
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Per rinominare un file con php basta questa semplice funzione</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;">rename</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/path/file.tx&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/path/newfile.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/rinominare-un-file-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copiare un file con php</title>
		<link>http://www.fabioricali.it/blog/copiare-un-file-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/copiare-un-file-con-php.html#comments</comments>
		<pubDate>Thu, 10 Jun 2010 18:41:53 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=73</guid>
		<description><![CDATA[Questa funzione ci permette di copiare un file sia locale che in remoto in un altro percorso

&#60;?php
function copyFile&#40;$source, $destination&#41;&#123;
    if&#40;!@copy&#40;$source,$destination&#41;&#41;&#123;
        $errors = error_get_last&#40;&#41;;
        $error  = $errors&#91;'type'&#93;.&#34;&#60;br/&#62;&#34;.$errors&#91;'message'&#93;;
        return $error;
   [...]]]></description>
			<content:encoded><![CDATA[<p>Questa funzione ci permette di copiare un file sia locale che in remoto in un altro percorso</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: #000000; font-weight: bold;">function</span> copyFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination</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: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #339933;">,</span><span style="color: #000088;">$destination</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">error_get_last</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$error</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$error</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>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Utilizzo:</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>
copyFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.sitoremoto.it/file.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;./file.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In caso di successo torna &#8220;true&#8221; altrimenti l&#8217;errore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/copiare-un-file-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convertire una data RFC822 in una normale</title>
		<link>http://www.fabioricali.it/blog/convertire-una-data-rfc822-in-una-normale.html</link>
		<comments>http://www.fabioricali.it/blog/convertire-una-data-rfc822-in-una-normale.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 22:14:13 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=71</guid>
		<description><![CDATA[Questa funzione ci permette di convertire una data GMT in un formato data normale

&#60;?php
function RFC822ToDate&#40;$gmtDate, $format=&#34;it&#34;, $showTime=true&#41;&#123;
        list&#40;$dayT, $dayN, $monthT, $year, $time&#41; = explode&#40;&#34; &#34;,$gmtDate&#41;;
        $dayT = trim&#40;$dayT,&#34;,&#34;&#41;;
        $months = array&#40;&#34;01&#34;=&#62;&#34;Jan&#34;,&#34;02&#34;=&#62;&#34;Feb&#34;,&#34;03&#34;=&#62;&#34;Mar&#34;,&#34;04&#34;=&#62;&#34;Apr&#34;,&#34;05&#34;=&#62;&#34;May&#34;,&#34;06&#34;=&#62;&#34;Jun&#34;,&#34;07&#34;=&#62;&#34;Jul&#34;,&#34;08&#34;=&#62;&#34;Aug&#34;,&#34;09&#34;=&#62;&#34;Sep&#34;,&#34;10&#34;=&#62;&#34;Oct&#34;,&#34;11&#34;=&#62;&#34;Nov&#34;,&#34;12&#34;=&#62;&#34;Dec&#34;&#41;;
    [...]]]></description>
			<content:encoded><![CDATA[<p>Questa funzione ci permette di convertire una data GMT in un formato data normale</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: #000000; font-weight: bold;">function</span> RFC822ToDate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$gmtDate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$showTime</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dayT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dayN</span><span style="color: #339933;">,</span> <span style="color: #000088;">$monthT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</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;">$gmtDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$dayT</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dayT</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;">$months</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;01&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jan&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;02&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Feb&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;03&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Mar&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;04&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Apr&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;05&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;May&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;06&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jun&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;07&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jul&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;08&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Aug&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;09&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Sep&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Oct&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;11&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Nov&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Dec&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$monthT</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_search</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$months</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$showTime</span><span style="color: #009900;">&#41;</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: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$format</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span> <span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;us&quot;</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span> <span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</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: #b1b100;">return</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> RFC822ToDate<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Tue, 08 Nov 2014 06:47:10 GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;">//stampa 08-11-2014 06:47:10   </span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/convertire-una-data-rfc822-in-una-normale.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leggere feed rss con DOM XML php</title>
		<link>http://www.fabioricali.it/blog/leggere-feed-rss-con-dom-xml-php.html</link>
		<comments>http://www.fabioricali.it/blog/leggere-feed-rss-con-dom-xml-php.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 21:56:07 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=69</guid>
		<description><![CDATA[Questa classe ci permette di leggere un RSS sfruttando la libreria DOM xml introdotta da PHP 5.
Il metodo principale è getRss con tre paramentri:
$urlXml (url al file xml)
getRss(&#8220;http://sito.it/rss.xml&#8221;)
$index di default è null (un numero corrispondente ad un nodo, es: se volessimo estrarre il nodo 5)
getRss(&#8220;http://sito.it/rss.xml&#8221;,5)
$offset di default é null (imposta assieme a $index il range [...]]]></description>
			<content:encoded><![CDATA[<p>Questa classe ci permette di leggere un RSS sfruttando la libreria DOM xml introdotta da PHP 5.<br />
Il metodo principale è getRss con tre paramentri:</p>
<p>$urlXml (url al file xml)<br />
getRss(&#8220;http://sito.it/rss.xml&#8221;)</p>
<p>$index di default è null (un numero corrispondente ad un nodo, es: se volessimo estrarre il nodo 5)<br />
getRss(&#8220;http://sito.it/rss.xml&#8221;,5)</p>
<p>$offset di default é null (imposta assieme a $index il range di nodi da estarre, es: dal nodo 1 al 5)<br />
getRss(&#8220;http://sito.it/rss.xml&#8221;,1,5)</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;">/**
 * rss
 * 
 * @package RssNow
 * @author Fabio Ricali
 * @copyright 2010
 * @version 1.0.0
 * @access public
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> RssNow<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * rss::getRss()
     * 
     * @param string $urlXml
     * @param int $index
     * @param int $offSet
     * @return array
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$urlXml</span><span style="color: #339933;">,</span> <span style="color: #000088;">$index</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offSet</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$urlXml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$doc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
            <span style="color: #000088;">$titles</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$titles</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$pubdates</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pubDate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$pubdate</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pubdates</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$descriptions</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$description</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$descriptions</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$categories</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;category&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$categories</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;author&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$author</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$authors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$comments</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;comments&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comments</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;link&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comments</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">nodeValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$enclosures</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enclosure&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$enclosures</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$enclosure_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
               <span style="color: #000088;">$enclosure</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$enclosure_</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000088;">$eval</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'
                $array[$i][\'title\'] = $title ;
                $array[$i][\'description\'] = $description ;
                $array[$i][\'pubDate\'] = $this-&gt;gmtToDate($pubdate) ;
                $array[$i][\'author\'] = $author ;
                $array[$i][\'comments\'] = $comment ;
                $array[$i][\'category\'] = $category ;
                $array[$i][\'enclosure\'] = $enclosure ;
                $array[$i][\'link\'] = $link ;
            '</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$offSet</span><span style="color: #339933;">==</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>    
                <span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$eval</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span><span style="color: #339933;">!=</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$offSet</span><span style="color: #339933;">!=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$range</span> <span style="color: #339933;">=</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span><span style="color: #339933;">,</span><span style="color: #000088;">$offSet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #000088;">$range</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$eval</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: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">==</span><span style="color: #000088;">$index</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$eval</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'[$i]'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$eval</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$eval</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$array</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: #666666; font-style: italic;">//$array[0]['length'] = $items-&gt;length;  </span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> gmtToDate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$gmtDate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$showTime</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dayT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dayN</span><span style="color: #339933;">,</span> <span style="color: #000088;">$monthT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$year</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#41;</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;">$gmtDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$dayT</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dayT</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;">$months</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;01&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jan&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;02&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Feb&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;03&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Mar&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;04&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Apr&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;05&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;May&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;06&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jun&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;07&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Jul&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;08&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Aug&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;09&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Sep&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Oct&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;11&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Nov&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;Dec&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$monthT</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_search</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">,</span> <span style="color: #000088;">$months</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$showTime</span><span style="color: #009900;">&#41;</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: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$format</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span> <span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;us&quot;</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span> <span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
                <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$year</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$monthT</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dayN</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</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: #b1b100;">return</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>     
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Utilizzo:</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: #000088;">$rss</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RssNow<span style="color: #339933;">;</span>
<span style="color: #000088;">$arr</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rss</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRss</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.repubblica.it/rss/cronaca/rss2.0.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; Titolo: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; Descrizione: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; Data pubbl.: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pubDate'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; Autore: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'author'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; Categoria: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/leggere-feed-rss-con-dom-xml-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect in base alla lingua del browser con php</title>
		<link>http://www.fabioricali.it/blog/redirect-in-base-alla-lingua-del-browser-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/redirect-in-base-alla-lingua-del-browser-con-php.html#comments</comments>
		<pubDate>Sun, 16 May 2010 20:41:31 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=65</guid>
		<description><![CDATA[
&#60;?php
$lang = substr&#40;$_SERVER&#91;'HTTP_ACCEPT_LANGUAGE'&#93;, 0, 2&#41;;
switch &#40;$lang&#41; &#123;
	case &#34;it&#34;:
			header&#40;&#34;location: it/&#34;&#41;;
		break;
	case &#34;en&#34;:
			header&#40;&#34;location: en/&#34;&#41;;
		break;
	default:
			header&#40;&#34;location: en/&#34;&#41;;
		break;
&#125;
?&#62;

]]></description>
			<content:encoded><![CDATA[
<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: #000088;">$lang</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_LANGUAGE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;location: it/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;location: en/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
			<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;location: en/&quot;</span><span style="color: #009900;">&#41;</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: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/redirect-in-base-alla-lingua-del-browser-con-php.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ottenere l&#8217;url corrente con php</title>
		<link>http://www.fabioricali.it/blog/ottenere-lurl-corrente-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/ottenere-lurl-corrente-con-php.html#comments</comments>
		<pubDate>Tue, 11 May 2010 21:45:12 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=63</guid>
		<description><![CDATA[Questa semplicissima funzione vi permettera di ottenere l&#8217;url corrente

&#60;?php
function getCurrentUrl&#40;&#41;&#123;
    return &#34;http://&#34;.$_SERVER&#91;'HTTP_HOST'&#93;.$_SERVER&#91;'REQUEST_URI'&#93;;
&#125;
&#160;
echo getCurrentUrl&#40;&#41;;
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Questa semplicissima funzione vi permettera di ottenere l&#8217;url corrente</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: #000000; font-weight: bold;">function</span> getCurrentUrl<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: #0000ff;">&quot;http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> getCurrentUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/ottenere-lurl-corrente-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rimuovere i tag HTML e PHP da una stringa</title>
		<link>http://www.fabioricali.it/blog/rimuovere-i-tag-html-e-php-da-una-stringa.html</link>
		<comments>http://www.fabioricali.it/blog/rimuovere-i-tag-html-e-php-da-una-stringa.html#comments</comments>
		<pubDate>Tue, 11 May 2010 06:36:46 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=60</guid>
		<description><![CDATA[La funzione strip_tags nativa in php permette di rimuovere i tag html e php da una stringa

echo strip_tags&#40;&#34;Testo con &#60;strong&#62;HTML&#60;/strong&#62;&#34;&#41;; //stampa &#34;Testo con HTML&#34;

]]></description>
			<content:encoded><![CDATA[<p>La funzione <strong>strip_tags</strong> nativa in php permette di rimuovere i tag html e php da una stringa</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Testo con &lt;strong&gt;HTML&lt;/strong&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//stampa &quot;Testo con HTML&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/rimuovere-i-tag-html-e-php-da-una-stringa.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ottenere il sistema operativo con php</title>
		<link>http://www.fabioricali.it/blog/ottenere-il-sistema-operativo-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/ottenere-il-sistema-operativo-con-php.html#comments</comments>
		<pubDate>Sun, 09 May 2010 12:53:51 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=50</guid>
		<description><![CDATA[Ecco come ottenere il sistema operativo dall&#8217;user agent

&#60;?php
function getOs&#40;&#41;&#123;
	$OSList = array&#40;
	// Match user agent string with operating systems
	'Windows 3.11' =&#62; 'Win16',
	'Windows 95' =&#62; '(Windows 95)&#124;(Win95)&#124;(Windows_95)',
	'Windows 98' =&#62; '(Windows 98)&#124;(Win98)',
	'Windows 2000' =&#62; '(Windows NT 5.0)&#124;(Windows 2000)',
	'Windows XP' =&#62; '(Windows NT 5.1)&#124;(Windows XP)',
	'Windows Server 2003' =&#62; '(Windows NT 5.2)',
	'Windows Vista' =&#62; '(Windows NT 6.0)',
	'Windows 7' =&#62; '(Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Ecco come ottenere il sistema operativo dall&#8217;user agent</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: #000000; font-weight: bold;">function</span> getOs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$OSList</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #666666; font-style: italic;">// Match user agent string with operating systems</span>
	<span style="color: #0000ff;">'Windows 3.11'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Win16'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows 95'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows 95)|(Win95)|(Windows_95)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows 98'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows 98)|(Win98)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows 2000'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 5.0)|(Windows 2000)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows XP'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 5.1)|(Windows XP)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows Server 2003'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 5.2)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows Vista'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 6.0)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows 7'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 7.0)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows NT 4.0'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Windows ME'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Windows ME'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Open BSD'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'OpenBSD'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Sun OS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'SunOS'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Linux'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Linux)|(X11)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Mac OS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'(Mac_PowerPC)|(Macintosh)'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'QNX'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'QNX'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'BeOS'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'BeOS'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'OS/2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'OS/2'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'Search Bot'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Loop through the array of user agents and matching operating systems</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$OSList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$CurrOS</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$Match</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Find a match</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$Match</span>/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// We found the correct match</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: #b1b100;">return</span> <span style="color: #000088;">$CurrOS</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.fabioricali.it/blog/ottenere-il-sistema-operativo-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generare una password facile da ricordare con php</title>
		<link>http://www.fabioricali.it/blog/generare-una-password-facile-da-ricordare-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/generare-una-password-facile-da-ricordare-con-php.html#comments</comments>
		<pubDate>Sun, 09 May 2010 12:39:27 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=45</guid>
		<description><![CDATA[Questa funzione permette di generare una password facile da ricordare a mente tipo fomudi_819

function easy_password&#40;$n=3&#41;&#123;
	$arr_consonant = array&#40;&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;f&#34;,&#34;g&#34;,&#34;l&#34;,&#34;m&#34;,&#34;n&#34;,&#34;v&#34;,&#34;z&#34;,&#34;k&#34;,&#34;w&#34;,&#34;x&#34;&#41;;
	$arr_vowel = array&#40;&#34;a&#34;,&#34;e&#34;,&#34;i&#34;,&#34;o&#34;,&#34;u&#34;,&#34;y&#34;&#41;;
	$arr_number = range&#40;0,9&#41;;
	shuffle&#40;$arr_consonant&#41;;
	shuffle&#40;$arr_vowel&#41;;
	shuffle&#40;$arr_number&#41;;
	$word = &#34;&#34;;
	$number = &#34;&#34;;
	for &#40;$i=0; $i&#60;$n; $i++&#41;&#123;
		$word .= $arr_consonant&#91;$i&#93;.$arr_vowel&#91;$i&#93;;
		$number .= $arr_number&#91;$i&#93;;
	&#125;
	return $word.&#34;_&#34;.$number;
&#125;
echo easy_password&#40;&#41;

Il paramentro opzionale da passare setta il numero di coppie &#8220;consonante-vocale&#8221;, di default è impostato a 3.
]]></description>
			<content:encoded><![CDATA[<p>Questa funzione permette di generare una password facile da ricordare a mente tipo <strong>fomudi_819</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> easy_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$arr_consonant</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;c&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;g&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;l&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;v&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;z&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;k&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$arr_vowel</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;e&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;o&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;u&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$arr_number</span> <span style="color: #339933;">=</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr_consonant</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr_vowel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr_number</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$word</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$number</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$word</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$arr_consonant</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$arr_vowel</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$number</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$arr_number</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$word</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$number</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> easy_password<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Il paramentro opzionale da passare setta il numero di coppie &#8220;consonante-vocale&#8221;, di default è impostato a 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fabioricali.it/blog/generare-una-password-facile-da-ricordare-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ricavare l&#8217;estensione di un file sul server con php</title>
		<link>http://www.fabioricali.it/blog/ricavare-lestensione-di-un-file-sul-server-con-php.html</link>
		<comments>http://www.fabioricali.it/blog/ricavare-lestensione-di-un-file-sul-server-con-php.html#comments</comments>
		<pubDate>Sat, 08 May 2010 19:28:40 +0000</pubDate>
		<dc:creator>info@fabioricali.it</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fabioricali.it/blog/?p=39</guid>
		<description><![CDATA[Semplice funzione per ricavare l&#8217;estensione di un file sul server

&#60;?php
function getFileExtension&#40;$file&#41;&#123;
	$filename = basename&#40;$file&#41;;
	return $file_extension = strtolower&#40;substr&#40;strrchr&#40;$filename,&#34;.&#34;&#41;,1&#41;&#41;;
&#125;
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Semplice funzione per ricavare l&#8217;estensione di un file sul server</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: #000000; font-weight: bold;">function</span> getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$file_extension</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strrchr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</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: #cc66cc;">1</span><span style="color: #009900;">&#41;</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.fabioricali.it/blog/ricavare-lestensione-di-un-file-sul-server-con-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

