﻿<?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>C#, .NET, Java, Php, Python, Wordpress, Windows, Linux... &#187; php</title>
	<atom:link href="http://www.marcobruni.info/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.marcobruni.info/wordpress</link>
	<description>Programmatore, Sviluppatore, Sistemista e Consulente Informatico: quando una passione è anche una professione.</description>
	<lastbuilddate>Fri, 20 Jan 2012 07:03:13 +0000</lastbuilddate>
	<language>en</language>
	<sy:updateperiod>hourly</sy:updateperiod>
	<sy:updatefrequency>1</sy:updatefrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Come iniziare con PHP?</title>
		<link>http://www.marcobruni.info/wordpress/come-iniziare-con-php.html</link>
		<comments>http://www.marcobruni.info/wordpress/come-iniziare-con-php.html#comments</comments>
		<pubdate>Thu, 01 Dec 2011 05:31:55 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[php]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/wordpress/?p=2889</guid>
		<description><![CDATA[Cosa è PHP? PHP è l&#8217;acronimo per Hypertext Preprocessor ed è un linguaggio scripting lato-server per lo sviluppo del web. Lato-server vuol dire che il codice PHP viene eseguito sul server web ed il risultato è una pagina HTML che viene mandata nel nostro browser. Script vuol dire che non ha bisogno di essere compilato [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/php.gif"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/php.gif" alt="" title="php" width="120" height="67" class="alignleft size-full wp-image-2890" /></a><strong>Cosa è PHP?</strong></p>
<p><a href="http://it.wikipedia.org/wiki/PHP" title="PHP la definizione di wikipedia" target="_blank">PHP</a> è l&#8217;acronimo per Hypertext Preprocessor ed è un linguaggio scripting lato-server per lo sviluppo del web. Lato-server vuol dire che il codice PHP viene eseguito sul server web ed il risultato è una pagina HTML che viene mandata nel nostro browser. Script vuol dire che non ha bisogno di essere compilato per eseguire il suo codice. PHP può essere inserito all&#8217;interno dell&#8217;HTML.</p>
<p>PHP può creare siti web e applicazioni web davvero impressionati, ed oggi è lo standard di fatto perchè utilizzato nel 70% dei server web mondiali. Si può facilmente imparare PHP se si ha familiarità con la programmazione come il linguaggio C.</p>
<p><strong>Di cosa hai bisogno per eseguire PHP nel tuo computer?</strong></p>
<p>1. web server(<a href="http://httpd.apache.org/download.cgi" title="Apache" target="_blank">Apache</a>, IIS, etc.)<br />
2. PHP (<a href="http://www.php.net/downloads.php" title="PHP" target="_blank">http://www.php.net/downloads.php</a>)<br />
3. MySQL (<a href="http://www.mysql.com/downloads/" title="MySQL" target="_blank">http://www.mysql.com/downloads/</a>)</p>
<p>Puoi installare questi 3 software uno ad uno oppure un solo pacchetto software che li installi automaticamente tutti semplificandoti la vita e la gestione, come ad esempio:</p>
<p>For Windows – <a href="http://www.wampserver.com/en/" title="WAMP" target="_blank">WAMP</a>, <a href="http://www.apachefriends.org/it/xampp.html" title="XAMPP" target="_blank">XAMPP</a>, <a href="http://www.easyphp.org/" title="EsayPHP" target="_blank">EasyPHP</a>, <a href="http://www.ampps.com/" title="AMPPS" target="_blank">AMPPS</a><br />
For Mac – <a href="http://www.apachefriends.org/it/xampp.html" title="XAMPP" target="_blank">XAMPP</a>, <a href="http://www.mamp.info/en/index.html" title="MAMP" target="_blank">MAMP</a><br />
For Linux – <a href="http://www.apachefriends.org/it/xampp.html" title="XAMPP per Linux" target="_blank">XAMPP</a></p>
<p><strong>XAMPP</strong><br />
Per quanto mi riguarda, io uso XAMPP che voglio introdurvi con questo articolo. XAMPP è possibile installarlo ed eseguirlo su tutti i più importanti sistema operativi.</p>
<p><strong>Installazione</strong></p>
<ul>
<li>Vai all&#8217;home page di XAMPP tramite questo <a href="http://www.apachefriends.org/it/xampp.html" title="XAMPP Italiano" target="_blank">link</a>.</li>
<li>Scegli il tuo sistema operativo</li>
<li>Scarica ed esegui l&#8217;installer</li>
</ul>
<p>Questo è tutto. Adesso sei pronto a scrivere il tuo sito in PHP.</p>
<p><strong>ESEGUI IL TUO SERVER</strong><br />
Esegui il tuo Pannello XAMPP tramite il link dal Desktop oppure dal menù di start se sei su windows.</p>
<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/xampp_control_panel.png"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/xampp_control_panel.png" alt="" title="Pannello di controllo XAMPP" width="447" height="399" class="aligncenter size-full wp-image-2901" /></a></p>
<p>Se non hai eseguito il tuo Apache, clicca la spunta e avvialo come puoi vedere nello screenshot.</p>
<p>Apri il tuo browser e vai all&#8217;indirizzo http://localhost/ e scegli la tua lingua, come puoi vedere dallo screenshot.</p>
<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/xampp_welcome.png"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/xampp_welcome.png" alt="" title="XAMPP Welcome" width="600" height="340" class="aligncenter size-full wp-image-2904" /></a></p>
<p>Congratulazioni: hai installato con successo XAMPP nel tuo sistema!</p>
<p><strong>Scriviamo in PHP</strong><br />
Come da tradizione ogni volta che si inizia ad imparare un nuovo linguaggio di programmazione, il primo programma che si scrive è la frase Hello World.</p>
<p>Facciamolo anche noi, apriamo un editor di testo e scriviamo:</p>
<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/helloworld1.jpg"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/helloworld1.jpg" alt="" title="Hello World in Php" width="215" height="77" class="aligncenter size-full wp-image-2912" /></a></p>
<p>Salviamo il file hello.php nella cartella C:\xampphtdocs . Apri il tuo browser e vai all&#8217;indirizzo http://localhost/hello.php e come per magia vedrai “Hello World!” sul tuo browser.</p>
<p><strong>Come lavora?</strong><br />
Come avete visto sopra, il nostro codice si trova tra ? , questo per far capire al server che quelle righe sono PHP. La scrittura del codice PHP può avvenire in 3 forme come di seguito. È possibile utilizzare una delle opzioni.</p>
<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/3op1.jpg"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/3op1.jpg" alt="" title="Php" width="242" height="254" class="aligncenter size-full wp-image-2917" /></a></p>
<p><strong>Inserire codice PHP all&#8217;interno dell&#8217;HTML</strong><br />
Come sapete, stiamo creando un sito web quindi è necessario inserire il codice PHP all&#8217;interno dell&#8217; HTML, come di seguito.</p>
<p><a href="http://www.marcobruni.info/wp-content/uploads/2011/12/html1.jpg"><img src="http://www.marcobruni.info/wp-content/uploads/2011/12/html1.jpg" alt="" title="html1" width="295" height="252" class="aligncenter size-full wp-image-2918" /></a></p>
<p>Se avete domande o consigli non esitate a contattarmi.</p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/come-iniziare-con-php.html/feed</wfw:commentrss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP compie 16 anni</title>
		<link>http://www.marcobruni.info/wordpress/php-compie-16-anni.html</link>
		<comments>http://www.marcobruni.info/wordpress/php-compie-16-anni.html#comments</comments>
		<pubdate>Thu, 09 Jun 2011 02:01:46 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[news]]></category>
		<category><![CDATA[php]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/wordpress/?p=2650</guid>
		<description><![CDATA[di Claudio Garau PHP, il noto linguaggio per lo scripting Server Side, ha compiuto 16 anni di vita, era infatti l’8 giugno del tecnologicamente lontanissimo 1995, quando lo sviluppatore danese Rasmus Lerdorf ne annunciava la nascita su USENET. Inizialmente l’acronimo PHP non corrispondeva all’attuale “PHP: Hypertext Preprocessor” ma a “Personal Home Page”. &#8211;> Leggi tutto [...]]]></description>
			<content:encoded><![CDATA[<p>di <a href="http://blog.html.it/author/claudiogarau/" target="_blank">Claudio Garau</a></p>
<p>PHP, il noto linguaggio per lo scripting Server Side, ha compiuto 16 anni di vita, era infatti l’8 giugno del tecnologicamente lontanissimo 1995, quando lo sviluppatore danese Rasmus Lerdorf ne annunciava la nascita su USENET. Inizialmente l’acronimo PHP non corrispondeva all’attuale “PHP: Hypertext Preprocessor” ma a “Personal Home Page”. &#8211;> <a href="http://blog.html.it/08/06/2011/php-compie-16-anni/" target="_blank">Leggi tutto l&#8217;articolo di Html.it</a></p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/php-compie-16-anni.html/feed</wfw:commentrss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Come creare in PHP una tabella in un database MySQL</title>
		<link>http://www.marcobruni.info/wordpress/come-creare-in-php-una-tabella-in-un-database-mysql.html</link>
		<comments>http://www.marcobruni.info/wordpress/come-creare-in-php-una-tabella-in-un-database-mysql.html#comments</comments>
		<pubdate>Wed, 22 Dec 2010 20:33:55 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/wordpress/?p=1335</guid>
		<description><![CDATA[In questo articolo vedremo come in Php si può creare una tabella di un database MySQL. Prima affronteremo il file config.php in cui ci sono i parametri di connessione al server MySQL e la funzione di php per la connessione e poi affronteremo il file per la creazione della tabella, alla fine del post troverai [...]]]></description>
			<content:encoded><![CDATA[<p>In questo articolo vedremo come in <a href="http://it.wikipedia.org/wiki/PHP" target="_blank">Php</a> si può creare una tabella di un <a href="http://it.wikipedia.org/wiki/Database" target="_blank">database</a> <a href="http://it.wikipedia.org/wiki/MySQL"  target="_blank">MySQL</a>. Prima affronteremo il file config.php in cui ci sono i parametri di connessione al server MySQL e la funzione di php per la connessione e poi affronteremo il file per la creazione della tabella, alla fine del post troverai lo zip con all&#8217;interno i 2 file php che puoi scaricare per fare tutte le prove che vuoi.</p>
<p><span id="more-1335"></span></p>
<p>Nel file config.php ,che troverai nello zip che puoi scaricare alla fine dell&#8217;articolo file, ci sono tutti i parametri per la connessione a MySQL applicati alla funzione mysql_connect.</p>
<p><strong>File config.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>
&nbsp;
<span style="color: #666666; font-style: italic;">// Definisci i parametri per il login del server MySQL, </span>
<span style="color: #666666; font-style: italic;">//l'indirizzo IP del server deve essere messo al posto di localhost</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;">$utente</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;nomeutente&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Connessione al server MySQL, </span>
<span style="color: #666666; font-style: italic;">// che nel caso riuscirà restituirà la connessione altrimenti errore</span>
<span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$host</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$utente</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$password</span>&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Adesso vediamo lo script per creare una tabella che si trova nel file crea_tabella.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">// In primo luogo abbiamo bisogno di connettersi a mysql server </span>
<span style="color: #666666; font-style: italic;">// e come spiegato prima viene effettuato includendo il file config.php </span>
<span style="color: #666666; font-style: italic;">// in cui ci sono tutti i parametri di connessione</span>
<span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Una volta effettuata la connessione al server MySQL </span>
<span style="color: #666666; font-style: italic;">// abbiamo bisogno di scegliere il database del server in cui lavorare.</span>
<span style="color: #990000;">mysql_select_db</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test_database&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Adesso che abbiamo selezionato il database cominciamo a scrivere la query </span>
<span style="color: #666666; font-style: italic;">// per creare la tabella. Definiamo il campo nome di 50 caratteri e obbligatorio, </span>
<span style="color: #666666; font-style: italic;">// email di 50 caratteri che è obbligatorio, id che è il campo chiave primaria  </span>
<span style="color: #666666; font-style: italic;">// che si incrementa automaticamente di 1 per ogni nuovo inserimento.</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CREATE TABLE contatti ( 
nome varchar(50) NOT NULL, 
email varchar(100) NOT NULL, 
id int(11) NOT NULL auto_increment, 
PRIMARY KEY (id) 
) TYPE=MyISAM;&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// Verifico se la tabella è stata creata oppure no oppure già esiste</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Impossibile creare la tabella oppure la tabella già esiste&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: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Tabella creata con successo&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Questo è un modo per creare una tabella di MySQL in php, però esistono anche altri strumenti come <a href="http://it.wikipedia.org/wiki/PhpMyAdmin" target="_blank">PhpMyAdmin</a> che di solito già sono installati nei vari hosting come Aruba.</p>
<p><em><strong><a href='http://www.marcobruni.info/wp-content/uploads/2010/12/seleziona_mysql_database_e_crea_tabella.zip' target="_blank">Per scaricare lo zip con i file di esempio clicca qui</a></strong></em></p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/come-creare-in-php-una-tabella-in-un-database-mysql.html/feed</wfw:commentrss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: Modificare il plugin transposh per le traduzioni automatiche</title>
		<link>http://www.marcobruni.info/wordpress/modificare-il-plugin-per-wordpress-transposh-per-le-traduzioni-automatiche.html</link>
		<comments>http://www.marcobruni.info/wordpress/modificare-il-plugin-per-wordpress-transposh-per-le-traduzioni-automatiche.html#comments</comments>
		<pubdate>Fri, 17 Dec 2010 21:29:24 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/?p=1177</guid>
		<description><![CDATA[Nel mio blog utilizzo il plugin transposh per le traduzioni automatiche della homepage, dei post e delle pagine. Mi succedeva che a fianco delle bandierine in home page comparisse la scritta Edit Translation che volevo nascondere allora ho deciso di mettere mani direttamente nel codice php del plugin. Ho modificato il file transposh_widget.php che si [...]]]></description>
			<content:encoded><![CDATA[<p>Nel mio blog utilizzo il <a href="http://transposh.org/" target="_blank">plugin transposh</a> per le traduzioni automatiche della homepage, dei post e delle pagine. Mi succedeva che a fianco delle bandierine in home page comparisse la scritta Edit Translation che volevo nascondere allora ho deciso di mettere mani direttamente nel codice php del plugin.</p>
<p>Ho modificato il file transposh_widget.php che si trova /wordpress/wp-content/plugins/transposh-translation-filter-for-wordpress/wp e nella classe transposh_plugin_widget ho modificato la funzione transposh_widget($args) commentando questa parte di codice:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #666666; font-style: italic;">// add the edit checkbox only for translators for languages marked as editable</span>
 <span style="color: #666666; font-style: italic;">// if ($this-&gt;transposh-&gt;is_editing_permitted()) {</span>
 <span style="color: #666666; font-style: italic;">//     echo '&lt;input type=&quot;checkbox&quot; name=&quot;' . EDIT_PARAM . '&quot; value=&quot;1&quot; ' .</span>
<span style="color: #666666; font-style: italic;">//      ($this-&gt;transposh-&gt;edit_mode ? 'checked=&quot;checked&quot;' : '') .</span>
<span style="color: #666666; font-style: italic;">//      ' onclick=&quot;this.form.submit();&quot;/&gt;&amp;nbsp;Edit Translation';</span>
<span style="color: #666666; font-style: italic;">//}</span></pre></div></div>

<p>[AGGIORNAMENTO]<br />
Parlando nei commenti con il realizzatore del plugin <a href="http://transposh.org/" target="_blank">Ofer Wald</a>, ho scoperto che si poteva fare il tutto senza toccare una linea di codice. Andando nella sezione Impostazioni->Transposh e settando nell&#8217;area Transalation Settings, l&#8217;opzione Who can translate ? solo per Amministratore e non Anonymous.</p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/modificare-il-plugin-per-wordpress-transposh-per-le-traduzioni-automatiche.html/feed</wfw:commentrss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress: personalizzare l&#8217;area quickpress della bacheca</title>
		<link>http://www.marcobruni.info/wordpress/personalizzare-larea-quickpress-della-bacheca-di-wordpress.html</link>
		<comments>http://www.marcobruni.info/wordpress/personalizzare-larea-quickpress-della-bacheca-di-wordpress.html#comments</comments>
		<pubdate>Fri, 17 Dec 2010 08:25:04 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/?p=1166</guid>
		<description><![CDATA[Quando mi vengono delle idee per nuovi argomenti/post per il mio blog me li appunto salvando una bozza tramite l&#8217;area quickpress della bacheca di wordpress. Recentemente mi è capitato per errore che invece di cliccare il bottone Salva Bozza ho cliccatto il bottone Pubblica rendendo pubblico un articolo non finito che è solo una bozza. [...]]]></description>
			<content:encoded><![CDATA[<p>Quando mi vengono delle idee per nuovi argomenti/post per il mio blog me li appunto salvando una bozza tramite l&#8217;area quickpress della bacheca di <a href="http://it.wikipedia.org/wiki/WordPress" target="_blank"><strong><em>wordpress</em></strong></a>.</p>
<p>Recentemente mi è capitato per errore che invece di cliccare il bottone Salva Bozza ho cliccatto il bottone Pubblica rendendo pubblico un articolo non finito che è solo una bozza. Se lo leggeva qualcuno tramite i miei <a href="http://feeds.feedburner.com/marcobruni" target="_blank">feed</a> o direttamente sul blog facevo una figuraccia.</p>
<p>Allora ho deciso di modificare il codice php dell&#8217;area quickpress della bacheca di wordpress per nascondere il bottone Pubblica e per evitare questi errori in futuro.</p>
<p>Ho preso il file dashboard.php che si trova nella cartella \wp-admin\includes\ e nella funzione wp_dashboard_quick_press_output() ho commentato la parte di codice che aggiungeva il bottone pubblica in questo modo:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!--&lt;span id=&quot;publishing-action&quot;&gt;
     &lt;input type=&quot;submit&quot; name=&quot;publish&quot; id=&quot;publish&quot; accesskey=&quot;p&quot; tabindex=&quot;5&quot; class=&quot;button-primary&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'publish_posts'</span><span style="color: #009900;">&#41;</span> ? esc_attr_e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Publish'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> esc_attr_e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Submit for Review'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
     &lt;img class=&quot;waiting&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> esc_url<span style="color: #009900;">&#40;</span> admin_url<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'images/wpspin_light.gif'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;/span&gt;--&gt;</pre></div></div>

<p>Ho solo commentato e non cancellato le righe di codice così in futuro posso riabilitare il bottone Pubblica. Adesso non c&#8217;è più pericolo di sbagliare.</p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/personalizzare-larea-quickpress-della-bacheca-di-wordpress.html/feed</wfw:commentrss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmazione in Php: 7 funzioni che probabilmente non hai mai usato</title>
		<link>http://www.marcobruni.info/wordpress/programmazione-in-php-7-funzioni-che-probabilmente-non-hai-mai-usato.html</link>
		<comments>http://www.marcobruni.info/wordpress/programmazione-in-php-7-funzioni-che-probabilmente-non-hai-mai-usato.html#comments</comments>
		<pubdate>Tue, 30 Nov 2010 21:58:34 +0000</pubdate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programmazione]]></category>

		<guid ispermalink="false">http://www.marcobruni.info/?p=471</guid>
		<description><![CDATA[Quando programmiamo in PHP, spesso ci limitiamo ad un numero limitato di funzioni API: quelli comuni, come il print (), header (), definire (), isset (), htmlspecialchars (), ecc Se alcune funzionalità necessarie non esistono, spesso ne scriviamo delle nuove facendo uso di questi componenti di base che conosciamo. Le API di PHP in realtà [...]]]></description>
			<content:encoded><![CDATA[<p>Quando programmiamo in PHP, spesso ci limitiamo ad un numero limitato di funzioni API: quelli comuni, come il print (), header (), definire (), isset (), htmlspecialchars (), ecc Se alcune funzionalità necessarie non esistono, spesso ne scriviamo delle nuove facendo uso di questi componenti di base che conosciamo. Le API di PHP in realtà offrono un sacco di funzionalità, alcune inutili e qualcuna utile, che vengono usate raramente. Ho cercato tra le funzioni disponibili e mi sono interessato a trovarne qualcuna di cui davvero ho bisogno. Ecco, condivido con voi le mie scoperte.</p>
<p><em><strong>1. sys_getloadavg ()</strong></em><br />
sys_getloadvg () è una funzione che restituisce tre misure del &#8220;carico&#8221; su un sistema. Il carico è il numero di processi in coda di esecuzione del sistema. I 3 elementi della matrice sono il carico medio per gli ultimi 1, 5 e 15 minuti.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$carico</span> <span style="color: #339933;">=</span> sys_getloadavg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
se <span style="color: #009900;">&#40;</span><span style="color: #000088;">$carico</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 503 Troppo occupato, riprovare più tardi'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Il server è occupato più tardi. Riprova.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Piuttosto che avere il servizio Web non più disponibile (offline) semplicemente perché è crollato tutto dopo aver ricevute troppe richieste, questo codice permetterà in maniera preventiva di accettare alcune richieste e di negarsi ad altre. Questo codice però non funziona su Windows.</p>
<p><em><strong>2. cal_days_in_month ()</strong></em><br />
cal_days_in_month () restituisce il numero di giorni in un dato mese:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$giorni</span> <span style="color: #339933;">=</span> <span style="color: #990000;">cal_days_in_month</span><span style="color: #009900;">&#40;</span>CAL_GREGORIAN<span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">31</span>
<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$giorni</span> <span style="color: #339933;">-</span> data<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d&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: #339933;">.</span><span style="color: #0000ff;">&quot;giorni fino a quando&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F&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> data<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1970</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><em><strong>3. get_browser ()</strong></em><br />
Non sarebbe bello scoprire che cosa può fare il browser di un utente prima di inviare la pagina? Beh, si può con get_browser (). Avrete bisogno di php_browscap.ini prima, e il punto di direttiva browscap al file. Si potrebbe avere qualcosa di simile a questa:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$browser</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_browser</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$browser</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;frames&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">|</span> <span style="color: #339933;">!</span>$ browser<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;cookies&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Si prega di aggiornare il browser o usare un browser più moderno ed attivare i cookies perchè alcune sezioni di questo sito potrebbero essere inaccessibili&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Questo non è in grado di rilevare le singole configurazioni di browser, tuttavia, non può essere utilizzato per rilevare se è abilitato JavaScript, per esempio. Questa funzione può essere utile per sapere quale browser si usa e quale piattaforma viene utilizzata.</p>
<p><strong><em>4. debug_print_backtrace ()</em></strong><br />
Può essere molto difficile da rintracciare un errore nel codice in particolare quando si cerca un errore logico, invece grazie a  debug_print_backtrace() potrebbe essere molto più facile. Come ad esempio:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> iterate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
      <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span> 
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$a</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> recur<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$a</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> recur<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
     <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span> 
     <span style="color: #000088;">$a</span><span style="color: #339933;">++;</span> 
     <span style="color: #666666; font-style: italic;">// how did I get here? </span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; <span style="color: #000099; font-weight: bold;">\n</span> <span style="color: #000099; font-weight: bold;">\n</span> <span style="color: #000099; font-weight: bold;">\n</span> &quot;</span><span style="color: #339933;">;</span> 
    debug_print_backtrace<span style="color: #009900;">&#40;</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: #000088;">$a</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span> iterate <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>   
&nbsp;
iterate <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #666666; font-style: italic;"># OUTPUT: #0 recur() called at [C:\htdocs\php_stuff\index.php:8] #1 iterate() called at [C:\htdocs\php_stuff\index.php:25] #0 recur() called at [C:\htdocs\php_stuff\index.php:8] #1 iterate() called at [C:\htdocs\php_stuff\index.php:21] #2 recur() called at [C:\htdocs\php_stuff\index.php:8] #3 iterate() called at [C:\htdocs\php_stuff\index.php:25] #0 recur() called at [C:\htdocs\php_stuff\index.php:8] #1 iterate() called at [C:\htdocs\php_stuff\index.php:21] #2 recur() called at [C:\htdocs\php_stuff\index.php:8] #3 iterate() called at [C:\htdocs\php_stuff\index.php:21] #4 recur() called at [C:\htdocs\php_stuff\index.php:8] #5 iterate() called at [C:\htdocs\php_stuff\index.php:25] [ ... ]</span></pre></td></tr></table></div>

<p><em><strong>5. natsort()</strong></em><br />
natsort() è una funzione che ordina elementi di una matrice in maniera naturale (cioè, in un ordine che sembra logico a una persona), piuttosto che un ordine  di tipo alfabetico. Prendete, per esempio:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;100 mele&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;5 mele&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;110 mele&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;55 mele&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">/</span> <span style="color: #339933;">/</span> normale ordinamento<span style="color: #339933;">:</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Il risultato:
</span><span style="color: #990000;">Array</span> <span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;"># (
</span><span style="color: #666666; font-style: italic;"># [0] =&gt; 100 mele
</span><span style="color: #666666; font-style: italic;"># [1] =&gt; 110 mele
</span><span style="color: #666666; font-style: italic;"># [2] =&gt; 5 mele
</span><span style="color: #666666; font-style: italic;"># [3] =&gt; 55 mele
</span><span style="color: #666666; font-style: italic;">#)
</span>
<span style="color: #990000;">natsort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Il risultato:
</span><span style="color: #666666; font-style: italic;"># Array
</span><span style="color: #666666; font-style: italic;"># (
</span><span style="color: #666666; font-style: italic;"># [2] =&gt; 5 mele
</span><span style="color: #666666; font-style: italic;"># [3] =&gt; 55 mele
</span><span style="color: #666666; font-style: italic;"># [0] =&gt; 100 mele
</span><span style="color: #666666; font-style: italic;"># [1] =&gt; 110 mele
</span><span style="color: #666666; font-style: italic;">#)</span></pre></td></tr></table></div>

<p><em><strong>6. Levenshtein()</strong></em><br />
Levenshtein() è una funzione che aiuta a trovare la miglior somiglianza tra 2 parole. Prendiamo, per esempio, il codice seguente:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$dictionary</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;php&quot;</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;javascript&quot;</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;css&quot;</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;japhp&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$best_match</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dictionary</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;">$match_value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">levenshtein</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dictionary</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;">$word</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;">$dictionary</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$w</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
     <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">levenshtein</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$word</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$w</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: #000088;">$value</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$match_value</span><span style="color: #009900;">&#41;</span> 
     <span style="color: #009900;">&#123;</span> 
          <span style="color: #000088;">$best_match</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$w</span><span style="color: #339933;">;</span> 
          <span style="color: #000088;">$match_value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span> 
     <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Forse cercavi la categoria ' <span style="color: #006699; font-weight: bold;">$best_match</span> ' ?&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In questo caso, l&#8217;utente è stato chiesto di fornire un nome di categoria. Ha scritto &#8220;japhp&#8221;, che non è valido. Poiché questo è probabile che sia un errore di digitazione, grazie a questa funzione riusciamo a trovare la categoria più somigliante (&#8220;Forse cercavi categoria &#8216;php&#8217;?&#8221;).</p>
<p><strong><em>7. glob()</em></strong><br />
glob() , vi farà sentire stupidi dopo l&#8217;uso di opendir(), readdir() e closedir() per cercare un file. La procedura è semplicissima:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;*. php&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;$ file\ n&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Di Più?<br />
Ci sono un sacco di funzioni utili e sconosciute là fuori come http_build_query(), register_shutdown_function() e pspell_suggest, quali sono le vostre preferite?</p>
<p>Fonte: <a href="http://infinity-infinity.com/2009/07/10-php-functions-you-probably-never-use/" target="_blank">infinity-infinity.com</a></p>
]]></content:encoded>
			<wfw:commentrss>http://www.marcobruni.info/wordpress/programmazione-in-php-7-funzioni-che-probabilmente-non-hai-mai-usato.html/feed</wfw:commentrss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.marcobruni.info @ 2012-02-09 07:36:45 -->
