<?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>blog.morphey.org &#187; PHP</title>
	<atom:link href="http://blog.morphey.org/category/informatica/programmazione/php-programmazione/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.morphey.org</link>
	<description>Il blog di morphey</description>
	<lastBuildDate>Sat, 24 Jul 2010 03:00:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WordPress: load cpu alto quando si scrive un articolo</title>
		<link>http://blog.morphey.org/2008/05/03/wordpress-load-cpu-alto-quando-si-scrive-un-articolo/</link>
		<comments>http://blog.morphey.org/2008/05/03/wordpress-load-cpu-alto-quando-si-scrive-un-articolo/#comments</comments>
		<pubDate>Sat, 03 May 2008 00:29:03 +0000</pubDate>
		<dc:creator>morphey</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[wordpress cpu]]></category>
		<category><![CDATA[wordpress high cpu]]></category>
		<category><![CDATA[wordpress load alto]]></category>
		<category><![CDATA[wp 2.5.1]]></category>
		<category><![CDATA[zlib.output_compression]]></category>

		<guid isPermaLink="false">http://blog.morphey.org/?p=164</guid>
		<description><![CDATA[Quando si effettua l&#8217;aggiornamento di WordPress dalla versione 2.5.0 alla 2.5.1, si può cadere in un errore di &#8220;aggiornamento&#8221;. In pratica, come è capitato a me e ad altre persone, quando si clicca su Scrivi (post o articolo che sia) la cpu scatta immediatamente al 100% di utilizzo. L&#8217;errore è nella cache del file di]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft alignnone size-thumbnail wp-image-163" style="float: left; margin-left: 6px; margin-right: 6px;" title="fireshot-capture-5-blog_morphey_org-e280ba-crea-un-nuovo-articolo-e28094-wordpress-blog_morphey_org_wp-admin_post-new_php" src="http://blog.morphey.org/wp-content/uploads/2008/05/fireshot-capture-5-blog_morphey_org-e280ba-crea-un-nuovo-articolo-e28094-wordpress-blog_morphey_org_wp-admin_post-new_php-150x150.png" alt="" width="150" height="150" /> Quando si effettua l&#8217;aggiornamento di <strong><a title="WordPress" href="http://www.wordpress.org" target="_blank">WordPress</a> </strong>dalla versione <strong>2.5.0</strong> alla <strong>2.5.1</strong>, si può cadere in un errore di &#8220;aggiornamento&#8221;.</p>
<p>In pratica, come è capitato a me e ad altre persone, quando si clicca su <em>Scrivi</em> (post o articolo che sia) la <strong>cpu</strong> scatta immediatamente al <strong>100%</strong> di utilizzo.</p>
<p>L&#8217;errore è nella <strong>cache </strong>del file di configurazione di <a title="TinyMCE" href="http://tinymce.moxiecode.com" target="_blank"><strong>TinyMCE </strong></a>che viene scritto sul server (al primo avvio di <em>Scrivi</em> dopo l&#8217;aggiornamento di WP) che <strong>non</strong> è perfettamente c<strong>ompatibile dalla versione 2.5.0 alla versione 2.5.1</strong>.</p>
<p>In alcuni post, tra cui <a href="http://wordpress.org/support/topic/164276" target="_blank">questo</a>, si dice che il problema risiede nella configurazione del server: più precisamente l&#8217;abilitazione di <strong>zlib.output_compression</strong> nel <strong>php.ini</strong>. Ciò non è affatto vero: vediamo qual&#8217;è il problema esatto e come risolverlo.</p>
<p><span id="more-164"></span></p>
<p>Il vero problema, a quanto ho potuto verificare, risiede nel fatto che <strong>alcuni client FTP non impostati correttamente o lasciati con le impostazioni di base, non sostituiscono alcuni files dell&#8217;aggiornamento di WP</strong> <strong>2.5.1</strong> (tra cui lo script php che genera la cache del file di configurazione di TinyMCE che viene effettivamente scaricato dal browser) e ciò comporta che tale configurazione non è compatibile al 100% con la pagina post-new.php o page-new.php. Lato client (cosa verificato per il momento solo su Firefox) TinyMCE fa andare al massimo la CPU rallentando, di fatto, tutto il sistema fino a freezarlo.</p>
<p>Per risolvere questo inconveniente, basta scaricare il pacchetto completo di WordPress da <a href="http://wordpress.org/download/" target="_blank">qui</a> ed aggiornare di nuovo tramite FTP, questa volta <strong>sostituendo &#8220;tutti&#8221; i files presenti</strong>.</p>
<p><!--upnews--></p>
<img src="http://blog.morphey.org/?ak_action=api_record_view&id=164&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.morphey.org/2008/05/03/wordpress-load-cpu-alto-quando-si-scrive-un-articolo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyMCE: integrare perfettamente Ajax File Manager</title>
		<link>http://blog.morphey.org/2008/05/02/tinymce-integrare-perfettamente-ajax-file-manager/</link>
		<comments>http://blog.morphey.org/2008/05/02/tinymce-integrare-perfettamente-ajax-file-manager/#comments</comments>
		<pubDate>Fri, 02 May 2008 14:05:21 +0000</pubDate>
		<dc:creator>morphey</dc:creator>
				<category><![CDATA[Generale]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[afm]]></category>
		<category><![CDATA[ajax file manger]]></category>
		<category><![CDATA[editor html]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[tinymce file manager]]></category>
		<category><![CDATA[tinymce immagini]]></category>
		<category><![CDATA[tinymce plugins]]></category>
		<category><![CDATA[tinymce upload]]></category>
		<category><![CDATA[WYSIWYG]]></category>

		<guid isPermaLink="false">http://blog.morphey.org/?p=160</guid>
		<description><![CDATA[TinyMCE, come molti sapranno, è un web editor WYSIWYG scritto in javascript che permette a chiunque di creare/editare pagine web senza conoscere l&#8217;HTML (una sorta di Word per il web). Il tutto lato-client (in javascript appunto) senza programmare particolari script php che trasformano le stringhe di testo puro nelle entità HTML equivalenti (per esempio i]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft alignnone size-medium wp-image-161" style="float: left; margin-left: 6px; margin-right: 6px;" title="screenshot tinymce" src="http://blog.morphey.org/wp-content/uploads/2008/05/screenshot_02-300x124.jpg" alt="" width="300" height="124" /> <a title="TinyMCE" href="http://tinymce.moxiecode.com" target="_blank"><strong>TinyMCE</strong></a>, come molti sapranno, è un web editor <a href="http://it.wikipedia.org/wiki/WYSIWYG" target="_blank">WYSIWYG</a> scritto in <a href="http://it.wikipedia.org/wiki/Javascript" target="_blank">javascript</a> che permette a chiunque di creare/editare pagine web senza conoscere l&#8217;HTML (una sorta di Word per il web).</p>
<p>Il tutto lato-client (in <strong>javascript </strong>appunto) senza programmare particolari script php che trasformano le stringhe di testo puro nelle entità HTML equivalenti (per esempio i caratteri accentati come le lettere &#8220;ò&#8221;,&#8221;à&#8221;,&#8221;è&#8221;&#8230;).</p>
<p>L&#8217;installazione e la personalizzazione è estremamente semplice, corredato da un <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Index" target="_blank">wiki</a> molto completo e <a href="http://wiki.moxiecode.com/examples/tinymce/installation_example_00.php" target="_blank">pagine di esempi</a> con tutte le possibile personalizzazioni dello script.</p>
<p><span id="more-160"></span></p>
<p>Si sa, però, che javscript è lato-client e non può essere utilizzato per effettuare <strong>upload </strong>su server se non tramite <strong>ajax </strong>o popup che hanno dietro <strong>pagine php programmate per effettuare tali uploads</strong>. Ciò rappresenta un problema se abbiamo la necessità di effettuare l&#8217;upload e il ridimensionamento di immagini ed inserirle all&#8217;interno dell&#8217;editor tinymce.</p>
<p>In giro ci sono alcuni plugin per tinymce che fanno questa cosa ma, purtroppo, molti sono a pagamento.</p>
<p>Risolviamo il problema utilizzando uno script open source di nome <a title="Ajax File Manager" href="http://www.phpletter.com/Demo/Ajax-File--Manager/" target="_blank"><strong>Ajax File Manager</strong></a>.</p>
<p>Tale script è a se stante e, di base, non vengono fornite spiegazione per integrarlo a TinyMCE, ma viene fornito solamente un pacchetto con TinyMCE e Ajax File Manager incluso.</p>
<p>Il problema del pacchetto è che viene fornito con TinyMCE v. 2.1.2 e Ajax File Manager v. 0.9. Domanda: come facciamo ad avere l&#8217;ultima versione di TinyMCE (<strong>3.08</strong>) e Ajax File Manager (<strong>1.0 RC 1</strong>)?</p>
<p>Ecco qui come integrare AFM 1.0 Rc1 nella versione 3.08 di TinyMCE.</p>
<p>Scarichiamo l&#8217;<strong>ultima versione di TinyMCE</strong> dalla pagina <a href="http://tinymce.moxiecode.com/download.php" target="_blank">http://tinymce.moxiecode.com/download.php</a>, scompattiamolo nella root-dir della nostra applicazione (per es. public_html/). Avremo così la cartella public_html/tiny_mce/.</p>
<p><a href="http://blog.morphey.org/wp-content/uploads/2008/05/screenshot_03.jpg"><img class="alignright alignnone size-thumbnail wp-image-162" style="float: right; margin-left: 6px; margin-right: 6px;" title="screenshot_03" src="http://blog.morphey.org/wp-content/uploads/2008/05/screenshot_03-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>Scarichiamo l&#8217;ultima versione di Ajax File manager dalla pagina <a href="http://www.phpletter.com/DOWNLOAD/" target="_blank">http://www.phpletter.com/DOWNLOAD/</a> e scompattiamo il file nella cartella public_html/tiny_mce/plugins/. Avremo così la cartella <strong>public_html/tiny_mce/plugins/ajaxfilemanager/</strong>.</p>
<p>Per prima cosa impostiamo correttamente il file public_html/tiny_mce/plugins/<strong>ajaxfilemanager/inc/config.base.php</strong> con i giusti parametri (login, formato file, percorsi).</p>
<p>In particolare, i percorsi ipotizzando che il nostro dominio si chiami www.miodominio.it e le immagini le uploadderemo nella cartella <strong>public_html/img con chmod a 777</strong> (avremo anche una <strong>cartella session in public_html/session con chmod a 777</strong> per la cache):</p>
<blockquote><p>/* &#8230;&#8230;&#8230; */<br />
define(&#8216;CONFIG_SYS_DEFAULT_PATH&#8217;, &#8216;../../../img/&#8217;);<br />
define(&#8216;CONFIG_SYS_ROOT_PATH&#8217;, &#8216;../../../img/&#8217;);<br />
define(&#8216;CONFIG_SYS_FOLDER_SHOWN_ON_TOP&#8217;, true);<br />
define(&#8220;CONFIG_SYS_DIR_SESSION_PATH&#8221;, &#8216;../../../session/&#8217;);<br />
/* &#8230;&#8230;&#8230; */<br />
define(&#8216;CONFIG_WEBSITE_DOCUMENT_ROOT&#8217;, &#8216;/home/utente/public_html/&#8217;);<br />
/* &#8230;&#8230;&#8230; */</p></blockquote>
<p>&#8220;Tutti&#8221; i percorsi devono avere il percorso relativo alla posizione public_html/tiny_mce/plugins/ajaxfilemanager/ .</p>
<p>Fatto questo possiamo impostare il nostro TinyMCE con le chiamate di callback dovute.</p>
<p>L&#8217;esempio di configurazione, di seguito, è standard: leggendo il codice possiamo personalizzarlo come vogliamo.</p>
<p>Nella pagina del form con un input testuale multilinea con l&#8217;ipotetico nome id=&#8221;input_txt&#8221; inseriamo nei tags &lt;script&gt;&lt;/script&gt; il seguente codice:</p>
<blockquote><p>&lt;script&gt;<br />
tinyMCE.init({<br />
mode : &#8220;textareas&#8221;,<br />
theme : &#8220;advanced&#8221;,<br />
plugins : &#8220;inlinepopups,advimage,media&#8221;,<br />
theme_advanced_buttons1 : &#8220;bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,image,removeformat,anchor,blockquote,code&#8221;,<br />
theme_advanced_buttons2 : &#8220;&#8221;,<br />
theme_advanced_buttons3 : &#8220;&#8221;,<br />
<strong>file_browser_callback : &#8220;ajaxfilemanager&#8221;,</strong><br />
theme_advanced_toolbar_location : &#8220;top&#8221;,<br />
theme_advanced_toolbar_align : &#8220;left&#8221;,<br />
theme_advanced_statusbar_location : &#8220;bottom&#8221;,<br />
width : &#8220;676&#8243;,<br />
height : &#8220;300&#8243;,<br />
extended_valid_elements : &#8220;a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]&#8220;,<br />
apply_source_formatting : true,<br />
relative_urls : false,<br />
remove_script_host : false,<br />
document_base_url : &#8220;&lt;?=SITE_URL?&gt;&#8221;,<br />
languages : &#8220;it&#8221;,<br />
theme_advanced_resize_horizontal : false,<br />
theme_advanced_resizing : true,<br />
convert_newlines_to_brs : false,<br />
force_br_newlines : false,<br />
force_p_newlines : false<br />
});<br />
<strong>function ajaxfilemanager(field_name, url, type, win) {</strong><br />
<strong> var ajaxfilemanagerurl = &#8220;http://www.miodominio.it/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php&#8221;;</strong><br />
switch (type) {<br />
case &#8220;image&#8221;:<br />
ajaxfilemanagerurl += &#8220;?type=img&#8221;;<br />
break;<br />
case &#8220;media&#8221;:<br />
ajaxfilemanagerurl += &#8220;?type=media&#8221;;<br />
break;<br />
case &#8220;flash&#8221;: //for older versions of tinymce<br />
ajaxfilemanagerurl += &#8220;?type=media&#8221;;<br />
break;<br />
case &#8220;file&#8221;:<br />
ajaxfilemanagerurl += &#8220;?type=files&#8221;;<br />
break;<br />
default:<br />
return false;<br />
}<br />
var fileBrowserWindow = new Array();<br />
fileBrowserWindow["file"] = ajaxfilemanagerurl;<br />
fileBrowserWindow["title"] = &#8220;Ajax File Manager&#8221;;<br />
fileBrowserWindow["width"] = &#8220;782&#8243;;<br />
fileBrowserWindow["height"] = &#8220;440&#8243;;<br />
fileBrowserWindow["resizable "] = &#8220;yes&#8221;;<br />
fileBrowserWindow["inline"] = &#8220;yes&#8221;;<br />
fileBrowserWindow["close_previous"] = &#8220;no&#8221;;<br />
tinyMCE.activeEditor.windowManager.open(fileBrowserWindow, {<br />
window : win,<br />
input : field_name<br />
});</p>
<p>return false;<br />
<strong>}</strong></p>
<p>&lt;/script&gt;</p></blockquote>
<p>Come potete vedere, abbiamo inserito nell&#8217;init di TinyMCE il richiamo alla funzione di callback <strong>file_browser_callback : &#8220;ajaxfilemanager&#8221;</strong> che fa riferimento alla funzione che abbiamo creato subito dopo.</p>
<p>Da notare che la variabile <strong>ajaxfilemanagerurl</strong> nella funzione <strong>ajaxfilemanager</strong> deve contenere l&#8217;url assoluto al file ajaxfilemanager.php.</p>
<p>Fatto questo possiamo caricare la pagina con il form via web e cliccare, quando abbiamo bisogno di inserire un&#8217;immagine, sull&#8217;icona IMMAGINE di tinymce e, successivamente quando ha caricato la popup del gestore immagini, clicchiamo sull&#8217;icona di fianco a <em>Image Url</em> e si aprirà la finestra di Ajax File Manager.</p>
<p><!--upnews--></p>
<img src="http://blog.morphey.org/?ak_action=api_record_view&id=160&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.morphey.org/2008/05/02/tinymce-integrare-perfettamente-ajax-file-manager/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
	</channel>
</rss>
